The 2D layer · interface
SpritePass
Explained in Sprites and tilemaps.
interface SpritePass extends PassDefinitionimport type { SpritePass } from '@driftengine/ui2d';Properties
| Name | Type | Description |
|---|---|---|
batchreadonly | SpriteBatch | The quads for this frame. Reset it, fill it with drawSprite, then call drawPass.MoreHeld by the pass rather than handed in per frame, because its size is the pass's GPU buffer and the two must agree. |
whitereadonly | number | A slot holding one opaque white texel, filled by the pass and not settable.MoreWhite is the identity of the multiply the shader does, so a quad on this slot draws exactly its
tint — which is what a solid rectangle is, and what A background on this slot and an image from a sheet are two runs, because a slot change is a run and the order may not be regrouped. A caller with many filled boxes and many images interleaved should pack a white texel into its own sheet and tint a frame of that instead: then the whole tree is one run. This slot is the convenience, and the sheet is the fast path. |
Methods
reset
reset(): voidClear the batch. Call once at the top of a frame.
setTransform
setTransform(affine: Affine2D): voidWhere the batch's coordinates are, from screenToNdc or worldToNdc.
| Parameter | Type | Description |
|---|---|---|
affine | Affine2D |
More
Copied, so the caller may reuse its array; and read at draw time, so this can be called before the pass has a device.
setTexture
setTexture(slot: number, source: SpriteImage, options?: SpriteTextureOptions): voidFill a texture slot. Safe before the pass is registered; applied when it gets a device.
| Parameter | Type | Description |
|---|---|---|
slot | number | |
source | SpriteImage | |
options? | SpriteTextureOptions |