Class RawCubeTexture
Hierarchy (View Summary)
- CubeTexture
- RawCubeTexture
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
-
new RawCubeTexture(
scene: Scene,
data: Nullable<ArrayBufferView<ArrayBufferLike>[]>,
size: number,
format?: number,
type?: number,
generateMipMaps?: boolean,
invertY?: boolean,
samplingMode?: number,
compression?: Nullable<string>,
): RawCubeTextureCreates a cube texture where the raw buffers are passed in.
Parameters
- scene: Scene
defines the scene the texture is attached to
- data: Nullable<ArrayBufferView<ArrayBufferLike>[]>
defines the array of data to use to create each face
- size: number
defines the size of the textures
- format: number = Constants.TEXTUREFORMAT_RGBA
defines the format of the data
- type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE
defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_BYTE)
- generateMipMaps: boolean = false
defines if the engine should generate the mip levels
- invertY: boolean = false
defines if data must be stored with Y axis inverted
- samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE
defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
- compression: Nullable<string> = null
defines the compression used (null by default)
Returns RawCubeTexture
- scene: Scene
Properties
animations
Define the list of animation attached to the texture.
anisotropic Filtering Level
With compliant hardware and browser (supporting anisotropic filtering) this defines the level of anisotropic filtering in the texture. The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
bounding Box Position
Gets or sets the center of the bounding box associated with the cube texture. It must define where the camera used to render the texture was set
delay Load State
Define the current state of the loading sequence when in delayed load mode.
display Name
Define the display name of the texture, which is used as tree item name of the dedicated node in the inspector
invert Z
Is Z inverted in the texture (useful in a cube texture).
is Render Target
Define if the texture is a render target.
level
Intensity or strength of the texture. It is commonly used by materials to fine tune the intensity of the texture
metadata
Gets or sets an object used to store user defined information.
name
Define the name of the texture.
on Dispose Observable
An event triggered when the texture is disposed.
on Load Observable
Observable triggered once the texture has been loaded.
optimize UV Allocation
Gets or sets a boolean indicating that the texture should try to reduce shader code if there is no UV manipulation. (ie. when texture.getTextureMatrix().isIdentityAs3x2() returns true)
reserved Data Store
For internal use only. Please do not use.
spherical Polynomial
Get the polynomial representation of the texture data. This is mainly use as a fast way to recover IBL Diffuse irradiance data.
unique Id
Gets or sets the unique id of the texture
url
The url of the texture
wrap R
| Value | Type | Description |
|---|---|---|
| 0 | CLAMP_ADDRESSMODE | |
| 1 | WRAP_ADDRESSMODE | |
| 2 | MIRROR_ADDRESSMODE |
StaticDEFAULT_ ANISOTROPIC_ FILTERING_ LEVEL
Default anisotropic filtering level for the application. It is set to 4 as a good tradeoff between perf and quality.
Accessors
bounding Box Size
can Rescale
-
get canRescale(): boolean
Get if the texture can rescale.
Returns boolean
coordinates Index
-
get coordinatesIndex(): number
Returns number
-
set coordinatesIndex(value: number): void
Define the UV channel to use starting from 0 and defaulting to 0. This is part of the texture as textures usually maps to one uv set.
Parameters
- value: number
Returns void
coordinates Mode
-
get coordinatesMode(): number
How a texture is mapped. Unused in thin texture mode.
Returns number
-
set coordinatesMode(value: number): void
How a texture is mapped.
Value Type Description 0 EXPLICIT_MODE 1 SPHERICAL_MODE 2 PLANAR_MODE 3 CUBIC_MODE 4 PROJECTION_MODE 5 SKYBOX_MODE 6 INVCUBIC_MODE 7 EQUIRECTANGULAR_MODE 8 FIXED_EQUIRECTANGULAR_MODE 9 FIXED_EQUIRECTANGULAR_MIRRORED_MODE Parameters
- value: number
Returns void
error Object
-
get errorObject(): { exception?: any; message?: string } | undefined
If a loading error occurred this object will be populated with information about the error.
Returns { exception?: any; message?: string } | undefined
forced Extension
-
Gets the forced extension (if any)
Returns Nullable<string>
gamma Space
-
get gammaSpace(): boolean
Define if the texture contains data in gamma space (most of the png/jpg aside bump). HDR texture are usually stored in linear space. This only impacts the PBR and Background materials
Returns boolean
-
set gammaSpace(gamma: boolean): void
Parameters
- gamma: boolean
Returns void
get Alpha From RGB
-
get getAlphaFromRGB(): boolean
Returns boolean
-
set getAlphaFromRGB(value: boolean): void
Defines if the alpha value should be determined via the rgb values. If true the luminance of the pixel might be used to find the corresponding alpha value.
Parameters
- value: boolean
Returns void
has Alpha
-
get hasAlpha(): boolean
Returns boolean
-
set hasAlpha(value: boolean): void
Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
Parameters
- value: boolean
Returns void
irradiance Texture
-
In case a better definition than spherical harmonics is required for the diffuse part of the environment. You can set the irradiance texture to rely on a texture instead of the spherical approach. This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
Returns Nullable<BaseTexture>
-
Parameters
- value: Nullable<BaseTexture>
Returns void
is2 D Array
-
get is2DArray(): boolean
Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
Returns boolean
-
set is2DArray(value: boolean): void
Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
Parameters
- value: boolean
Returns void
is3 D
-
get is3D(): boolean
Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
Returns boolean
-
set is3D(value: boolean): void
Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
Parameters
- value: boolean
Returns void
is Blocking
-
get isBlocking(): boolean
Define if the texture is preventing a material to render or not. If not and the texture is not ready, the engine will use a default black texture instead.
Returns boolean
is Cube
-
get isCube(): boolean
Define if the texture is a cube texture or if false a 2d texture.
Returns boolean
-
set isCube(value: boolean): void
Define if the texture is a cube texture or if false a 2d texture.
Parameters
- value: boolean
Returns void
is RGBD
-
get isRGBD(): boolean
Gets or sets whether or not the texture contains RGBD data.
Returns boolean
-
set isRGBD(value: boolean): void
Parameters
- value: boolean
Returns void
linear Specular LOD
-
get linearSpecularLOD(): boolean
With prefiltered texture, defined if the specular generation is based on a linear ramp. By default we are using a log2 of the linear roughness helping to keep a better resolution for average roughness values.
Returns boolean
-
set linearSpecularLOD(value: boolean): void
Parameters
- value: boolean
Returns void
loading Error
-
get loadingError(): boolean
Was there any loading error?
Returns boolean
lod Generation Offset
-
get lodGenerationOffset(): number
With prefiltered texture, defined the offset used during the prefiltering steps.
Returns number
-
set lodGenerationOffset(value: number): void
Parameters
- value: number
Returns void
lod Generation Scale
-
get lodGenerationScale(): number
With prefiltered texture, defined the scale used during the prefiltering steps.
Returns number
-
set lodGenerationScale(value: number): void
Parameters
- value: number
Returns void
no Mipmap
-
get noMipmap(): boolean
Are mip maps generated for this texture or not.
Returns boolean
on Dispose
-
set onDispose(callback: () => void): void
Callback triggered when the texture has been disposed. Kept for back compatibility, you can use the onDisposeObservable instead.
Parameters
- callback: () => void
Returns void
rotation Y
-
get rotationY(): number
Gets texture matrix rotation angle around Y axis radians.
Returns number
-
set rotationY(value: number): void
Sets texture matrix rotation angle around Y axis in radians.
Parameters
- value: number
Returns void
sampling Mode
-
get samplingMode(): number
Get the current sampling mode associated with the texture.
Returns number
texture Format
-
get textureFormat(): number
Get the texture underlying format (RGB, RGBA...)
Returns number
texture Type
-
get textureType(): number
Get the texture underlying type (INT, FLOAT...)
Returns number
uid
-
get uid(): string
Define the unique id of the texture in the scene.
Returns string
wrap U
-
get wrapU(): number
Value Type Description 0 CLAMP_ADDRESSMODE 1 WRAP_ADDRESSMODE 2 MIRROR_ADDRESSMODE Returns number
-
set wrapU(value: number): void
Value Type Description 0 CLAMP_ADDRESSMODE 1 WRAP_ADDRESSMODE 2 MIRROR_ADDRESSMODE Parameters
- value: number
Returns void
wrap V
-
get wrapV(): number
Value Type Description 0 CLAMP_ADDRESSMODE 1 WRAP_ADDRESSMODE 2 MIRROR_ADDRESSMODE Returns number
-
set wrapV(value: number): void
Value Type Description 0 CLAMP_ADDRESSMODE 1 WRAP_ADDRESSMODE 2 MIRROR_ADDRESSMODE Parameters
- value: number
Returns void
Methods
clone
delay Load
-
Delays loading of the cube texture
Parameters
OptionalforcedExtension: stringdefines the extension to use
Returns void
dispose
-
Dispose the texture and release its associated resources.
Returns void
force Spherical Polynomials Recompute
-
Force recomputation of spherical polynomials. Can be useful if you generate a cubemap multiple times (from a probe for eg) and you need the proper polynomials each time
Returns void
get Base Size
-
Get the base size of the texture. It can be different from the size if the texture has been resized for POT for instance
Returns ISize
the base size
get Class Name
-
Get the current class name of the texture useful for serialization or dynamic coding.
Returns string
"CubeTexture"
get Internal Texture
-
Get the underlying lower level texture from Babylon.
Returns Nullable<InternalTexture>
the internal texture
get Reflection Texture Matrix
get Refraction Texture Matrix
-
Gets a suitable rotate/transform matrix when the texture is used for refraction. There's a separate function from getReflectionTextureMatrix because refraction requires a special configuration of the matrix in right-handed mode.
Returns Matrix
The refraction matrix
get Scene
get Size
get Texture Matrix
-
Get the texture transform matrix used to offset tile the texture for instance.
Returns Matrix
the transformation matrix
is Ready
-
Get if the texture is ready to be used (downloaded, converted, mip mapped...).
Returns boolean
true if fully ready
is Ready Or Not Blocking
-
Get if the texture is ready to be consumed (either it is ready or it is not blocking)
Returns boolean
true if ready, not blocking or if there was an error loading the texture
read Pixels
-
readPixels(
faceIndex?: number,
level?: number,
buffer?: Nullable<ArrayBufferView<ArrayBufferLike>>,
flushRenderer?: boolean,
noDataConversion?: boolean,
x?: number,
y?: number,
width?: number,
height?: number,
): Nullable<Promise<ArrayBufferView<ArrayBufferLike>>>Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer. This will returns an RGBA array buffer containing either in values (0-255) or float values (0-1) depending of the underlying buffer type. Note that you can use GetTextureDataAsync instead, which will also support reading from a compressed texture (by rendering it to an intermediate RGBA texture and retrieving the bytes from it).
Parameters
- faceIndex: number = 0
defines the face of the texture to read (in case of cube texture)
- level: number = 0
defines the LOD level of the texture to read (in case of Mip Maps)
- buffer: Nullable<ArrayBufferView<ArrayBufferLike>> = null
defines a user defined buffer to fill with data (can be null)
- flushRenderer: boolean = true
true to flush the renderer from the pending commands before reading the pixels
- noDataConversion: boolean = false
false to convert the data to Uint8Array (if texture type is UNSIGNED_BYTE) or to Float32Array (if texture type is anything but UNSIGNED_BYTE). If true, the type of the generated buffer (if buffer==null) will depend on the type of the texture
- x: number = 0
defines the region x coordinates to start reading from (default to 0)
- y: number = 0
defines the region y coordinates to start reading from (default to 0)
- width: number = Number.MAX_VALUE
defines the region width to read from (default to the texture size at level)
- height: number = Number.MAX_VALUE
defines the region width to read from (default to the texture size at level)
Returns Nullable<Promise<ArrayBufferView<ArrayBufferLike>>>
The Array buffer promise containing the pixels data.
- faceIndex: number = 0
release Internal Texture
-
Release and destroy the underlying lower level texture aka internalTexture.
Returns void
scale
-
Scales the texture if is
canRescale()Parameters
- ratio: number
the resize factor we want to use to rescale
Returns void
- ratio: number
serialize
-
Serialize the texture into a JSON representation that can be parsed later on.
Parameters
- allowEmptyName: boolean = false
True to force serialization even if name is empty. Default: false
Returns any
the JSON representation of the texture
- allowEmptyName: boolean = false
set Reflection Texture Matrix
to String
-
Return a string representation of the texture.
Returns string
the texture as a string
update
-
update(
data: ArrayBufferView<ArrayBufferLike>[],
format: number,
type: number,
invertY: boolean,
compression?: Nullable<string>,
): voidUpdates the raw cube texture.
Parameters
- data: ArrayBufferView<ArrayBufferLike>[]
defines the data to store
- format: number
defines the data format
- type: number
defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)
- invertY: boolean
defines if data must be stored with Y axis inverted
- compression: Nullable<string> = null
defines the compression used (null by default)
Returns void
- data: ArrayBufferView<ArrayBufferLike>[]
update RGBD Async
-
updateRGBDAsync(
data: ArrayBufferView<ArrayBufferLike>[][],
sphericalPolynomial?: Nullable<SphericalPolynomial>,
lodScale?: number,
lodOffset?: number,
): Promise<void>Updates a raw cube texture with RGBD encoded data.
Parameters
- data: ArrayBufferView<ArrayBufferLike>[][]
defines the array of data [mipmap][face] to use to create each face
- sphericalPolynomial: Nullable<SphericalPolynomial> = null
defines the spherical polynomial for irradiance
- lodScale: number = 0.8
defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
- lodOffset: number = 0
defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
Returns Promise<void>
a promise that resolves when the operation is complete
- data: ArrayBufferView<ArrayBufferLike>[][]
update Sampling Mode
-
Update the sampling mode of the texture. Default is Trilinear mode.
Value Type Description 1 NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR Nearest is: mag = nearest, min = nearest, mip = linear 2 BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST Bilinear is: mag = linear, min = linear, mip = nearest 3 TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR Trilinear is: mag = linear, min = linear, mip = linear 4 NEAREST_NEAREST_MIPNEAREST 5 NEAREST_LINEAR_MIPNEAREST 6 NEAREST_LINEAR_MIPLINEAR 7 NEAREST_LINEAR 8 NEAREST_NEAREST 9 LINEAR_NEAREST_MIPNEAREST 10 LINEAR_NEAREST_MIPLINEAR 11 LINEAR_LINEAR 12 LINEAR_NEAREST mag: magnification filter (close to the viewer) min: minification filter (far from the viewer) mip: filter used between mip map levels
Parameters
- samplingMode: number
Define the new sampling mode of the texture
- generateMipMaps: boolean = false
Define if the texture should generate mip maps or not. Default is false.
Returns void
- samplingMode: number
update URL
-
updateURL(
url: string,
forcedExtension?: Nullable<string>,
onLoad?: Nullable<() => void>,
prefiltered?: boolean,
onError?: Nullable<(message?: string, exception?: any) => void>,
extensions?: Nullable<string[]>,
delayLoad?: boolean,
files?: Nullable<string[]>,
buffer?: Nullable<ArrayBufferView<ArrayBufferLike>>,
): voidUpdate the url (and optional buffer) of this texture if url was null during construction.
Parameters
- url: string
the url of the texture
- forcedExtension: Nullable<string> = null
defines the extension to use
- onLoad: Nullable<() => void> = null
callback called when the texture is loaded (defaults to null)
- prefiltered: boolean = false
Defines whether the updated texture is prefiltered or not
- onError: Nullable<(message?: string, exception?: any) => void> = null
callback called if there was an error during the loading process (defaults to null)
- extensions: Nullable<string[]> = null
defines the suffixes add to the picture name in case six images are in use like _px.jpg...
- delayLoad: boolean = false
defines if the texture should be loaded now (false by default)
- files: Nullable<string[]> = null
defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
- buffer: Nullable<ArrayBufferView<ArrayBufferLike>> = null
the buffer to use instead of loading from the url
Returns void
- url: string
StaticWhen All Ready
-
Helper function to be called back once a list of texture contains only ready textures.
Parameters
- textures: BaseTexture[]
Define the list of textures to wait for
- callback: () => void
Define the callback triggered once the entire list will be ready
Returns void
- textures: BaseTexture[]
Raw cube texture where the raw buffers are passed in