SpriteStudioInternalPlayer class
Layer 2 — the Widget-agnostic drawing engine (ports the SDK's
SSInternalPlayer).
Owns the FFI Context and a hold on the shared SsabPack, advances time,
pulls the per-frame FrameData + SoA buffers from the Brain, and drives a
RenderBackend (Canvas or flutter_gpu) to turn each DrawBatch into pixels.
It is dispose-able and reusable from higher layers (Player) or headless
tests. As RenderHost it exposes the per-player data the backend draws from.
- Implemented types
Constructors
-
SpriteStudioInternalPlayer.load(Uint8List ssab, {TextureRegistry? textures, Map<
int, Uint8List> ? instancePacks, SpriteStudioBackend backend = SpriteStudioBackend.auto, @visibleForTesting RenderBackend? renderBackendOverride}) -
Loads
ssabinto a fresh Context, binds it, and recursively spawns any instance children.factory
Properties
- currentAnimationIndex → int?
-
Index into the pack's animations of what track 0's main source plays:
the animation setupAnimation chose, or what a crossfade or track
animation on track 0 handed over to.
no setter
- debugEvaluations → int
-
How many times getFrameData has asked the Brain to evaluate a frame,
for tests.
no setter
-
effectParts
→ List<
EffectPart> -
The effect-hosting parts in this pack (empty when it has none).
no setter
- endFrame → int
-
See SpriteStudioPlayer.endFrame.
no setter
- frameNo → double
-
See SpriteStudioPlayer.frameNo.
no setter
- frameRate ↔ int
-
See SpriteStudioPlayer.frameRate.
getter/setter pair
- frameSkipEnabled ↔ bool
-
See SpriteStudioPlayer.frameSkipEnabled.
getter/setter pair
- geometry → GeometryBuilder
-
RenderHost: the shared SoA→vertex baker.no setter - hasEffects → bool
-
RenderHost: whether this player hosts any effect parts.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- instanceContext → SsContext
-
The child's runtime Context.
ss_instance_slot_stepsteps this, while theEventInstanceis resolved against the parent's context.no setteroverride -
instanceParts
→ List<
InstancePart> -
The instance-hosting parts in this pack (empty when it has none).
no setter
- isClockPausing → bool
-
Whether a pause holds the clock, track 0 finished or not. Implies
isClockPlaying.
no setter
- isClockPlaying → bool
-
The character's clock, which every track and every fade runs on: started
by play, stopped by stop and by a successful setupAnimation. Not
isPlaying, which is track 0's — track 0 running out leaves it running
for the overlays and fades.
no setter
- isDisposed → bool
-
Whether dispose has run. Every call but this one is then an error.
no setter
- isFinished → bool
-
Every configured loop has played. Sticky until the next play/setup, so
callers wanting a one-shot notification must take the rising edge.
no setter
- isFrameInvalidated → bool
-
Whether a call that changes the pose without moving the clock — a track
call, a part override — still waits for the update that builds it: the
Brain applies those when it next builds a frame.
no setter
- isPausing → bool
-
Whether playback is paused. Note the Brain keeps isPlaying
truewhile paused (pause is a hold, not a stop).falsebefore the firstplayand afterstop— the Brain keeps "paused" implying "playing" — so this can be read on its own.no setter - isPlaying → bool
-
See SpriteStudioPlayer.isPlaying.
no setter
- isPlayingForward → bool
-
Which way the playhead is actually travelling — see
SpriteStudioPlayer.isPlayingForward.
no setter
- isStackInMotion → bool
-
Whether the track stack moves the pose for a reason other than track 0's
own animation stepping: a fade in flight, or another source playing at a
speed and weight above zero on a track that is heard. The Brain's verdict,
not a copy kept here — a crossfade that completes releases its outgoing
source on its own, and a copy would keep counting it.
no setter
- justLooped → bool
-
See SpriteStudioPlayer.justLooped.
no setter
- keptFrame → bool
-
Whether the last updateMs kept the frame it already had, so the pose it
leaves is the one already drawn.
no setter
- lastErrorMessage → String?
-
Why the last call that tracks a reason failed, or null when it succeeded.
no setter
- loopCount ← int
-
See SpriteStudioPlayer.loopCount.
no getter
- onNeedsRepaint ↔ VoidCallback?
-
Called when the backend finishes preparing a resource the last paint drew
without (a GPU texture upload), so the frame should be painted again.
getter/setter pair
- pack → SsabPack
-
The pack this player holds, for a test to compare holders by.
no setter
- partNames → PartNameTable
-
Pack-level part names / name→index lookup. Indices are stable
within one
.ssab; resolve once and reuse.no setter - playbackDirection → SsPlaybackDirection
-
See SpriteStudioPlayer.playbackDirection.
no setter
- playbackStyle → SsPlaybackStyle
-
See SpriteStudioPlayer.playbackStyle.
no setter
- playsOnItsOwn → bool
-
Whether an effect or instance part in this tree runs on its own clock, and
so has to keep getting ticks through a pause.
no setter
- rootTransform ↔ SsRootTransform
-
The player-level flip / offset (default SsRootTransform.identity) — see
SsRootTransform for what it is and why it lives at this layer.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- speedScale ← double
-
See SpriteStudioPlayer.speedScale.
no getter
- startFrame → int
-
See SpriteStudioPlayer.startFrame.
no setter
- subFrameEnabled ↔ bool
-
When true (default), rendering samples the Brain's fractional (sub-frame)
frame number, giving smooth playback beyond the source FPS on high-refresh
displays. Set false to snap to integer frames.
getter/setter pair
- textures → TextureRegistry
-
texture_hash → decoded image / shader. Populated by the caller. Public as
part of
RenderHost.final - trackCount → int
-
See SpriteStudioPlayer.trackCount.
no setter
Methods
-
addTrackSource(
int track, String name, double weight) → int? - See SpriteStudioPlayer.addTrackSource.
-
cancelTrackFade(
int track) → bool - See SpriteStudioPlayer.cancelTrackFade.
-
cellmapTextureOverride(
int textureHash) → Image? -
The runtime override currently set for
textureHash(the override VALUE only, never the loaded original), or null when none is set. -
cellMeta(
) → Float32List - Per-part cell meta (parts × 6: pivot_x,pivot_y,w,h,rect_left,rect_top).
-
clearAllPartOverrides(
) → bool - Clears every per-part override on this player (all parts, all attributes). Does not recurse into instance children — each child owns its own context and therefore its own override table.
-
clearPartCellOverride(
String partName) → bool - Index form of clearPartCellOverride.
-
clearPartCellOverrideByIndex(
int partIndex) → bool -
Clears
partIndex's cell override (revert to the animation). -
clearPartColorOverride(
String partName) → bool - Index form of clearPartColorOverride.
-
clearPartColorOverrideByIndex(
int partIndex) → bool -
Clears
partIndex's colour override (revert to the animation). -
clearPartVisibilityOverride(
String partName) → bool - Index form of clearPartVisibilityOverride.
-
clearPartVisibilityOverrideByIndex(
int partIndex) → bool -
Clears
partIndex's visibility override (revert to the animation). -
clearTrack(
int track) → bool - See SpriteStudioPlayer.clearTrack.
-
crossfade(
int track, String name, Duration duration) → bool - See SpriteStudioPlayer.crossfade.
-
dispose(
) → void - Releases the native context, its instance children and effect slots, this player's hold on the pack and the render backend. Idempotent.
-
effectPlanFor(
int partIndex) → EffectDrawPlan? -
The particle plan for effect part
partIndexas of the last update, or null when that slot drew nothing (dead, unstarted, past its lifetime, or its part hidden). -
fadeTrack(
int track, double targetAlpha, Duration duration) → bool - See SpriteStudioPlayer.fadeTrack.
-
findPartIndex(
String name) → int -
Resolves
nameto its part index, or -1 when this pack has no such part. -
flagsFor(
int partIndex) → MaskPartFlags -
Static per-part mask role; MaskPartFlags.none past the part range.
Public as part of
RenderHost— the backend reads it to peel mask targets. -
getFrameData(
double frameNo) → FrameData? -
Parses the FlatBuffers
FrameDataforframeNo. The returned view aliases the Brain's internal buffer and is only valid until the next update — read it within the current frame. -
hashString(
String name) → int - Canonical name→id hash (never re-implement FNV-1a on the Dart side).
-
hitTestPart(
Offset point, {Iterable< int> ? parts}) → int -
The front-most part whose partQuad holds
point, amongparts(every part when null), on the frame this player last built — or -1 when none does.pointis in the space partQuad reports. -
instanceDispose(
) → void -
override
-
instancePlay(
) → void -
Starts the child from its (just-configured) start frame — what the Brain
requires on a transition edge.
override
-
instanceResetSlots(
) → void -
Re-arms the child's own slot debounces (recursively), without touching its
playback — the head-out half of instancePlay.
override
-
instanceSlotFor(
int partIndex) → InstanceSlot< SpriteStudioInternalPlayer> ? -
The live slot for instance part
partIndex— the child player and the frame the Brain last stepped it to — or null when the part has no child (its pack did not resolve). -
instanceStepSlots(
double childFrame, double deltaMs, bool childLooped) → void -
Drives the child's own per-frame slots (its effects and nested instances)
at the frame the Brain just stepped it to. The child's animation clock is
owned by
ss_instance_slot_step, so this must NOT callss_runtime_update.override -
instanceStop(
) → void -
Stops the child's own clock. Called once at setup: a child must not
self-advance before its
EventInstanceever fires.override -
isTrackFinished(
int track) → bool - See SpriteStudioPlayer.isTrackFinished.
-
localUvs(
) → Float32List - Per-part local UVs (parts × 10 floats: lt,rt,lb,rb,center in texture pixels).
-
localVertices(
) → Float32List - Per-part local vertices (parts × 10 floats: lt,rt,lb,rb,center).
-
meshIndexOffsets(
) → Uint32List - CSR prefix sum into meshIndices.
-
meshIndices(
) → Int32List - Mesh triangle indices, part-local and 0-based, sliced by meshIndexOffsets. Static.
-
meshUvs(
) → Float32List -
Mesh per-vertex UVs in texture-pixel space, interleaved
[u,v,…]and sliced by meshVertexOffsets (so vertexvis at2v,2v+1). Static. -
meshVertexOffsets(
) → Uint32List - CSR prefix sum into meshVerticesX / meshVerticesY / meshUvs.
-
meshVerticesX(
) → Float32List - Mesh per-vertex X coordinates, world space, all parts concatenated.
-
meshVerticesY(
) → Float32List - Mesh per-vertex Y coordinates (SoA companion to meshVerticesX).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
paint(
Canvas canvas, {Rect? dst, Size? sourceSize}) → void -
Draws the current frame into
canvas(ports ForGodot's_drawAnimation). Gathers the FlatBuffersFrameData+ SoA views into one DrawFrame, hands frame placement to theRenderBackend(which centers the animation's world origin indst), then dispatches eachDrawBatchon itskindto the backend. -
partHidden(
int partIndex) → bool -
Whether
partIndexis hidden on the frame this player last built — the keyframehidecomposed with any visibility override, read from the FrameData paint draws. Like partWorldMatrix it builds nothing: an override shows from the next frame built, and before any frame has been built every part reads as not hidden. A part absent from the frame'spartsreads as not hidden (its world matrix is still valid), matching ForGodot's and ForUnity's followers. Out-of-range → false. -
partQuad(
int partIndex) → SsPartQuad? -
The outline
partIndexis drawn with on the frame this player last built, in the space partWorldMatrix reports, or null when the part is hidden, draws nothing of its own, or no frame has been built. -
partSkinnedMesh(
int partIndex) → bool -
Whether
partIndexis a bone-bound (skinned) mesh part — a static fact read once from the.ssabPartDataat load, not a per-frame value. -
partWorldMatrix(
int partIndex) → Matrix4? -
The current-frame world transform of
partIndexas a Matrix4 in player-local (animation) space, or null when the index is out of range or no frame is available. -
passedEventIndices(
) → List< int> -
Indices, into an ssab
events()table, that were passed on the last update. The caller resolves user data / signals / audio from the ssab. -
passedEventSourceHandles(
) → List< int> -
The source that fired each of passedEventIndices, in the same order;
-1where the Brain names none. -
pause(
) → void - See SpriteStudioPlayer.pause.
-
play(
[double? startFrame]) → void - See SpriteStudioPlayer.play.
-
resume(
) → void - See SpriteStudioPlayer.resume.
-
seek(
double frame) → void - Moves the playhead, then re-resolves the slot-based kinds at the new frame. Without that second half an instance child keeps whatever visibility and child frame the last updateMs left it on, so a scrubbed or frozen frame can drop the children entirely.
-
setAnimationSection(
int startFrame, int endFrame) → bool -
Restricts playback to
[startFrame, endFrame]of the current animation. Reflected bystartFrame/endFrame, which report the played range. -
setCellmapTexture(
int textureHash, Image? image) → bool -
Replaces the texture registered under
textureHashwithimage, or restores the loaded original whenimageis null. Returns false for the reserved0hash (a TCHG "no override" / an unresolved name) and for a nullimagewhen no override was set (nothing changed).imagestays the caller's — the registry borrows it and never disposes it. -
setPartCellOverride(
String partName, String cellmapName, String cellName, {SsOverridePriority priority = SsOverridePriority.holdUntilNextAnimation}) → bool - Index form of setPartCellOverride.
-
setPartCellOverrideByIndex(
int partIndex, String cellmapName, String cellName, {SsOverridePriority priority = SsOverridePriority.holdUntilNextAnimation}) → bool -
Makes
partIndexdraw a different cell.cellmapNamecarries NO.ssceextension. Normal + Mask parts only. -
setPartColorOverride(
String partName, Color color, {SsBlendOp blendOp = SsBlendOp.mix, SsOverridePriority priority = SsOverridePriority.holdUntilNextAnimation}) → bool - Index form of setPartColorOverride.
-
setPartColorOverrideByIndex(
int partIndex, Color color, {SsBlendOp blendOp = SsBlendOp.mix, SsOverridePriority priority = SsOverridePriority.holdUntilNextAnimation}) → bool -
Overrides
partIndex's colour with one value flowed to all four corners. Normal parts only — other types return true and are ignored at the seam. -
setPartColorOverrideCorners(
String partName, SsCornerColors corners, {SsBlendOp blendOp = SsBlendOp.mix, SsOverridePriority priority = SsOverridePriority.holdUntilNextAnimation}) → bool - Index form of setPartColorOverrideCorners.
-
setPartColorOverrideCornersByIndex(
int partIndex, SsCornerColors corners, {SsBlendOp blendOp = SsBlendOp.mix, SsOverridePriority priority = SsOverridePriority.holdUntilNextAnimation}) → bool -
Four-corner form of setPartColorOverride (a gradient). The corner order
is the Brain's: left-top, right-top, left-bottom, right-bottom — swapping
leftBottomandrightTopsilently mirrors the gradient. -
setPartVisibilityOverride(
String partName, bool hide, {bool cascade = false}) → bool - Index form of setPartVisibilityOverride.
-
setPartVisibilityOverrideByIndex(
int partIndex, bool hide, {bool cascade = false}) → bool -
Force-hides
partIndex(hidetrue) or reverts it to the animation. Withcascadethe force-hide propagates to the part's descendants. -
setPlaybackDirection(
SsPlaybackDirection direction, SsPlaybackStyle style) → void - See SpriteStudioPlayer.setPlaybackDirection.
-
setSourceEventThreshold(
int source, double threshold) → bool - See SpriteStudioPlayer.setSourceEventThreshold.
-
setSourceFrame(
int source, double frame) → bool - See SpriteStudioPlayer.setSourceFrame.
-
setSourceWeight(
int source, double weight) → bool - See SpriteStudioPlayer.setSourceWeight.
-
setTrackAlpha(
int track, double alpha) → bool - See SpriteStudioPlayer.setTrackAlpha.
-
setTrackAnimation(
int track, String name) → bool - See SpriteStudioPlayer.setTrackAnimation.
-
setTrackBlend(
int track, SsTrackBlend blend) → bool - See SpriteStudioPlayer.setTrackBlend.
-
setTrackFrame(
int track, double frame) → bool - See SpriteStudioPlayer.setTrackFrame.
-
setTrackFrameRate(
int track, int fps) → bool - See SpriteStudioPlayer.setTrackFrameRate.
-
setTrackFrameSkipEnabled(
int track, bool skip) → bool - See SpriteStudioPlayer.setTrackFrameSkipEnabled.
-
setTrackLoopCount(
int track, int count) → bool - See SpriteStudioPlayer.setTrackLoopCount.
-
setTrackOutgoingEventThreshold(
int track, double threshold) → bool - See SpriteStudioPlayer.setTrackOutgoingEventThreshold.
-
setTrackPlaybackDirection(
int track, SsPlaybackDirection direction, SsPlaybackStyle style) → bool - See SpriteStudioPlayer.setTrackPlaybackDirection.
-
setTrackSpeed(
int track, double speed) → bool - See SpriteStudioPlayer.setTrackSpeed.
-
setTrackSync(
int track, SsTrackSync sync) → bool - See SpriteStudioPlayer.setTrackSync.
-
setupAnimation(
String name) → bool - Selects the animation to play by name and rewinds to frame 0.
-
shapeVertexBoxCoords(
) → Float32List -
Normalised
[fx,fy,…]box coordinates paired with shapeVertices, same stride — the weights for per-vertex PartColor. -
shapeVertexCounts(
) → Int32List -
Live vertex count per part for shapeVertices. The only valid slice: a
Shape batch's
vertex_count/index_countare 0. -
shapeVertices(
) → Float32List -
Shape polygon vertices in local space, interleaved
[x,y,…]at a fixed stride of 24 floats per part (ShapeBuffers.stride) — not CSR like the mesh. Apply the world matrix; pivot and the Y-Down flip are already in. -
sourceAnimationIndex(
int source) → int? -
Index into the pack's animations of what
sourceplays — the table its passed events address. -
sourceEventThreshold(
int source) → double? - See SpriteStudioPlayer.sourceEventThreshold.
-
sourceFrame(
int source) → double? - See SpriteStudioPlayer.sourceFrame.
-
sourceWeight(
int source) → double? - See SpriteStudioPlayer.sourceWeight.
-
stop(
) → void - See SpriteStudioPlayer.stop.
-
toString(
) → String -
A string representation of this object.
inherited
-
trackAlpha(
int track) → double? - See SpriteStudioPlayer.trackAlpha.
-
trackBlend(
int track) → SsTrackBlend? - See SpriteStudioPlayer.trackBlend.
-
trackFadeProgress(
int track) → double? - See SpriteStudioPlayer.trackFadeProgress.
-
trackFrame(
int track) → double? - See SpriteStudioPlayer.trackFrame.
-
trackFrameRate(
int track) → int? - See SpriteStudioPlayer.trackFrameRate.
-
trackFrameSkipEnabled(
int track) → bool? - See SpriteStudioPlayer.trackFrameSkipEnabled.
-
trackJustLooped(
int track) → bool - A pulse, like justLooped: the Brain clears it on entry to every update, so it describes the last one.
-
trackLoopCount(
int track) → int? - See SpriteStudioPlayer.trackLoopCount.
-
trackMainSource(
int track) → int? - See SpriteStudioPlayer.trackMainSource.
-
trackOutgoingEventThreshold(
int track) → double? - See SpriteStudioPlayer.trackOutgoingEventThreshold.
-
trackPlaybackDirection(
int track) → SsPlaybackDirection? - See SpriteStudioPlayer.trackPlaybackDirection.
-
trackPlaybackStyle(
int track) → SsPlaybackStyle? - See SpriteStudioPlayer.trackPlaybackStyle.
-
trackSpeed(
int track) → double? - See SpriteStudioPlayer.trackSpeed.
-
trackSync(
int track) → SsTrackSync? - See SpriteStudioPlayer.trackSync.
-
update(
Duration delta) → double - Advances internal time. Returns the new (sub-frame) frame number.
-
updateMs(
double deltaMs) → double - update with the delta in milliseconds, as the Brain takes it.
-
worldMatrices(
) → Float32List - Per-part 4×4 world matrices (parts × 16 floats).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited