AbstractRelease any GPU/CPU resources held by this texture. The texture must not be used after calling destroy. No-op by default — subclasses override when they own resources (a baked canvas, a cached GL texture, a pooled render target).
AbstractgetReturn the drawable source for this texture — assignable to Sprite#image, Sprite#normalMap, an ImageLayer, or bound as a sampler uniform in a custom shader.
the backing canvas/image
Abstract base for a user-constructed 2D texture asset — an object that owns a drawable image source and can be used anywhere the engine expects an image: Sprite#image, Sprite#normalMap, an ImageLayer, or bound as a sampler uniform in a custom GLShader.
A
Texture2dis recognized by the renderables viainstanceofand resolved to its backing canvas/image through Texture2d#getTexture — so passing the asset object directly ({ image: myTexture }) works the same as passing a rawHTMLCanvasElement. Raw DOM image/canvas sources and the loader's decodedCompressedImagedata are accepted too, but are not part of this class hierarchy.Concrete implementations:
A future WebGPU implementation would back Texture2d#getTexture with a
GPUTexture-wrapping surface rather than anHTMLCanvasElement.