AbstractRelease any GPU/CPU resources held by this texture. The texture must not be used after calling destroy.
Broadcasts event.TEXTURE2D_DESTROYED with the backing source so
GPU-side caches keyed by source image (e.g. the lit batcher's normal-map
textures) release what they hold for it. Subclasses that own additional
resources override this and call super.destroy() FIRST — the source
must still be resolvable when the event fires.
AbstractgetReturn the backing source for this texture — a drawable canvas/image for CPU-backed assets (assignable to Sprite#image / Sprite#normalMap / an ImageLayer), or an opaque GPU-resident backing for GPU-resident ones (bind those as a custom-shader sampler via ShaderEffect#setTexture; they are not drawable sources).
the backing source
Abstract base for a 2D texture asset — an object that owns a texture 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 shader (see ShaderEffect#setTexture).
A
Texture2dis recognized viainstanceofand resolved to its backing source 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.Most assets are CPU-backed and resolve to a drawable canvas/image — those are the ones assignable to Sprite#image / Sprite#normalMap / an ImageLayer (which upload the drawable through the texture cache). Subclasses may also be GPU-resident, resolving to an opaque renderer backing that never leaves the GPU (e.g. the capture returned by
renderer.toFrameTexture()). A GPU-resident texture is not a drawable source: use it as a custom-shader sampler via ShaderEffect#setTexture (which binds its live GL handle), NOT asSprite#image. The contract admits both (a future WebGPU backend follows the same shape with aGPUTexture).Concrete implementations: