rig-play 1.5.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 +34 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +86 -19
- package/dist/index.js.map +1 -1
- package/dist/player.d.ts +54 -8
- package/dist/player.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/player.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface RigPlayerOptions {
|
|
|
27
27
|
skin?: string;
|
|
28
28
|
/** The per-pose adjustment of bone locals (`player.adjust`), set from the first pose. */
|
|
29
29
|
adjust?: BoneAdjust | null;
|
|
30
|
+
/** Which slots this player draws (`player.slots`); every slot when absent. */
|
|
31
|
+
slots?: SlotFilter | null;
|
|
30
32
|
/** How the player draws (see `RenderMode`). Default `'dom'`. Can be changed later through `mode`. */
|
|
31
33
|
mode?: RenderMode;
|
|
32
34
|
/** The mesh tier's rasterizer (see `DomRenderer.meshBackend`) — the DOM mode only. */
|
|
@@ -37,6 +39,18 @@ export interface RigPlayerOptions {
|
|
|
37
39
|
* and the pose at a time depends on the steps taken to reach it.
|
|
38
40
|
*/
|
|
39
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;
|
|
40
54
|
}
|
|
41
55
|
/** What `on('event', …)` hands a listener: one event key the step crossed. */
|
|
42
56
|
export interface RigEvent {
|
|
@@ -152,6 +166,13 @@ export interface BoneWorld {
|
|
|
152
166
|
scaleX: number;
|
|
153
167
|
scaleY: number;
|
|
154
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Which slots a player draws: an allow list of slot names, or a predicate
|
|
171
|
+
* over the name. The pose is the whole rig's whatever the filter — bones,
|
|
172
|
+
* constraints, physics, `bone()` and `adjust` are untouched — and only the
|
|
173
|
+
* draw is filtered. A clipping slot the filter leaves out does not clip.
|
|
174
|
+
*/
|
|
175
|
+
export type SlotFilter = readonly string[] | ((slot: string) => boolean);
|
|
155
176
|
/** A box in world units, Y up: `y` is the bottom edge. */
|
|
156
177
|
export interface PoseBounds {
|
|
157
178
|
x: number;
|
|
@@ -200,10 +221,17 @@ export declare class RigPlayer {
|
|
|
200
221
|
private loop;
|
|
201
222
|
/** One past the highest track touched — how many `current(track)` reads a step takes. */
|
|
202
223
|
private trackCount;
|
|
224
|
+
/** `RigPlayerOptions.tracks`: every play opens the live tracks, never the single track. */
|
|
225
|
+
private readonly trackMode;
|
|
226
|
+
/** 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. */
|
|
227
|
+
private beyondBase;
|
|
203
228
|
private paused;
|
|
204
229
|
private pose;
|
|
205
230
|
private setup;
|
|
206
231
|
private adjustFn;
|
|
232
|
+
private slotFilter;
|
|
233
|
+
/** `slotFilter` as a predicate; every slot when null. */
|
|
234
|
+
private draws;
|
|
207
235
|
/** Handed to every track the player opens; reads the current `adjust` so setting it later needs no reopen. */
|
|
208
236
|
private readonly adjustHook;
|
|
209
237
|
private readonly listeners;
|
|
@@ -265,11 +293,14 @@ export declare class RigPlayer {
|
|
|
265
293
|
/** Whether the player is composed: on the live tracks rather than the single track. */
|
|
266
294
|
get composed(): boolean;
|
|
267
295
|
/**
|
|
268
|
-
* The live tracks, opened by the first composing call
|
|
269
|
-
* play
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
296
|
+
* The live tracks, opened by the first composing call (or by the first
|
|
297
|
+
* `play` under `tracks: true`). A single track in play is carried over by
|
|
298
|
+
* replay: track 0 set to its animation, pose 0 taken by `start()` (the
|
|
299
|
+
* player's — nothing steps before it) and the tracks stepped to the single
|
|
300
|
+
* track's time in `seekStep` increments, so a physics rig's history
|
|
301
|
+
* restarts there and nothing is fired on the way. The core offers no
|
|
302
|
+
* hand-over of a live track's state, so that replay costs one pose per
|
|
303
|
+
* `seekStep` of time played — which `tracks: true` avoids entirely.
|
|
273
304
|
*/
|
|
274
305
|
private compose;
|
|
275
306
|
/** Stops stepping; `frame` keeps drawing the pose it holds. */
|
|
@@ -286,7 +317,7 @@ export declare class RigPlayer {
|
|
|
286
317
|
* player forward instead.
|
|
287
318
|
*/
|
|
288
319
|
seek(time: number): void;
|
|
289
|
-
/**
|
|
320
|
+
/** 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`. */
|
|
290
321
|
private reopen;
|
|
291
322
|
/** Steps whatever is open forward to `time` in `seekStep` increments, the last one shorter. */
|
|
292
323
|
private stepTo;
|
|
@@ -319,6 +350,15 @@ export declare class RigPlayer {
|
|
|
319
350
|
*/
|
|
320
351
|
get skin(): string | undefined;
|
|
321
352
|
set skin(name: string | undefined);
|
|
353
|
+
/**
|
|
354
|
+
* Which slots this player draws (`SlotFilter`), or null for every slot.
|
|
355
|
+
* Settable on a live player: the next `draw` shows it, and `bounds()` reads
|
|
356
|
+
* the drawn slots. An allow list naming a slot the document does not have
|
|
357
|
+
* is refused by name. The pose is the whole rig's: `bone()`, `adjust`, the
|
|
358
|
+
* events and the tracks see no filter.
|
|
359
|
+
*/
|
|
360
|
+
get slots(): SlotFilter | null;
|
|
361
|
+
set slots(filter: SlotFilter | null);
|
|
322
362
|
/**
|
|
323
363
|
* The per-pose adjustment of bone locals (`BoneAdjust`), or null for none.
|
|
324
364
|
* It is applied by every track the player opens — `play`, the reopen inside
|
|
@@ -356,8 +396,14 @@ export declare class RigPlayer {
|
|
|
356
396
|
bounds(): PoseBounds | null;
|
|
357
397
|
/** The pose the reads above see: the track's, or the setup pose before `play` (posed once). */
|
|
358
398
|
private posed;
|
|
359
|
-
/**
|
|
360
|
-
|
|
399
|
+
/**
|
|
400
|
+
* The pose the player holds, as the frame record the renderer draws — under
|
|
401
|
+
* this player's `slots` filter, or under `slots` given here instead (a
|
|
402
|
+
* second renderer over the same assets drawing this player's pose on
|
|
403
|
+
* another root: `other.render(player.posedFrame(['hand_f']))`, the one rig
|
|
404
|
+
* posed once).
|
|
405
|
+
*/
|
|
406
|
+
posedFrame(slots?: SlotFilter | null): PosedFrame;
|
|
361
407
|
/** Removes the renderer's elements and hands its GPU pages back. The assets stay the caller's. */
|
|
362
408
|
dispose(): void;
|
|
363
409
|
/** The single track's step: its events (track 0) and its complete, as every 1.x player fired them. */
|
package/dist/player.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"player.d.ts","sourceRoot":"","sources":["../src/player.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAA0C,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE1F;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE1C,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yFAAyF;IACzF,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3B,qGAAqG;IACrG,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,sFAAsF;IACtF,WAAW,CAAC,EAAE,WAA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G,IAAI,CAE9B;IAED,IAAI,MAAM,CAAC,EAAE,EAAE,UAAU,GAAG,IAAI,EAI/B;IAED;;;;;;OAMG;IACH,MAAM,IAAI,IAAI;IAMd;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IAsB7B;;;;;;;;OAQG;IACH,MAAM,IAAI,UAAU,GAAG,IAAI;IA6B3B,+FAA+F;IAC/F,OAAO,CAAC,KAAK;IAMb;;;;;;OAMG;IACH,UAAU,CAAC,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.7.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",
|