rig-play 1.6.0 → 1.7.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 +9 -3
- package/dist/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/dist/player.d.ts +25 -6
- package/dist/player.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -306,9 +306,15 @@ player.entry(2); // { animation, loop
|
|
|
306
306
|
`play(name)` keeps meaning what it meant: a plain play on track 0 runs on rig-c's
|
|
307
307
|
single live track, which poses everything the core poses. The first call that
|
|
308
308
|
composes — a `mix`, a `track` above 0, a `queue`, a `clear` — moves the player onto
|
|
309
|
-
the tracks, carrying the single track over by replay (its animation set, pose 0
|
|
310
|
-
taken, stepped to its time
|
|
311
|
-
|
|
309
|
+
the tracks, carrying the single track over by **replay** (its animation set, pose 0
|
|
310
|
+
taken, stepped to its time in `seekStep` increments — one pose per step played, so
|
|
311
|
+
on a stage that idled a while that is one long frame; the core offers no hand-over
|
|
312
|
+
of a live track's state). To never pay it, stand the player on the tracks from the
|
|
313
|
+
start: `new RigPlayer(root, assets, { tracks: true })`. Pick the single track for a
|
|
314
|
+
rig whose animations key what the tracks do not mix (below); pick the tracks for
|
|
315
|
+
layering. Either way, after the first `mix`, `track` above 0, `queue` or `clear`,
|
|
316
|
+
`seek` and `skin` are refused by name, since the player cannot replay a composition
|
|
317
|
+
to a time — step it forward instead.
|
|
312
318
|
Every entry mixes from the setup pose each step, so `adjust` writes still last one
|
|
313
319
|
pose. **What the tracks do not mix**, in rig-c's words at `play`/`queue`: an
|
|
314
320
|
animation keying a constraint (ik, transform, path, physics, slider), a sequence,
|
package/dist/index.js
CHANGED
|
@@ -8342,6 +8342,10 @@ class RigPlayer {
|
|
|
8342
8342
|
loop = true;
|
|
8343
8343
|
/** One past the highest track touched — how many `current(track)` reads a step takes. */
|
|
8344
8344
|
trackCount = 0;
|
|
8345
|
+
/** `RigPlayerOptions.tracks`: every play opens the live tracks, never the single track. */
|
|
8346
|
+
trackMode;
|
|
8347
|
+
/** Set once anything beyond a plain play on track 0 happened: a mix, another track, a queue, a clear. `seek` and `skin` then cannot replay and refuse. */
|
|
8348
|
+
beyondBase = false;
|
|
8345
8349
|
paused = false;
|
|
8346
8350
|
pose = null;
|
|
8347
8351
|
setup = null;
|
|
@@ -8364,6 +8368,7 @@ class RigPlayer {
|
|
|
8364
8368
|
this.view = options.skin === void 0 ? underNoSkin(read.doc) : underSkin(read.doc, options.skin);
|
|
8365
8369
|
this.source = frameSource(this.view, read.parsed);
|
|
8366
8370
|
this.seekStep = options.seekStep ?? 1 / 60;
|
|
8371
|
+
this.trackMode = options.tracks === true;
|
|
8367
8372
|
if (!(this.seekStep > 0)) throw new Error(`seekStep must be a positive number of seconds, got ${String(options.seekStep)}`);
|
|
8368
8373
|
this.root = root;
|
|
8369
8374
|
this.assets = assets;
|
|
@@ -8434,7 +8439,8 @@ class RigPlayer {
|
|
|
8434
8439
|
const loop = options.loop ?? true;
|
|
8435
8440
|
const mix = options.mix ?? 0;
|
|
8436
8441
|
this.paused = false;
|
|
8437
|
-
if (
|
|
8442
|
+
if (track !== 0 || mix !== 0) this.beyondBase = true;
|
|
8443
|
+
if (this.tracks === null && track === 0 && mix === 0 && !this.trackMode) {
|
|
8438
8444
|
this.animation = name;
|
|
8439
8445
|
this.loop = loop;
|
|
8440
8446
|
this.track = openTrack(this.view, name, { loop, reset: "animation", adjust: this.adjustHook });
|
|
@@ -8458,6 +8464,7 @@ class RigPlayer {
|
|
|
8458
8464
|
*/
|
|
8459
8465
|
queue(name, options = {}) {
|
|
8460
8466
|
const track = options.track ?? 0;
|
|
8467
|
+
this.beyondBase = true;
|
|
8461
8468
|
const tracks = this.compose();
|
|
8462
8469
|
tracks.addAnimation(track, name, { loop: options.loop ?? true, mixDuration: options.mix ?? 0, delay: options.delay ?? 0 });
|
|
8463
8470
|
this.trackCount = Math.max(this.trackCount, track + 1);
|
|
@@ -8469,6 +8476,7 @@ class RigPlayer {
|
|
|
8469
8476
|
* setup pose. The pose the player holds is re-posed at once.
|
|
8470
8477
|
*/
|
|
8471
8478
|
clear(track = 0, options = {}) {
|
|
8479
|
+
this.beyondBase = true;
|
|
8472
8480
|
const tracks = this.compose();
|
|
8473
8481
|
tracks.setEmptyAnimation(track, options.mix ?? 0);
|
|
8474
8482
|
this.trackCount = Math.max(this.trackCount, track + 1);
|
|
@@ -8481,6 +8489,7 @@ class RigPlayer {
|
|
|
8481
8489
|
* its last `mix` seconds.
|
|
8482
8490
|
*/
|
|
8483
8491
|
queueClear(track = 0, options = {}) {
|
|
8492
|
+
this.beyondBase = true;
|
|
8484
8493
|
const tracks = this.compose();
|
|
8485
8494
|
tracks.addEmptyAnimation(track, options.mix ?? 0, options.delay ?? 0);
|
|
8486
8495
|
this.trackCount = Math.max(this.trackCount, track + 1);
|
|
@@ -8501,11 +8510,14 @@ class RigPlayer {
|
|
|
8501
8510
|
return this.tracks !== null;
|
|
8502
8511
|
}
|
|
8503
8512
|
/**
|
|
8504
|
-
* The live tracks, opened by the first composing call
|
|
8505
|
-
* play
|
|
8506
|
-
*
|
|
8507
|
-
*
|
|
8508
|
-
*
|
|
8513
|
+
* The live tracks, opened by the first composing call (or by the first
|
|
8514
|
+
* `play` under `tracks: true`). A single track in play is carried over by
|
|
8515
|
+
* replay: track 0 set to its animation, pose 0 taken by `start()` (the
|
|
8516
|
+
* player's — nothing steps before it) and the tracks stepped to the single
|
|
8517
|
+
* track's time in `seekStep` increments, so a physics rig's history
|
|
8518
|
+
* restarts there and nothing is fired on the way. The core offers no
|
|
8519
|
+
* hand-over of a live track's state, so that replay costs one pose per
|
|
8520
|
+
* `seekStep` of time played — which `tracks: true` avoids entirely.
|
|
8509
8521
|
*/
|
|
8510
8522
|
compose() {
|
|
8511
8523
|
if (this.tracks !== null) return this.tracks;
|
|
@@ -8542,12 +8554,20 @@ class RigPlayer {
|
|
|
8542
8554
|
seek(time) {
|
|
8543
8555
|
if (this.animation === null) throw new Error("seek before play: no animation is open");
|
|
8544
8556
|
if (!(time >= 0) || !Number.isFinite(time)) throw new Error(`seek time must be a finite time at or above 0, got ${String(time)}`);
|
|
8545
|
-
if (this.
|
|
8557
|
+
if (this.beyondBase) throw new Error("seek is defined for a single animation on track 0; after a mix, another track, a queue or a clear the player cannot replay to a time — step it forward with frame/advance instead");
|
|
8546
8558
|
this.reopen();
|
|
8547
8559
|
this.stepTo(time);
|
|
8548
8560
|
}
|
|
8549
|
-
/**
|
|
8561
|
+
/** Whatever is open, opened again with track 0's animation as `play` last set it, at pose 0: the single track, or the tracks under `tracks: true`. */
|
|
8550
8562
|
reopen() {
|
|
8563
|
+
if (this.tracks !== null) {
|
|
8564
|
+
const tracks = openTracks(this.view, { reset: "animation", adjust: this.adjustHook });
|
|
8565
|
+
tracks.setAnimation(0, this.animation, { loop: this.loop, mixDuration: 0 });
|
|
8566
|
+
this.trackCount = 1;
|
|
8567
|
+
this.tracks = tracks;
|
|
8568
|
+
this.pose = tracks.start();
|
|
8569
|
+
return;
|
|
8570
|
+
}
|
|
8551
8571
|
this.track = openTrack(this.view, this.animation, { loop: this.loop, reset: "animation", adjust: this.adjustHook });
|
|
8552
8572
|
this.pose = this.track.first;
|
|
8553
8573
|
}
|
|
@@ -8616,14 +8636,14 @@ class RigPlayer {
|
|
|
8616
8636
|
}
|
|
8617
8637
|
set skin(name) {
|
|
8618
8638
|
if (name === this.skinName) return;
|
|
8619
|
-
if (this.
|
|
8639
|
+
if (this.beyondBase) throw new Error("skin cannot change after a mix, another track, a queue or a clear: the player cannot replay those to the current time — set it before composing, or play again");
|
|
8620
8640
|
const view = name === void 0 ? underNoSkin(this.read.doc) : underSkin(this.read.doc, name);
|
|
8621
8641
|
this.view = view;
|
|
8622
8642
|
this.source = frameSource(view, this.read.parsed);
|
|
8623
8643
|
this.skinName = name;
|
|
8624
8644
|
this.setup = null;
|
|
8625
|
-
if (this.animation !== null && this.track !== null) {
|
|
8626
|
-
const time = this.
|
|
8645
|
+
if (this.animation !== null && (this.track !== null || this.tracks !== null)) {
|
|
8646
|
+
const time = this.time;
|
|
8627
8647
|
this.reopen();
|
|
8628
8648
|
this.stepTo(time);
|
|
8629
8649
|
}
|