rig-play 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -263,6 +263,38 @@ box, an inverse clip removes nothing, and bounding boxes, paths and points do
263
263
  not draw and do not count. Both cost nothing until called and read the same
264
264
  numbers in `dom` and `canvas` mode.
265
265
 
266
+ ### Several tracks
267
+
268
+ A base on track 0, a layer over it, a one-shot played once and mixed back out —
269
+ rig-c's live tracks (`openTracks`), whose mixing is the Spine runtime's
270
+ `AnimationState` held at tolerance 0:
271
+
272
+ ```ts
273
+ player.play('idle'); // track 0, as always
274
+ player.play('smile', { track: 1, loop: false, mix: 0.2 }); // held at its end, mixed in over 0.2 s
275
+ player.play('wave', { track: 2, loop: false, mix: 0.1 }); // a one-shot…
276
+ player.queueClear(2, { mix: 0.1 }); // …mixed back out over its last 0.1 s
277
+ player.queue('idle_b', { track: 0, mix: 0.3 }); // after the current idle cycle completes
278
+ player.clear(1, { mix: 0.2 }); // the layer gone, the base showing through
279
+ player.entry(2); // { animation, loop, trackTime, animationTime, duration } | null
280
+ ```
281
+
282
+ `play(name)` keeps meaning what it meant: a plain play on track 0 runs on rig-c's
283
+ single live track, which poses everything the core poses. The first call that
284
+ composes — a `mix`, a `track` above 0, a `queue`, a `clear` — moves the player onto
285
+ the tracks, carrying the single track over by replay (its animation set, pose 0
286
+ taken, stepped to its time); from then on `seek` and `skin` are refused by name,
287
+ since the player cannot replay a composition to a time — step it forward instead.
288
+ Every entry mixes from the setup pose each step, so `adjust` writes still last one
289
+ pose. **What the tracks do not mix**, in rig-c's words at `play`/`queue`: an
290
+ animation keying a constraint (ik, transform, path, physics, slider), a sequence,
291
+ the draw order, or a path's deform is refused when it is set on the tracks — it
292
+ plays on the single track only. `'event'` carries `track`; a one-shot that is
293
+ mixing out fires nothing. `'complete'` is per track, the player's rule: a looping
294
+ entry each cycle, a held one when it reaches its duration, and an entry that is
295
+ replaced — by `play`, or by the queued entry that starts at its completion less the
296
+ mix — completes no more than it fires.
297
+
266
298
  ### Adjusting bones
267
299
 
268
300
  A per-pose write to bone locals — a breath's scale, a look's rotation, a mouth
@@ -596,11 +628,12 @@ name, and unloading is still elements first, bitmaps second.
596
628
  | `DomTexture` | none | Not exported; there is no atlas page to attach a texture to. |
597
629
  | `new Skeleton(assets.data)` and `new AnimationState(new AnimationStateData(assets.data))` | `new RigPlayer(root, assets, options?)` | The player holds the pose and the track. |
598
630
  | `state.setAnimation(0, 'walk', true)` | `player.play('walk', { loop: true })` | `loop` defaults to true. `play` opens the animation at its first pose with the physics reset there. `player.current` names what is playing. |
631
+ | `state.setAnimation(1, 'smile', false)` with a mix, `addAnimation`, `setEmptyAnimation`, `addEmptyAnimation`, `getCurrent(track)` | `player.play(name, { track, loop, mix })`, `player.queue(name, { track, loop, mix, delay })`, `player.clear(track, { mix })`, `player.queueClear(track, { mix, delay })`, `player.entry(track)` | Since 1.5.0, rig-c's live tracks: the runtime's mixing at tolerance 0. Constraint, sequence, draw-order and path-deform timelines are not mixed and are refused on the tracks. See *Several tracks*. |
599
632
  | `state.update(delta)`, `state.apply(skeleton)`, `skeleton.update(delta)`, `skeleton.updateWorldTransform(Physics.update)`, `renderer.render(skeleton)` | `player.frame(dt)` | Or `player.advance(dt)` then `player.draw()`, to time the two apart. |
600
633
  | time scale (the caller's own, on the spine-core side) | `player.timeScale` | Multiplies every step. 0 holds the pose without re-posing it; a negative value is not stepped. |
601
634
  | holding a pose (the caller stopped advancing) | `player.pause()`, `player.resume()` | `frame` keeps drawing the held pose. |
602
635
  | moving to a time (the caller's own, on the spine-core side) | `player.seek(time)`, `RigPlayerOptions.seekStep`, `player.time` | A seek reopens the animation and steps forward in `seekStep` increments (1/60 s by default). Events and completes crossed on the way are not fired. |
603
- | events (the caller's own listener on the spine-core side) | `player.on('event', listener)`, `player.on('complete', listener)` | `'event'` hands a `RigEvent` (`name`, `time`, `int`, `float`, `string`); `'complete'` hands `{ animation }`. `on` returns a function that removes the listener. |
636
+ | events (the caller's own listener on the spine-core side) | `player.on('event', listener)`, `player.on('complete', listener)` | `'event'` hands a `RigEvent` (`name`, `time`, `int`, `float`, `string`, `track`); `'complete'` hands `{ animation, track }`. `on` returns a function that removes the listener. |
604
637
  | skin (set by the caller on its `Skeleton`) | `RigPlayerOptions.skin`, `player.skin` | A constructor option, and settable on a live player since 1.4.0: the pose re-resolves under the new skin and the track keeps its animation, loop and time (reopened and stepped there, as `seek` does). The names are in `ModelAssets.skins`. Without it the rig is posed with no skin set. |
605
638
  | `SpineHtmlRenderer` | `DomRenderer`, reached as `player.renderer` | In `mode: 'dom'`, the default. `mode: 'canvas'` is new and makes `player.renderer` a `CanvasRenderer`. |
606
639
  | `new SpineHtmlRenderer(root, regionImages)` | `new DomRenderer(root, regionImages, pages?)` | Only for drawing your own frames; `RigPlayer` constructs its renderer. `pages` is the page-image map the mesh tier samples (`ModelAssets.pageImages`). A hand-built `regionImages` map is still accepted. |
@@ -634,8 +667,6 @@ export, for which 1.0.0 declares nothing:
634
667
  - **One unpacked atlas shared by different skeletons.** A document is one rig, and each
635
668
  `loadModel` cuts its own regions and owns its own blob URLs. Sharing is per rig: one
636
669
  load, several players.
637
- - **More than one track, mixing between animations, or queueing one after another.**
638
- `RigPlayer` declares one track; `play` reopens it at the animation's first pose.
639
670
  - **Changing one slot from code** (its attachment, its colour). `RigPlayer` declares only
640
671
  the whole-rig `color`. The frame record is a plain object, so a caller that draws its
641
672
  own frames through `DomRenderer.render` or `CanvasRenderer.render` decides what is in
package/dist/index.d.ts CHANGED
@@ -2,6 +2,6 @@ export { type CanvasBackend, CanvasRenderer, type CanvasViewport } from './Canva
2
2
  export { DomRenderer, type MeshBackend } from './DomRenderer.js';
3
3
  export { type PageLayout, type PageRegion, type RegionEncoding, type RegionImage, revokeRegions, type UnpackRegionsOptions, unpackRegions } from './DomTexture.js';
4
4
  export { type LoadModelOptions, loadModel, type ModelAssets, type ModelDocument, type RegionLoading } from './loadModel.js';
5
- export { type AdjustableBones, type BoneAdjust, type BoneLocals, type BoneWorld, type PoseBounds, type RenderMode, type RigEvent, RigPlayer, type RigPlayerOptions } from './player.js';
5
+ export { type AdjustableBones, type BoneAdjust, type BoneLocals, type BoneWorld, type PlayOptions, type PoseBounds, type QueueOptions, type RenderMode, type RigComplete, type RigEvent, RigPlayer, type RigPlayerOptions, type TrackEntry } from './player.js';
6
6
  export type { BlendMode, PosedClip, PosedFrame, PosedMesh, PosedRegion, PosedSlot, } from './posedFrame.js';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnK,OAAO,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5H,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACxL,YAAY,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,GACV,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings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