@rig-c/three 0.1.3 → 0.2.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 +7 -0
- package/package.json +2 -1
- package/skills/rig-three/SKILL.md +91 -0
package/README.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
<img src="https://raw.githubusercontent.com/rig-c/adapters/main/packages/three/assets/banner.svg" alt="@rig-c/three — Draw a rig-c model in a native Three.js scene through @rig-c/play" width="100%" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@rig-c/three"><img src="https://img.shields.io/npm/v/@rig-c/three.svg?style=flat-square&color=FF6B4A" alt="npm version" /></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/@rig-c/three"><img src="https://img.shields.io/npm/dm/@rig-c/three.svg?style=flat-square&color=EC4899" alt="npm downloads" /></a>
|
|
8
|
+
<a href="https://github.com/rig-c/adapters/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-38BDF8.svg?style=flat-square" alt="license" /></a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
5
11
|
# @rig-c/three
|
|
6
12
|
|
|
7
13
|
Draw a rig-c model in a native Three.js scene through `@rig-c/play`. `ThreeRig`
|
|
@@ -113,3 +119,4 @@ float storage and transformed geometry, same-browser CanvasRenderer pictures,
|
|
|
113
119
|
planted picture faults, exact pose parity, fixed updates, native held uploads,
|
|
114
120
|
shared page lifetime, buffer deletion, package contents and installed exports.
|
|
115
121
|
The release pipeline registers this package independently of the other hosts.
|
|
122
|
+
The router skill for an agent is [`skills/rig-three/SKILL.md`](skills/rig-three/SKILL.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rig-c/three",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Play rig-c model documents in a native Three.js scene through @rig-c/play.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"dist",
|
|
24
|
+
"skills",
|
|
24
25
|
"README.md",
|
|
25
26
|
"LICENSE",
|
|
26
27
|
"NOTICE"
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rig-three
|
|
3
|
+
description: Play a rig built by rigc (skeleton.model.json) inside a native Three.js WebGL2 scene with @rig-c/three (ThreeRig and ThreeRenderer), posed through @rig-c/play under an orthographic or perspective camera with no Spine runtime. Use when the request puts a 2D rig into a Three.js Scene or Group, orders flat rigs in 3D space, or renders LiveFrame/PosedFrame as native Three.js Mesh objects. Not for standalone DOM/canvas pages (use rig-play), PixiJS (use rig-pixi), Phaser (use rig-phaser), WebGPURenderer, or compiling a rig (use rigc or rig-parts).
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: Browser ES2022 runtime with Three.js (three ^0.186.1, plus @types/three for TypeScript) and @rig-c/play (^1.20.0) installed as peerDependencies. The npm package is @rig-c/three (npm i @rig-c/three three @rig-c/play); requires Three.js WebGLRenderer (WebGL2) and links no Esoteric Software runtime.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# @rig-c/three — playing a rig-c model in Three.js
|
|
9
|
+
|
|
10
|
+
Load this when a built rig (`skeleton.model.json` and its atlas page images from
|
|
11
|
+
`rigc build`) goes **inside a Three.js `Scene` (orthographic or perspective)**
|
|
12
|
+
as a native `Group` (`ThreeRig`) or through `ThreeRenderer`. Every rule below is
|
|
13
|
+
owned by the shipped
|
|
14
|
+
[README.md](https://github.com/rig-c/adapters/blob/main/packages/three/README.md)
|
|
15
|
+
and [`dist/index.d.ts`](https://github.com/rig-c/adapters/tree/main/packages/three);
|
|
16
|
+
this file says when to open them and what `@rig-c/three` will not do.
|
|
17
|
+
|
|
18
|
+
## Minimal loop
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { loadModel } from '@rig-c/play';
|
|
22
|
+
import { OrthographicCamera, Scene, WebGLRenderer } from 'three';
|
|
23
|
+
import { ThreeRig } from '@rig-c/three';
|
|
24
|
+
|
|
25
|
+
const renderer = new WebGLRenderer({ alpha: true });
|
|
26
|
+
renderer.setSize(800, 600);
|
|
27
|
+
document.body.appendChild(renderer.domElement);
|
|
28
|
+
|
|
29
|
+
const scene = new Scene();
|
|
30
|
+
const camera = new OrthographicCamera(-400, 400, 300, -300, 0.1, 2000);
|
|
31
|
+
camera.position.z = 1000;
|
|
32
|
+
|
|
33
|
+
const assets = await loadModel({ modelUrl: '/rigs/walk/skeleton.model.json' });
|
|
34
|
+
const rig = new ThreeRig(assets, { renderer });
|
|
35
|
+
rig.play('walk');
|
|
36
|
+
scene.add(rig);
|
|
37
|
+
|
|
38
|
+
// The app owns the loop: call rig.update(dt) in seconds before renderer.render
|
|
39
|
+
let previous: number | undefined;
|
|
40
|
+
function frame(now: number) {
|
|
41
|
+
if (previous !== undefined) rig.update((now - previous) / 1000);
|
|
42
|
+
previous = now;
|
|
43
|
+
renderer.render(scene, camera);
|
|
44
|
+
requestAnimationFrame(frame);
|
|
45
|
+
}
|
|
46
|
+
requestAnimationFrame(frame);
|
|
47
|
+
|
|
48
|
+
// On removal: rig.destroy(); assets.dispose(); renderer.dispose();
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Non-negotiables
|
|
52
|
+
|
|
53
|
+
- **The application owns the render loop and `WebGLRenderer`.** Pass `{ renderer }`
|
|
54
|
+
(`Three.WebGLRenderer`, WebGL2) to `new ThreeRig(assets, { renderer })` and
|
|
55
|
+
call `rig.update(dt)` (or `rig.advance(dt)`, in seconds) before
|
|
56
|
+
`renderer.render(scene, camera)`; `WebGPURenderer` is not supported —
|
|
57
|
+
[README.md](https://github.com/rig-c/adapters/blob/main/packages/three/README.md#live-object).
|
|
58
|
+
- **World bounds are Y-up in rig-local space.** `ThreeRig` is a `Group` that can
|
|
59
|
+
be translated, rotated and scaled under an orthographic or perspective camera;
|
|
60
|
+
use the `Group`'s `renderOrder` to order separate flat rigs in overlapping
|
|
61
|
+
scenes —
|
|
62
|
+
[README.md](https://github.com/rig-c/adapters/blob/main/packages/three/README.md#native-drawing-and-scene-placement).
|
|
63
|
+
- **Clips are shader polygons bounded by `MAX_TEXTURE_SIZE`.** A clip polygon
|
|
64
|
+
with more vertices than the renderer's `MAX_TEXTURE_SIZE` is refused as
|
|
65
|
+
`THREE_CLIP_CAPACITY` before any scene or resource change, and malformed,
|
|
66
|
+
crossing, zero-area or conflicting-`pma` inputs are refused by slot/page name —
|
|
67
|
+
[README.md](https://github.com/rig-c/adapters/blob/main/packages/three/README.md#native-drawing-and-scene-placement).
|
|
68
|
+
- **Destroy every `ThreeRig` before `assets.dispose()`.** `rig.destroy()` is
|
|
69
|
+
idempotent and frees only that rig's meshes, geometries, materials, clip
|
|
70
|
+
textures and shared page-texture references; it never disposes the
|
|
71
|
+
application's `WebGLRenderer` or `ModelAssets`.
|
|
72
|
+
|
|
73
|
+
## What this will not do
|
|
74
|
+
|
|
75
|
+
- Run on `WebGPURenderer` or rasterize the rig into an offscreen 2D canvas.
|
|
76
|
+
- Apply Three.js scene lights or tone mapping to the rig's shader (it matches
|
|
77
|
+
`@rig-c/play`'s premultiplied two-colour expression and blend factors).
|
|
78
|
+
- Play on a plain DOM page without Three.js (use `rig-play`) or inside PixiJS /
|
|
79
|
+
Phaser (use `rig-pixi` or `rig-phaser`).
|
|
80
|
+
- Compile, gate or retarget a rig (use `rigc`, `rig-parts` or `rig-pose`).
|
|
81
|
+
|
|
82
|
+
## Read, in this order
|
|
83
|
+
|
|
84
|
+
1. `node_modules/@rig-c/three/README.md` ([on GitHub](https://github.com/rig-c/adapters/blob/main/packages/three/README.md)) —
|
|
85
|
+
`ThreeRig`, `ThreeRenderer`, `resourceCounts()`, shared page textures, depth
|
|
86
|
+
and `renderOrder`, shader blend/tint rules and `THREE_CLIP_CAPACITY`.
|
|
87
|
+
2. `node_modules/@rig-c/three/dist/index.d.ts` — the exact exported types and
|
|
88
|
+
options matching the installed version.
|
|
89
|
+
3. [@rig-c/play's REFERENCE.md](https://github.com/rig-c/play/blob/main/docs/REFERENCE.md) —
|
|
90
|
+
the underlying `loadModel`, `RigPlayer`, `LiveFrame` and `PosedFrame`
|
|
91
|
+
contracts.
|