The 2D layer · interface

SpriteSheet

The frames of one texture.

Explained in Sprites and tilemaps.

interface SpriteSheet
import 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

NameTypeDescription
texturereadonlynumberThe slot on the pass this sheet's texture was set into.
widthreadonlynumberThe texture's own size, in texels.
heightreadonlynumber
countreadonlynumber
uvsreadonlyFloat32ArrayFour per frame: u0, v0, u1, v1.
sizesreadonlyFloat32ArrayTwo per frame: width and height in texels, for drawing a frame at its own scale.
namesreadonlyReadonlyMap<string, number>