@rig-c/play 1.21.3 → 1.22.1
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 +3 -0
- package/package.json +3 -2
- package/skills/rig-play/SKILL.md +80 -0
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-38BDF8.svg?style=flat-square" alt="license" /></a>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
+
# @rig-c/play
|
|
12
|
+
|
|
11
13
|
`@rig-c/play` plays the rigs [rigc](https://github.com/rig-c/core) builds — the
|
|
12
14
|
compiled model document `rigc build` writes, `skeleton.model.json` — as **plain
|
|
13
15
|
DOM**: one absolutely-positioned `<img>` per rigid slot, posed with a single CSS
|
|
@@ -145,6 +147,7 @@ package built from this tree.
|
|
|
145
147
|
not evidence of.
|
|
146
148
|
- [CHANGELOG.md](https://github.com/rig-c/play/blob/main/CHANGELOG.md) — what each version changed;
|
|
147
149
|
[RELEASING.md](https://github.com/rig-c/play/blob/main/RELEASING.md) — how a version is cut.
|
|
150
|
+
- [`skills/rig-play/SKILL.md`](skills/rig-play/SKILL.md) — the agent skill that routes a web-page playback or live-frame request to the guides above.
|
|
148
151
|
|
|
149
152
|
## Demo (this repository)
|
|
150
153
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rig-c/play",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.1",
|
|
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",
|
|
@@ -60,7 +60,8 @@
|
|
|
60
60
|
"dist/liveFrame.d.ts",
|
|
61
61
|
"dist/liveFrame.d.ts.map",
|
|
62
62
|
"dist/liveFrameSource.d.ts",
|
|
63
|
-
"dist/liveFrameSource.d.ts.map"
|
|
63
|
+
"dist/liveFrameSource.d.ts.map",
|
|
64
|
+
"skills"
|
|
64
65
|
],
|
|
65
66
|
"sideEffects": false,
|
|
66
67
|
"scripts": {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rig-play
|
|
3
|
+
description: Play a rig built by rigc (skeleton.model.json) on a web page with @rig-c/play — as plain DOM (<img> for rigid slots posed by CSS matrix(), small per-part canvases for deforming meshes) or as one <canvas> per player, with multi-track playback, attachment sets, wind and gravity physics, bone adjustments and live-frame borrowing. Use when the request puts a compiled rig into the DOM or a standalone page canvas, or integrates a custom consumer over LiveFrame or PosedFrame. Not for authoring or compiling a rig (use rigc or rig-parts), retargeting a pose sequence (use rig-pose), or drawing inside PixiJS, Phaser or Three.js (use the rig-pixi, rig-phaser or rig-three skill).
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: Browser ES2022 runtime (DOM and Canvas2D/WebGL). The canonical npm package is @rig-c/play (npm i @rig-c/play; rig-play is the convenience install name, spine-html is the legacy install name). Loads skeleton.model.json written by rigc build (@rig-c/core); bundles its own posing core and links no Esoteric Software runtime.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# @rig-c/play — playing a built rig on a web page
|
|
9
|
+
|
|
10
|
+
Load this when a built rig (`skeleton.model.json` and its page images from
|
|
11
|
+
`rigc build`, authored under `--profile rig-play`) goes **onto a web page as DOM
|
|
12
|
+
elements or a standalone canvas**, or when a custom renderer consumes
|
|
13
|
+
`player.liveFrame()` or `player.posedFrame()`. Every rule below is owned by
|
|
14
|
+
[docs/REFERENCE.md](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md);
|
|
15
|
+
this file says when to open it and when an engine adapter is the better route.
|
|
16
|
+
|
|
17
|
+
## When an engine adapter is the better route
|
|
18
|
+
|
|
19
|
+
- **The page already runs PixiJS 8, Phaser 4.2+ or Three.js.** Do not stack a
|
|
20
|
+
separate DOM root or second `<canvas>` over an engine canvas: use
|
|
21
|
+
[`@rig-c/pixi`](https://github.com/rig-c/adapters/tree/main/packages/pixi) (`rig-pixi` skill),
|
|
22
|
+
[`@rig-c/phaser`](https://github.com/rig-c/adapters/tree/main/packages/phaser) (`rig-phaser` skill) or
|
|
23
|
+
[`@rig-c/three`](https://github.com/rig-c/adapters/tree/main/packages/three) (`rig-three` skill) so the rig draws
|
|
24
|
+
inside the host's scene graph, camera, draw order and WebGL context while
|
|
25
|
+
posing through `@rig-c/play`.
|
|
26
|
+
- **High-count meshed grids.** Where many meshed instances are drawn together,
|
|
27
|
+
batched WebGL draw calls lead DOM/per-player canvas modes; use a host WebGL
|
|
28
|
+
adapter or check the scene tradeoffs in [docs/BENCHMARK.md](https://github.com/rig-c/play/blob/main/docs/BENCHMARK.md#measured).
|
|
29
|
+
|
|
30
|
+
## Non-negotiables
|
|
31
|
+
|
|
32
|
+
- **Load `skeleton.model.json`, never a Spine export.** `loadModel` reads
|
|
33
|
+
`rigc-compiled/*` (with `pages`) emitted by `rigc build` and refuses
|
|
34
|
+
`skeleton.json`, `.skel` and `rigc-compiled/1` by name before fetching —
|
|
35
|
+
[REFERENCE.md](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#status).
|
|
36
|
+
- **Layout, Y-up origin and `syncPixelRatio()` belong to the caller.** The root
|
|
37
|
+
element is the rig's world origin (`Y` grows upward); after scaling the root
|
|
38
|
+
or container in CSS, call `player.renderer.syncPixelRatio()` so mesh canvases
|
|
39
|
+
raster at screen size rather than `1 / scale²` —
|
|
40
|
+
[README.md](https://github.com/rig-c/play/blob/main/README.md#a-minimal-page) and
|
|
41
|
+
[REFERENCE.md](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#runtime-knobs-and-what-they-cost).
|
|
42
|
+
- **Respect `LiveFrame` lease lifetime.** `player.liveFrame()` is a borrowed
|
|
43
|
+
buffer valid only until the next pose mutation (`frame`, `seek`, `play`,
|
|
44
|
+
`setAttachmentSet`, physics or bone adjust); call `player.posedFrame()` when a
|
|
45
|
+
detached snapshot must survive later mutations —
|
|
46
|
+
[REFERENCE.md](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#borrowing-a-live-frame).
|
|
47
|
+
- **Dispose player before assets.** Call `player.dispose()` first to remove DOM
|
|
48
|
+
elements and release shared WebGL page-texture references, then
|
|
49
|
+
`assets.dispose()` (or `revokeRegions`) once no player draws from those assets
|
|
50
|
+
so cut region blob URLs are freed —
|
|
51
|
+
[REFERENCE.md](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#what-unloading-frees).
|
|
52
|
+
|
|
53
|
+
## What this will not do
|
|
54
|
+
|
|
55
|
+
- Compile, gate or edit a rig (build with `rigc build --profile rig-play` first).
|
|
56
|
+
- Load Spine `skeleton.json` or `.skel` exports, or link any `@esotericsoftware/*` runtime.
|
|
57
|
+
- Render two-colour dark tint (`rgb2`) in DOM mode or the canvas2d fallback (supported on `CanvasRenderer`'s WebGL path; [REFERENCE.md](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#status)).
|
|
58
|
+
- Re-measure CSS scale per frame (`syncPixelRatio()` forces a layout read and is caller-invoked only).
|
|
59
|
+
|
|
60
|
+
## Read, in this order
|
|
61
|
+
|
|
62
|
+
1. [README.md](https://github.com/rig-c/play/blob/main/README.md#install) —
|
|
63
|
+
`loadModel` + `RigPlayer`, fitting `assets.stage ?? player.bounds()` to a
|
|
64
|
+
container, `syncPixelRatio()` and cleanup (`node_modules/@rig-c/play/README.md` in an install).
|
|
65
|
+
2. [docs/REFERENCE.md](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md) —
|
|
66
|
+
[what ships and what is measured](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#status),
|
|
67
|
+
[wind, gravity and dragging](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#wind-gravity-and-dragging-the-rig),
|
|
68
|
+
[borrowing a live frame](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#borrowing-a-live-frame),
|
|
69
|
+
[attachment sets (`sets.json`)](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#attachment-sets-setsjson),
|
|
70
|
+
[several tracks](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#several-tracks),
|
|
71
|
+
[adjusting bones](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#adjusting-bones),
|
|
72
|
+
[live physics parameters](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#live-physics-parameters),
|
|
73
|
+
[what unloading frees](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#what-unloading-frees) and
|
|
74
|
+
[runtime knobs](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md#runtime-knobs-and-what-they-cost).
|
|
75
|
+
3. [docs/MIGRATION.md](https://github.com/rig-c/play/blob/main/docs/MIGRATION.md) and
|
|
76
|
+
[docs/BENCHMARK.md](https://github.com/rig-c/play/blob/main/docs/BENCHMARK.md).
|
|
77
|
+
|
|
78
|
+
`docs/` lives in the GitHub repository and is not packed into `node_modules/@rig-c/play`;
|
|
79
|
+
the installed package carries `README.md` and the exact TypeScript declarations
|
|
80
|
+
under `node_modules/@rig-c/play/dist/*.d.ts`.
|