Expand description
ssplayer-wgpu — a wgpu-based player for SpriteStudio animations.
The player borrows the host’s wgpu device, queue and render target rather than owning them, so it draws into any wgpu host — a standalone viewer, a browser canvas, or an engine like Bevy.
Three types, split by how long their resources stay useful:
SSRenderer— one per device: pipelines, bind group layouts, the sampler and the atlas textures. The host owns it and lends it.SSScene— one per render target: the projection and the frame’s geometry.SSPlayer— one per character: the playback tree. Holds no GPU resource.
Re-exports§
Modules§
- ffi
- The “ffi” face: the C ABI over the Rust API, for C/C++ hosts on DX12 / Vulkan / Metal.
- fit
fit/align— placing an animation inside a box the host laid out.- host
- A self-contained native host: owns a wgpu stack built from a raw window
handle and drives any number of
SSPlayers with it.
Structs§
- Atlas
Keys - Which renderer key each of one pack’s cellmaps resolves to.
- Audio
Event - An audio trigger. The player never produces sound: this says what to play and how many times, and the host feeds its own audio stack.
- Batch
Info - The fields of one
DrawBatchthe renderer needs, extracted by the caller so the operation layer keeps ownership of batch iteration. - Crowd
Member - One of the copies
SSPlayer::set_crowddraws: where it stands, and how it is faded and tinted, each on top of the player’s own. - Embedded
Image - One atlas an embedded
.ssabcarries, still in the form the exporter wrote it: encoded image bytes (PNG), not pixels. - Embedded
Texture - One atlas image decoded out of an embedded
.ssab. - Frame
Chunk - One frame of one render target: the arena, primitives, mesh stream and draw
calls every player sharing the target appends to, in its
order. - Frame
View - Everything
crate::SSSceneneeds to draw one frame, as borrows into runtime-owned data. - Mask
Writer - One planned stencil writer for the current frame.
- Mask
Writers - One frame’s planned writers, held inline: what
plan_writershands back. - Missing
Asset - Something a load needed and did not get.
- Node
Slot - Where one node’s placement and coverage block sit in the frame arena.
- Part
Mask Flags - Static, per-part mask flags read once from ssab
PartData. - SSPack
- A loaded
.ssab, shareable between players. - SSPlayer
- The SpriteStudio player. One instance owns one animation-instance tree.
- SSRenderer
- Everything whose useful lifetime is the device, not one player and not one render target.
- SSScene
- The per-target, per-frame half — what one render target’s worth of geometry looks like this frame.
- Scene
Config - Construction config for SSScene, matched to the host’s render target.
- Scene
Stats - What one frame of a
crate::SSScenecost. - Scoped
Writer - A writer placed on its player’s tree sequence: the whole instance tree numbered in drawing order, each sub-animation in its instance part’s place.
- Signal
Event - A “Signal”: a named command plus its parameters.
- Signal
Param - One
param_id→ value pair on a signal. - SsContext
Web - The page’s WebGPU context: one adapter, one device, one
SSRenderer, shared by every canvas and every player on the page. - SsPlayer
Web - One character. Holds the playback tree and its placement in the scene — and no GPU resource at all, which is what makes it cheap to have many.
- SsSurface
Web - One canvas and the scene drawn into it. Holds any number of
players, composited in ascending
orderin a single render pass. - Texture
Ref - One atlas a pack asks for, described the way the
.ssabitself describes it. - User
Data Event - A “User Data” marker: up to four optional values, in whatever combination
the animator filled in. A field is
Nonewhen it was left unset — which is not the same as zero, and is why these are options rather than defaults.
Enums§
- Alpha
Mode - How a texture’s colour channels relate to its alpha.
- BlendOp
- How an override’s colour combines with what is underneath — the same four operations the authored PartColor offers.
- Geom
Kind - Geometry a part contributes as a mask writer. Text/Nines are not yet rendered, so they cannot write coverage yet.
- Mask
Backend - How a scene rasterises mask coverage.
- MaskOp
- Stencil write operation, resolved by the caller from a writer’s op and whether it is being added or removed from coverage. Increment pairs with decrement (its inverse); invert is its own inverse.
- Missing
Kind - What kind of thing
SSPlayer::loadcould not get. - Override
Priority - How long an override outlives the keyframes it beats.
- Playback
Direction - Which way the playhead walks the animation.
- Playback
Style - What happens when the playhead reaches the far end of the range.
- Retention
- Whether
SSRenderer::upload_texturekeeps a copy of the pixels for device loss recovery. - SSRuntime
Error - Everything that can go wrong loading or playing back an animation.
- Signal
Value - One value carried by a signal parameter.
- SsEvent
- Something that happened on a frame the last update crossed.
- Stencil
Test - Stencil test mode baked into a content pipeline. Selected per masked part
from the target’s
visible_inside_maskpolarity. - Track
Blend - Re-exported from the runtime: how a track folds onto the tracks below it. How a track folds onto the pose the tracks below it produced.
- Track
Sync - Re-exported from the runtime: where the animations laid on a track start.
How the animation laid on a track keeps time with track 0. Sync means the
normalised phase: how far through its section an animation stands, from
0.0at the section start towards1.0at its end, so animations of different lengths line up by proportion rather than by frame.
Constants§
- IDENTITY_
TRANSFORM - Column-major 4x4 identity. Used as the root transform (children compose their parent instance part’s world matrix onto this).
- MAX_
CROWD_ MEMBERS - The most members
SSPlayer::set_crowddraws; those past it are left out. - SDK_
VERSION - The SpriteStudio-SDK version whose runtime this build links, written as
its release tag (
v7.0.0).scripts/build.shnames it from the submodule’s version; a plaincargo buildsayslocal. - VERSION
- This player’s version,
ssplayer-wgpu’s own.
Traits§
- Asset
Loader - The three things the loading walk cannot do for itself: reach a file, decode an image, and know what the renderer already holds.
Functions§
- plan_
writers - Plan the frame’s stencil writers by walking
draw_batches, mirroring the WebGLMaskPlanner.plan.mask_flagsis indexed by part index (static ssab data). Returns writers in ascending rank order, capped atMAX_MASK_WRITERS.