The 2D layer · interface
SpriteSheet
The frames of one texture.
Explained in Sprites and tilemaps.
interface SpriteSheetimport type { SpriteSheet } from '@driftengine/ui2d';In depth
Two flat arrays and a name index rather than an array of objects: reading a frame in a draw loop
is four Float32Array reads and no property lookups, and a tilemap does that per tile.
Properties
| Name | Type | Description |
|---|---|---|
texturereadonly | number | The slot on the pass this sheet's texture was set into. |
widthreadonly | number | The texture's own size, in texels. |
heightreadonly | number | |
countreadonly | number | |
uvsreadonly | Float32Array | Four per frame: u0, v0, u1, v1. |
sizesreadonly | Float32Array | Two per frame: width and height in texels, for drawing a frame at its own scale. |
namesreadonly | ReadonlyMap<string, number> |