API

Class BaseTexture

Base class of all the textures in babylon. It groups all the common properties the materials, post process, lights... might need in order to make a correct use of the texture.

Hierarchy (View Summary)

Implements

Index
animations: Animation[] = []

Define the list of animation attached to the texture.

anisotropicFilteringLevel: number = BaseTexture.DEFAULT_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.

delayLoadState: number = Constants.DELAYLOADSTATE_NONE

Define the current state of the loading sequence when in delayed load mode.

displayName: string

Define the display name of the texture, which is used as tree item name of the dedicated node in the inspector

invertZ: boolean = false

Is Z inverted in the texture (useful in a cube texture).

isRenderTarget: boolean = false

Define if the texture is a render target.

level: number = 1

Intensity or strength of the texture. It is commonly used by materials to fine tune the intensity of the texture

metadata: any = null

Gets or sets an object used to store user defined information.

name: string

Define the name of the texture.

onDisposeObservable: Observable<BaseTexture> = ...

An event triggered when the texture is disposed.

optimizeUVAllocation: boolean = true

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)

reservedDataStore: any = null

For internal use only. Please do not use.

sphericalPolynomial: Nullable<SphericalPolynomial>

Get the polynomial representation of the texture data. This is mainly use as a fast way to recover IBL Diffuse irradiance data.

uniqueId: number

Gets or sets the unique id of the texture

wrapR: number = Constants.TEXTURE_WRAP_ADDRESSMODE
ValueTypeDescription
0CLAMP_ADDRESSMODE
1WRAP_ADDRESSMODE
2MIRROR_ADDRESSMODE
DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number = 4

Default anisotropic filtering level for the application. It is set to 4 as a good tradeoff between perf and quality.

  • 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.

  • 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

  • Update the sampling mode of the texture. Default is Trilinear mode.

    ValueTypeDescription
    1NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEARNearest is: mag = nearest, min = nearest, mip = linear
    2BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEARESTBilinear is: mag = linear, min = linear, mip = nearest
    3TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEARTrilinear is: mag = linear, min = linear, mip = linear
    4NEAREST_NEAREST_MIPNEAREST
    5NEAREST_LINEAR_MIPNEAREST
    6NEAREST_LINEAR_MIPLINEAR
    7NEAREST_LINEAR
    8NEAREST_NEAREST
    9LINEAR_NEAREST_MIPNEAREST
    10LINEAR_NEAREST_MIPLINEAR
    11LINEAR_LINEAR
    12LINEAR_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