Texture

Wrapper around a native texture data.

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

ParamTypeDescription
engineWonderlandEngineThe engine instance
paramnumber | ImageLikeHTML media element to create texture from or texture id to wrap.

.engine: WonderlandEngine 

Hosting engine instance.

.height: number 

Height of the texture.

.id: number 

Index in this manager.

.valid: boolean 

Whether this texture is valid.

.width: number 

Width of the texture.

.destroy() ⇒ void 

0.8.5+

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;

.equals(otherTexture: undefined | null | Texture) ⇒ boolean 

0.8.5+

Checks equality by comparing whether the wrapped native texture ids are equal.

Returns: Whether this texture equals the given texture.

ParamTypeDescription
otherTextureundefined | null | TextureTexture to check equality with.

.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