Texture

Wrapper around a native texture data.

For more information about how to create meshes, have a look at the TextureManager class.

Note: Textures are per-engine, they can thus be shared by multiple scenes.

.constructor(engine: WonderlandEngine, param: number | ImageLike) ⇒ Texture 

Deprecated: Use create instead, accessible via textures:

1const image = new Image();
2image.onload = () => {
3    const texture = engine.textures.create(image);
4};
ParamTypeDescription
engineWonderlandEngine
paramnumber | ImageLike

.height: number 

Height of the texture.

.htmlElement: null | ImageLike 

Returns the html element associated to this texture.

Note: This accessor will return null if the image is compressed.

.id: number 

Index in this manager.

Deprecated: Use index instead.

.valid: boolean 

Whether this texture is valid

Deprecated: Use isDestroyed instead.

.width: number 

Width of the texture.

.destroy() ⇒ void 

0.9.0+

Destroy and free the texture’s texture altas space and memory.

It is best practice to set the texture variable to null after calling destroy to prevent accidental use of the invalid texture:

1  texture.destroy();
2  texture = null;

.toString() ⇒ string 

.update() ⇒ void 

Update the texture to match the HTML element (e.g. reflect the current frame of a video).

.updateSubImage(x: number, y: number, w: number, h: number) ⇒ void 

Update a subrange on the texture to match the HTML element (e.g. reflect the current frame of a video).

Usage:

1// Copies rectangle of pixel starting from (10, 20)
2texture.updateSubImage(10, 20, 600, 400);
ParamTypeDescription
xnumberx offset
ynumbery offset
wnumberwidth
hnumberheight