Creates a DynamicTexture
defines the name of the texture
provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
Optional
scene: Nullable<Scene>defines the scene where you want the texture
Optional
generateMipMaps: booleandefines the use of MinMaps or not (default is false)
Optional
samplingMode: numberdefines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
Optional
format: numberdefines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
Optional
invertY: booleandefines if the texture needs to be inverted on the y axis during loading
Define the list of animation attached to the texture.
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.
Define the current state of the loading sequence when in delayed load mode.
Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
List of inspectable custom properties (used by the Inspector)
https://doc.babylonjs.com/toolsAndResources/inspector#extensibility
Is Z inverted in the texture (useful in a cube texture).
Define if the texture is a render target.
Intensity or strength of the texture. It is commonly used by materials to fine tune the intensity of the texture
Gets or sets an object used to store user defined information.
Define the name of the texture.
An event triggered when the texture is disposed.
Observable triggered once the texture has been loaded.
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)
For internal use only. Please do not use.
Get the polynomial representation of the texture data. This is mainly use as a fast way to recover IBL Diffuse irradiance data.
Define an offset on the texture to rotate around the u coordinates of the UVs The angle is defined in radians.
https://doc.babylonjs.com/features/featuresDeepDive/materials/using/moreMaterials
Define an offset on the texture to offset the u coordinates of the UVs
https://doc.babylonjs.com/features/featuresDeepDive/materials/using/moreMaterials#offsetting
Defines the center of rotation (U)
Define an offset on the texture to scale the u coordinates of the UVs
https://doc.babylonjs.com/features/featuresDeepDive/materials/using/moreMaterials#tiling
Gets or sets the unique id of the texture
Define the url of the texture.
Define an offset on the texture to rotate around the v coordinates of the UVs The angle is defined in radians.
https://doc.babylonjs.com/features/featuresDeepDive/materials/using/moreMaterials
Define an offset on the texture to offset the v coordinates of the UVs
https://doc.babylonjs.com/features/featuresDeepDive/materials/using/moreMaterials#offsetting
Defines the center of rotation (V)
Define an offset on the texture to scale the v coordinates of the UVs
https://doc.babylonjs.com/features/featuresDeepDive/materials/using/moreMaterials#tiling
Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture) The angle is defined in radians.
https://doc.babylonjs.com/features/featuresDeepDive/materials/using/moreMaterials
Defines the center of rotation (W)
Value | Type | Description |
---|---|---|
0 | CLAMP_ADDRESSMODE | |
1 | WRAP_ADDRESSMODE | |
2 | MIRROR_ADDRESSMODE |
Static
Readonly
BILINEAR_Bilinear is mag = linear and min = linear and no mip
Static
Readonly
CLAMP_Texture is not repeating outside of 0..1 UVs
Static
Readonly
CUBIC_Cubic coordinates mode
Static
DEFAULT_Default anisotropic filtering level for the application. It is set to 4 as a good tradeoff between perf and quality.
Static
Readonly
EQUIRECTANGULAR_Equirectangular coordinates mode
Static
Readonly
EXPLICIT_Explicit coordinates mode
Static
Readonly
FIXED_Equirectangular Fixed Mirrored coordinates mode
Static
Readonly
FIXED_Equirectangular Fixed coordinates mode
Static
ForceGets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process. If no buffer exists, one will be created as base64 string from the internal webgl data.
Static
Readonly
INVCUBIC_Inverse Cubic coordinates mode
Static
Readonly
LINEAR_mag = linear and min = linear and mip = none
Static
Readonly
LINEAR_Trilinear is mag = linear and min = linear and mip = linear
Static
Readonly
LINEAR_Bilinear is mag = linear and min = linear and mip = nearest
Static
Readonly
LINEAR_mag = linear and min = nearest and mip = none
Static
Readonly
LINEAR_mag = linear and min = nearest and mip = linear
Static
Readonly
LINEAR_mag = linear and min = nearest and mip = nearest
Static
Readonly
MIRROR_Texture is repeating and mirrored
Static
Readonly
NEAREST_mag = nearest and min = linear and mip = none
Static
Readonly
NEAREST_mag = nearest and min = linear and mip = linear
Static
Readonly
NEAREST_mag = nearest and min = linear and mip = nearest
Static
Readonly
NEAREST_mag = nearest and min = nearest and mip = none
Static
Readonly
NEAREST_nearest is mag = nearest and min = nearest and mip = linear
Static
Readonly
NEAREST_mag = nearest and min = nearest and mip = nearest
Static
Readonly
NEAREST_nearest is mag = nearest and min = nearest and no mip
Static
OnThis observable will notify when any texture had a loading error
Static
Readonly
PLANAR_Planar coordinates mode
Static
Readonly
PROJECTION_Projection coordinates mode
Static
Readonly
SKYBOX_Inverse Cubic coordinates mode
Static
Readonly
SPHERICAL_Spherical coordinates mode
Static
SerializeGets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
Static
Readonly
TRILINEAR_Trilinear is mag = linear and min = linear and mip = linear
Static
UseGets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
Static
Readonly
WRAP_Texture is repeating outside of 0..1 UVs
Gets the current state of canRescale
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.
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 |
If a loading error occurred this object will be populated with information about the error.
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
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.
Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
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).
Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
Is the texture preventing material to render while loading. If false, a default texture will be used instead of the loading one during the preparation step.
Define if the texture is a cube texture or if false a 2d texture.
Gets or sets whether or not the texture contains RGBD data.
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.
Was there any loading error?
With prefiltered texture, defined the offset used during the prefiltering steps.
With prefiltered texture, defined the scale used during the prefiltering steps.
Returns the texture mime type if it was defined by a loader (undefined else)
Are mip maps generated for this texture or not.
Callback triggered when the texture has been disposed. Kept for back compatibility, you can use the onDisposeObservable instead.
Get the current sampling mode associated with the texture.
Get the texture underlying format (RGB, RGBA...)
Get the texture underlying type (INT, FLOAT...)
Define the unique id of the texture in the scene.
Value | Type | Description |
---|---|---|
0 | CLAMP_ADDRESSMODE | |
1 | WRAP_ADDRESSMODE | |
2 | MIRROR_ADDRESSMODE |
Value | Type | Description |
---|---|---|
0 | CLAMP_ADDRESSMODE | |
1 | WRAP_ADDRESSMODE | |
2 | MIRROR_ADDRESSMODE |
Clones the texture
the clone of the texture.
Draws text onto the texture
defines the text to be drawn
defines the placement of the text from the left
defines the placement of the text from the top when invertY is true and from the bottom when false
defines the font to be used with font-style, font-size, font-name
defines the color used for the text
defines the color for the canvas, use null to not overwrite canvas
Optional
invertY: booleandefines the direction for the Y axis (default is true - y increases downwards)
Optional
update: booleandefines whether texture is immediately update (default is true)
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.
The refraction matrix
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.
The Array buffer promise containing the pixels data.
Optional
faceIndex: numberdefines the face of the texture to read (in case of cube texture)
Optional
level: numberdefines the LOD level of the texture to read (in case of Mip Maps)
Optional
buffer: Nullable<ArrayBufferView>defines a user defined buffer to fill with data (can be null)
Optional
flushRenderer: booleantrue to flush the renderer from the pending commands before reading the pixels
Optional
noDataConversion: booleanfalse 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
Optional
x: numberdefines the region x coordinates to start reading from (default to 0)
Optional
y: numberdefines the region y coordinates to start reading from (default to 0)
Optional
width: numberdefines the region width to read from (default to the texture size at level)
Optional
height: numberdefines the region width to read from (default to the texture size at level)
Updates the texture
Optional
invertY: booleandefines the direction for the Y axis (default is true - y increases downwards)
Optional
premulAlpha: booleandefines if alpha is stored as premultiplied (default is false)
Optional
allowGPUOptimization: booleantrue to allow some specific GPU optimizations (subject to engine feature "allowGPUOptimizationsForGUI" being true)
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
Define the new sampling mode of the texture
Update the url (and optional buffer) of this texture if url was null during construction.
the url of the texture
Optional
buffer: Nullable<string | HTMLImageElement | Blob | ArrayBuffer | ArrayBufferView | ImageBitmap>the buffer of the texture (defaults to null)
Optional
onLoad: (() => void)callback called when the texture is loaded (defaults to null)
Optional
forcedExtension: stringdefines the extension to use to pick the right loader
Static
CreateCreates a texture from its base 64 representation.
the created texture
Define the base64 payload without the data: prefix
Define the name of the texture in the scene useful fo caching purpose for instance
Define the scene the texture should belong to
Optional
noMipmapOrOptions: boolean | ITextureCreationOptionsdefines if the texture will require mip maps or not or set of all options to create the texture
Optional
invertY: booleandefine if the texture needs to be inverted on the y axis during loading
Optional
samplingMode: numberdefine the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
Optional
onLoad: Nullable<(() => void)>define a callback triggered when the texture has been loaded
Optional
onError: Nullable<(() => void)>define a callback triggered when an error occurred during the loading session
Optional
format: numberdefine the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
Optional
creationFlags: numberspecific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)
Static
LoadCreates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
the created texture
Define the name of the texture in the scene useful fo caching purpose for instance
define the buffer to load the texture from in case the texture is loaded from a buffer representation
Define the scene the texture should belong to
Optional
deleteBuffer: booleandefine if the buffer we are loading the texture from should be deleted after load
Optional
noMipmapOrOptions: boolean | ITextureCreationOptionsdefines if the texture will require mip maps or not or set of all options to create the texture
Optional
invertY: booleandefine if the texture needs to be inverted on the y axis during loading
Optional
samplingMode: numberdefine the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
Optional
onLoad: Nullable<(() => void)>define a callback triggered when the texture has been loaded
Optional
onError: Nullable<((message?: string, exception?: any) => void)>define a callback triggered when an error occurred during the loading session
Optional
format: numberdefine the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
Optional
creationFlags: numberspecific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)
Static
ParseParse the JSON representation of a texture in order to recreate the texture in the given scene.
The parsed texture if successful
Define the JSON representation of the texture
Define the scene the parsed texture should be instantiated in
Define the root url of the parsing sequence in the case of relative dependencies
Static
WhenHelper function to be called back once a list of texture contains only ready textures.
Define the list of textures to wait for
Define the callback triggered once the entire list will be ready
Static
_Optional
generateMipMaps: booleanOptional
invertY: booleanOptional
samplingMode: numberOptional
settings: Partial<VideoTextureSettings>Optional
onError: Nullable<((message?: string, exception?: any) => void)>Optional
format: numberGenerated using TypeDoc
A class extending Texture allowing drawing on a texture
See
https://doc.babylonjs.com/features/featuresDeepDive/materials/using/dynamicTexture