@khr3/core 0.1.3 → 0.1.5

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/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { C as e, S as t, T as n, _ as r, a as i, b as a, c as o, d as s, f as c, g as l, h as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y, v as b, w as x, x as S, y as C } from "./BundleSceneHost-CE3HPB8a.js";
2
- import { useCallback as w, useContext as T, useImperativeHandle as ee, useLayoutEffect as E, useMemo as D, useRef as O } from "react";
3
- import { useFrame as te, useLoader as k } from "@react-three/fiber";
4
- import { Physics as A, RigidBody as j, useRapier as M } from "@react-three/rapier";
5
- import * as N from "three";
6
- import { jsx as P, jsxs as F } from "react/jsx-runtime";
7
- import { GLTFLoader as I } from "three/examples/jsm/loaders/GLTFLoader.js";
8
- import { GLTFExporter as L } from "three/examples/jsm/exporters/GLTFExporter.js";
2
+ import { useCallback as w, useContext as T, useEffect as E, useImperativeHandle as ee, useLayoutEffect as D, useMemo as O, useRef as k, useState as A } from "react";
3
+ import { useFrame as j, useLoader as M } from "@react-three/fiber";
4
+ import { Physics as N, RigidBody as P, useRapier as F } from "@react-three/rapier";
5
+ import * as I from "three";
6
+ import { jsx as L, jsxs as te } from "react/jsx-runtime";
7
+ import { GLTFLoader as R } from "three/examples/jsm/loaders/GLTFLoader.js";
8
+ import { GLTFExporter as ne } from "three/examples/jsm/exporters/GLTFExporter.js";
9
9
  // src/jointDynamics.ts
10
- var R = new N.Vector3(), z = new N.Vector3(), B = new N.Vector3(), ne = new N.Quaternion(), re = new N.Quaternion(), ie = new N.Matrix4(), ae = new N.Matrix4(), oe = new N.Matrix4(), se = new N.Matrix4(), V = new N.Vector3(), H = new N.Quaternion(), ce = new N.Vector3();
11
- function le(e, t, n = []) {
10
+ var z = new I.Vector3(), B = new I.Vector3(), re = new I.Vector3(), ie = new I.Quaternion(), ae = new I.Quaternion(), oe = new I.Matrix4(), se = new I.Matrix4(), ce = new I.Matrix4(), le = new I.Matrix4(), V = new I.Vector3(), H = new I.Quaternion(), ue = new I.Vector3();
11
+ function de(e, t, n = []) {
12
12
  if (t.kind === "fixed") return 0;
13
13
  let r = n.length > 0 ? [e, ...n] : [e];
14
14
  if (t.kind === "prismatic") {
@@ -16,19 +16,19 @@ function le(e, t, n = []) {
16
16
  for (let n of r) n.isKinematic && n !== e || (t += n.mass);
17
17
  return t;
18
18
  }
19
- R.fromArray(t.axis).normalize(), n.length > 0 && x(e, ie).invert();
19
+ z.fromArray(t.axis).normalize(), n.length > 0 && x(e, oe).invert();
20
20
  let i = 0;
21
21
  for (let t of r) {
22
22
  if (t !== e && t.isKinematic) continue;
23
- t === e ? (V.set(0, 0, 0), H.identity()) : (ae.multiplyMatrices(ie, x(t, se)).decompose(V, H, ce), H.normalize()), re.copy(H).multiply(ne.fromArray(t.inertiaOrientation)).invert(), z.copy(R).applyQuaternion(re);
24
- let [n, r, a] = t.inertiaDiagonal, o = n * z.x * z.x + r * z.y * z.y + a * z.z * z.z;
25
- B.fromArray(t.centerOfMass).applyQuaternion(H).add(V);
26
- let s = B.dot(R);
27
- i += o + t.mass * (B.lengthSq() - s * s);
23
+ t === e ? (V.set(0, 0, 0), H.identity()) : (se.multiplyMatrices(oe, x(t, le)).decompose(V, H, ue), H.normalize()), ae.copy(H).multiply(ie.fromArray(t.inertiaOrientation)).invert(), B.copy(z).applyQuaternion(ae);
24
+ let [n, r, a] = t.inertiaDiagonal, o = n * B.x * B.x + r * B.y * B.y + a * B.z * B.z;
25
+ re.fromArray(t.centerOfMass).applyQuaternion(H).add(V);
26
+ let s = re.dot(z);
27
+ i += o + t.mass * (re.lengthSq() - s * s);
28
28
  }
29
29
  return i;
30
30
  }
31
- function ue(t, n) {
31
+ function fe(t, n) {
32
32
  if (t.kind === "fixed" || !(n > 0)) return;
33
33
  let r = t.drive, i = r?.mode === "force", a = t.limits !== null && t.limitStiffness !== null;
34
34
  if ((i || a) && !(t.inertia > 0)) throw new e(`Joint "${t.nodeName}" requires positive effective inertia (got ${t.inertia})`);
@@ -49,79 +49,46 @@ function ue(t, n) {
49
49
  }
50
50
  t.v = p, t.q += p * n, t.limits && t.limitStiffness === null && (t.q < t.limits[0] ? (t.q = t.limits[0], t.v < 0 && (t.v = 0)) : t.q > t.limits[1] && (t.q = t.limits[1], t.v > 0 && (t.v = 0)));
51
51
  }
52
- var de = 1e-7;
53
- function fe(e, t) {
52
+ var pe = 1e-7;
53
+ function me(e, t) {
54
54
  if (e.stamp === t) return;
55
- e.parent && e.parent.stamp !== t && fe(e.parent, t), e.stamp = t;
55
+ e.parent && e.parent.stamp !== t && me(e.parent, t), e.stamp = t;
56
56
  let n = e.parent !== null && e.parent.dirtyStamp === t, r = e.colliders.every((e) => e.ref.current !== null);
57
- if (e.lastWrittenQ === void 0 || Math.abs(e.q - e.lastWrittenQ) > de || n) {
58
- e.dirtyStamp = t, r && (e.lastWrittenQ = e.q), e.kind === "revolute" ? (ne.setFromAxisAngle(e.axis, e.q), e.object.quaternion.copy(e.restQuaternion).multiply(ne), e.object.position.copy(e.restPosition), oe.makeRotationFromQuaternion(ne)) : e.kind === "prismatic" ? (R.copy(e.axis).multiplyScalar(e.q), e.object.quaternion.copy(e.restQuaternion), e.object.position.copy(R).applyQuaternion(e.restQuaternion).add(e.restPosition), oe.makeTranslation(R.x, R.y, R.z)) : oe.identity(), e.parent ? e.current.multiplyMatrices(e.parent.current, e.restRelParent) : e.current.copy(e.restRelParent), e.current.multiply(oe);
57
+ if (e.lastWrittenQ === void 0 || Math.abs(e.q - e.lastWrittenQ) > pe || n) {
58
+ e.dirtyStamp = t, r && (e.lastWrittenQ = e.q), e.kind === "revolute" ? (ie.setFromAxisAngle(e.axis, e.q), e.object.quaternion.copy(e.restQuaternion).multiply(ie), e.object.position.copy(e.restPosition), ce.makeRotationFromQuaternion(ie)) : e.kind === "prismatic" ? (z.copy(e.axis).multiplyScalar(e.q), e.object.quaternion.copy(e.restQuaternion), e.object.position.copy(z).applyQuaternion(e.restQuaternion).add(e.restPosition), ce.makeTranslation(z.x, z.y, z.z)) : ce.identity(), e.parent ? e.current.multiplyMatrices(e.parent.current, e.restRelParent) : e.current.copy(e.restRelParent), e.current.multiply(ce);
59
59
  for (let t of e.colliders) {
60
60
  let n = t.ref.current;
61
- n && (se.multiplyMatrices(e.current, t.local).decompose(V, H, ce), n.setTranslationWrtParent(V), n.setRotationWrtParent(H));
61
+ n && (le.multiplyMatrices(e.current, t.local).decompose(V, H, ue), n.setTranslationWrtParent(V), n.setRotationWrtParent(H));
62
62
  }
63
63
  }
64
64
  }
65
65
  // src/PhysicsWorld.tsx
66
- var pe = (e) => typeof e == "number" ? e : e.current;
67
- function me({ paused: e, timeScale: t, maxDelta: n, joints: r, dtRef: i, frozenRef: a }) {
68
- let { world: o } = M(), s = O(0);
69
- return te((c, l) => {
70
- let u = pe(t), d = Math.max(0, pe(n)), f = !e && u > 0 && d > 0 && l > 0 ? Math.min(Math.min(l, d) * u, .5) : 0;
71
- if (!(f > 0)) {
72
- i.current = 0, o.timestep > 0 || (o.timestep = 1 / 60);
73
- let e = a.current;
74
- e.length = 0, o.bodies.forEach((t) => {
75
- if (!t.isDynamic()) return;
76
- let n = t.linvel(), r = t.angvel();
77
- e.push({
78
- rb: t,
79
- lx: n.x,
80
- ly: n.y,
81
- lz: n.z,
82
- ax: r.x,
83
- ay: r.y,
84
- az: r.z,
85
- sleeping: t.isSleeping()
86
- });
87
- });
88
- } else if (a.current.length = 0, i.current = f, o.timestep = f, r.size > 0) {
89
- let e = ++s.current;
90
- for (let e of r) ue(e, f);
91
- for (let t of r) fe(t, e);
66
+ var he = (e) => typeof e == "number" ? e : e.current;
67
+ function ge({ paused: e, timeScale: t, maxDelta: n, joints: r, dtRef: i, activeRef: a, setActiveState: o }) {
68
+ let { world: s } = F(), c = k(0);
69
+ return j((l, u) => {
70
+ let d = he(t), f = Math.max(0, he(n)), p = !e && d > 0 && f > 0 && u > 0, m = p ? Math.min(Math.min(u, f) * d, .5) : 0;
71
+ if (p !== a.current && (a.current = p, o(p)), !(m > 0)) i.current = 0;
72
+ else if (i.current = m, s.timestep = m, r.size > 0) {
73
+ let e = ++c.current;
74
+ for (let e of r) fe(e, m);
75
+ for (let t of r) me(t, e);
92
76
  }
93
77
  }), null;
94
78
  }
95
- function he({ dtRef: e, frozenRef: t }) {
96
- let { step: n } = M();
97
- return te(() => {
98
- let r = e.current;
99
- if (r > 0) {
100
- n(r);
101
- return;
102
- }
103
- let i = t.current;
104
- for (let e = 0; e < i.length; e++) {
105
- let t = i[e];
106
- t.rb.setLinvel({
107
- x: t.lx,
108
- y: t.ly,
109
- z: t.lz
110
- }, !1), t.rb.setAngvel({
111
- x: t.ax,
112
- y: t.ay,
113
- z: t.az
114
- }, !1), t.sleeping && !t.rb.isSleeping() && t.rb.sleep();
115
- }
116
- i.length = 0;
79
+ function _e({ dtRef: e }) {
80
+ let { step: t } = F();
81
+ return j(() => {
82
+ let n = e.current;
83
+ n > 0 && t(n);
117
84
  }), null;
118
85
  }
119
- function ge({ paused: e = !1, timeScale: n = 1, maxDelta: r = 1 / 30, gravity: i = [
86
+ function ve({ paused: e = !1, timeScale: n = 1, maxDelta: r = 1 / 30, gravity: i = [
120
87
  0,
121
88
  -9.81,
122
89
  0
123
90
  ], children: o, ...s }) {
124
- let c = D(() => /* @__PURE__ */ new Set(), []), l = O(0), u = O([]), d = D(() => [
91
+ let c = O(() => /* @__PURE__ */ new Set(), []), l = k(0), u = !e && (typeof n != "number" || n > 0) && (typeof r != "number" || r > 0), [d, f] = A(u), p = k(u), m = u && d, h = O(() => [
125
92
  i[0],
126
93
  i[1],
127
94
  i[2]
@@ -129,34 +96,32 @@ function ge({ paused: e = !1, timeScale: n = 1, maxDelta: r = 1 / 30, gravity: i
129
96
  i[0],
130
97
  i[1],
131
98
  i[2]
132
- ]), f = !e && (typeof n != "number" || n > 0) && (typeof r != "number" || r > 0);
133
- return /* @__PURE__ */ P(C.Provider, {
99
+ ]);
100
+ return /* @__PURE__ */ L(C.Provider, {
134
101
  value: c,
135
- children: /* @__PURE__ */ P(S.Provider, {
136
- value: d,
137
- children: /* @__PURE__ */ P(a.Provider, {
138
- value: f,
139
- children: /* @__PURE__ */ P(t.Provider, {
102
+ children: /* @__PURE__ */ L(S.Provider, {
103
+ value: h,
104
+ children: /* @__PURE__ */ L(a.Provider, {
105
+ value: m,
106
+ children: /* @__PURE__ */ L(t.Provider, {
140
107
  value: l,
141
- children: /* @__PURE__ */ F(A, {
108
+ children: /* @__PURE__ */ te(N, {
142
109
  ...s,
143
110
  paused: !0,
144
111
  timeStep: "vary",
145
112
  gravity: i,
146
113
  children: [
147
- /* @__PURE__ */ P(me, {
114
+ /* @__PURE__ */ L(ge, {
148
115
  paused: e,
149
116
  timeScale: n,
150
117
  maxDelta: r,
151
118
  joints: c,
152
119
  dtRef: l,
153
- frozenRef: u
120
+ activeRef: p,
121
+ setActiveState: f
154
122
  }),
155
123
  o,
156
- /* @__PURE__ */ P(he, {
157
- dtRef: l,
158
- frozenRef: u
159
- })
124
+ /* @__PURE__ */ L(_e, { dtRef: l })
160
125
  ]
161
126
  })
162
127
  })
@@ -165,8 +130,8 @@ function ge({ paused: e = !1, timeScale: n = 1, maxDelta: r = 1 / 30, gravity: i
165
130
  });
166
131
  }
167
132
  // src/khrGlb.ts
168
- var _e = 1179937895, ve = 1313821514, ye = 5130562;
169
- function be(t) {
133
+ var ye = 1179937895, be = 1313821514, xe = 5130562;
134
+ function Se(t) {
170
135
  if (t.byteLength < 20) throw new e("GLB buffer shorter than 20-byte header");
171
136
  let n = new DataView(t);
172
137
  if (n.getUint32(0, !0) !== 1179937895) throw new e("Invalid GLB magic");
@@ -176,7 +141,7 @@ function be(t) {
176
141
  if (20 + r > t.byteLength) throw new e("Truncated GLB JSON chunk");
177
142
  return r;
178
143
  }
179
- function xe() {
144
+ function Ce() {
180
145
  if (globalThis.FileReader !== void 0) return;
181
146
  class e {
182
147
  result = null;
@@ -203,28 +168,28 @@ function xe() {
203
168
  }
204
169
  globalThis.FileReader = e;
205
170
  }
206
- function Se(e) {
171
+ function we(e) {
207
172
  let t = new TextEncoder().encode(JSON.stringify(e)), n = t.byteLength + 3 & -4, r = 20 + n, i = new ArrayBuffer(r), a = new DataView(i), o = new Uint8Array(i);
208
- return a.setUint32(0, _e, !0), a.setUint32(4, 2, !0), a.setUint32(8, r, !0), a.setUint32(12, n, !0), a.setUint32(16, ve, !0), o.set(t, 20), o.fill(32, 20 + t.byteLength, 20 + n), i;
173
+ return a.setUint32(0, ye, !0), a.setUint32(4, 2, !0), a.setUint32(8, r, !0), a.setUint32(12, n, !0), a.setUint32(16, be, !0), o.set(t, 20), o.fill(32, 20 + t.byteLength, 20 + n), i;
209
174
  }
210
- function Ce(t, n) {
211
- let r = t instanceof ArrayBuffer ? t : t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength), i = be(r), a = new DataView(r), o;
175
+ function Te(t, n) {
176
+ let r = t instanceof ArrayBuffer ? t : t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength), i = Se(r), a = new DataView(r), o;
212
177
  try {
213
178
  o = JSON.parse(new TextDecoder().decode(new Uint8Array(r, 20, i)));
214
179
  } catch {
215
180
  throw new e("Malformed GLB JSON chunk");
216
181
  }
217
182
  n(o);
218
- let s = new TextEncoder().encode(JSON.stringify(o)), c = s.byteLength + 3 & -4, l = 20 + i, u = l + 8 <= r.byteLength, d = u ? Math.min(a.getUint32(l, !0), r.byteLength - (l + 8)) : 0, f = u ? a.getUint32(l + 4, !0) : ye, p = u ? new Uint8Array(r, l + 8, d) : /* @__PURE__ */ new Uint8Array(), m = p.byteLength + 3 & -4, h = 20 + c + (u ? 8 + m : 0), g = new ArrayBuffer(h), _ = new DataView(g), v = new Uint8Array(g);
219
- return _.setUint32(0, _e, !0), _.setUint32(4, 2, !0), _.setUint32(8, h, !0), _.setUint32(12, c, !0), _.setUint32(16, ve, !0), v.set(s, 20), v.fill(32, 20 + s.byteLength, 20 + c), u && (_.setUint32(20 + c, m, !0), _.setUint32(24 + c, f, !0), v.set(p, 28 + c)), g;
183
+ let s = new TextEncoder().encode(JSON.stringify(o)), c = s.byteLength + 3 & -4, l = 20 + i, u = l + 8 <= r.byteLength, d = u ? Math.min(a.getUint32(l, !0), r.byteLength - (l + 8)) : 0, f = u ? a.getUint32(l + 4, !0) : xe, p = u ? new Uint8Array(r, l + 8, d) : /* @__PURE__ */ new Uint8Array(), m = p.byteLength + 3 & -4, h = 20 + c + (u ? 8 + m : 0), g = new ArrayBuffer(h), _ = new DataView(g), v = new Uint8Array(g);
184
+ return _.setUint32(0, ye, !0), _.setUint32(4, 2, !0), _.setUint32(8, h, !0), _.setUint32(12, c, !0), _.setUint32(16, be, !0), v.set(s, 20), v.fill(32, 20 + s.byteLength, 20 + c), u && (_.setUint32(20 + c, m, !0), _.setUint32(24 + c, f, !0), v.set(p, 28 + c)), g;
220
185
  }
221
186
  // src/khrExtras.ts
222
- var we = /* @__PURE__ */ new WeakMap();
223
- function Te(e, t) {
224
- we.set(e, t);
187
+ var Ee = /* @__PURE__ */ new WeakMap();
188
+ function De(e, t) {
189
+ Ee.set(e, t);
225
190
  }
226
- function Ee(e, t, n, r) {
227
- let i = we.get(t.scene);
191
+ function Oe(e, t, n, r) {
192
+ let i = Ee.get(t.scene);
228
193
  if (i) {
229
194
  if (n) for (let t = 0; t < e.bodies.length; t++) {
230
195
  let r = i.bodies[t], a = e.bodies[t];
@@ -247,9 +212,9 @@ function Ee(e, t, n, r) {
247
212
  }
248
213
  }
249
214
  }
250
- var De = new N.Vector3(), U = new N.Quaternion(), Oe = new N.Quaternion();
251
- function ke(e, t) {
252
- return e.updateWorldMatrix(!0, !1), e.getWorldQuaternion(U), t && (t.updateWorldMatrix(!0, !1), U.premultiply(t.getWorldQuaternion(Oe).invert())), U.lengthSq() > 0 ? U.normalize() : U.identity(), [
215
+ var ke = new I.Vector3(), U = new I.Quaternion(), Ae = new I.Quaternion();
216
+ function je(e, t) {
217
+ return e.updateWorldMatrix(!0, !1), e.getWorldQuaternion(U), t && (t.updateWorldMatrix(!0, !1), U.premultiply(t.getWorldQuaternion(Ae).invert())), U.lengthSq() > 0 ? U.normalize() : U.identity(), [
253
218
  U.x || 0,
254
219
  U.y || 0,
255
220
  U.z || 0,
@@ -264,24 +229,30 @@ function K(t, n, r, i = !1) {
264
229
  return a;
265
230
  }
266
231
  }
267
- function Ae(t, n, r, i) {
232
+ function Me(t, n, r, i) {
268
233
  let a = t[n];
269
234
  if (a !== void 0) {
270
235
  if (typeof a != "boolean") throw new e(`${r} "${i}" has non-boolean ${r}.${n}`);
271
236
  return a;
272
237
  }
273
238
  }
274
- function je(t, n, r) {
239
+ function Ne(t, n, r) {
275
240
  if (t !== void 0) {
276
- if (!W(t) || !Array.isArray(t.points) || t.points.length === 0) throw new e(`ecctrlWheel "${r}" has invalid ecctrlWheel.${n}`);
241
+ if (!W(t) || !Array.isArray(t.points) || t.points.length < 2) throw new e(`ecctrlWheel "${r}" has invalid ecctrlWheel.${n}`);
277
242
  for (let i of t.points) if (!W(i) || !G(i.x) || !G(i.y)) throw new e(`ecctrlWheel "${r}" has invalid point in ecctrlWheel.${n}`);
278
243
  if (t.samples !== void 0 && (!G(t.samples) || t.samples <= 0)) throw new e(`ecctrlWheel "${r}" has invalid samples in ecctrlWheel.${n}`);
279
244
  return t;
280
245
  }
281
246
  }
282
- function Me(t, n, r, i, a) {
247
+ function Pe(t, n) {
248
+ if (t !== void 0) {
249
+ if (t === "shapeCast" || t === "rayCast") return t;
250
+ throw new e(`ecctrlWheel "${n}" has invalid ecctrlWheel.groundDetection`);
251
+ }
252
+ }
253
+ function Fe(t, n, r, i, a) {
283
254
  if (r.socketId !== void 0 && (typeof r.socketId != "string" || r.socketId.length === 0)) throw new e(`Node "${n}" has invalid extras.socketId`);
284
- let o = t.getWorldPosition(new N.Vector3()), s = [
255
+ let o = t.getWorldPosition(new I.Vector3()), s = [
285
256
  o.x,
286
257
  o.y,
287
258
  o.z
@@ -296,11 +267,11 @@ function Me(t, n, r, i, a) {
296
267
  t.getWorldQuaternion(U), l = [];
297
268
  for (let t of r.contactDots) {
298
269
  if (!W(t) || typeof t.role != "string" || t.role.length === 0 || !Array.isArray(t.pos) || t.pos.length !== 3 || !t.pos.every(G)) throw new e(`Node "${n}" has invalid entry in extras.contactDots`);
299
- De.set(t.pos[0], t.pos[1], t.pos[2]).applyQuaternion(U).add(o);
270
+ ke.set(t.pos[0], t.pos[1], t.pos[2]).applyQuaternion(U).add(o);
300
271
  let r = [
301
- De.x,
302
- De.y,
303
- De.z
272
+ ke.x,
273
+ ke.y,
274
+ ke.z
304
275
  ];
305
276
  i[t.role] = r, l.push([t.role, r]);
306
277
  }
@@ -312,7 +283,7 @@ function Me(t, n, r, i, a) {
312
283
  ...l ? { contactDots: l } : {}
313
284
  };
314
285
  }
315
- function Ne(t, n, r, i) {
286
+ function Ie(t, n, r, i) {
316
287
  if (y(t, n), !W(r)) throw new e(`ecctrlWheel "${n}" must be an object`);
317
288
  let a = (t) => {
318
289
  let i = r[t];
@@ -328,7 +299,7 @@ function Ne(t, n, r, i) {
328
299
  return i;
329
300
  }, c = a("radius"), l = a("width"), u = o("travel"), d = o("sag");
330
301
  if (d > u) throw new e(`ecctrlWheel "${n}" has invalid ecctrlWheel.sag (${d}) > ecctrlWheel.travel (${u})`);
331
- let f = s("steer"), p = s("drive"), m = s("brake"), h = new N.Box3().setFromObject(t), g = h.isEmpty() ? t.getWorldPosition(new N.Vector3()) : h.getCenter(new N.Vector3());
302
+ let f = s("steer"), p = s("drive"), m = s("brake"), h = new I.Box3().setFromObject(t), g = h.isEmpty() ? t.getWorldPosition(new I.Vector3()) : h.getCenter(new I.Vector3());
332
303
  return {
333
304
  nodeName: n,
334
305
  object: t,
@@ -337,13 +308,13 @@ function Ne(t, n, r, i) {
337
308
  g.y,
338
309
  g.z
339
310
  ],
340
- quaternion: ke(t, i),
311
+ quaternion: je(t, i),
341
312
  radius: c,
342
313
  width: l,
343
314
  steer: f,
344
- steerInvert: Ae(r, "steerInvert", "ecctrlWheel", n),
315
+ steerInvert: Me(r, "steerInvert", "ecctrlWheel", n),
345
316
  drive: p,
346
- driveInvert: Ae(r, "driveInvert", "ecctrlWheel", n),
317
+ driveInvert: Me(r, "driveInvert", "ecctrlWheel", n),
347
318
  brake: m,
348
319
  travel: u,
349
320
  sag: d,
@@ -352,16 +323,20 @@ function Ne(t, n, r, i) {
352
323
  maxBrakeTorque: K(r, "maxBrakeTorque", n),
353
324
  rollingResistanceCoef: K(r, "rollingResistanceCoef", n),
354
325
  wheelDensity: K(r, "wheelDensity", n, !0),
326
+ groundDetection: Pe(r.groundDetection, n),
355
327
  driveTorqueWeight: K(r, "driveTorqueWeight", n),
356
328
  tireGripFactor: K(r, "tireGripFactor", n),
329
+ lngFrictionEllipseScale: K(r, "lngFrictionEllipseScale", n),
357
330
  latFrictionEllipseScale: K(r, "latFrictionEllipseScale", n),
358
331
  relaxLngRate: K(r, "relaxLngRate", n),
359
332
  relaxLatRate: K(r, "relaxLatRate", n),
360
- lngSlipRatioCurveData: je(r.lngSlipRatioCurveData, "lngSlipRatioCurveData", n),
361
- latSlipRatioCurveData: je(r.latSlipRatioCurveData, "latSlipRatioCurveData", n)
333
+ minLngRelaxCoeff: K(r, "minLngRelaxCoeff", n),
334
+ minLatRelaxCoeff: K(r, "minLatRelaxCoeff", n),
335
+ lngSlipRatioCurveData: Ne(r.lngSlipRatioCurveData, "lngSlipRatioCurveData", n),
336
+ latSlipRatioCurveData: Ne(r.latSlipRatioCurveData, "latSlipRatioCurveData", n)
362
337
  };
363
338
  }
364
- function Pe(t, n, r, i) {
339
+ function Le(t, n, r, i) {
365
340
  if (y(t, n), !W(r)) throw new e(`ecctrlPropeller "${n}" must be an object`);
366
341
  if (!G(r.maxThrust) || r.maxThrust <= 0) throw new e(`ecctrlPropeller "${n}" is missing positive finite ecctrlPropeller.maxThrust`);
367
342
  let a;
@@ -369,7 +344,7 @@ function Pe(t, n, r, i) {
369
344
  if (!G(r.torqueRatio)) throw new e(`ecctrlPropeller "${n}" has invalid ecctrlPropeller.torqueRatio`);
370
345
  a = r.torqueRatio;
371
346
  }
372
- let o = new N.Box3().setFromObject(t), s = o.isEmpty() ? t.getWorldPosition(new N.Vector3()) : o.getCenter(new N.Vector3());
347
+ let o = new I.Box3().setFromObject(t), s = o.isEmpty() ? t.getWorldPosition(new I.Vector3()) : o.getCenter(new I.Vector3());
373
348
  return {
374
349
  nodeName: n,
375
350
  object: t,
@@ -378,23 +353,23 @@ function Pe(t, n, r, i) {
378
353
  s.y,
379
354
  s.z
380
355
  ],
381
- quaternion: ke(t, i),
356
+ quaternion: je(t, i),
382
357
  maxThrust: r.maxThrust,
383
358
  torqueRatio: a,
384
- invertThrust: Ae(r, "invertThrust", "ecctrlPropeller", n),
385
- invertTorque: Ae(r, "invertTorque", "ecctrlPropeller", n)
359
+ invertThrust: Me(r, "invertThrust", "ecctrlPropeller", n),
360
+ invertTorque: Me(r, "invertTorque", "ecctrlPropeller", n)
386
361
  };
387
362
  }
388
363
  // src/khrParsers.ts
389
- var Fe = /* @__PURE__ */ new Map([["default", 0]]), Ie = 1, Le = (e) => typeof e == "object" && !!e && !Array.isArray(e), q = (e) => typeof e == "number" && Number.isFinite(e) && e > 0, Re = (e) => typeof e == "number" && Number.isFinite(e) && e >= 0;
364
+ var Re = /* @__PURE__ */ new Map([["default", 0]]), ze = 1, Be = (e) => typeof e == "object" && !!e && !Array.isArray(e), q = (e) => typeof e == "number" && Number.isFinite(e) && e > 0, Ve = (e) => typeof e == "number" && Number.isFinite(e) && e >= 0;
390
365
  function J(t, n, r = !1) {
391
366
  if (t !== void 0) {
392
367
  if (typeof t != "number" || !Number.isFinite(t) || r && t < 0) throw new e(`Invalid ${n}`);
393
368
  return t;
394
369
  }
395
370
  }
396
- function ze(t, n) {
397
- if (!Le(t)) throw new e(`KHR_implicit_shapes[${n}] must be an object`);
371
+ function He(t, n) {
372
+ if (!Be(t)) throw new e(`KHR_implicit_shapes[${n}] must be an object`);
398
373
  let r = t.type;
399
374
  if (r === "box" && t.box && typeof t.box == "object") {
400
375
  let r = t.box.size;
@@ -431,25 +406,25 @@ function ze(t, n) {
431
406
  }
432
407
  throw new e(`KHR_implicit_shapes[${n}] unsupported shape type "${r}"`);
433
408
  }
434
- function Be(t, n, r) {
409
+ function Ue(t, n, r) {
435
410
  if (n === void 0) return {};
436
411
  if (typeof n != "number" || !Number.isInteger(n) || n < 0 || n >= t.length) throw new e(`Node "${r}" references out-of-bounds physicsMaterial ${String(n)}`);
437
412
  let i = t[n];
438
- if (!Le(i)) throw new e(`Invalid physicsMaterials[${n}] on "${r}"`);
413
+ if (!Be(i)) throw new e(`Invalid physicsMaterials[${n}] on "${r}"`);
439
414
  let a = J(i.dynamicFriction, `physicsMaterials[${n}].dynamicFriction`, !0), o = J(i.staticFriction, `physicsMaterials[${n}].staticFriction`, !0), s = J(i.restitution, `physicsMaterials[${n}].restitution`, !0);
440
415
  return {
441
416
  ...a !== void 0 || o !== void 0 ? { friction: a ?? o } : {},
442
417
  ...s === void 0 ? {} : { restitution: s }
443
418
  };
444
419
  }
445
- function Ve(t, n, i) {
420
+ function We(t, n, i) {
446
421
  if (t.isKinematic !== void 0 && typeof t.isKinematic != "boolean") throw new e(`Node "${i}" has non-boolean motion.isKinematic`);
447
422
  let a = !n || !!t.isKinematic, o = 0;
448
423
  if (!a) {
449
424
  if (!q(t.mass)) throw new e(`Dynamic node "${i}" is missing positive finite motion.mass`);
450
425
  o = t.mass;
451
426
  } else if (t.mass !== void 0) {
452
- if (!Re(t.mass)) throw new e(`Kinematic node "${i}" has invalid motion.mass`);
427
+ if (!Ve(t.mass)) throw new e(`Kinematic node "${i}" has invalid motion.mass`);
453
428
  o = t.mass;
454
429
  }
455
430
  let s = t.centerOfMass === void 0 ? [
@@ -480,13 +455,13 @@ function Ve(t, n, i) {
480
455
  ...p === void 0 ? {} : { gravityFactor: p }
481
456
  };
482
457
  }
483
- function He(t) {
458
+ function Ge(t) {
484
459
  let n = (t) => {
485
- let n = Fe.get(t);
460
+ let n = Re.get(t);
486
461
  if (n !== void 0) return n;
487
- if (Ie > 15) throw new e(`Exceeded Rapier 16-group limit for collisionSystem "${t}"`);
488
- let r = Ie++;
489
- return Fe.set(t, r), r;
462
+ if (ze > 15) throw new e(`Exceeded Rapier 16-group limit for collisionSystem "${t}"`);
463
+ let r = ze++;
464
+ return Re.set(t, r), r;
490
465
  }, r = (t, r) => {
491
466
  if (t === void 0) return 0;
492
467
  if (!Array.isArray(t)) throw new e(`collisionFilter.${r} must be an array`);
@@ -504,7 +479,7 @@ function He(t) {
504
479
  return (i & 65535) << 16 | a & 65535;
505
480
  });
506
481
  }
507
- var Ue = (e) => e === 0 ? [
482
+ var Ke = (e) => e === 0 ? [
508
483
  1,
509
484
  0,
510
485
  0
@@ -517,7 +492,7 @@ var Ue = (e) => e === 0 ? [
517
492
  0,
518
493
  1
519
494
  ];
520
- function We(t, n, r) {
495
+ function qe(t, n, r) {
521
496
  return t.map((t, i) => {
522
497
  let a = `physicsJoints[${n}].drives[${i}] on "${r}"`;
523
498
  if (!t || typeof t != "object" || Array.isArray(t)) throw new e(`${a} must be an object`);
@@ -539,9 +514,9 @@ function We(t, n, r) {
539
514
  };
540
515
  });
541
516
  }
542
- function Ge(t, n, r, i, a, o, s, c = i.name) {
517
+ function Je(t, n, r, i, a, o, s, c = i.name) {
543
518
  let l = t[n];
544
- if (!Le(l)) throw new e(`physicsJoints[${n}] out of bounds for "${r}"`);
519
+ if (!Be(l)) throw new e(`physicsJoints[${n}] out of bounds for "${r}"`);
545
520
  if (l.limits !== void 0 && !Array.isArray(l.limits)) throw new e(`physicsJoints[${n}].limits on "${r}" must be an array`);
546
521
  if (l.drives !== void 0 && !Array.isArray(l.drives)) throw new e(`physicsJoints[${n}].drives on "${r}" must be an array`);
547
522
  let u = l.limits ?? [], d = l.drives ?? [], f = [
@@ -577,7 +552,7 @@ function Ge(t, n, r, i, a, o, s, c = i.name) {
577
552
  });
578
553
  };
579
554
  for (let t of u) {
580
- if (!Le(t)) throw new e(`physicsJoints[${n}].limits entry on "${r}" must be an object`);
555
+ if (!Be(t)) throw new e(`physicsJoints[${n}].limits entry on "${r}" must be an object`);
581
556
  g(t.linearAxes, t, f, m), g(t.angularAxes, t, p, h);
582
557
  }
583
558
  let _ = [
@@ -595,15 +570,15 @@ function Ge(t, n, r, i, a, o, s, c = i.name) {
595
570
  ], x = null, S;
596
571
  if (_.length === 0 && v.length === 0) y = "fixed";
597
572
  else if (_.length === 0 && v.length === 1) {
598
- y = "revolute", b = Ue(v[0]);
573
+ y = "revolute", b = Ke(v[0]);
599
574
  let e = p[v[0]];
600
575
  x = Array.isArray(e) ? e : null, S = h[v[0]];
601
576
  } else if (v.length === 0 && _.length === 1) {
602
- y = "prismatic", b = Ue(_[0]);
577
+ y = "prismatic", b = Ke(_[0]);
603
578
  let e = f[_[0]];
604
579
  x = Array.isArray(e) ? e : null, S = m[_[0]];
605
580
  } else throw new e(`physicsJoints[${n}] unsupported DOF (${_.length} lin, ${v.length} ang) on "${r}"`);
606
- let C = We(d, n, r), w = a.getWorldPosition(new N.Vector3()).sub(i.getWorldPosition(new N.Vector3())).applyQuaternion(i.getWorldQuaternion(new N.Quaternion()).invert());
581
+ let C = qe(d, n, r), w = a.getWorldPosition(new I.Vector3()).sub(i.getWorldPosition(new I.Vector3())).applyQuaternion(i.getWorldQuaternion(new I.Quaternion()).invert());
607
582
  return {
608
583
  index: n,
609
584
  nodeName: r,
@@ -636,16 +611,16 @@ function X(t, n) {
636
611
  if (!Array.isArray(t)) throw new e(`${n} must be an array`);
637
612
  return t;
638
613
  }
639
- function Ke() {
614
+ function Ye() {
640
615
  return (e) => ({
641
616
  name: "khr3_headless_texture",
642
617
  loadTexture(t) {
643
- let n = new N.Texture();
618
+ let n = new I.Texture();
644
619
  return n.flipY = !1, e.associations.set(n, { textures: t }), Promise.resolve(n);
645
620
  }
646
621
  });
647
622
  }
648
- function qe(t, n, r = t.parser?.json) {
623
+ function Xe(t, n, r = t.parser?.json) {
649
624
  let i = new Int32Array(n.length).fill(-1);
650
625
  for (let t = 0; t < n.length; t++) {
651
626
  let r = n[t];
@@ -721,12 +696,12 @@ function qe(t, n, r = t.parser?.json) {
721
696
  if (e < 0 || e >= n.length || !o.has(e)) return;
722
697
  let r = d.get(e);
723
698
  if (r) return r;
724
- let i = l[e], a = N.PropertyBinding.sanitizeNodeName(i);
699
+ let i = l[e], a = I.PropertyBinding.sanitizeNodeName(i);
725
700
  return f.get(i) ?? f.get(a) ?? t.scene.getObjectByName(i);
726
701
  }
727
702
  };
728
703
  }
729
- function Je(t, n, r, i, a) {
704
+ function Ze(t, n, r, i, a) {
730
705
  if (!Y(t)) throw new e(`Node "${n}" has invalid collider (expected object)`);
731
706
  let o = t.geometry;
732
707
  if (!Y(o)) throw new e(`Node "${n}" is missing collider.geometry object`);
@@ -744,8 +719,8 @@ function Je(t, n, r, i, a) {
744
719
  throw new e(`Node "${n}" collider.geometry must specify shape or node`);
745
720
  }
746
721
  // src/khrPlugin.ts
747
- var Ye = "khrBundle";
748
- function Xe(t, n) {
722
+ var Qe = "khrBundle";
723
+ function $e(t, n) {
749
724
  if (!t.scene) throw new e("GLTF asset has no active scene");
750
725
  t.scene.updateMatrixWorld(!0), s(t.scene);
751
726
  let i = t.parser?.json;
@@ -755,14 +730,14 @@ function Xe(t, n) {
755
730
  if (a !== void 0 && !Y(a)) throw new e("KHR_physics_rigid_bodies extension must be an object");
756
731
  let o = i.extensions?.KHR_implicit_shapes;
757
732
  if (o !== void 0 && !Y(o)) throw new e("KHR_implicit_shapes extension must be an object");
758
- let c = X(o?.shapes, "KHR_implicit_shapes.shapes").map((e, t) => ze(e, t)), l = X(a?.physicsMaterials, "KHR_physics_rigid_bodies.physicsMaterials"), d = He(X(a?.collisionFilters, "KHR_physics_rigid_bodies.collisionFilters")), p = X(a?.physicsJoints, "KHR_physics_rigid_bodies.physicsJoints"), m = X(i.nodes, "glTF nodes"), { parentIdx: g, nodeNames: _, resolveObj: v } = qe(t, m, i), y = [], b = {};
733
+ let c = X(o?.shapes, "KHR_implicit_shapes.shapes").map((e, t) => He(e, t)), l = X(a?.physicsMaterials, "KHR_physics_rigid_bodies.physicsMaterials"), d = Ge(X(a?.collisionFilters, "KHR_physics_rigid_bodies.collisionFilters")), p = X(a?.physicsJoints, "KHR_physics_rigid_bodies.physicsJoints"), m = X(i.nodes, "glTF nodes"), { parentIdx: g, nodeNames: _, resolveObj: v } = Xe(t, m, i), y = [], b = {};
759
734
  for (let e = 0; e < m.length; e++) {
760
735
  let t = v(e);
761
736
  if (!t) continue;
762
737
  let r = Y(m[e].extras) ? m[e].extras : {};
763
- y.push(Me(t, _[e], r, b, n?.isSocketNode));
738
+ y.push(Fe(t, _[e], r, b, n?.isSocketNode));
764
739
  }
765
- let x = [], S = [], C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Set(), T = [], ee = [], E = (e) => {
740
+ let x = [], S = [], C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Set(), T = [], E = [], ee = (e) => {
766
741
  for (let t = g[e]; t !== -1; t = g[t]) if (m[t].extensions?.KHR_physics_rigid_bodies?.motion) return t;
767
742
  return -1;
768
743
  }, D = (e) => {
@@ -778,7 +753,7 @@ function Xe(t, n) {
778
753
  let s = Y(i.extras) ? i.extras : {};
779
754
  if (s.ecctrlWheel !== void 0 || s.ecctrlPropeller !== void 0) {
780
755
  if (g[r] !== -1 && D(g[r])) throw new e(`Nested rotor "${a}" inside detached rotor is unsupported`);
781
- s.ecctrlWheel === void 0 ? ee.push(Pe(o, a, s.ecctrlPropeller, t.scene)) : T.push(Ne(o, a, s.ecctrlWheel, t.scene));
756
+ s.ecctrlWheel === void 0 ? E.push(Le(o, a, s.ecctrlPropeller, t.scene)) : T.push(Ie(o, a, s.ecctrlWheel, t.scene));
782
757
  continue;
783
758
  }
784
759
  if (D(r)) continue;
@@ -786,12 +761,12 @@ function Xe(t, n) {
786
761
  if (c === void 0) continue;
787
762
  if (!Y(c)) throw new e(`Node "${a}" has invalid KHR_physics_rigid_bodies`);
788
763
  if (c.motion === void 0 && c.collider === void 0 && c.joint === void 0) continue;
789
- if (c.motion === void 0 && E(r) !== -1) {
764
+ if (c.motion === void 0 && ee(r) !== -1) {
790
765
  if (c.joint !== void 0) throw new e(`Node "${a}" has joint without motion`);
791
766
  continue;
792
767
  }
793
768
  if (c.motion !== void 0 && !Y(c.motion)) throw new e(`Node "${a}" has invalid motion`);
794
- let { hasExplicitInertia: l, ...u } = Ve(c.motion ?? {}, c.motion !== void 0, a);
769
+ let { hasExplicitInertia: l, ...u } = We(c.motion ?? {}, c.motion !== void 0, a);
795
770
  l && w.add(r);
796
771
  let d = n?.extractRole?.(a, s) ?? (typeof s.role == "string" ? s.role : null), f = null;
797
772
  if (c.joint !== void 0) {
@@ -803,9 +778,9 @@ function Xe(t, n) {
803
778
  let n = t.connectedNode, r = _[n] ?? `node_${n}`, i = v(n);
804
779
  if (!i) throw new e(`Joint on "${a}" targets missing connectedNode "${r}"`);
805
780
  if (D(n)) throw new e(`Joint on "${a}" cannot target detached rotor "${r}"`);
806
- f = Ge(p, t.joint, a, i, o, !!t.enableCollision, d, r);
781
+ f = Je(p, t.joint, a, i, o, !!t.enableCollision, d, r);
807
782
  }
808
- let h = o.getWorldPosition(new N.Vector3()), y = o.getWorldQuaternion(new N.Quaternion()), b = {
783
+ let h = o.getWorldPosition(new I.Vector3()), y = o.getWorldQuaternion(new I.Quaternion()), b = {
809
784
  nodeName: a,
810
785
  ...u,
811
786
  localPosition: [
@@ -835,9 +810,9 @@ function Xe(t, n) {
835
810
  if (n === void 0) continue;
836
811
  let r = v(t);
837
812
  if (!r) continue;
838
- let i = C.has(t) ? t : E(t), a = C.get(i);
813
+ let i = C.has(t) ? t : ee(t), a = C.get(i);
839
814
  if (!a) continue;
840
- let o = Je(n, _[t], c, _, v), s = n, f = i === t ? {
815
+ let o = Ze(n, _[t], c, _, v), s = n, f = i === t ? {
841
816
  localPosition: [
842
817
  0,
843
818
  0,
@@ -849,7 +824,7 @@ function Xe(t, n) {
849
824
  0,
850
825
  1
851
826
  ]
852
- } : u(a.object, r), p = Be(l, s.physicsMaterial, _[t]), h;
827
+ } : u(a.object, r), p = Ue(l, s.physicsMaterial, _[t]), h;
853
828
  if (s.collisionFilter !== void 0) {
854
829
  if (typeof s.collisionFilter != "number" || !Number.isInteger(s.collisionFilter) || s.collisionFilter < 0 || s.collisionFilter >= d.length) throw new e(`Node "${_[t]}" references out-of-bounds collisionFilter ${String(s.collisionFilter)}`);
855
830
  h = d[s.collisionFilter];
@@ -863,61 +838,61 @@ function Xe(t, n) {
863
838
  });
864
839
  }
865
840
  for (let [e, t] of C) w.has(e) || t.isKinematic || (t.inertiaDiagonal = f(t.colliders, t.mass, t.centerOfMass, t.inertiaOrientation, t.nodeName));
866
- let { totalDynamicMass: O, centerOfMass: te } = h(x), k = [], A = i.scenes?.[i.scene ?? 0]?.extras ?? i.extras;
867
- if (A?.ikSockets !== void 0) {
868
- if (!Y(A.ikSockets)) throw new e("scene.extras.ikSockets must be an object");
869
- for (let [e, t] of Object.entries(A.ikSockets)) {
841
+ let { totalDynamicMass: O, centerOfMass: k } = h(x), A = [], j = i.scenes?.[i.scene ?? 0]?.extras ?? i.extras;
842
+ if (j?.ikSockets !== void 0) {
843
+ if (!Y(j.ikSockets)) throw new e("scene.extras.ikSockets must be an object");
844
+ for (let [e, t] of Object.entries(j.ikSockets)) {
870
845
  let n = r(t, `scene.extras.ikSockets.${e}`);
871
- b[e] = n, k.push([e, n]);
846
+ b[e] = n, A.push([e, n]);
872
847
  }
873
848
  }
874
- let j = Y(A?.tune) ? A.tune : void 0, M = Y(A?.droneTune) ? A.droneTune : void 0;
875
- return Te(t.scene, {
849
+ let M = Y(j?.tune) ? j.tune : void 0, N = Y(j?.droneTune) ? j.droneTune : void 0;
850
+ return De(t.scene, {
876
851
  nodes: y,
877
852
  bodies: S,
878
- ikSockets: k
853
+ ikSockets: A
879
854
  }), {
880
855
  scene: t.scene,
881
856
  bodies: x,
882
857
  wheels: T,
883
- propellers: ee,
858
+ propellers: E,
884
859
  sockets: b,
885
860
  totalDynamicMass: O,
886
- centerOfMass: te,
887
- tune: j,
888
- droneTune: M
861
+ centerOfMass: k,
862
+ tune: M,
863
+ droneTune: N
889
864
  };
890
865
  }
891
- function Ze(e) {
866
+ function et(e) {
892
867
  let t = typeof document > "u" && typeof createImageBitmap > "u";
893
868
  return (n) => ({
894
869
  name: "KHR_physics_rigid_bodies",
895
870
  ...t ? { loadTexture(e) {
896
- let t = new N.Texture();
871
+ let t = new I.Texture();
897
872
  return t.flipY = !1, n.associations.set(t, { textures: e }), Promise.resolve(t);
898
873
  } } : {},
899
874
  afterRoot(t) {
900
- return t.userData[Ye] = Xe(t, e), null;
875
+ return t.userData[Qe] = $e(t, e), null;
901
876
  }
902
877
  });
903
878
  }
904
879
  // src/khrLoader.ts
905
- var Qe = Ke();
906
- function $e() {
907
- let e = new I();
908
- return typeof document > "u" && typeof createImageBitmap > "u" && e.register(Qe), e;
880
+ var tt = Ye();
881
+ function nt() {
882
+ let e = new R();
883
+ return typeof document > "u" && typeof createImageBitmap > "u" && e.register(tt), e;
909
884
  }
910
- async function et(t, n) {
885
+ async function rt(t, n) {
911
886
  let r = t instanceof Uint8Array ? t : new Uint8Array(t), i = new ArrayBuffer(r.byteLength);
912
- new Uint8Array(i).set(r), be(i);
913
- let a = n?.loader ?? $e(), o = Ze(n);
887
+ new Uint8Array(i).set(r), Se(i);
888
+ let a = n?.loader ?? nt(), o = et(n);
914
889
  a.register(o);
915
890
  try {
916
891
  let t = (t) => t instanceof e ? t : new e(t instanceof Error ? t.message : "Failed to parse GLB"), n = (await new Promise((e, n) => {
917
892
  a.parse(i, "", e, (e) => n(t(e)));
918
893
  }).catch((e) => {
919
894
  throw t(e);
920
- })).userData[Ye];
895
+ })).userData[Qe];
921
896
  if (!n) throw new e("Missing parsed KHR bundle on GLTF userData");
922
897
  return n;
923
898
  } finally {
@@ -932,7 +907,7 @@ function Q(t, n, r = !1) {
932
907
  return t;
933
908
  }
934
909
  }
935
- function tt(t, n) {
910
+ function it(t, n) {
936
911
  if (t.type === "box") {
937
912
  if (!Array.isArray(t.size) || t.size.length !== 3 || !t.size.every(Z)) throw new e(`exportKhrGlb: invalid box.size on "${n}"`);
938
913
  return {
@@ -958,13 +933,13 @@ function tt(t, n) {
958
933
  }
959
934
  };
960
935
  }
961
- function nt(t, n, r) {
936
+ function at(t, n, r) {
962
937
  if (!Array.isArray(t) || t.length !== 3 || !t.every((e) => typeof e == "number" && Number.isFinite(e))) throw new e(`exportKhrGlb: ${n} joint on "${r}" requires a finite axis`);
963
938
  let i = Math.abs(t[0]), a = Math.abs(t[1]), o = Math.abs(t[2]);
964
939
  if (Math.hypot(i, a, o) <= 1e-8) throw new e(`exportKhrGlb: ${n} joint on "${r}" requires non-zero axis`);
965
940
  return i >= a && i >= o ? 0 : a >= o ? 1 : 2;
966
941
  }
967
- function rt(t, n, r, i) {
942
+ function ot(t, n, r, i) {
968
943
  if (!t || typeof t != "object" || Array.isArray(t)) throw new e(`exportKhrGlb: joint drive on "${i}" must be an object`);
969
944
  if (t.mode !== "force" && t.mode !== "acceleration") throw new e(`exportKhrGlb: joint drive on "${i}" requires drive.mode ("force" | "acceleration")`);
970
945
  if (t.type !== void 0 && t.type !== "linear" && t.type !== "angular") throw new e(`exportKhrGlb: joint drive on "${i}" has invalid drive.type`);
@@ -983,7 +958,7 @@ function rt(t, n, r, i) {
983
958
  ...l === void 0 ? {} : { maxForce: l }
984
959
  };
985
960
  }
986
- function it(t, n) {
961
+ function st(t, n) {
987
962
  if (t.kind !== "fixed" && t.kind !== "revolute" && t.kind !== "prismatic") throw new e(`exportKhrGlb: invalid joint.kind "${String(t.kind)}" on "${n}"`);
988
963
  if (t.kind === "fixed") {
989
964
  if (t.drive || t.drives && t.drives.length > 0) throw new e(`exportKhrGlb: fixed joint on "${n}" cannot define drives`);
@@ -1005,7 +980,7 @@ function it(t, n) {
1005
980
  max: 0
1006
981
  }] };
1007
982
  }
1008
- let r = nt(t.axis, t.kind, n), i = [
983
+ let r = at(t.axis, t.kind, n), i = [
1009
984
  0,
1010
985
  1,
1011
986
  2
@@ -1052,9 +1027,9 @@ function it(t, n) {
1052
1027
  },
1053
1028
  ...c
1054
1029
  ] }, u = t.drives ?? (t.drive ? [t.drive] : []);
1055
- return u.length > 0 && (l.drives = u.map((e) => rt(e, t.kind === "revolute" ? "angular" : "linear", r, n))), l;
1030
+ return u.length > 0 && (l.drives = u.map((e) => ot(e, t.kind === "revolute" ? "angular" : "linear", r, n))), l;
1056
1031
  }
1057
- function at(t, n) {
1032
+ function ct(t, n) {
1058
1033
  let i = !!t.isKinematic;
1059
1034
  if (!i && !Z(t.mass)) throw new e(`exportKhrGlb: dynamic node "${n}" requires positive finite motion.mass`);
1060
1035
  if (i && t.mass !== void 0 && Q(t.mass, `kinematic motion.mass on "${n}"`, !0), t.inertiaDiagonal && r(t.inertiaDiagonal, `${n}.motion.inertiaDiagonal`).some((e) => i ? e < 0 : e <= 0)) throw new e(`exportKhrGlb: invalid motion.inertiaDiagonal on "${n}"`);
@@ -1070,11 +1045,11 @@ function at(t, n) {
1070
1045
  ...t.gravityFactor === void 0 ? {} : { gravityFactor: t.gravityFactor }
1071
1046
  };
1072
1047
  }
1073
- async function ot(t, n, r) {
1074
- xe(), t.updateMatrixWorld(!0);
1075
- let i = new L();
1076
- return Ce(await new Promise((e, n) => {
1077
- i.parse(t, (t) => e(t instanceof ArrayBuffer ? t : Se(t)), n, { binary: !0 });
1048
+ async function lt(t, n, r) {
1049
+ Ce(), t.updateMatrixWorld(!0);
1050
+ let i = new ne();
1051
+ return Te(await new Promise((e, n) => {
1052
+ i.parse(t, (t) => e(t instanceof ArrayBuffer ? t : we(t)), n, { binary: !0 });
1078
1053
  }), (t) => {
1079
1054
  let i = t.nodes ?? [], a = /* @__PURE__ */ new Map();
1080
1055
  i.forEach((e, t) => {
@@ -1092,11 +1067,11 @@ async function ot(t, n, r) {
1092
1067
  ...t.extras
1093
1068
  });
1094
1069
  let r = {};
1095
- if (t.motion && (f = !0, r.motion = at(t.motion, t.nodeName)), t.collider) {
1070
+ if (t.motion && (f = !0, r.motion = ct(t.motion, t.nodeName)), t.collider) {
1096
1071
  f = !0;
1097
1072
  let n = {};
1098
1073
  if (t.collider.shape) {
1099
- let e = tt(t.collider.shape, t.nodeName), r = JSON.stringify(e), i = c.get(r);
1074
+ let e = it(t.collider.shape, t.nodeName), r = JSON.stringify(e), i = c.get(r);
1100
1075
  i === void 0 && (i = s.length, s.push(e), c.set(r, i)), n.geometry = { shape: i };
1101
1076
  } else if (t.collider.meshNodeName) {
1102
1077
  if (typeof t.collider.convexHull != "boolean") throw new e(`exportKhrGlb: mesh collider on "${t.nodeName}" requires explicit boolean convexHull`);
@@ -1126,7 +1101,7 @@ async function ot(t, n, r) {
1126
1101
  if (t.joint) {
1127
1102
  f = !0;
1128
1103
  let e = o(t.joint.connectedNodeName);
1129
- d.push(it(t.joint, t.nodeName)), r.joint = {
1104
+ d.push(st(t.joint, t.nodeName)), r.joint = {
1130
1105
  joint: d.length - 1,
1131
1106
  connectedNode: e,
1132
1107
  enableCollision: !!t.joint.enableCollision
@@ -1156,15 +1131,15 @@ async function ot(t, n, r) {
1156
1131
  });
1157
1132
  }
1158
1133
  // src/assemblyPlan.ts
1159
- function st(t, n) {
1160
- let r = new N.Matrix4();
1134
+ function ut(t, n) {
1135
+ let r = new I.Matrix4();
1161
1136
  for (let i = t; i && i !== n; i = i.parent) {
1162
1137
  if (!i.parent) throw new e(`Node "${t.name}" is detached from bundle.scene`);
1163
1138
  i.updateMatrix(), r.premultiply(i.matrix);
1164
1139
  }
1165
1140
  return r;
1166
1141
  }
1167
- function ct(e, t) {
1142
+ function dt(e, t) {
1168
1143
  let n = (e) => {
1169
1144
  let n = [];
1170
1145
  for (let r = e; r && (n.push(r), r !== t); r = r.parent);
@@ -1177,8 +1152,8 @@ function ct(e, t) {
1177
1152
  for (let t of n(e[0])) if (r.has(t)) return t;
1178
1153
  return t;
1179
1154
  }
1180
- function lt(e, t, n) {
1181
- let r = new N.Vector3().fromArray(e.com), i = new N.Quaternion().fromArray(e.inertiaFrame);
1155
+ function ft(e, t, n) {
1156
+ let r = new I.Vector3().fromArray(e.com), i = new I.Quaternion().fromArray(e.inertiaFrame);
1182
1157
  return t && n && (r.applyMatrix4(t.clone().invert()), i.premultiply(n.clone().invert()).normalize()), {
1183
1158
  mass: e.mass,
1184
1159
  centerOfMass: {
@@ -1199,10 +1174,10 @@ function lt(e, t, n) {
1199
1174
  }
1200
1175
  };
1201
1176
  }
1202
- function ut(e, t, n) {
1177
+ function pt(e, t, n) {
1203
1178
  return e.colliders.map((e, r) => {
1204
- let i = new N.Quaternion().fromArray(e.localQuaternion), a = new N.Matrix4().compose(new N.Vector3().fromArray(e.localPosition), i, new N.Vector3(1, 1, 1)), o = new N.Vector3(), s = new N.Quaternion(), c = new N.Vector3();
1205
- new N.Matrix4().multiplyMatrices(t, a).decompose(o, s, c);
1179
+ let i = new I.Quaternion().fromArray(e.localQuaternion), a = new I.Matrix4().compose(new I.Vector3().fromArray(e.localPosition), i, new I.Vector3(1, 1, 1)), o = new I.Vector3(), s = new I.Quaternion(), c = new I.Vector3();
1180
+ new I.Matrix4().multiplyMatrices(t, a).decompose(o, s, c);
1206
1181
  let l = {
1207
1182
  spec: e,
1208
1183
  local: a,
@@ -1218,14 +1193,14 @@ function ut(e, t, n) {
1218
1193
  s.w
1219
1194
  ]
1220
1195
  };
1221
- return r === 0 && n && (l.massProperties = lt(n, a, i)), l;
1196
+ return r === 0 && n && (l.massProperties = ft(n, a, i)), l;
1222
1197
  });
1223
1198
  }
1224
- function dt(e, t, n) {
1199
+ function mt(e, t, n) {
1225
1200
  for (let r = e.joint ? n.get(e.joint.connectedNodeName) : void 0; r; r = r.joint ? n.get(r.joint.connectedNodeName) : void 0) if (r.nodeName === t) return !0;
1226
1201
  return !1;
1227
1202
  }
1228
- function ft(t) {
1203
+ function ht(t) {
1229
1204
  let r = new Map(t.bodies.map((e) => [e.nodeName, e])), i = (t, n = /* @__PURE__ */ new Set()) => {
1230
1205
  if (!t.joint) return t;
1231
1206
  if (n.has(t.nodeName)) throw new e(`Joint cycle through "${t.nodeName}"`);
@@ -1238,19 +1213,19 @@ function ft(t) {
1238
1213
  s.sort((e, t) => c(e) - c(t));
1239
1214
  let l = /* @__PURE__ */ new Map(), u = s.map((t) => {
1240
1215
  let n = t.joint, i = l.get(n.connectedNodeName) ?? null;
1241
- if (i && !pt(t.object, i.spec.object)) throw new e(`Jointed node "${t.nodeName}" must be a scene-graph descendant of its jointed parent "${n.connectedNodeName}"`);
1216
+ if (i && !gt(t.object, i.spec.object)) throw new e(`Jointed node "${t.nodeName}" must be a scene-graph descendant of its jointed parent "${n.connectedNodeName}"`);
1242
1217
  let a = o.clone().multiply(x(t)), c = {
1243
1218
  spec: t,
1244
1219
  joint: n,
1245
1220
  parent: i,
1246
1221
  restRelParent: i ? x(i.spec).invert().multiply(x(t)) : a,
1247
- inertia: le(t, n, s.filter((e) => e !== t && dt(e, t.nodeName, r))),
1248
- colliders: ut(t, a, null)
1222
+ inertia: de(t, n, s.filter((e) => e !== t && mt(e, t.nodeName, r))),
1223
+ colliders: pt(t, a, null)
1249
1224
  };
1250
1225
  return l.set(t.nodeName, c), c;
1251
- }), d = a.isKinematic ? null : n([a, ...s], o), f = ut(a, new N.Matrix4(), d), p = d && f.length === 0 ? lt(d) : void 0, m = ct([a.object, ...s.map((e) => e.object)], t.scene), h = o.clone().multiply(st(m, t.scene)), g = new N.Vector3(), _ = new N.Quaternion(), v = new N.Vector3();
1226
+ }), d = a.isKinematic ? null : n([a, ...s], o), f = pt(a, new I.Matrix4(), d), p = d && f.length === 0 ? ft(d) : void 0, m = dt([a.object, ...s.map((e) => e.object)], t.scene), h = o.clone().multiply(ut(m, t.scene)), g = new I.Vector3(), _ = new I.Quaternion(), v = new I.Vector3();
1252
1227
  o.decompose(g, _, v), _.normalize();
1253
- let y = new N.Vector3(), b = new N.Quaternion(), S = new N.Vector3();
1228
+ let y = new I.Vector3(), b = new I.Quaternion(), S = new I.Vector3();
1254
1229
  return h.decompose(y, b, S), b.normalize(), {
1255
1230
  spec: a,
1256
1231
  sceneInRootPos: [
@@ -1282,20 +1257,20 @@ function ft(t) {
1282
1257
  parts: u
1283
1258
  };
1284
1259
  });
1285
- for (let t of a) for (let n of a) if (t !== n && pt(n.mountNode, t.mountNode)) throw new e(`Root bodies "${t.spec.nodeName}" and "${n.spec.nodeName}" share scene subtree "${t.mountNode.name}"; split them into separate glTF branches`);
1260
+ for (let t of a) for (let n of a) if (t !== n && gt(n.mountNode, t.mountNode)) throw new e(`Root bodies "${t.spec.nodeName}" and "${n.spec.nodeName}" share scene subtree "${t.mountNode.name}"; split them into separate glTF branches`);
1286
1261
  return a;
1287
1262
  }
1288
- function pt(e, t) {
1263
+ function gt(e, t) {
1289
1264
  for (let n = e; n; n = n.parent) if (n === t) return !0;
1290
1265
  return !1;
1291
1266
  }
1292
1267
  // src/AssemblyRootBody.tsx
1293
- function mt({ plan: e, assemblyId: t, position: n, quaternion: r, fixedRoot: a, rigidBodyProps: o, onBody: s, onJoints: c, children: l }) {
1294
- let u = T(C), d = O(null), f = D(() => e.parts.map((e) => e.colliders.map(() => ({ current: null }))), [e]), p = e.spec;
1268
+ function _t({ plan: e, assemblyId: t, position: n, quaternion: r, fixedRoot: a, rigidBodyProps: o, onBody: s, onJoints: c, children: l }) {
1269
+ let u = T(C), d = k(null), f = O(() => e.parts.map((e) => e.colliders.map(() => ({ current: null }))), [e]), p = e.spec;
1295
1270
  E(() => (s(p.nodeName, d), () => s(p.nodeName, null)), [p, s]), E(() => {
1296
1271
  let t = d.current, n = e.rootMass;
1297
1272
  t && n && (t.setAdditionalMassProperties(n.mass, n.centerOfMass, n.principalAngularInertia, n.angularInertiaLocalFrame, !0), t.recomputeMassPropertiesFromColliders());
1298
- }, [e.rootMass]), E(() => {
1273
+ }, [e.rootMass]), D(() => {
1299
1274
  let n = /* @__PURE__ */ new Map();
1300
1275
  for (let r = 0; r < e.parts.length; r++) {
1301
1276
  let i = e.parts[r], a = i.joint.drive, o = {
@@ -1304,7 +1279,7 @@ function mt({ plan: e, assemblyId: t, position: n, quaternion: r, fixedRoot: a,
1304
1279
  role: i.joint.role,
1305
1280
  kind: i.joint.kind,
1306
1281
  object: i.spec.object,
1307
- axis: new N.Vector3().fromArray(i.joint.axis).normalize(),
1282
+ axis: new I.Vector3().fromArray(i.joint.axis).normalize(),
1308
1283
  restPosition: i.spec.object.position.clone(),
1309
1284
  restQuaternion: i.spec.object.quaternion.clone(),
1310
1285
  q: 0,
@@ -1340,7 +1315,7 @@ function mt({ plan: e, assemblyId: t, position: n, quaternion: r, fixedRoot: a,
1340
1315
  c
1341
1316
  ]);
1342
1317
  let m = p.isKinematic ? a ? "fixed" : "kinematicPosition" : "dynamic";
1343
- return /* @__PURE__ */ F(j, {
1318
+ return /* @__PURE__ */ te(P, {
1344
1319
  ...o,
1345
1320
  ref: d,
1346
1321
  type: m,
@@ -1352,13 +1327,13 @@ function mt({ plan: e, assemblyId: t, position: n, quaternion: r, fixedRoot: a,
1352
1327
  ...p.gravityFactor === void 0 ? {} : { gravityScale: p.gravityFactor },
1353
1328
  children: [
1354
1329
  l,
1355
- e.colliders.map((e, t) => /* @__PURE__ */ P(i, {
1330
+ e.colliders.map((e, t) => /* @__PURE__ */ L(i, {
1356
1331
  c: e.spec,
1357
1332
  position: e.position,
1358
1333
  quaternion: e.quaternion,
1359
1334
  massProperties: e.massProperties
1360
1335
  }, `r${t}`)),
1361
- e.parts.map((e, t) => e.colliders.map((n, r) => /* @__PURE__ */ P(i, {
1336
+ e.parts.map((e, t) => e.colliders.map((n, r) => /* @__PURE__ */ L(i, {
1362
1337
  ref: f[t][r],
1363
1338
  c: n.spec,
1364
1339
  position: n.position,
@@ -1369,32 +1344,32 @@ function mt({ plan: e, assemblyId: t, position: n, quaternion: r, fixedRoot: a,
1369
1344
  });
1370
1345
  }
1371
1346
  // src/KhrAssembly.tsx
1372
- var ht = 0;
1373
- function gt({ ref: t, bundle: n, position: r = [
1347
+ var vt = 0;
1348
+ function yt({ ref: t, bundle: n, position: r = [
1374
1349
  0,
1375
1350
  0,
1376
1351
  0
1377
1352
  ], rotation: i, quaternion: a, scale: o, fixedRoot: l = !1, rigidBodyProps: u, children: d, ...f }) {
1378
1353
  c(o, "KhrAssembly"), n.scene.updateMatrixWorld(!0), s(n.scene);
1379
- let m = D(() => ht++, []), h = D(() => ft(n), [n]), _ = D(() => h.length > 1 ? g(h.map((e) => e.mountNode)) : null, [h]), [y, b, x] = r, [S, C, T] = i ?? [
1354
+ let m = O(() => vt++, []), h = O(() => ht(n), [n]), _ = O(() => h.length > 1 ? g(h.map((e) => e.mountNode)) : null, [h]), [y, b, x] = r, [S, C, T] = i ?? [
1380
1355
  0,
1381
1356
  0,
1382
1357
  0
1383
- ], [E, te, k, A] = a ?? [
1358
+ ], [E, D, A, j] = a ?? [
1384
1359
  NaN,
1385
1360
  NaN,
1386
1361
  NaN,
1387
1362
  NaN
1388
- ], j = D(() => a ? new N.Quaternion(E, te, k, A) : new N.Quaternion().setFromEuler(new N.Euler(S, C, T)), [
1363
+ ], M = O(() => a ? new I.Quaternion(E, D, A, j) : new I.Quaternion().setFromEuler(new I.Euler(S, C, T)), [
1389
1364
  E,
1390
- te,
1391
- k,
1365
+ D,
1392
1366
  A,
1367
+ j,
1393
1368
  S,
1394
1369
  C,
1395
1370
  T
1396
- ]), M = D(() => h.map((e) => {
1397
- let t = new N.Vector3().fromArray(e.spec.localPosition).applyQuaternion(j).add(new N.Vector3(y, b, x)), n = j.clone().multiply(new N.Quaternion().fromArray(e.spec.localQuaternion));
1371
+ ]), N = O(() => h.map((e) => {
1372
+ let t = new I.Vector3().fromArray(e.spec.localPosition).applyQuaternion(M).add(new I.Vector3(y, b, x)), n = M.clone().multiply(new I.Quaternion().fromArray(e.spec.localQuaternion));
1398
1373
  return {
1399
1374
  position: [
1400
1375
  t.x,
@@ -1410,59 +1385,59 @@ function gt({ ref: t, bundle: n, position: r = [
1410
1385
  };
1411
1386
  }), [
1412
1387
  h,
1413
- j,
1388
+ M,
1414
1389
  y,
1415
1390
  b,
1416
1391
  x
1417
- ]), I = O(/* @__PURE__ */ new Map()), L = O(/* @__PURE__ */ new Map()), R = D(() => {
1392
+ ]), P = k(/* @__PURE__ */ new Map()), F = k(/* @__PURE__ */ new Map()), R = O(() => {
1418
1393
  let e = /* @__PURE__ */ new Map();
1419
1394
  for (let t of h) {
1420
1395
  e.set(t.spec.nodeName, t.spec.nodeName);
1421
1396
  for (let n of t.parts) e.set(n.spec.nodeName, t.spec.nodeName);
1422
1397
  }
1423
1398
  return e;
1424
- }, [h]), z = w((e, t) => {
1425
- t ? I.current.set(e, t) : I.current.delete(e);
1426
- }, []), B = w((e, t) => {
1427
- t ? L.current.set(e, t) : L.current.delete(e);
1399
+ }, [h]), ne = w((e, t) => {
1400
+ t ? P.current.set(e, t) : P.current.delete(e);
1401
+ }, []), z = w((e, t) => {
1402
+ t ? F.current.set(e, t) : F.current.delete(e);
1428
1403
  }, []);
1429
1404
  if (ee(t, () => {
1430
1405
  let t = (t, n) => {
1431
1406
  if (!t.drive || t.drive.stiffness === void 0) throw new e(`Joint "${t.nodeName}" has no authored drive stiffness; cannot set a position target`);
1432
1407
  t.positionTarget = n;
1433
- let r = I.current.get(R.get(t.nodeName))?.current;
1408
+ let r = P.current.get(R.get(t.nodeName))?.current;
1434
1409
  r && r.isDynamic() && r.wakeUp();
1435
1410
  };
1436
1411
  return {
1437
1412
  getBody: (e) => {
1438
1413
  let t = R.get(e);
1439
- return t ? I.current.get(t)?.current ?? null : null;
1414
+ return t ? P.current.get(t)?.current ?? null : null;
1440
1415
  },
1441
1416
  setJointTarget: (e, n) => {
1442
- let r = L.current.get(R.get(e) ?? "")?.get(e);
1417
+ let r = F.current.get(R.get(e) ?? "")?.get(e);
1443
1418
  r && t(r, n);
1444
1419
  },
1445
1420
  setRoleTarget: (e, n) => {
1446
- for (let r of L.current.values()) for (let i of r.values()) i.role === e && t(i, n);
1421
+ for (let r of F.current.values()) for (let i of r.values()) i.role === e && t(i, n);
1447
1422
  }
1448
1423
  };
1449
1424
  }, [R]), h.length === 1) {
1450
1425
  let e = h[0];
1451
- return /* @__PURE__ */ P("group", {
1426
+ return /* @__PURE__ */ L("group", {
1452
1427
  ...f,
1453
- children: /* @__PURE__ */ P(mt, {
1428
+ children: /* @__PURE__ */ L(_t, {
1454
1429
  plan: e,
1455
1430
  assemblyId: m,
1456
- position: M[0].position,
1457
- quaternion: M[0].quaternion,
1431
+ position: N[0].position,
1432
+ quaternion: N[0].quaternion,
1458
1433
  fixedRoot: l,
1459
1434
  rigidBodyProps: u,
1460
- onBody: z,
1461
- onJoints: B,
1462
- children: /* @__PURE__ */ F("group", {
1435
+ onBody: ne,
1436
+ onJoints: z,
1437
+ children: /* @__PURE__ */ te("group", {
1463
1438
  position: e.sceneInRootPos,
1464
1439
  quaternion: e.sceneInRootQuat,
1465
- children: [/* @__PURE__ */ P(v, {
1440
+ children: [/* @__PURE__ */ L(v, {
1466
1441
  bundle: n,
1467
1442
  owner: "KhrAssembly"
1468
1443
  }), d]
@@ -1470,25 +1445,25 @@ function gt({ ref: t, bundle: n, position: r = [
1470
1445
  }, `${n.scene.uuid}:${e.spec.nodeName}`)
1471
1446
  });
1472
1447
  }
1473
- return /* @__PURE__ */ F("group", {
1448
+ return /* @__PURE__ */ te("group", {
1474
1449
  ...f,
1475
- children: [/* @__PURE__ */ F("group", {
1450
+ children: [/* @__PURE__ */ te("group", {
1476
1451
  position: r,
1477
- quaternion: j,
1478
- children: [/* @__PURE__ */ P(v, {
1452
+ quaternion: M,
1453
+ children: [/* @__PURE__ */ L(v, {
1479
1454
  bundle: n,
1480
1455
  owner: "KhrAssembly"
1481
1456
  }), d]
1482
- }), h.map((e, t) => /* @__PURE__ */ P(mt, {
1457
+ }), h.map((e, t) => /* @__PURE__ */ L(_t, {
1483
1458
  plan: e,
1484
1459
  assemblyId: m,
1485
- position: M[t].position,
1486
- quaternion: M[t].quaternion,
1460
+ position: N[t].position,
1461
+ quaternion: N[t].quaternion,
1487
1462
  fixedRoot: l,
1488
1463
  rigidBodyProps: u,
1489
- onBody: z,
1490
- onJoints: B,
1491
- children: /* @__PURE__ */ P(p, {
1464
+ onBody: ne,
1465
+ onJoints: z,
1466
+ children: /* @__PURE__ */ L(p, {
1492
1467
  object: e.mountNode,
1493
1468
  position: e.mountPosition,
1494
1469
  quaternion: e.mountQuaternion,
@@ -1498,28 +1473,28 @@ function gt({ ref: t, bundle: n, position: r = [
1498
1473
  });
1499
1474
  }
1500
1475
  // src/useKhrGlb.ts
1501
- var _t = class extends I {
1476
+ var bt = class extends R {
1502
1477
  static khrLoaderScope = Symbol("KhrGLTFLoader");
1503
- }, vt = Ke(), yt = Ze(), bt = /* @__PURE__ */ new WeakSet(), xt = /* @__PURE__ */ new WeakSet(), $ = /* @__PURE__ */ new Map();
1504
- function St(e) {
1505
- bt.has(e) || (bt.add(e), typeof document > "u" && typeof createImageBitmap > "u" && e.register(vt), e.register(yt));
1478
+ }, xt = Ye(), St = et(), Ct = /* @__PURE__ */ new WeakSet(), wt = /* @__PURE__ */ new WeakSet(), $ = /* @__PURE__ */ new Map();
1479
+ function Tt(e) {
1480
+ Ct.has(e) || (Ct.add(e), typeof document > "u" && typeof createImageBitmap > "u" && e.register(xt), e.register(St));
1506
1481
  }
1507
- function Ct(e) {
1482
+ function Et(e) {
1508
1483
  return !!(e?.extendLoader || e?.cacheKey !== void 0);
1509
1484
  }
1510
- function wt(e) {
1485
+ function Dt(e) {
1511
1486
  return e.cacheKey === void 0 ? `src:${Function.prototype.toString.call(e.extendLoader)}` : `key:${e.cacheKey}`;
1512
1487
  }
1513
- function Tt(e, t) {
1514
- let n = wt(t), r = $.get(e);
1488
+ function Ot(e, t) {
1489
+ let n = Dt(t), r = $.get(e);
1515
1490
  r || (r = /* @__PURE__ */ new Map(), $.set(e, r));
1516
1491
  let i = r.get(n);
1517
1492
  if (!i) {
1518
- let a = new I(), o = t.extendLoader, s = {
1493
+ let a = new R(), o = t.extendLoader, s = {
1519
1494
  loader: a,
1520
1495
  registerExtensions: (t) => {
1521
- if (St(t), o && !xt.has(t)) try {
1522
- o(t), xt.add(t);
1496
+ if (Tt(t), o && !wt.has(t)) try {
1497
+ o(t), wt.add(t);
1523
1498
  } catch (t) {
1524
1499
  let r = $.get(e);
1525
1500
  throw r?.get(n) === s && (r.delete(n), r.size === 0 && $.delete(e)), t;
@@ -1530,33 +1505,33 @@ function Tt(e, t) {
1530
1505
  }
1531
1506
  return i;
1532
1507
  }
1533
- function Et(t, n) {
1534
- let r = n?.extractRole, i = n?.isSocketNode, a = Ct(n) ? Tt(t, n) : null, o = a ? a.loader : _t, s = a ? a.registerExtensions : St, c = k(o, t, s).userData[Ye];
1535
- if (!c) throw new e(`useKhrGlb: missing "${Ye}" on loaded GLTF for "${t}"`);
1536
- return D(() => {
1508
+ function kt(t, n) {
1509
+ let r = n?.extractRole, i = n?.isSocketNode, a = Et(n) ? Ot(t, n) : null, o = a ? a.loader : bt, s = a ? a.registerExtensions : Tt, c = M(o, t, s).userData[Qe];
1510
+ if (!c) throw new e(`useKhrGlb: missing "${Qe}" on loaded GLTF for "${t}"`);
1511
+ return O(() => {
1537
1512
  let e = _(c);
1538
- return (r || i) && Ee(e, c, r, i), e;
1513
+ return (r || i) && Oe(e, c, r, i), e;
1539
1514
  }, [
1540
1515
  c,
1541
1516
  r,
1542
1517
  i
1543
1518
  ]);
1544
1519
  }
1545
- Et.preload = (e, t) => {
1546
- let n = Ct(t) ? Tt(e, t) : null, r = n ? n.loader : _t, i = n ? n.registerExtensions : St;
1547
- k.preload(r, e, i);
1548
- }, Et.clear = (e, t) => {
1549
- if (Ct(t)) {
1520
+ kt.preload = (e, t) => {
1521
+ let n = Et(t) ? Ot(e, t) : null, r = n ? n.loader : bt, i = n ? n.registerExtensions : Tt;
1522
+ M.preload(r, e, i);
1523
+ }, kt.clear = (e, t) => {
1524
+ if (Et(t)) {
1550
1525
  let n = $.get(e);
1551
1526
  if (!n) return;
1552
- let r = wt(t), i = n.get(r);
1553
- i && (k.clear(i.loader, e), n.delete(r), n.size === 0 && $.delete(e));
1554
- } else if (k.clear(_t, e), t === void 0) {
1527
+ let r = Dt(t), i = n.get(r);
1528
+ i && (M.clear(i.loader, e), n.delete(r), n.size === 0 && $.delete(e));
1529
+ } else if (M.clear(bt, e), t === void 0) {
1555
1530
  let t = $.get(e);
1556
1531
  if (t) {
1557
- for (let n of t.values()) k.clear(n.loader, e);
1532
+ for (let n of t.values()) M.clear(n.loader, e);
1558
1533
  $.delete(e);
1559
1534
  }
1560
1535
  }
1561
1536
  };
1562
- export { C as JointRegistryContext, gt as KhrAssembly, i as KhrCollider, e as KhrValidationError, ge as PhysicsWorld, y as assertIdentityWorldScale, s as assertSceneIdentityWorldScale, c as assertUnitScale, m as claimBundleMount, _ as cloneKhrBundle, Ze as createKhrGltfPlugin, o as disposeKhrBundle, ot as exportKhrGlb, et as loadKhrGlb, Ce as patchGlbJsonChunk, d as releaseBundleMount, Et as useKhrGlb };
1537
+ export { C as JointRegistryContext, yt as KhrAssembly, i as KhrCollider, e as KhrValidationError, ve as PhysicsWorld, y as assertIdentityWorldScale, s as assertSceneIdentityWorldScale, c as assertUnitScale, m as claimBundleMount, _ as cloneKhrBundle, et as createKhrGltfPlugin, o as disposeKhrBundle, lt as exportKhrGlb, rt as loadKhrGlb, Te as patchGlbJsonChunk, d as releaseBundleMount, kt as useKhrGlb };