@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
99 lines (98 loc) • 5.23 kB
TypeScript
import type { BaseTexture } from "../Materials/Textures/baseTexture.js";
import type { InternalTexture } from "../Materials/Textures/internalTexture.js";
import { Texture } from "../Materials/Textures/texture.js";
import type { Scene } from "../scene.js";
/**
* Uses the GPU to create a copy texture rescaled at a given size
* @param texture Texture to copy from
* @param width defines the desired width
* @param height defines the desired height
* @param useBilinearMode defines if bilinear mode has to be used
* @returns the generated texture
*/
export declare function CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
/**
* Apply a post process to a texture
* @param postProcessName name of the fragment post process
* @param internalTexture the texture to encode
* @param scene the scene hosting the texture
* @param type type of the output texture. If not provided, use the one from internalTexture
* @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
* @param format format of the output texture. If not provided, use the one from internalTexture
* @param width width of the output texture. If not provided, use the one from internalTexture
* @param height height of the output texture. If not provided, use the one from internalTexture
* @returns a promise with the internalTexture having its texture replaced by the result of the processing
*/
export declare function ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number, width?: number, height?: number): Promise<InternalTexture>;
/**
* Converts a number to half float
* @param value number to convert
* @returns converted number
*/
export declare function ToHalfFloat(value: number): number;
/**
* Converts a half float to a number
* @param value half float to convert
* @returns converted half float
*/
export declare function FromHalfFloat(value: number): number;
/**
* 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.
* @param texture the source texture
* @param width the width of the result, which does not have to match the source texture width
* @param height the height of the result, which does not have to match the source texture height
* @param face if the texture has multiple faces, the face index to use for the source
* @param lod if the texture has multiple LODs, the lod index to use for the source
* @returns the 8-bit texture data
*/
export declare function GetTextureDataAsync(texture: BaseTexture, width: number, height: number, face?: number, lod?: number): Promise<Uint8Array>;
/**
* Class used to host texture specific utilities
*/
export declare const TextureTools: {
/**
* Uses the GPU to create a copy texture rescaled at a given size
* @param texture Texture to copy from
* @param width defines the desired width
* @param height defines the desired height
* @param useBilinearMode defines if bilinear mode has to be used
* @returns the generated texture
*/
CreateResizedCopy: typeof CreateResizedCopy;
/**
* Apply a post process to a texture
* @param postProcessName name of the fragment post process
* @param internalTexture the texture to encode
* @param scene the scene hosting the texture
* @param type type of the output texture. If not provided, use the one from internalTexture
* @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
* @param format format of the output texture. If not provided, use the one from internalTexture
* @returns a promise with the internalTexture having its texture replaced by the result of the processing
*/
ApplyPostProcess: typeof ApplyPostProcess;
/**
* Converts a number to half float
* @param value number to convert
* @returns converted number
*/
ToHalfFloat: typeof ToHalfFloat;
/**
* Converts a half float to a number
* @param value half float to convert
* @returns converted half float
*/
FromHalfFloat: typeof FromHalfFloat;
/**
* 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.
* @param texture the source texture
* @param width the width of the result, which does not have to match the source texture width
* @param height the height of the result, which does not have to match the source texture height
* @param face if the texture has multiple faces, the face index to use for the source
* @param channels a filter for which of the RGBA channels to return in the result
* @param lod if the texture has multiple LODs, the lod index to use for the source
* @returns the 8-bit texture data
*/
GetTextureDataAsync: typeof GetTextureDataAsync;
};