rig-play 1.6.0 → 1.8.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 +27 -5
- package/dist/index.js +166 -48
- package/dist/index.js.map +1 -1
- package/dist/player.d.ts +53 -6
- package/dist/player.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/player.d.ts
CHANGED
|
@@ -39,6 +39,18 @@ export interface RigPlayerOptions {
|
|
|
39
39
|
* and the pose at a time depends on the steps taken to reach it.
|
|
40
40
|
*/
|
|
41
41
|
seekStep?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Stand the player on rig-c's live tracks from the first `play`, so the
|
|
44
|
+
* first composing call — a mix, another track, a queue, a clear — never
|
|
45
|
+
* replays. Without it a plain `play` runs on the single live track, and the
|
|
46
|
+
* first composing call carries it over by replaying the time played in
|
|
47
|
+
* `seekStep` increments (there is no hand-over of a live track's physics
|
|
48
|
+
* state in the core), which on a stage that idled a while is one long
|
|
49
|
+
* frame. Pick the single track for a rig whose animations key what the
|
|
50
|
+
* tracks do not mix (constraints, sequences, the draw order, a path's
|
|
51
|
+
* deform); pick the tracks for layering.
|
|
52
|
+
*/
|
|
53
|
+
tracks?: boolean;
|
|
42
54
|
}
|
|
43
55
|
/** What `on('event', …)` hands a listener: one event key the step crossed. */
|
|
44
56
|
export interface RigEvent {
|
|
@@ -70,6 +82,22 @@ export interface PlayOptions {
|
|
|
70
82
|
track?: number;
|
|
71
83
|
/** Seconds the entry this one replaces mixes out over; 0 (the default) cuts. */
|
|
72
84
|
mix?: number;
|
|
85
|
+
/**
|
|
86
|
+
* The entry's weight, from 0 to 1 (1 by default), multiplied into every
|
|
87
|
+
* timeline it applies — the same clip at 0.6 and at 0.85. Change it while
|
|
88
|
+
* the entry plays with `setAlpha`. It does not touch events (fired at any
|
|
89
|
+
* alpha, 0 included) or attachments (kept at any alpha).
|
|
90
|
+
*/
|
|
91
|
+
alpha?: number;
|
|
92
|
+
/**
|
|
93
|
+
* The entry adds its keyed bone and deform values to what the tracks below
|
|
94
|
+
* posed, rather than replacing them — a layer keying the same bone channels
|
|
95
|
+
* as the base without covering its motion (false by default). Fixed when the
|
|
96
|
+
* entry is set or queued. A rotation is added as it stands, with no
|
|
97
|
+
* shortest-angle wrap; mixing out, an additive entry fades with its alpha
|
|
98
|
+
* and is never held.
|
|
99
|
+
*/
|
|
100
|
+
additive?: boolean;
|
|
73
101
|
}
|
|
74
102
|
export interface QueueOptions extends PlayOptions {
|
|
75
103
|
/**
|
|
@@ -90,6 +118,10 @@ export interface TrackEntry {
|
|
|
90
118
|
/** The animation time it applies at now: the track time wrapped, or held at the duration. */
|
|
91
119
|
animationTime: number;
|
|
92
120
|
duration: number;
|
|
121
|
+
/** The entry's weight as it stands (`PlayOptions.alpha`, `setAlpha`). */
|
|
122
|
+
alpha: number;
|
|
123
|
+
/** Whether the entry adds (`PlayOptions.additive`). */
|
|
124
|
+
additive: boolean;
|
|
93
125
|
}
|
|
94
126
|
type Listener<T> = (payload: T) => void;
|
|
95
127
|
/**
|
|
@@ -209,6 +241,10 @@ export declare class RigPlayer {
|
|
|
209
241
|
private loop;
|
|
210
242
|
/** One past the highest track touched — how many `current(track)` reads a step takes. */
|
|
211
243
|
private trackCount;
|
|
244
|
+
/** `RigPlayerOptions.tracks`: every play opens the live tracks, never the single track. */
|
|
245
|
+
private readonly trackMode;
|
|
246
|
+
/** 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. */
|
|
247
|
+
private beyondBase;
|
|
212
248
|
private paused;
|
|
213
249
|
private pose;
|
|
214
250
|
private setup;
|
|
@@ -272,16 +308,27 @@ export declare class RigPlayer {
|
|
|
272
308
|
mix?: number;
|
|
273
309
|
delay?: number;
|
|
274
310
|
}): void;
|
|
311
|
+
/**
|
|
312
|
+
* Sets the weight of `track`'s current entry, from 0 to 1, from the next pose
|
|
313
|
+
* on — the pose the player holds is re-posed at once, so a held player shows
|
|
314
|
+
* it on its next `draw`. An entry it is mixing from keeps its own weight. A
|
|
315
|
+
* track playing nothing, or a weight outside 0..1, is refused in the core's
|
|
316
|
+
* words. On the single track this composes: the player moves onto the tracks.
|
|
317
|
+
*/
|
|
318
|
+
setAlpha(track: number, alpha: number): void;
|
|
275
319
|
/** `track`'s current entry, or null where it plays nothing (and before `play`). */
|
|
276
320
|
entry(track?: number): TrackEntry | null;
|
|
277
321
|
/** Whether the player is composed: on the live tracks rather than the single track. */
|
|
278
322
|
get composed(): boolean;
|
|
279
323
|
/**
|
|
280
|
-
* The live tracks, opened by the first composing call
|
|
281
|
-
* play
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
324
|
+
* The live tracks, opened by the first composing call (or by the first
|
|
325
|
+
* `play` under `tracks: true`). A single track in play is carried over by
|
|
326
|
+
* replay: track 0 set to its animation, pose 0 taken by `start()` (the
|
|
327
|
+
* player's — nothing steps before it) and the tracks stepped to the single
|
|
328
|
+
* track's time in `seekStep` increments, so a physics rig's history
|
|
329
|
+
* restarts there and nothing is fired on the way. The core offers no
|
|
330
|
+
* hand-over of a live track's state, so that replay costs one pose per
|
|
331
|
+
* `seekStep` of time played — which `tracks: true` avoids entirely.
|
|
285
332
|
*/
|
|
286
333
|
private compose;
|
|
287
334
|
/** Stops stepping; `frame` keeps drawing the pose it holds. */
|
|
@@ -298,7 +345,7 @@ export declare class RigPlayer {
|
|
|
298
345
|
* player forward instead.
|
|
299
346
|
*/
|
|
300
347
|
seek(time: number): void;
|
|
301
|
-
/**
|
|
348
|
+
/** 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`. */
|
|
302
349
|
private reopen;
|
|
303
350
|
/** Steps whatever is open forward to `time` in `seekStep` increments, the last one shorter. */
|
|
304
351
|
private stepTo;
|
package/dist/player.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"player.d.ts","sourceRoot":"","sources":["../src/player.ts"],"names":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C,KAAK,CAAC,EAAE,UAAU,GAAG,IAAI,GAAG,UAAU;IAMjD,kGAAkG;IAClG,OAAO,IAAI,IAAI;IAOf,sGAAsG;IACtG,OAAO,CAAC,cAAc;IAmBtB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,QAAQ;CAsDjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rig-play",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Plays skeleton.model.json written by rigc build as plain DOM elements — rigid slots as <img> posed by CSS matrix, deform meshes on small per-part canvases — or as one canvas.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@playwright/test": "1.62.1",
|
|
59
59
|
"@types/node": "^22",
|
|
60
|
-
"rig-c": "2.
|
|
60
|
+
"rig-c": "2.39.0",
|
|
61
61
|
"typescript": "^5.6.0",
|
|
62
62
|
"vite": "^6.0.0"
|
|
63
63
|
}
|