Skip to main content

Crate ssplayer_bevy

Crate ssplayer_bevy 

Source
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, SsTransform and SsPlayback. Spawn them, change them, and that is the whole authoring surface. The .ssab a character plays is an SsPack asset, loaded through the AssetServer.
  • Render world — the playback trees, one device-scoped SSRenderer and one target-scoped SSScene. 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 SSScene with every character in it, and SSScene::update fuses 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§

AudioEvent
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.
CrowdMember
One of the copies SSPlayer::set_crowd draws: where it stands, and how it is faded and tinted, each on top of the player’s own.
SignalEvent
A “Signal”: a named command plus its parameters.
SignalParam
One param_id → value pair on a signal.
SsCellmapTextures
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_crowd does.
SsEventMessage
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.
SsPackLoader
Loads .ssab files as SsPack.
SsPlay
Start a character’s animation from the head of its section, or from start_frame, as ssplayer_wgpu::SSPlayer::play and ssplayer_wgpu::SSPlayer::play_from do: it rewinds, re-arms the loop count and starts even a finished or stopped animation. start_frame: None is what bumping SsPlayback::restart does.
SsPlayback
Transport and compositing state — everything that costs nothing to change.
SsPlaybackState
Playback state read back from the render world, refreshed every frame.
SsPlayer
A SpriteStudio character.
SsPlayerPlugin
Adds SpriteStudio playback and drawing to a Bevy app.
SsSceneSettings
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, as ssplayer_wgpu::SSPlayer::seek does: a fractional frame is honoured, and the playhead stays inside the section.
SsSourceInfo
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::SsPlayer while crate::SsPlayback::playing is on, playing turning on for a tree that has not started yet, an crate::SsPlay, or a bumped restart. Turning playing back on after a pause resumes, and is not a start; nor is a new animation with crate::SsPlayer::transition_ms above zero, which crossfades on the tree that is already playing.
SsStop
End a character’s playback where it stands, as ssplayer_wgpu::SSPlayer::stop does. The playhead stays, so the frame it stopped on is still drawn, and it does not count as finished.
SsTrackCommand
One operation on a character’s track stack — motion blending, as ssplayer_wgpu::SSPlayer’s track API performs it.
SsTrackInfo
One track of SsTrackState.
SsTrackState
A character’s track stack as the render world last left it — the readable half of SsTrackCommand. One frame behind, like SsPlaybackState. Required by SsPlayer, 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_transform takes but in Bevy’s world units — logical pixels under the default 2D projection — from the view’s centre, with y downward. The camera’s own Transform and zoom do not apply.
UserDataEvent
A “User Data” marker: up to four optional values, in whatever combination the animator filled in. A field is None when it was left unset — which is not the same as zero, and is why these are options rather than defaults.

Enums§

PlaybackDirection
Which way the playhead walks the animation.
PlaybackStyle
What happens when the playhead reaches the far end of the range.
SignalValue
One value carried by a signal parameter.
SsEvent
Something that happened on a frame the last update crossed.
SsPackLoadError
Why a .ssab did not load.
TrackBlend
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.
TrackCommand
What an SsTrackCommand does. Each variant is the ssplayer_wgpu::SSPlayer call of the same name.
TrackSync
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.0 at the section start towards 1.0 at its end, so animations of different lengths line up by proportion rather than by frame.