Expand description
Bevy adapter for ssplayer_wgpu — SpriteStudio characters inside a Bevy
app, drawn on the device Bevy already owns.
§Shape
Bevy renders in two worlds, and this crate is split along that seam:
- Main world —
SsPlayer,SsTransformandSsPlayback. Spawn them, change them, and that is the whole authoring surface. The.ssaba character plays is anSsPackasset, loaded through theAssetServer. - Render world — the playback trees, one device-scoped
SSRendererand one target-scopedSSScene. Nothing here is reachable from gameplay code.
Authoring state crosses to the render world through ExtractSchedule;
playback state crosses back through a shared buffer — the timeline events
(SsEventMessage), the start, loop and completion edges (SsStarted,
SsLooped, SsFinished), and the frame landed on (SsPlaybackState). The
return trip is one frame late, because playback runs in the render world.
The player never owns Bevy’s Device / Queue / render target; the draw
system lends them for the frame, which is the same contract the winit viewer
and the C++ hosts honour.
§Supported Bevy
Bevy 0.20.x, and no other line. Bevy and this player must resolve to one
wgpu — 0.20 wants ^30 and the player is pinned to 30 — because two
majors of wgpu are two unrelated sets of types, and no amount of glue
bridges them. npm would express this as a peer dependency; cargo has no such
thing, so it is stated here and enforced by the workspace resolving one
wgpu.
§Masks
Bevy’s 2d depth texture is Depth32Float and carries no stencil, so this
adapter selects the player’s coverage-bitmap mask backend
(MaskBackend::Coverage) rather than its stencil one. Nothing is asked of
Bevy’s attachments; the player rasterises its own bitmap into the encoder the
draw pass is opened on, which is what makes the clip this frame’s rather than
the last one’s. It costs one extra render pass per masking character.
§Fades and crowds
SsSceneSettings::group_alpha fades a character as one layer rather than
part by part, drawn ahead of the pass into the same encoder, as the masks
are. SsCrowd draws one character’s playhead at many placements for the
cost of one.
§Limits of this version
- One view. The adapter holds one
SSScenewith every character in it, andSSScene::updatefuses the timeline advance with the geometry build, so a second view would advance every animation twice per frame. Later views are skipped, with a warning. - MSAA must be off. The player’s pipelines are single-sampled.
Structs§
- 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.
- 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. - Signal
Event - A “Signal”: a named command plus its parameters.
- Signal
Param - One
param_id→ value pair on a signal. - SsCellmap
Textures - Runtime texture replacement: swap the texture a cellmap binds for a Bevy image, live, from gameplay code (costume changes, dynamic expressions).
- SsCrowd
- Draw this character’s one playhead once at each member’s placement: a crowd
that costs one character’s evaluation and draw calls, however large, as
ssplayer_wgpu::SSPlayer::set_crowddoes. - SsEvent
Message - A timeline event raised on one character this frame.
- SsFinished
- Raised once, on the frame a character’s animation reached its end.
- SsLooped
- Raised once, on the frame a character’s timeline wrapped back to the start.
- SsPack
- A
.ssab, with every pack its instance parts play from and every atlas it draws with. - SsPack
Loader - Loads
.ssabfiles asSsPack. - SsPlay
- Start a character’s animation from the head of its section, or from
start_frame, asssplayer_wgpu::SSPlayer::playandssplayer_wgpu::SSPlayer::play_fromdo: it rewinds, re-arms the loop count and starts even a finished or stopped animation.start_frame: Noneis what bumpingSsPlayback::restartdoes. - SsPlayback
- Transport and compositing state — everything that costs nothing to change.
- SsPlayback
State - Playback state read back from the render world, refreshed every frame.
- SsPlayer
- A SpriteStudio character.
- SsPlayer
Plugin - Adds SpriteStudio playback and drawing to a Bevy app.
- SsScene
Settings - How this crate’s scene draws. A resource, present from the moment the plugin is added; change it whenever.
- SsSeek
- Move a character’s playhead to
frame, asssplayer_wgpu::SSPlayer::seekdoes: a fractional frame is honoured, and the playhead stays inside the section. - SsSource
Info - A source added with
TrackCommand::AddSource, as it stands. - SsStarted
- Raised once, on the first frame a character’s animation ran after a start:
a new pack or animation on
crate::SsPlayerwhilecrate::SsPlayback::playingis on,playingturning on for a tree that has not started yet, ancrate::SsPlay, or a bumpedrestart. Turningplayingback on after a pause resumes, and is not a start; nor is a new animation withcrate::SsPlayer::transition_msabove zero, which crossfades on the tree that is already playing. - SsStop
- End a character’s playback where it stands, as
ssplayer_wgpu::SSPlayer::stopdoes. The playhead stays, so the frame it stopped on is still drawn, and it does not count as finished. - SsTrack
Command - One operation on a character’s track stack — motion blending, as
ssplayer_wgpu::SSPlayer’s track API performs it. - SsTrack
Info - One track of
SsTrackState. - SsTrack
State - A character’s track stack as the render world last left it — the readable
half of
SsTrackCommand. One frame behind, likeSsPlaybackState. Required bySsPlayer, so it is always present; empty until the character’s animation is set up. - SsTransform
- Where the character sits, in the same terms
ssplayer_wgpu::SSPlayer::set_transformtakes but in Bevy’s world units — logical pixels under the default 2D projection — from the view’s centre, withydownward. The camera’s ownTransformand zoom do not apply. - 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§
- Playback
Direction - Which way the playhead walks the animation.
- Playback
Style - What happens when the playhead reaches the far end of the range.
- Signal
Value - One value carried by a signal parameter.
- SsEvent
- Something that happened on a frame the last update crossed.
- SsPack
Load Error - Why a
.ssabdid not load. - 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
Command - What an
SsTrackCommanddoes. Each variant is thessplayer_wgpu::SSPlayercall of the same name. - 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.