API

Variable TextureToolsConst

TextureTools: {
    ApplyPostProcess: (
        postProcessName: string,
        internalTexture: InternalTexture,
        scene: Scene,
        type?: number,
        samplingMode?: number,
        format?: number,
        width?: number,
        height?: number,
    ) => Promise<InternalTexture>;
    CreateResizedCopy: (
        texture: Texture,
        width: number,
        height: number,
        useBilinearMode?: boolean,
    ) => Texture;
    FromHalfFloat: (value: number) => number;
    GetTextureDataAsync: (
        texture: BaseTexture,
        width?: number,
        height?: number,
        face?: number,
        lod?: number,
        forceRTT?: boolean,
        slice?: number,
    ) => Promise<Uint8Array<ArrayBufferLike>>;
    ToHalfFloat: (value: number) => number;
} = ...

Class used to host texture specific utilities

Type Declaration

  • ApplyPostProcess: (
        postProcessName: string,
        internalTexture: InternalTexture,
        scene: Scene,
        type?: number,
        samplingMode?: number,
        format?: number,
        width?: number,
        height?: number,
    ) => Promise<InternalTexture>

    Apply a post process to a texture

    name of the fragment post process

    the texture to encode

    the scene hosting the texture

    type of the output texture. If not provided, use the one from internalTexture

    sampling mode to use to sample the source texture. If not provided, use the one from internalTexture

    format of the output texture. If not provided, use the one from internalTexture

    a promise with the internalTexture having its texture replaced by the result of the processing

  • CreateResizedCopy: (
        texture: Texture,
        width: number,
        height: number,
        useBilinearMode?: boolean,
    ) => Texture

    Uses the GPU to create a copy texture rescaled at a given size

    Texture to copy from

    defines the desired width

    defines the desired height

    defines if bilinear mode has to be used

    the generated texture

  • FromHalfFloat: (value: number) => number

    Converts a half float to a number

    half float to convert

    converted half float

  • GetTextureDataAsync: (
        texture: BaseTexture,
        width?: number,
        height?: number,
        face?: number,
        lod?: number,
        forceRTT?: boolean,
        slice?: number,
    ) => Promise<Uint8Array<ArrayBufferLike>>

    Gets the data of the specified texture by rendering it to an intermediate RGBA texture and retrieving the bytes from it. This is convienent to get 8-bit RGBA values for a texture in a GPU compressed format.

    the source texture

    the width of the result, which does not have to match the source texture width

    the height of the result, which does not have to match the source texture height

    if the texture has multiple faces, the face index to use for the source

    if the texture has multiple LODs, the lod index to use for the source

    the 8-bit texture data

  • ToHalfFloat: (value: number) => number

    Converts a number to half float

    number to convert

    converted number