@rig-c/three 0.1.2 → 0.1.3

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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/dist/index.js +22 -12
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,3 +1,7 @@
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
+
1
5
  # @rig-c/three
2
6
 
3
7
  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
- validated = /* @__PURE__ */ new WeakSet();
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
- if (!this.validated.has(a)) {
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)) this.validated.add(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
- slot.slot = a.slot;
115
- slot.blend = a.blend;
116
- slot.page = a.page ?? "";
117
- slot.pma = a.pma;
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 === "region") slot.region = a.region ?? "";
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rig-c/three",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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",