the renderable this engine drives. Read for the
texture it animates (source / textureAtlas / atlasIndices) and the
mutable cycle-end callback (onended). These are read lazily (the texture is
usually resolved after the engine is constructed), which is why they live on
the host rather than being passed in. The engine does not touch isDirty —
the host marks itself dirty inside applyFrame.
defined animations, keyed by id
pause flag — freezes the current frame
default frame cycling speed (ms between frames)
current frame info
elapsed time within the current frame, in ms
add an animation definition (see Sprite#addAnimation).
animation id
frame indices / names / objects
Optionalanimationspeed: numbercycling speed in ms
number of frames added (0 if no texture atlas)
release engine-held resources — returns the pooled current.offset
Vector2d to the pool. Call from the host's destroy().
the frame object for the given index within the current animation.
the frame id
the frame data
the names of every defined animation
the current animation frame index
animation id
true if name is the current animation
clear the frame timer and the play-once "done" hold, without changing the current frame (the timer half of a stop, used by the video path which has no frame to rewind to).
reverse the given (or current) animation in place (see Sprite#reverseAnimation).
The host marks itself dirty (this path doesn't re-apply a frame, so it's the
one place a host's reverseAnimation wrapper sets isDirty).
Optionalname: stringanimation id
reset the current animation to its first frame (the frame-animation half of Sprite#stop — the host still handles any video / pause concerns).
force the current animation frame index (see Sprite#setAnimationFrame).
Optionalindex: number = 0animation frame index
the host (for method chaining)
select the active animation (see Sprite#setCurrentAnimation).
animation id
OptionalresetAnim: string | object | Functionloop / chain / completion behavior
Optionalpreserve_dt: boolean = falsekeep the elapsed-frame timer
the host (for method chaining)
apply a texture region as the current frame: store its geometry into
current and hand it to the host to draw (see Sprite#setRegion).
the texture region object
the host (for method chaining)
advance the frame animation by dt milliseconds, stepping frames, looping
and chaining as configured (see Sprite#update). On a frame change the
host marks itself dirty via _applyFrame (the engine owns no dirty flag);
this returns whether a frame actually changed this tick — a finer-grained
signal than the host's isDirty (which means "needs redraw for any reason").
elapsed time since the last update, in milliseconds
true if a frame changed this tick
The shared frame-animation engine behind Sprite (2D) and Sprite3d (3D billboards). It owns the animation state — definitions, the current frame, timing, looping and chaining — everything independent of how a frame is ultimately drawn, and drives its host renderable through a small contract:
host.source,host.textureAtlas,host.atlasIndices) to turn a frame index/name into a region;applyFrame(region)callback passed to the constructor whenever the frame changes — the host applies it to its own geometry (Sprite swaps its source sub-texture, size and anchor; Sprite3d maps the region onto its quad's UVs + vertices) and marks itself dirty there;host.onended()at each cycle end.The engine owns no dirty flag: a frame change flows through
applyFrame, where the host sets its ownisDirty. Callers read dirtiness from the host (the host'supdate()returnssuper.update()→isDirty).Hosts expose the public-facing state (
anim,current,animationspeed,animationpause, …) as thin accessors onto this engine, so 2D and 3D frame animation share one implementation with no behavioral fork.