@rig-c/three 0.1.2 → 0.1.4
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 +10 -0
- package/dist/index.js +22 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
<p align="center">
|
|
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
|
+
</p>
|
|
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
|
+
|
|
1
11
|
# @rig-c/three
|
|
2
12
|
|
|
3
13
|
Draw a rig-c model in a native Three.js scene through `@rig-c/play`. `ThreeRig`
|
package/dist/index.js
CHANGED
|
@@ -63,7 +63,10 @@ var LiveDrawViews = class {
|
|
|
63
63
|
owner;
|
|
64
64
|
order = [];
|
|
65
65
|
rows = [];
|
|
66
|
-
|
|
66
|
+
// Only a numeric token survives release: no borrowed attachment or buffer
|
|
67
|
+
// reference is retained to identify an immutable metadata row.
|
|
68
|
+
validated = /* @__PURE__ */ new WeakMap();
|
|
69
|
+
nextIdentity = 1;
|
|
67
70
|
read(frame) {
|
|
68
71
|
void frame.generation;
|
|
69
72
|
const { drawOrder, vertices, tint, attachments, count } = frame;
|
|
@@ -81,14 +84,18 @@ var LiveDrawViews = class {
|
|
|
81
84
|
throw new Error(`${owner}: live drawOrder[${i}]=${index} needs a region or mesh attachment`);
|
|
82
85
|
}
|
|
83
86
|
const a = attachment;
|
|
84
|
-
|
|
87
|
+
let identity2 = this.validated.get(a) ?? 0;
|
|
88
|
+
if (identity2 === 0) {
|
|
85
89
|
if (typeof a.slot !== "string" || a.slot.length === 0 || typeof a.page !== "string" || a.page.length === 0 || a.kind === "region" && (typeof a.region !== "string" || a.region.length === 0)) {
|
|
86
90
|
throw new Error(`${owner}: live slot "${a.slot}" needs named slot, page and region metadata`);
|
|
87
91
|
}
|
|
88
92
|
if (!Number.isInteger(a.offset) || !Number.isInteger(a.count) || a.offset < 0 || a.count < 0 || !Number.isInteger(a.slotIndex) || a.slotIndex < 0) {
|
|
89
93
|
throw new Error(`${owner}: live slot "${a.slot}" has invalid vertex span ${a.offset}+${a.count} or tint slotIndex=${a.slotIndex}`);
|
|
90
94
|
}
|
|
91
|
-
if (frozenData(a))
|
|
95
|
+
if (frozenData(a)) {
|
|
96
|
+
identity2 = this.nextIdentity++;
|
|
97
|
+
this.validated.set(a, identity2);
|
|
98
|
+
}
|
|
92
99
|
}
|
|
93
100
|
numbers(a.uvs, owner, "uvs", a.slot);
|
|
94
101
|
numbers(a.triangles, owner, "triangles", a.slot);
|
|
@@ -103,23 +110,26 @@ var LiveDrawViews = class {
|
|
|
103
110
|
const tint2 = new NumberSpan(4);
|
|
104
111
|
const common = { slot: a.slot, blend: a.blend, tint: tint2, page: a.page ?? "", pma: a.pma, uvs: EMPTY };
|
|
105
112
|
const slot2 = a.kind === "region" ? { ...common, kind: "region", region: a.region ?? "", corners: points } : { ...common, kind: "mesh", vertices: points, triangles: EMPTY };
|
|
106
|
-
row = { slot: slot2, points, tint: tint2 };
|
|
113
|
+
row = { slot: slot2, points, tint: tint2, identity: 0 };
|
|
107
114
|
this.rows[i] = row;
|
|
108
115
|
}
|
|
109
116
|
row.points.source = vertices;
|
|
110
|
-
row.points.offset = a.offset;
|
|
111
117
|
row.tint.source = tint;
|
|
112
|
-
row.tint.offset = a.slotIndex * 4;
|
|
113
118
|
const slot = row.slot;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
if (identity2 === 0 || row.identity !== identity2) {
|
|
120
|
+
row.points.offset = a.offset;
|
|
121
|
+
row.tint.offset = a.slotIndex * 4;
|
|
122
|
+
slot.slot = a.slot;
|
|
123
|
+
slot.blend = a.blend;
|
|
124
|
+
slot.page = a.page ?? "";
|
|
125
|
+
slot.pma = a.pma;
|
|
126
|
+
if (slot.kind === "region") slot.region = a.region ?? "";
|
|
127
|
+
row.identity = identity2;
|
|
128
|
+
}
|
|
118
129
|
slot.uvs = a.uvs;
|
|
119
130
|
slot.dark = a.dark ?? void 0;
|
|
120
131
|
slot.clip = a.clip ?? void 0;
|
|
121
|
-
if (slot.kind === "
|
|
122
|
-
else slot.triangles = a.triangles;
|
|
132
|
+
if (slot.kind === "mesh") slot.triangles = a.triangles;
|
|
123
133
|
this.order[i] = slot;
|
|
124
134
|
}
|
|
125
135
|
this.order.length = count;
|