Texture
Texture API reference
Wrapper around a native texture data.
.constructor(engine: WonderlandEngine, param: number | ImageLike) ⇒ Texture
Param | Type | Description |
---|---|---|
engine | WonderlandEngine | The engine instance |
param | number | ImageLike | HTML 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.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:
.equals(otherTexture: undefined | null | Texture) ⇒ boolean
1.0.0+Checks equality by comparing whether the wrapped native texture ids are equal.
Returns: Whether this texture equals the given texture.
Param | Type | Description |
---|---|---|
otherTexture | undefined | null | Texture | Texture 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:
Param | Type | Description |
---|---|---|
x | number | x offset |
y | number | y offset |
w | number | width |
h | number | height |