Class: TextureManager
Creates, updates, and reads textures.
Constructors
Constructor
new TextureManager(): TextureManager;
Returns
TextureManager
Methods
Create2D()
static Create2D(
width,
height,
format?,
linear?): Promise<number>;
Creates a 2D texture.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | The texture width, in pixels. |
height | number | The texture height, in pixels. |
format? | TextureFormat | The texture format. Defaults to TextureFormat.RGBA32. |
linear? | boolean | Whether the texture should use linear color format. Defaults to false (sRGB). |
Returns
Promise<number>
A promise that resolves to the created Texture.
CreateRenderTexture()
static CreateRenderTexture(
width?,
height?,
depth?,
dimension?,
format?): Promise<number>;
Creates a render texture.
Parameters
| Parameter | Type | Description |
|---|---|---|
width? | number | The texture width, in pixels. Defaults to 512. |
height? | number | The texture height, in pixels. Defaults to 512. |
depth? | number | The depth buffer size. Defaults to 16. |
dimension? | TextureDimension | The texture dimension. Defaults to TextureDimension.Tex2D. |
format? | RenderTextureFormat | The texture format. Defaults to RenderTextureFormat.DefaultHDR. |
Returns
Promise<number>
A promise that resolves to the created Texture.
Destroy()
static Destroy(handle): Promise<boolean>;
Destroys a texture.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Texture to destroy. |
Returns
Promise<boolean>
A promise that resolves to true if the texture was destroyed, or
false otherwise.
GetTextureSize()
static GetTextureSize(handle): Promise<vec2>;
Gets the size of a texture.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Texture to inspect. |
Returns
Promise<vec2>
A promise that resolves to the texture size as [width, height].
LoadRGBAImage()
static LoadRGBAImage(
handle,
rgbaData,
width,
height): Promise<void>;
Sets raw RGBA image data for a texture.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Texture to update. |
rgbaData | Uint8Array | RGBA byte data in R, G, B, A order. |
width | number | The image width, in pixels. |
height | number | The image height, in pixels. |
Returns
Promise<void>
A promise that resolves when the image data has been changed.
LoadImage()
static LoadImage(handle, image): Promise<void>;
Loads encoded image data into a texture.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Texture to update. |
image | Uint8Array | PNG, JPG, or EXR image data. |
Returns
Promise<void>
A promise that resolves when the image data has been changed.
ReadbackRGBAImage()
static ReadbackRGBAImage(handle): Promise<ImageReadbackResult>;
Gets image data from a texture in RGBA format.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Texture to read. |
Returns
Promise<ImageReadbackResult>
A promise that resolves to the image data.
ReadbackJPGImage()
static ReadbackJPGImage(handle, quality?): Promise<ImageReadbackResult>;
Gets image data from a texture in JPEG format.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Texture to read. |
quality? | number | The JPEG quality, from 0 to 100. Defaults to 75. |
Returns
Promise<ImageReadbackResult>
A promise that resolves to the image data.
ReadbackPNGImage()
static ReadbackPNGImage(handle): Promise<ImageReadbackResult>;
Gets image data from a texture in PNG format.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Texture to read. |
Returns
Promise<ImageReadbackResult>
A promise that resolves to the image data.
SetFilterMode()
static SetFilterMode(handle, mode): Promise<void>;
Sets the filter mode of a texture.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Texture to update. |
mode | TextureFilterMode | The filter mode to apply. |
Returns
Promise<void>
A promise that resolves when the filter mode has been changed.
SetWrapModeU()
static SetWrapModeU(handle, wrapMode): Promise<void>;
Sets the wrap mode of a texture on the U axis.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Texture to update. |
wrapMode | TextureWrapMode | The wrap mode to apply. |
Returns
Promise<void>
A promise that resolves when the wrap mode has been changed.
SetWrapModeV()
static SetWrapModeV(handle, wrapMode): Promise<void>;
Sets the wrap mode of a texture on the V axis.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Texture to update. |
wrapMode | TextureWrapMode | The wrap mode to apply. |
Returns
Promise<void>
A promise that resolves when the wrap mode has been changed.