Texture
Texture
Wrapper around a native texture data.
.constructor(engine: WonderlandEngine, param: number | HTMLCanvasElement | HTMLImageElement | HTMLVideoElement) ⇒ Texture
Param | Type | Description |
---|---|---|
engine | WonderlandEngine | The engine instance |
param | number | HTMLCanvasElement | HTMLImageElement | HTMLVideoElement | HTML media element to create texture from or texture id to wrap. |
.engine
Hosting engine instance.
.height
Height of the texture.
.id
Index in this manager.
.valid
Whether this texture is valid.
.width
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 |