API

Function appendSpriteAtlasFrames

  • Append sources into the remaining free space of an atlas previously built by createSpriteAtlasFromFrames. The existing GPUTexture (and any bind group already referencing it) stays valid — each new frame is uploaded with a single queue.writeTexture and the UV slots of the existing frames are not touched, so sprite instances already drawing from this atlas remain correct.

    Returns the integer indices of the newly-appended frames in atlas.frames, in input order. Sources are validated and placed before any texel is written, so a thrown "atlas full" error leaves the atlas state untouched (all-or-nothing semantics).

    Throws when:

    • The atlas was built by createGridSpriteAtlas / loadSpriteAtlas (no packer state).
    • Any source has invalid size / sub-rect / pixel buffer length.
    • A source wider than maxWidthPx is supplied (cannot fit any shelf).
    • The packed sources would overflow the atlas height. Pre-size the atlas via createSpriteAtlasFromFrames(engine, [...], { capacityPx: [w, h] }) to reserve room.

    Parameters

    Returns number[]