@khr3/core 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/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, useState as te } from "react";
3
- import { useFrame as k, useLoader as A } from "@react-three/fiber";
4
- import { Physics as j, RigidBody as M, useRapier as N } from "@react-three/rapier";
5
- import * as P from "three";
6
- import { jsx as F, jsxs as I } from "react/jsx-runtime";
7
- import { GLTFLoader as L } from "three/examples/jsm/loaders/GLTFLoader.js";
8
- import { GLTFExporter as R } 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 te, useRapier as P } from "@react-three/rapier";
5
+ import * as F from "three";
6
+ import { jsx as I, jsxs as L } 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 z = new P.Vector3(), B = new P.Vector3(), ne = new P.Vector3(), re = new P.Quaternion(), ie = new P.Quaternion(), ae = new P.Matrix4(), oe = new P.Matrix4(), se = new P.Matrix4(), ce = new P.Matrix4(), V = new P.Vector3(), H = new P.Quaternion(), le = new P.Vector3();
11
- function ue(e, t, n = []) {
10
+ var z = new F.Vector3(), B = new F.Vector3(), re = new F.Vector3(), ie = new F.Quaternion(), ae = new F.Quaternion(), oe = new F.Matrix4(), se = new F.Matrix4(), ce = new F.Matrix4(), le = new F.Matrix4(), V = new F.Vector3(), H = new F.Quaternion(), ue = new F.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 ue(e, t, n = []) {
16
16
  for (let n of r) n.isKinematic && n !== e || (t += n.mass);
17
17
  return t;
18
18
  }
19
- z.fromArray(t.axis).normalize(), n.length > 0 && x(e, ae).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()) : (oe.multiplyMatrices(ae, x(t, ce)).decompose(V, H, le), H.normalize()), ie.copy(H).multiply(re.fromArray(t.inertiaOrientation)).invert(), B.copy(z).applyQuaternion(ie);
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
24
  let [n, r, a] = t.inertiaDiagonal, o = n * B.x * B.x + r * B.y * B.y + a * B.z * B.z;
25
- ne.fromArray(t.centerOfMass).applyQuaternion(H).add(V);
26
- let s = ne.dot(z);
27
- i += o + t.mass * (ne.lengthSq() - s * s);
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 de(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,51 +49,46 @@ function de(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 fe = 1e-7;
53
- function pe(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 && pe(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) > fe || n) {
58
- e.dirtyStamp = t, r && (e.lastWrittenQ = e.q), e.kind === "revolute" ? (re.setFromAxisAngle(e.axis, e.q), e.object.quaternion.copy(e.restQuaternion).multiply(re), e.object.position.copy(e.restPosition), se.makeRotationFromQuaternion(re)) : 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), se.makeTranslation(z.x, z.y, z.z)) : se.identity(), e.parent ? e.current.multiplyMatrices(e.parent.current, e.restRelParent) : e.current.copy(e.restRelParent), e.current.multiply(se);
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 && (ce.multiplyMatrices(e.current, t.local).decompose(V, H, le), 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 me = (e) => typeof e == "number" ? e : e.current;
67
- function he({ paused: e, timeScale: t, maxDelta: n, joints: r, dtRef: i, refActiveRef: a, setRefActive: o }) {
68
- let { world: s } = N(), c = O(0);
69
- return k((l, u) => {
70
- let d = me(t), f = Math.max(0, me(n)), p = !e && d > 0 && f > 0;
71
- if (p !== a.current && (a.current = p, o(p)), !p || !(u > 0)) {
72
- i.current = 0, s.timestep = 0;
73
- return;
74
- }
75
- let m = Math.min(Math.min(u, f) * d, .5);
76
- if (!(m > 0)) i.current = 0, s.timestep = 0;
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 } = P(), 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;
77
72
  else if (i.current = m, s.timestep = m, r.size > 0) {
78
73
  let e = ++c.current;
79
- for (let e of r) de(e, m);
80
- for (let t of r) pe(t, e);
74
+ for (let e of r) fe(e, m);
75
+ for (let t of r) me(t, e);
81
76
  }
82
- }, -.5), null;
77
+ }), null;
83
78
  }
84
- function ge({ dtRef: e }) {
85
- let { step: t } = N();
86
- return k(() => {
79
+ function _e({ dtRef: e }) {
80
+ let { step: t } = P();
81
+ return j(() => {
87
82
  let n = e.current;
88
83
  n > 0 && t(n);
89
- }, 0), null;
84
+ }), null;
90
85
  }
91
- function _e({ 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 = [
92
87
  0,
93
88
  -9.81,
94
89
  0
95
90
  ], children: o, ...s }) {
96
- let c = D(() => /* @__PURE__ */ new Set(), []), l = O(0), [u, d] = te(() => me(n) > 0 && me(r) > 0), f = O(u), p = 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(() => [
97
92
  i[0],
98
93
  i[1],
99
94
  i[2]
@@ -101,32 +96,32 @@ function _e({ paused: e = !1, timeScale: n = 1, maxDelta: r = 1 / 30, gravity: i
101
96
  i[0],
102
97
  i[1],
103
98
  i[2]
104
- ]), m = !e && u && (typeof n != "number" || n > 0) && (typeof r != "number" || r > 0);
105
- return /* @__PURE__ */ F(C.Provider, {
99
+ ]);
100
+ return /* @__PURE__ */ I(C.Provider, {
106
101
  value: c,
107
- children: /* @__PURE__ */ F(S.Provider, {
108
- value: p,
109
- children: /* @__PURE__ */ F(a.Provider, {
102
+ children: /* @__PURE__ */ I(S.Provider, {
103
+ value: h,
104
+ children: /* @__PURE__ */ I(a.Provider, {
110
105
  value: m,
111
- children: /* @__PURE__ */ F(t.Provider, {
106
+ children: /* @__PURE__ */ I(t.Provider, {
112
107
  value: l,
113
- children: /* @__PURE__ */ I(j, {
108
+ children: /* @__PURE__ */ L(N, {
114
109
  ...s,
115
110
  paused: !0,
116
111
  timeStep: "vary",
117
112
  gravity: i,
118
113
  children: [
119
- /* @__PURE__ */ F(he, {
114
+ /* @__PURE__ */ I(ge, {
120
115
  paused: e,
121
116
  timeScale: n,
122
117
  maxDelta: r,
123
118
  joints: c,
124
119
  dtRef: l,
125
- refActiveRef: f,
126
- setRefActive: d
120
+ activeRef: p,
121
+ setActiveState: f
127
122
  }),
128
123
  o,
129
- /* @__PURE__ */ F(ge, { dtRef: l })
124
+ /* @__PURE__ */ I(_e, { dtRef: l })
130
125
  ]
131
126
  })
132
127
  })
@@ -135,8 +130,8 @@ function _e({ paused: e = !1, timeScale: n = 1, maxDelta: r = 1 / 30, gravity: i
135
130
  });
136
131
  }
137
132
  // src/khrGlb.ts
138
- var ve = 1179937895, ye = 1313821514, be = 5130562;
139
- function xe(t) {
133
+ var ye = 1179937895, be = 1313821514, xe = 5130562;
134
+ function Se(t) {
140
135
  if (t.byteLength < 20) throw new e("GLB buffer shorter than 20-byte header");
141
136
  let n = new DataView(t);
142
137
  if (n.getUint32(0, !0) !== 1179937895) throw new e("Invalid GLB magic");
@@ -146,7 +141,7 @@ function xe(t) {
146
141
  if (20 + r > t.byteLength) throw new e("Truncated GLB JSON chunk");
147
142
  return r;
148
143
  }
149
- function Se() {
144
+ function Ce() {
150
145
  if (globalThis.FileReader !== void 0) return;
151
146
  class e {
152
147
  result = null;
@@ -173,28 +168,28 @@ function Se() {
173
168
  }
174
169
  globalThis.FileReader = e;
175
170
  }
176
- function Ce(e) {
171
+ function we(e) {
177
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);
178
- return a.setUint32(0, ve, !0), a.setUint32(4, 2, !0), a.setUint32(8, r, !0), a.setUint32(12, n, !0), a.setUint32(16, ye, !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;
179
174
  }
180
- function we(t, n) {
181
- let r = t instanceof ArrayBuffer ? t : t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength), i = xe(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;
182
177
  try {
183
178
  o = JSON.parse(new TextDecoder().decode(new Uint8Array(r, 20, i)));
184
179
  } catch {
185
180
  throw new e("Malformed GLB JSON chunk");
186
181
  }
187
182
  n(o);
188
- 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) : be, 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);
189
- return _.setUint32(0, ve, !0), _.setUint32(4, 2, !0), _.setUint32(8, h, !0), _.setUint32(12, c, !0), _.setUint32(16, ye, !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;
190
185
  }
191
186
  // src/khrExtras.ts
192
- var Te = /* @__PURE__ */ new WeakMap();
193
- function Ee(e, t) {
194
- Te.set(e, t);
187
+ var Ee = /* @__PURE__ */ new WeakMap();
188
+ function De(e, t) {
189
+ Ee.set(e, t);
195
190
  }
196
- function De(e, t, n, r) {
197
- let i = Te.get(t.scene);
191
+ function Oe(e, t, n, r) {
192
+ let i = Ee.get(t.scene);
198
193
  if (i) {
199
194
  if (n) for (let t = 0; t < e.bodies.length; t++) {
200
195
  let r = i.bodies[t], a = e.bodies[t];
@@ -217,9 +212,9 @@ function De(e, t, n, r) {
217
212
  }
218
213
  }
219
214
  }
220
- var Oe = new P.Vector3(), U = new P.Quaternion(), ke = new P.Quaternion();
221
- function Ae(e, t) {
222
- return e.updateWorldMatrix(!0, !1), e.getWorldQuaternion(U), t && (t.updateWorldMatrix(!0, !1), U.premultiply(t.getWorldQuaternion(ke).invert())), U.lengthSq() > 0 ? U.normalize() : U.identity(), [
215
+ var ke = new F.Vector3(), U = new F.Quaternion(), Ae = new F.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(), [
223
218
  U.x || 0,
224
219
  U.y || 0,
225
220
  U.z || 0,
@@ -234,14 +229,14 @@ function K(t, n, r, i = !1) {
234
229
  return a;
235
230
  }
236
231
  }
237
- function je(t, n, r, i) {
232
+ function Me(t, n, r, i) {
238
233
  let a = t[n];
239
234
  if (a !== void 0) {
240
235
  if (typeof a != "boolean") throw new e(`${r} "${i}" has non-boolean ${r}.${n}`);
241
236
  return a;
242
237
  }
243
238
  }
244
- function Me(t, n, r) {
239
+ function Ne(t, n, r) {
245
240
  if (t !== void 0) {
246
241
  if (!W(t) || !Array.isArray(t.points) || t.points.length === 0) throw new e(`ecctrlWheel "${r}" has invalid ecctrlWheel.${n}`);
247
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}`);
@@ -249,9 +244,9 @@ function Me(t, n, r) {
249
244
  return t;
250
245
  }
251
246
  }
252
- function Ne(t, n, r, i, a) {
247
+ function Pe(t, n, r, i, a) {
253
248
  if (r.socketId !== void 0 && (typeof r.socketId != "string" || r.socketId.length === 0)) throw new e(`Node "${n}" has invalid extras.socketId`);
254
- let o = t.getWorldPosition(new P.Vector3()), s = [
249
+ let o = t.getWorldPosition(new F.Vector3()), s = [
255
250
  o.x,
256
251
  o.y,
257
252
  o.z
@@ -266,11 +261,11 @@ function Ne(t, n, r, i, a) {
266
261
  t.getWorldQuaternion(U), l = [];
267
262
  for (let t of r.contactDots) {
268
263
  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`);
269
- Oe.set(t.pos[0], t.pos[1], t.pos[2]).applyQuaternion(U).add(o);
264
+ ke.set(t.pos[0], t.pos[1], t.pos[2]).applyQuaternion(U).add(o);
270
265
  let r = [
271
- Oe.x,
272
- Oe.y,
273
- Oe.z
266
+ ke.x,
267
+ ke.y,
268
+ ke.z
274
269
  ];
275
270
  i[t.role] = r, l.push([t.role, r]);
276
271
  }
@@ -282,7 +277,7 @@ function Ne(t, n, r, i, a) {
282
277
  ...l ? { contactDots: l } : {}
283
278
  };
284
279
  }
285
- function Pe(t, n, r, i) {
280
+ function Fe(t, n, r, i) {
286
281
  if (y(t, n), !W(r)) throw new e(`ecctrlWheel "${n}" must be an object`);
287
282
  let a = (t) => {
288
283
  let i = r[t];
@@ -298,7 +293,7 @@ function Pe(t, n, r, i) {
298
293
  return i;
299
294
  }, c = a("radius"), l = a("width"), u = o("travel"), d = o("sag");
300
295
  if (d > u) throw new e(`ecctrlWheel "${n}" has invalid ecctrlWheel.sag (${d}) > ecctrlWheel.travel (${u})`);
301
- let f = s("steer"), p = s("drive"), m = s("brake"), h = new P.Box3().setFromObject(t), g = h.isEmpty() ? t.getWorldPosition(new P.Vector3()) : h.getCenter(new P.Vector3());
296
+ let f = s("steer"), p = s("drive"), m = s("brake"), h = new F.Box3().setFromObject(t), g = h.isEmpty() ? t.getWorldPosition(new F.Vector3()) : h.getCenter(new F.Vector3());
302
297
  return {
303
298
  nodeName: n,
304
299
  object: t,
@@ -307,13 +302,13 @@ function Pe(t, n, r, i) {
307
302
  g.y,
308
303
  g.z
309
304
  ],
310
- quaternion: Ae(t, i),
305
+ quaternion: je(t, i),
311
306
  radius: c,
312
307
  width: l,
313
308
  steer: f,
314
- steerInvert: je(r, "steerInvert", "ecctrlWheel", n),
309
+ steerInvert: Me(r, "steerInvert", "ecctrlWheel", n),
315
310
  drive: p,
316
- driveInvert: je(r, "driveInvert", "ecctrlWheel", n),
311
+ driveInvert: Me(r, "driveInvert", "ecctrlWheel", n),
317
312
  brake: m,
318
313
  travel: u,
319
314
  sag: d,
@@ -327,11 +322,11 @@ function Pe(t, n, r, i) {
327
322
  latFrictionEllipseScale: K(r, "latFrictionEllipseScale", n),
328
323
  relaxLngRate: K(r, "relaxLngRate", n),
329
324
  relaxLatRate: K(r, "relaxLatRate", n),
330
- lngSlipRatioCurveData: Me(r.lngSlipRatioCurveData, "lngSlipRatioCurveData", n),
331
- latSlipRatioCurveData: Me(r.latSlipRatioCurveData, "latSlipRatioCurveData", n)
325
+ lngSlipRatioCurveData: Ne(r.lngSlipRatioCurveData, "lngSlipRatioCurveData", n),
326
+ latSlipRatioCurveData: Ne(r.latSlipRatioCurveData, "latSlipRatioCurveData", n)
332
327
  };
333
328
  }
334
- function Fe(t, n, r, i) {
329
+ function Ie(t, n, r, i) {
335
330
  if (y(t, n), !W(r)) throw new e(`ecctrlPropeller "${n}" must be an object`);
336
331
  if (!G(r.maxThrust) || r.maxThrust <= 0) throw new e(`ecctrlPropeller "${n}" is missing positive finite ecctrlPropeller.maxThrust`);
337
332
  let a;
@@ -339,7 +334,7 @@ function Fe(t, n, r, i) {
339
334
  if (!G(r.torqueRatio)) throw new e(`ecctrlPropeller "${n}" has invalid ecctrlPropeller.torqueRatio`);
340
335
  a = r.torqueRatio;
341
336
  }
342
- let o = new P.Box3().setFromObject(t), s = o.isEmpty() ? t.getWorldPosition(new P.Vector3()) : o.getCenter(new P.Vector3());
337
+ let o = new F.Box3().setFromObject(t), s = o.isEmpty() ? t.getWorldPosition(new F.Vector3()) : o.getCenter(new F.Vector3());
343
338
  return {
344
339
  nodeName: n,
345
340
  object: t,
@@ -348,23 +343,23 @@ function Fe(t, n, r, i) {
348
343
  s.y,
349
344
  s.z
350
345
  ],
351
- quaternion: Ae(t, i),
346
+ quaternion: je(t, i),
352
347
  maxThrust: r.maxThrust,
353
348
  torqueRatio: a,
354
- invertThrust: je(r, "invertThrust", "ecctrlPropeller", n),
355
- invertTorque: je(r, "invertTorque", "ecctrlPropeller", n)
349
+ invertThrust: Me(r, "invertThrust", "ecctrlPropeller", n),
350
+ invertTorque: Me(r, "invertTorque", "ecctrlPropeller", n)
356
351
  };
357
352
  }
358
353
  // src/khrParsers.ts
359
- var Ie = /* @__PURE__ */ new Map([["default", 0]]), Le = 1, Re = (e) => typeof e == "object" && !!e && !Array.isArray(e), q = (e) => typeof e == "number" && Number.isFinite(e) && e > 0, ze = (e) => typeof e == "number" && Number.isFinite(e) && e >= 0;
354
+ var Le = /* @__PURE__ */ new Map([["default", 0]]), Re = 1, ze = (e) => typeof e == "object" && !!e && !Array.isArray(e), q = (e) => typeof e == "number" && Number.isFinite(e) && e > 0, Be = (e) => typeof e == "number" && Number.isFinite(e) && e >= 0;
360
355
  function J(t, n, r = !1) {
361
356
  if (t !== void 0) {
362
357
  if (typeof t != "number" || !Number.isFinite(t) || r && t < 0) throw new e(`Invalid ${n}`);
363
358
  return t;
364
359
  }
365
360
  }
366
- function Be(t, n) {
367
- if (!Re(t)) throw new e(`KHR_implicit_shapes[${n}] must be an object`);
361
+ function Ve(t, n) {
362
+ if (!ze(t)) throw new e(`KHR_implicit_shapes[${n}] must be an object`);
368
363
  let r = t.type;
369
364
  if (r === "box" && t.box && typeof t.box == "object") {
370
365
  let r = t.box.size;
@@ -401,25 +396,25 @@ function Be(t, n) {
401
396
  }
402
397
  throw new e(`KHR_implicit_shapes[${n}] unsupported shape type "${r}"`);
403
398
  }
404
- function Ve(t, n, r) {
399
+ function He(t, n, r) {
405
400
  if (n === void 0) return {};
406
401
  if (typeof n != "number" || !Number.isInteger(n) || n < 0 || n >= t.length) throw new e(`Node "${r}" references out-of-bounds physicsMaterial ${String(n)}`);
407
402
  let i = t[n];
408
- if (!Re(i)) throw new e(`Invalid physicsMaterials[${n}] on "${r}"`);
403
+ if (!ze(i)) throw new e(`Invalid physicsMaterials[${n}] on "${r}"`);
409
404
  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);
410
405
  return {
411
406
  ...a !== void 0 || o !== void 0 ? { friction: a ?? o } : {},
412
407
  ...s === void 0 ? {} : { restitution: s }
413
408
  };
414
409
  }
415
- function He(t, n, i) {
410
+ function Ue(t, n, i) {
416
411
  if (t.isKinematic !== void 0 && typeof t.isKinematic != "boolean") throw new e(`Node "${i}" has non-boolean motion.isKinematic`);
417
412
  let a = !n || !!t.isKinematic, o = 0;
418
413
  if (!a) {
419
414
  if (!q(t.mass)) throw new e(`Dynamic node "${i}" is missing positive finite motion.mass`);
420
415
  o = t.mass;
421
416
  } else if (t.mass !== void 0) {
422
- if (!ze(t.mass)) throw new e(`Kinematic node "${i}" has invalid motion.mass`);
417
+ if (!Be(t.mass)) throw new e(`Kinematic node "${i}" has invalid motion.mass`);
423
418
  o = t.mass;
424
419
  }
425
420
  let s = t.centerOfMass === void 0 ? [
@@ -450,13 +445,13 @@ function He(t, n, i) {
450
445
  ...p === void 0 ? {} : { gravityFactor: p }
451
446
  };
452
447
  }
453
- function Ue(t) {
448
+ function We(t) {
454
449
  let n = (t) => {
455
- let n = Ie.get(t);
450
+ let n = Le.get(t);
456
451
  if (n !== void 0) return n;
457
- if (Le > 15) throw new e(`Exceeded Rapier 16-group limit for collisionSystem "${t}"`);
458
- let r = Le++;
459
- return Ie.set(t, r), r;
452
+ if (Re > 15) throw new e(`Exceeded Rapier 16-group limit for collisionSystem "${t}"`);
453
+ let r = Re++;
454
+ return Le.set(t, r), r;
460
455
  }, r = (t, r) => {
461
456
  if (t === void 0) return 0;
462
457
  if (!Array.isArray(t)) throw new e(`collisionFilter.${r} must be an array`);
@@ -474,7 +469,7 @@ function Ue(t) {
474
469
  return (i & 65535) << 16 | a & 65535;
475
470
  });
476
471
  }
477
- var We = (e) => e === 0 ? [
472
+ var Ge = (e) => e === 0 ? [
478
473
  1,
479
474
  0,
480
475
  0
@@ -487,7 +482,7 @@ var We = (e) => e === 0 ? [
487
482
  0,
488
483
  1
489
484
  ];
490
- function Ge(t, n, r) {
485
+ function Ke(t, n, r) {
491
486
  return t.map((t, i) => {
492
487
  let a = `physicsJoints[${n}].drives[${i}] on "${r}"`;
493
488
  if (!t || typeof t != "object" || Array.isArray(t)) throw new e(`${a} must be an object`);
@@ -509,9 +504,9 @@ function Ge(t, n, r) {
509
504
  };
510
505
  });
511
506
  }
512
- function Ke(t, n, r, i, a, o, s, c = i.name) {
507
+ function qe(t, n, r, i, a, o, s, c = i.name) {
513
508
  let l = t[n];
514
- if (!Re(l)) throw new e(`physicsJoints[${n}] out of bounds for "${r}"`);
509
+ if (!ze(l)) throw new e(`physicsJoints[${n}] out of bounds for "${r}"`);
515
510
  if (l.limits !== void 0 && !Array.isArray(l.limits)) throw new e(`physicsJoints[${n}].limits on "${r}" must be an array`);
516
511
  if (l.drives !== void 0 && !Array.isArray(l.drives)) throw new e(`physicsJoints[${n}].drives on "${r}" must be an array`);
517
512
  let u = l.limits ?? [], d = l.drives ?? [], f = [
@@ -547,7 +542,7 @@ function Ke(t, n, r, i, a, o, s, c = i.name) {
547
542
  });
548
543
  };
549
544
  for (let t of u) {
550
- if (!Re(t)) throw new e(`physicsJoints[${n}].limits entry on "${r}" must be an object`);
545
+ if (!ze(t)) throw new e(`physicsJoints[${n}].limits entry on "${r}" must be an object`);
551
546
  g(t.linearAxes, t, f, m), g(t.angularAxes, t, p, h);
552
547
  }
553
548
  let _ = [
@@ -565,15 +560,15 @@ function Ke(t, n, r, i, a, o, s, c = i.name) {
565
560
  ], x = null, S;
566
561
  if (_.length === 0 && v.length === 0) y = "fixed";
567
562
  else if (_.length === 0 && v.length === 1) {
568
- y = "revolute", b = We(v[0]);
563
+ y = "revolute", b = Ge(v[0]);
569
564
  let e = p[v[0]];
570
565
  x = Array.isArray(e) ? e : null, S = h[v[0]];
571
566
  } else if (v.length === 0 && _.length === 1) {
572
- y = "prismatic", b = We(_[0]);
567
+ y = "prismatic", b = Ge(_[0]);
573
568
  let e = f[_[0]];
574
569
  x = Array.isArray(e) ? e : null, S = m[_[0]];
575
570
  } else throw new e(`physicsJoints[${n}] unsupported DOF (${_.length} lin, ${v.length} ang) on "${r}"`);
576
- let C = Ge(d, n, r), w = a.getWorldPosition(new P.Vector3()).sub(i.getWorldPosition(new P.Vector3())).applyQuaternion(i.getWorldQuaternion(new P.Quaternion()).invert());
571
+ let C = Ke(d, n, r), w = a.getWorldPosition(new F.Vector3()).sub(i.getWorldPosition(new F.Vector3())).applyQuaternion(i.getWorldQuaternion(new F.Quaternion()).invert());
577
572
  return {
578
573
  index: n,
579
574
  nodeName: r,
@@ -606,16 +601,16 @@ function X(t, n) {
606
601
  if (!Array.isArray(t)) throw new e(`${n} must be an array`);
607
602
  return t;
608
603
  }
609
- function qe() {
604
+ function Je() {
610
605
  return (e) => ({
611
606
  name: "khr3_headless_texture",
612
607
  loadTexture(t) {
613
- let n = new P.Texture();
608
+ let n = new F.Texture();
614
609
  return n.flipY = !1, e.associations.set(n, { textures: t }), Promise.resolve(n);
615
610
  }
616
611
  });
617
612
  }
618
- function Je(t, n, r = t.parser?.json) {
613
+ function Ye(t, n, r = t.parser?.json) {
619
614
  let i = new Int32Array(n.length).fill(-1);
620
615
  for (let t = 0; t < n.length; t++) {
621
616
  let r = n[t];
@@ -691,12 +686,12 @@ function Je(t, n, r = t.parser?.json) {
691
686
  if (e < 0 || e >= n.length || !o.has(e)) return;
692
687
  let r = d.get(e);
693
688
  if (r) return r;
694
- let i = l[e], a = P.PropertyBinding.sanitizeNodeName(i);
689
+ let i = l[e], a = F.PropertyBinding.sanitizeNodeName(i);
695
690
  return f.get(i) ?? f.get(a) ?? t.scene.getObjectByName(i);
696
691
  }
697
692
  };
698
693
  }
699
- function Ye(t, n, r, i, a) {
694
+ function Xe(t, n, r, i, a) {
700
695
  if (!Y(t)) throw new e(`Node "${n}" has invalid collider (expected object)`);
701
696
  let o = t.geometry;
702
697
  if (!Y(o)) throw new e(`Node "${n}" is missing collider.geometry object`);
@@ -714,8 +709,8 @@ function Ye(t, n, r, i, a) {
714
709
  throw new e(`Node "${n}" collider.geometry must specify shape or node`);
715
710
  }
716
711
  // src/khrPlugin.ts
717
- var Xe = "khrBundle";
718
- function Ze(t, n) {
712
+ var Ze = "khrBundle";
713
+ function Qe(t, n) {
719
714
  if (!t.scene) throw new e("GLTF asset has no active scene");
720
715
  t.scene.updateMatrixWorld(!0), s(t.scene);
721
716
  let i = t.parser?.json;
@@ -725,14 +720,14 @@ function Ze(t, n) {
725
720
  if (a !== void 0 && !Y(a)) throw new e("KHR_physics_rigid_bodies extension must be an object");
726
721
  let o = i.extensions?.KHR_implicit_shapes;
727
722
  if (o !== void 0 && !Y(o)) throw new e("KHR_implicit_shapes extension must be an object");
728
- let c = X(o?.shapes, "KHR_implicit_shapes.shapes").map((e, t) => Be(e, t)), l = X(a?.physicsMaterials, "KHR_physics_rigid_bodies.physicsMaterials"), d = Ue(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 } = Je(t, m, i), y = [], b = {};
723
+ let c = X(o?.shapes, "KHR_implicit_shapes.shapes").map((e, t) => Ve(e, t)), l = X(a?.physicsMaterials, "KHR_physics_rigid_bodies.physicsMaterials"), d = We(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 } = Ye(t, m, i), y = [], b = {};
729
724
  for (let e = 0; e < m.length; e++) {
730
725
  let t = v(e);
731
726
  if (!t) continue;
732
727
  let r = Y(m[e].extras) ? m[e].extras : {};
733
- y.push(Ne(t, _[e], r, b, n?.isSocketNode));
728
+ y.push(Pe(t, _[e], r, b, n?.isSocketNode));
734
729
  }
735
- let x = [], S = [], C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Set(), T = [], ee = [], E = (e) => {
730
+ let x = [], S = [], C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Set(), T = [], E = [], ee = (e) => {
736
731
  for (let t = g[e]; t !== -1; t = g[t]) if (m[t].extensions?.KHR_physics_rigid_bodies?.motion) return t;
737
732
  return -1;
738
733
  }, D = (e) => {
@@ -748,7 +743,7 @@ function Ze(t, n) {
748
743
  let s = Y(i.extras) ? i.extras : {};
749
744
  if (s.ecctrlWheel !== void 0 || s.ecctrlPropeller !== void 0) {
750
745
  if (g[r] !== -1 && D(g[r])) throw new e(`Nested rotor "${a}" inside detached rotor is unsupported`);
751
- s.ecctrlWheel === void 0 ? ee.push(Fe(o, a, s.ecctrlPropeller, t.scene)) : T.push(Pe(o, a, s.ecctrlWheel, t.scene));
746
+ s.ecctrlWheel === void 0 ? E.push(Ie(o, a, s.ecctrlPropeller, t.scene)) : T.push(Fe(o, a, s.ecctrlWheel, t.scene));
752
747
  continue;
753
748
  }
754
749
  if (D(r)) continue;
@@ -756,12 +751,12 @@ function Ze(t, n) {
756
751
  if (c === void 0) continue;
757
752
  if (!Y(c)) throw new e(`Node "${a}" has invalid KHR_physics_rigid_bodies`);
758
753
  if (c.motion === void 0 && c.collider === void 0 && c.joint === void 0) continue;
759
- if (c.motion === void 0 && E(r) !== -1) {
754
+ if (c.motion === void 0 && ee(r) !== -1) {
760
755
  if (c.joint !== void 0) throw new e(`Node "${a}" has joint without motion`);
761
756
  continue;
762
757
  }
763
758
  if (c.motion !== void 0 && !Y(c.motion)) throw new e(`Node "${a}" has invalid motion`);
764
- let { hasExplicitInertia: l, ...u } = He(c.motion ?? {}, c.motion !== void 0, a);
759
+ let { hasExplicitInertia: l, ...u } = Ue(c.motion ?? {}, c.motion !== void 0, a);
765
760
  l && w.add(r);
766
761
  let d = n?.extractRole?.(a, s) ?? (typeof s.role == "string" ? s.role : null), f = null;
767
762
  if (c.joint !== void 0) {
@@ -773,9 +768,9 @@ function Ze(t, n) {
773
768
  let n = t.connectedNode, r = _[n] ?? `node_${n}`, i = v(n);
774
769
  if (!i) throw new e(`Joint on "${a}" targets missing connectedNode "${r}"`);
775
770
  if (D(n)) throw new e(`Joint on "${a}" cannot target detached rotor "${r}"`);
776
- f = Ke(p, t.joint, a, i, o, !!t.enableCollision, d, r);
771
+ f = qe(p, t.joint, a, i, o, !!t.enableCollision, d, r);
777
772
  }
778
- let h = o.getWorldPosition(new P.Vector3()), y = o.getWorldQuaternion(new P.Quaternion()), b = {
773
+ let h = o.getWorldPosition(new F.Vector3()), y = o.getWorldQuaternion(new F.Quaternion()), b = {
779
774
  nodeName: a,
780
775
  ...u,
781
776
  localPosition: [
@@ -805,9 +800,9 @@ function Ze(t, n) {
805
800
  if (n === void 0) continue;
806
801
  let r = v(t);
807
802
  if (!r) continue;
808
- let i = C.has(t) ? t : E(t), a = C.get(i);
803
+ let i = C.has(t) ? t : ee(t), a = C.get(i);
809
804
  if (!a) continue;
810
- let o = Ye(n, _[t], c, _, v), s = n, f = i === t ? {
805
+ let o = Xe(n, _[t], c, _, v), s = n, f = i === t ? {
811
806
  localPosition: [
812
807
  0,
813
808
  0,
@@ -819,7 +814,7 @@ function Ze(t, n) {
819
814
  0,
820
815
  1
821
816
  ]
822
- } : u(a.object, r), p = Ve(l, s.physicsMaterial, _[t]), h;
817
+ } : u(a.object, r), p = He(l, s.physicsMaterial, _[t]), h;
823
818
  if (s.collisionFilter !== void 0) {
824
819
  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)}`);
825
820
  h = d[s.collisionFilter];
@@ -833,61 +828,61 @@ function Ze(t, n) {
833
828
  });
834
829
  }
835
830
  for (let [e, t] of C) w.has(e) || t.isKinematic || (t.inertiaDiagonal = f(t.colliders, t.mass, t.centerOfMass, t.inertiaOrientation, t.nodeName));
836
- let { totalDynamicMass: O, centerOfMass: te } = h(x), k = [], A = i.scenes?.[i.scene ?? 0]?.extras ?? i.extras;
837
- if (A?.ikSockets !== void 0) {
838
- if (!Y(A.ikSockets)) throw new e("scene.extras.ikSockets must be an object");
839
- for (let [e, t] of Object.entries(A.ikSockets)) {
831
+ let { totalDynamicMass: O, centerOfMass: k } = h(x), A = [], j = i.scenes?.[i.scene ?? 0]?.extras ?? i.extras;
832
+ if (j?.ikSockets !== void 0) {
833
+ if (!Y(j.ikSockets)) throw new e("scene.extras.ikSockets must be an object");
834
+ for (let [e, t] of Object.entries(j.ikSockets)) {
840
835
  let n = r(t, `scene.extras.ikSockets.${e}`);
841
- b[e] = n, k.push([e, n]);
836
+ b[e] = n, A.push([e, n]);
842
837
  }
843
838
  }
844
- let j = Y(A?.tune) ? A.tune : void 0, M = Y(A?.droneTune) ? A.droneTune : void 0;
845
- return Ee(t.scene, {
839
+ let M = Y(j?.tune) ? j.tune : void 0, N = Y(j?.droneTune) ? j.droneTune : void 0;
840
+ return De(t.scene, {
846
841
  nodes: y,
847
842
  bodies: S,
848
- ikSockets: k
843
+ ikSockets: A
849
844
  }), {
850
845
  scene: t.scene,
851
846
  bodies: x,
852
847
  wheels: T,
853
- propellers: ee,
848
+ propellers: E,
854
849
  sockets: b,
855
850
  totalDynamicMass: O,
856
- centerOfMass: te,
857
- tune: j,
858
- droneTune: M
851
+ centerOfMass: k,
852
+ tune: M,
853
+ droneTune: N
859
854
  };
860
855
  }
861
- function Qe(e) {
856
+ function $e(e) {
862
857
  let t = typeof document > "u" && typeof createImageBitmap > "u";
863
858
  return (n) => ({
864
859
  name: "KHR_physics_rigid_bodies",
865
860
  ...t ? { loadTexture(e) {
866
- let t = new P.Texture();
861
+ let t = new F.Texture();
867
862
  return t.flipY = !1, n.associations.set(t, { textures: e }), Promise.resolve(t);
868
863
  } } : {},
869
864
  afterRoot(t) {
870
- return t.userData[Xe] = Ze(t, e), null;
865
+ return t.userData[Ze] = Qe(t, e), null;
871
866
  }
872
867
  });
873
868
  }
874
869
  // src/khrLoader.ts
875
- var $e = qe();
876
- function et() {
877
- let e = new L();
878
- return typeof document > "u" && typeof createImageBitmap > "u" && e.register($e), e;
870
+ var et = Je();
871
+ function tt() {
872
+ let e = new R();
873
+ return typeof document > "u" && typeof createImageBitmap > "u" && e.register(et), e;
879
874
  }
880
- async function tt(t, n) {
875
+ async function nt(t, n) {
881
876
  let r = t instanceof Uint8Array ? t : new Uint8Array(t), i = new ArrayBuffer(r.byteLength);
882
- new Uint8Array(i).set(r), xe(i);
883
- let a = n?.loader ?? et(), o = Qe(n);
877
+ new Uint8Array(i).set(r), Se(i);
878
+ let a = n?.loader ?? tt(), o = $e(n);
884
879
  a.register(o);
885
880
  try {
886
881
  let t = (t) => t instanceof e ? t : new e(t instanceof Error ? t.message : "Failed to parse GLB"), n = (await new Promise((e, n) => {
887
882
  a.parse(i, "", e, (e) => n(t(e)));
888
883
  }).catch((e) => {
889
884
  throw t(e);
890
- })).userData[Xe];
885
+ })).userData[Ze];
891
886
  if (!n) throw new e("Missing parsed KHR bundle on GLTF userData");
892
887
  return n;
893
888
  } finally {
@@ -902,7 +897,7 @@ function Q(t, n, r = !1) {
902
897
  return t;
903
898
  }
904
899
  }
905
- function nt(t, n) {
900
+ function rt(t, n) {
906
901
  if (t.type === "box") {
907
902
  if (!Array.isArray(t.size) || t.size.length !== 3 || !t.size.every(Z)) throw new e(`exportKhrGlb: invalid box.size on "${n}"`);
908
903
  return {
@@ -928,13 +923,13 @@ function nt(t, n) {
928
923
  }
929
924
  };
930
925
  }
931
- function rt(t, n, r) {
926
+ function it(t, n, r) {
932
927
  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`);
933
928
  let i = Math.abs(t[0]), a = Math.abs(t[1]), o = Math.abs(t[2]);
934
929
  if (Math.hypot(i, a, o) <= 1e-8) throw new e(`exportKhrGlb: ${n} joint on "${r}" requires non-zero axis`);
935
930
  return i >= a && i >= o ? 0 : a >= o ? 1 : 2;
936
931
  }
937
- function it(t, n, r, i) {
932
+ function at(t, n, r, i) {
938
933
  if (!t || typeof t != "object" || Array.isArray(t)) throw new e(`exportKhrGlb: joint drive on "${i}" must be an object`);
939
934
  if (t.mode !== "force" && t.mode !== "acceleration") throw new e(`exportKhrGlb: joint drive on "${i}" requires drive.mode ("force" | "acceleration")`);
940
935
  if (t.type !== void 0 && t.type !== "linear" && t.type !== "angular") throw new e(`exportKhrGlb: joint drive on "${i}" has invalid drive.type`);
@@ -953,7 +948,7 @@ function it(t, n, r, i) {
953
948
  ...l === void 0 ? {} : { maxForce: l }
954
949
  };
955
950
  }
956
- function at(t, n) {
951
+ function ot(t, n) {
957
952
  if (t.kind !== "fixed" && t.kind !== "revolute" && t.kind !== "prismatic") throw new e(`exportKhrGlb: invalid joint.kind "${String(t.kind)}" on "${n}"`);
958
953
  if (t.kind === "fixed") {
959
954
  if (t.drive || t.drives && t.drives.length > 0) throw new e(`exportKhrGlb: fixed joint on "${n}" cannot define drives`);
@@ -975,7 +970,7 @@ function at(t, n) {
975
970
  max: 0
976
971
  }] };
977
972
  }
978
- let r = rt(t.axis, t.kind, n), i = [
973
+ let r = it(t.axis, t.kind, n), i = [
979
974
  0,
980
975
  1,
981
976
  2
@@ -1022,9 +1017,9 @@ function at(t, n) {
1022
1017
  },
1023
1018
  ...c
1024
1019
  ] }, u = t.drives ?? (t.drive ? [t.drive] : []);
1025
- return u.length > 0 && (l.drives = u.map((e) => it(e, t.kind === "revolute" ? "angular" : "linear", r, n))), l;
1020
+ return u.length > 0 && (l.drives = u.map((e) => at(e, t.kind === "revolute" ? "angular" : "linear", r, n))), l;
1026
1021
  }
1027
- function ot(t, n) {
1022
+ function st(t, n) {
1028
1023
  let i = !!t.isKinematic;
1029
1024
  if (!i && !Z(t.mass)) throw new e(`exportKhrGlb: dynamic node "${n}" requires positive finite motion.mass`);
1030
1025
  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}"`);
@@ -1040,11 +1035,11 @@ function ot(t, n) {
1040
1035
  ...t.gravityFactor === void 0 ? {} : { gravityFactor: t.gravityFactor }
1041
1036
  };
1042
1037
  }
1043
- async function st(t, n, r) {
1044
- Se(), t.updateMatrixWorld(!0);
1045
- let i = new R();
1046
- return we(await new Promise((e, n) => {
1047
- i.parse(t, (t) => e(t instanceof ArrayBuffer ? t : Ce(t)), n, { binary: !0 });
1038
+ async function ct(t, n, r) {
1039
+ Ce(), t.updateMatrixWorld(!0);
1040
+ let i = new ne();
1041
+ return Te(await new Promise((e, n) => {
1042
+ i.parse(t, (t) => e(t instanceof ArrayBuffer ? t : we(t)), n, { binary: !0 });
1048
1043
  }), (t) => {
1049
1044
  let i = t.nodes ?? [], a = /* @__PURE__ */ new Map();
1050
1045
  i.forEach((e, t) => {
@@ -1062,11 +1057,11 @@ async function st(t, n, r) {
1062
1057
  ...t.extras
1063
1058
  });
1064
1059
  let r = {};
1065
- if (t.motion && (f = !0, r.motion = ot(t.motion, t.nodeName)), t.collider) {
1060
+ if (t.motion && (f = !0, r.motion = st(t.motion, t.nodeName)), t.collider) {
1066
1061
  f = !0;
1067
1062
  let n = {};
1068
1063
  if (t.collider.shape) {
1069
- let e = nt(t.collider.shape, t.nodeName), r = JSON.stringify(e), i = c.get(r);
1064
+ let e = rt(t.collider.shape, t.nodeName), r = JSON.stringify(e), i = c.get(r);
1070
1065
  i === void 0 && (i = s.length, s.push(e), c.set(r, i)), n.geometry = { shape: i };
1071
1066
  } else if (t.collider.meshNodeName) {
1072
1067
  if (typeof t.collider.convexHull != "boolean") throw new e(`exportKhrGlb: mesh collider on "${t.nodeName}" requires explicit boolean convexHull`);
@@ -1096,7 +1091,7 @@ async function st(t, n, r) {
1096
1091
  if (t.joint) {
1097
1092
  f = !0;
1098
1093
  let e = o(t.joint.connectedNodeName);
1099
- d.push(at(t.joint, t.nodeName)), r.joint = {
1094
+ d.push(ot(t.joint, t.nodeName)), r.joint = {
1100
1095
  joint: d.length - 1,
1101
1096
  connectedNode: e,
1102
1097
  enableCollision: !!t.joint.enableCollision
@@ -1126,15 +1121,15 @@ async function st(t, n, r) {
1126
1121
  });
1127
1122
  }
1128
1123
  // src/assemblyPlan.ts
1129
- function ct(t, n) {
1130
- let r = new P.Matrix4();
1124
+ function lt(t, n) {
1125
+ let r = new F.Matrix4();
1131
1126
  for (let i = t; i && i !== n; i = i.parent) {
1132
1127
  if (!i.parent) throw new e(`Node "${t.name}" is detached from bundle.scene`);
1133
1128
  i.updateMatrix(), r.premultiply(i.matrix);
1134
1129
  }
1135
1130
  return r;
1136
1131
  }
1137
- function lt(e, t) {
1132
+ function ut(e, t) {
1138
1133
  let n = (e) => {
1139
1134
  let n = [];
1140
1135
  for (let r = e; r && (n.push(r), r !== t); r = r.parent);
@@ -1147,8 +1142,8 @@ function lt(e, t) {
1147
1142
  for (let t of n(e[0])) if (r.has(t)) return t;
1148
1143
  return t;
1149
1144
  }
1150
- function ut(e, t, n) {
1151
- let r = new P.Vector3().fromArray(e.com), i = new P.Quaternion().fromArray(e.inertiaFrame);
1145
+ function dt(e, t, n) {
1146
+ let r = new F.Vector3().fromArray(e.com), i = new F.Quaternion().fromArray(e.inertiaFrame);
1152
1147
  return t && n && (r.applyMatrix4(t.clone().invert()), i.premultiply(n.clone().invert()).normalize()), {
1153
1148
  mass: e.mass,
1154
1149
  centerOfMass: {
@@ -1169,10 +1164,10 @@ function ut(e, t, n) {
1169
1164
  }
1170
1165
  };
1171
1166
  }
1172
- function dt(e, t, n) {
1167
+ function ft(e, t, n) {
1173
1168
  return e.colliders.map((e, r) => {
1174
- let i = new P.Quaternion().fromArray(e.localQuaternion), a = new P.Matrix4().compose(new P.Vector3().fromArray(e.localPosition), i, new P.Vector3(1, 1, 1)), o = new P.Vector3(), s = new P.Quaternion(), c = new P.Vector3();
1175
- new P.Matrix4().multiplyMatrices(t, a).decompose(o, s, c);
1169
+ let i = new F.Quaternion().fromArray(e.localQuaternion), a = new F.Matrix4().compose(new F.Vector3().fromArray(e.localPosition), i, new F.Vector3(1, 1, 1)), o = new F.Vector3(), s = new F.Quaternion(), c = new F.Vector3();
1170
+ new F.Matrix4().multiplyMatrices(t, a).decompose(o, s, c);
1176
1171
  let l = {
1177
1172
  spec: e,
1178
1173
  local: a,
@@ -1188,14 +1183,14 @@ function dt(e, t, n) {
1188
1183
  s.w
1189
1184
  ]
1190
1185
  };
1191
- return r === 0 && n && (l.massProperties = ut(n, a, i)), l;
1186
+ return r === 0 && n && (l.massProperties = dt(n, a, i)), l;
1192
1187
  });
1193
1188
  }
1194
- function ft(e, t, n) {
1189
+ function pt(e, t, n) {
1195
1190
  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;
1196
1191
  return !1;
1197
1192
  }
1198
- function pt(t) {
1193
+ function mt(t) {
1199
1194
  let r = new Map(t.bodies.map((e) => [e.nodeName, e])), i = (t, n = /* @__PURE__ */ new Set()) => {
1200
1195
  if (!t.joint) return t;
1201
1196
  if (n.has(t.nodeName)) throw new e(`Joint cycle through "${t.nodeName}"`);
@@ -1208,19 +1203,19 @@ function pt(t) {
1208
1203
  s.sort((e, t) => c(e) - c(t));
1209
1204
  let l = /* @__PURE__ */ new Map(), u = s.map((t) => {
1210
1205
  let n = t.joint, i = l.get(n.connectedNodeName) ?? null;
1211
- if (i && !mt(t.object, i.spec.object)) throw new e(`Jointed node "${t.nodeName}" must be a scene-graph descendant of its jointed parent "${n.connectedNodeName}"`);
1206
+ if (i && !ht(t.object, i.spec.object)) throw new e(`Jointed node "${t.nodeName}" must be a scene-graph descendant of its jointed parent "${n.connectedNodeName}"`);
1212
1207
  let a = o.clone().multiply(x(t)), c = {
1213
1208
  spec: t,
1214
1209
  joint: n,
1215
1210
  parent: i,
1216
1211
  restRelParent: i ? x(i.spec).invert().multiply(x(t)) : a,
1217
- inertia: ue(t, n, s.filter((e) => e !== t && ft(e, t.nodeName, r))),
1218
- colliders: dt(t, a, null)
1212
+ inertia: de(t, n, s.filter((e) => e !== t && pt(e, t.nodeName, r))),
1213
+ colliders: ft(t, a, null)
1219
1214
  };
1220
1215
  return l.set(t.nodeName, c), c;
1221
- }), d = a.isKinematic ? null : n([a, ...s], o), f = dt(a, new P.Matrix4(), d), p = d && f.length === 0 ? ut(d) : void 0, m = lt([a.object, ...s.map((e) => e.object)], t.scene), h = o.clone().multiply(ct(m, t.scene)), g = new P.Vector3(), _ = new P.Quaternion(), v = new P.Vector3();
1216
+ }), d = a.isKinematic ? null : n([a, ...s], o), f = ft(a, new F.Matrix4(), d), p = d && f.length === 0 ? dt(d) : void 0, m = ut([a.object, ...s.map((e) => e.object)], t.scene), h = o.clone().multiply(lt(m, t.scene)), g = new F.Vector3(), _ = new F.Quaternion(), v = new F.Vector3();
1222
1217
  o.decompose(g, _, v), _.normalize();
1223
- let y = new P.Vector3(), b = new P.Quaternion(), S = new P.Vector3();
1218
+ let y = new F.Vector3(), b = new F.Quaternion(), S = new F.Vector3();
1224
1219
  return h.decompose(y, b, S), b.normalize(), {
1225
1220
  spec: a,
1226
1221
  sceneInRootPos: [
@@ -1252,20 +1247,20 @@ function pt(t) {
1252
1247
  parts: u
1253
1248
  };
1254
1249
  });
1255
- for (let t of a) for (let n of a) if (t !== n && mt(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`);
1250
+ for (let t of a) for (let n of a) if (t !== n && ht(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`);
1256
1251
  return a;
1257
1252
  }
1258
- function mt(e, t) {
1253
+ function ht(e, t) {
1259
1254
  for (let n = e; n; n = n.parent) if (n === t) return !0;
1260
1255
  return !1;
1261
1256
  }
1262
1257
  // src/AssemblyRootBody.tsx
1263
- function ht({ plan: e, assemblyId: t, position: n, quaternion: r, fixedRoot: a, rigidBodyProps: o, onBody: s, onJoints: c, children: l }) {
1264
- let u = T(C), d = O(null), f = D(() => e.parts.map((e) => e.colliders.map(() => ({ current: null }))), [e]), p = e.spec;
1258
+ function gt({ plan: e, assemblyId: t, position: n, quaternion: r, fixedRoot: a, rigidBodyProps: o, onBody: s, onJoints: c, children: l }) {
1259
+ let u = T(C), d = k(null), f = O(() => e.parts.map((e) => e.colliders.map(() => ({ current: null }))), [e]), p = e.spec;
1265
1260
  E(() => (s(p.nodeName, d), () => s(p.nodeName, null)), [p, s]), E(() => {
1266
1261
  let t = d.current, n = e.rootMass;
1267
1262
  t && n && (t.setAdditionalMassProperties(n.mass, n.centerOfMass, n.principalAngularInertia, n.angularInertiaLocalFrame, !0), t.recomputeMassPropertiesFromColliders());
1268
- }, [e.rootMass]), E(() => {
1263
+ }, [e.rootMass]), D(() => {
1269
1264
  let n = /* @__PURE__ */ new Map();
1270
1265
  for (let r = 0; r < e.parts.length; r++) {
1271
1266
  let i = e.parts[r], a = i.joint.drive, o = {
@@ -1274,7 +1269,7 @@ function ht({ plan: e, assemblyId: t, position: n, quaternion: r, fixedRoot: a,
1274
1269
  role: i.joint.role,
1275
1270
  kind: i.joint.kind,
1276
1271
  object: i.spec.object,
1277
- axis: new P.Vector3().fromArray(i.joint.axis).normalize(),
1272
+ axis: new F.Vector3().fromArray(i.joint.axis).normalize(),
1278
1273
  restPosition: i.spec.object.position.clone(),
1279
1274
  restQuaternion: i.spec.object.quaternion.clone(),
1280
1275
  q: 0,
@@ -1310,7 +1305,7 @@ function ht({ plan: e, assemblyId: t, position: n, quaternion: r, fixedRoot: a,
1310
1305
  c
1311
1306
  ]);
1312
1307
  let m = p.isKinematic ? a ? "fixed" : "kinematicPosition" : "dynamic";
1313
- return /* @__PURE__ */ I(M, {
1308
+ return /* @__PURE__ */ L(te, {
1314
1309
  ...o,
1315
1310
  ref: d,
1316
1311
  type: m,
@@ -1322,13 +1317,13 @@ function ht({ plan: e, assemblyId: t, position: n, quaternion: r, fixedRoot: a,
1322
1317
  ...p.gravityFactor === void 0 ? {} : { gravityScale: p.gravityFactor },
1323
1318
  children: [
1324
1319
  l,
1325
- e.colliders.map((e, t) => /* @__PURE__ */ F(i, {
1320
+ e.colliders.map((e, t) => /* @__PURE__ */ I(i, {
1326
1321
  c: e.spec,
1327
1322
  position: e.position,
1328
1323
  quaternion: e.quaternion,
1329
1324
  massProperties: e.massProperties
1330
1325
  }, `r${t}`)),
1331
- e.parts.map((e, t) => e.colliders.map((n, r) => /* @__PURE__ */ F(i, {
1326
+ e.parts.map((e, t) => e.colliders.map((n, r) => /* @__PURE__ */ I(i, {
1332
1327
  ref: f[t][r],
1333
1328
  c: n.spec,
1334
1329
  position: n.position,
@@ -1339,32 +1334,32 @@ function ht({ plan: e, assemblyId: t, position: n, quaternion: r, fixedRoot: a,
1339
1334
  });
1340
1335
  }
1341
1336
  // src/KhrAssembly.tsx
1342
- var gt = 0;
1343
- function _t({ ref: t, bundle: n, position: r = [
1337
+ var _t = 0;
1338
+ function vt({ ref: t, bundle: n, position: r = [
1344
1339
  0,
1345
1340
  0,
1346
1341
  0
1347
1342
  ], rotation: i, quaternion: a, scale: o, fixedRoot: l = !1, rigidBodyProps: u, children: d, ...f }) {
1348
1343
  c(o, "KhrAssembly"), n.scene.updateMatrixWorld(!0), s(n.scene);
1349
- let m = D(() => gt++, []), h = D(() => pt(n), [n]), _ = D(() => h.length > 1 ? g(h.map((e) => e.mountNode)) : null, [h]), [y, b, x] = r, [S, C, T] = i ?? [
1344
+ let m = O(() => _t++, []), h = O(() => mt(n), [n]), _ = O(() => h.length > 1 ? g(h.map((e) => e.mountNode)) : null, [h]), [y, b, x] = r, [S, C, T] = i ?? [
1350
1345
  0,
1351
1346
  0,
1352
1347
  0
1353
- ], [E, te, k, A] = a ?? [
1348
+ ], [E, D, A, j] = a ?? [
1354
1349
  NaN,
1355
1350
  NaN,
1356
1351
  NaN,
1357
1352
  NaN
1358
- ], j = D(() => a ? new P.Quaternion(E, te, k, A) : new P.Quaternion().setFromEuler(new P.Euler(S, C, T)), [
1353
+ ], M = O(() => a ? new F.Quaternion(E, D, A, j) : new F.Quaternion().setFromEuler(new F.Euler(S, C, T)), [
1359
1354
  E,
1360
- te,
1361
- k,
1355
+ D,
1362
1356
  A,
1357
+ j,
1363
1358
  S,
1364
1359
  C,
1365
1360
  T
1366
- ]), M = D(() => h.map((e) => {
1367
- let t = new P.Vector3().fromArray(e.spec.localPosition).applyQuaternion(j).add(new P.Vector3(y, b, x)), n = j.clone().multiply(new P.Quaternion().fromArray(e.spec.localQuaternion));
1361
+ ]), N = O(() => h.map((e) => {
1362
+ let t = new F.Vector3().fromArray(e.spec.localPosition).applyQuaternion(M).add(new F.Vector3(y, b, x)), n = M.clone().multiply(new F.Quaternion().fromArray(e.spec.localQuaternion));
1368
1363
  return {
1369
1364
  position: [
1370
1365
  t.x,
@@ -1380,59 +1375,59 @@ function _t({ ref: t, bundle: n, position: r = [
1380
1375
  };
1381
1376
  }), [
1382
1377
  h,
1383
- j,
1378
+ M,
1384
1379
  y,
1385
1380
  b,
1386
1381
  x
1387
- ]), N = O(/* @__PURE__ */ new Map()), L = O(/* @__PURE__ */ new Map()), R = D(() => {
1382
+ ]), te = k(/* @__PURE__ */ new Map()), P = k(/* @__PURE__ */ new Map()), R = O(() => {
1388
1383
  let e = /* @__PURE__ */ new Map();
1389
1384
  for (let t of h) {
1390
1385
  e.set(t.spec.nodeName, t.spec.nodeName);
1391
1386
  for (let n of t.parts) e.set(n.spec.nodeName, t.spec.nodeName);
1392
1387
  }
1393
1388
  return e;
1394
- }, [h]), z = w((e, t) => {
1395
- t ? N.current.set(e, t) : N.current.delete(e);
1396
- }, []), B = w((e, t) => {
1397
- t ? L.current.set(e, t) : L.current.delete(e);
1389
+ }, [h]), ne = w((e, t) => {
1390
+ t ? te.current.set(e, t) : te.current.delete(e);
1391
+ }, []), z = w((e, t) => {
1392
+ t ? P.current.set(e, t) : P.current.delete(e);
1398
1393
  }, []);
1399
1394
  if (ee(t, () => {
1400
1395
  let t = (t, n) => {
1401
1396
  if (!t.drive || t.drive.stiffness === void 0) throw new e(`Joint "${t.nodeName}" has no authored drive stiffness; cannot set a position target`);
1402
1397
  t.positionTarget = n;
1403
- let r = N.current.get(R.get(t.nodeName))?.current;
1398
+ let r = te.current.get(R.get(t.nodeName))?.current;
1404
1399
  r && r.isDynamic() && r.wakeUp();
1405
1400
  };
1406
1401
  return {
1407
1402
  getBody: (e) => {
1408
1403
  let t = R.get(e);
1409
- return t ? N.current.get(t)?.current ?? null : null;
1404
+ return t ? te.current.get(t)?.current ?? null : null;
1410
1405
  },
1411
1406
  setJointTarget: (e, n) => {
1412
- let r = L.current.get(R.get(e) ?? "")?.get(e);
1407
+ let r = P.current.get(R.get(e) ?? "")?.get(e);
1413
1408
  r && t(r, n);
1414
1409
  },
1415
1410
  setRoleTarget: (e, n) => {
1416
- for (let r of L.current.values()) for (let i of r.values()) i.role === e && t(i, n);
1411
+ for (let r of P.current.values()) for (let i of r.values()) i.role === e && t(i, n);
1417
1412
  }
1418
1413
  };
1419
1414
  }, [R]), h.length === 1) {
1420
1415
  let e = h[0];
1421
- return /* @__PURE__ */ F("group", {
1416
+ return /* @__PURE__ */ I("group", {
1422
1417
  ...f,
1423
- children: /* @__PURE__ */ F(ht, {
1418
+ children: /* @__PURE__ */ I(gt, {
1424
1419
  plan: e,
1425
1420
  assemblyId: m,
1426
- position: M[0].position,
1427
- quaternion: M[0].quaternion,
1421
+ position: N[0].position,
1422
+ quaternion: N[0].quaternion,
1428
1423
  fixedRoot: l,
1429
1424
  rigidBodyProps: u,
1430
- onBody: z,
1431
- onJoints: B,
1432
- children: /* @__PURE__ */ I("group", {
1425
+ onBody: ne,
1426
+ onJoints: z,
1427
+ children: /* @__PURE__ */ L("group", {
1433
1428
  position: e.sceneInRootPos,
1434
1429
  quaternion: e.sceneInRootQuat,
1435
- children: [/* @__PURE__ */ F(v, {
1430
+ children: [/* @__PURE__ */ I(v, {
1436
1431
  bundle: n,
1437
1432
  owner: "KhrAssembly"
1438
1433
  }), d]
@@ -1440,25 +1435,25 @@ function _t({ ref: t, bundle: n, position: r = [
1440
1435
  }, `${n.scene.uuid}:${e.spec.nodeName}`)
1441
1436
  });
1442
1437
  }
1443
- return /* @__PURE__ */ I("group", {
1438
+ return /* @__PURE__ */ L("group", {
1444
1439
  ...f,
1445
- children: [/* @__PURE__ */ I("group", {
1440
+ children: [/* @__PURE__ */ L("group", {
1446
1441
  position: r,
1447
- quaternion: j,
1448
- children: [/* @__PURE__ */ F(v, {
1442
+ quaternion: M,
1443
+ children: [/* @__PURE__ */ I(v, {
1449
1444
  bundle: n,
1450
1445
  owner: "KhrAssembly"
1451
1446
  }), d]
1452
- }), h.map((e, t) => /* @__PURE__ */ F(ht, {
1447
+ }), h.map((e, t) => /* @__PURE__ */ I(gt, {
1453
1448
  plan: e,
1454
1449
  assemblyId: m,
1455
- position: M[t].position,
1456
- quaternion: M[t].quaternion,
1450
+ position: N[t].position,
1451
+ quaternion: N[t].quaternion,
1457
1452
  fixedRoot: l,
1458
1453
  rigidBodyProps: u,
1459
- onBody: z,
1460
- onJoints: B,
1461
- children: /* @__PURE__ */ F(p, {
1454
+ onBody: ne,
1455
+ onJoints: z,
1456
+ children: /* @__PURE__ */ I(p, {
1462
1457
  object: e.mountNode,
1463
1458
  position: e.mountPosition,
1464
1459
  quaternion: e.mountQuaternion,
@@ -1468,28 +1463,28 @@ function _t({ ref: t, bundle: n, position: r = [
1468
1463
  });
1469
1464
  }
1470
1465
  // src/useKhrGlb.ts
1471
- var vt = class extends L {
1466
+ var yt = class extends R {
1472
1467
  static khrLoaderScope = Symbol("KhrGLTFLoader");
1473
- }, yt = qe(), bt = Qe(), xt = /* @__PURE__ */ new WeakSet(), St = /* @__PURE__ */ new WeakSet(), $ = /* @__PURE__ */ new Map();
1474
- function Ct(e) {
1475
- xt.has(e) || (xt.add(e), typeof document > "u" && typeof createImageBitmap > "u" && e.register(yt), e.register(bt));
1476
- }
1468
+ }, bt = Je(), xt = $e(), St = /* @__PURE__ */ new WeakSet(), Ct = /* @__PURE__ */ new WeakSet(), $ = /* @__PURE__ */ new Map();
1477
1469
  function wt(e) {
1478
- return !!(e?.extendLoader || e?.cacheKey !== void 0);
1470
+ St.has(e) || (St.add(e), typeof document > "u" && typeof createImageBitmap > "u" && e.register(bt), e.register(xt));
1479
1471
  }
1480
1472
  function Tt(e) {
1473
+ return !!(e?.extendLoader || e?.cacheKey !== void 0);
1474
+ }
1475
+ function Et(e) {
1481
1476
  return e.cacheKey === void 0 ? `src:${Function.prototype.toString.call(e.extendLoader)}` : `key:${e.cacheKey}`;
1482
1477
  }
1483
- function Et(e, t) {
1484
- let n = Tt(t), r = $.get(e);
1478
+ function Dt(e, t) {
1479
+ let n = Et(t), r = $.get(e);
1485
1480
  r || (r = /* @__PURE__ */ new Map(), $.set(e, r));
1486
1481
  let i = r.get(n);
1487
1482
  if (!i) {
1488
- let a = new L(), o = t.extendLoader, s = {
1483
+ let a = new R(), o = t.extendLoader, s = {
1489
1484
  loader: a,
1490
1485
  registerExtensions: (t) => {
1491
- if (Ct(t), o && !St.has(t)) try {
1492
- o(t), St.add(t);
1486
+ if (wt(t), o && !Ct.has(t)) try {
1487
+ o(t), Ct.add(t);
1493
1488
  } catch (t) {
1494
1489
  let r = $.get(e);
1495
1490
  throw r?.get(n) === s && (r.delete(n), r.size === 0 && $.delete(e)), t;
@@ -1500,33 +1495,33 @@ function Et(e, t) {
1500
1495
  }
1501
1496
  return i;
1502
1497
  }
1503
- function Dt(t, n) {
1504
- let r = n?.extractRole, i = n?.isSocketNode, a = wt(n) ? Et(t, n) : null, o = a ? a.loader : vt, s = a ? a.registerExtensions : Ct, c = A(o, t, s).userData[Xe];
1505
- if (!c) throw new e(`useKhrGlb: missing "${Xe}" on loaded GLTF for "${t}"`);
1506
- return D(() => {
1498
+ function Ot(t, n) {
1499
+ let r = n?.extractRole, i = n?.isSocketNode, a = Tt(n) ? Dt(t, n) : null, o = a ? a.loader : yt, s = a ? a.registerExtensions : wt, c = M(o, t, s).userData[Ze];
1500
+ if (!c) throw new e(`useKhrGlb: missing "${Ze}" on loaded GLTF for "${t}"`);
1501
+ return O(() => {
1507
1502
  let e = _(c);
1508
- return (r || i) && De(e, c, r, i), e;
1503
+ return (r || i) && Oe(e, c, r, i), e;
1509
1504
  }, [
1510
1505
  c,
1511
1506
  r,
1512
1507
  i
1513
1508
  ]);
1514
1509
  }
1515
- Dt.preload = (e, t) => {
1516
- let n = wt(t) ? Et(e, t) : null, r = n ? n.loader : vt, i = n ? n.registerExtensions : Ct;
1517
- A.preload(r, e, i);
1518
- }, Dt.clear = (e, t) => {
1519
- if (wt(t)) {
1510
+ Ot.preload = (e, t) => {
1511
+ let n = Tt(t) ? Dt(e, t) : null, r = n ? n.loader : yt, i = n ? n.registerExtensions : wt;
1512
+ M.preload(r, e, i);
1513
+ }, Ot.clear = (e, t) => {
1514
+ if (Tt(t)) {
1520
1515
  let n = $.get(e);
1521
1516
  if (!n) return;
1522
- let r = Tt(t), i = n.get(r);
1523
- i && (A.clear(i.loader, e), n.delete(r), n.size === 0 && $.delete(e));
1524
- } else if (A.clear(vt, e), t === void 0) {
1517
+ let r = Et(t), i = n.get(r);
1518
+ i && (M.clear(i.loader, e), n.delete(r), n.size === 0 && $.delete(e));
1519
+ } else if (M.clear(yt, e), t === void 0) {
1525
1520
  let t = $.get(e);
1526
1521
  if (t) {
1527
- for (let n of t.values()) A.clear(n.loader, e);
1522
+ for (let n of t.values()) M.clear(n.loader, e);
1528
1523
  $.delete(e);
1529
1524
  }
1530
1525
  }
1531
1526
  };
1532
- export { C as JointRegistryContext, _t as KhrAssembly, i as KhrCollider, e as KhrValidationError, _e as PhysicsWorld, y as assertIdentityWorldScale, s as assertSceneIdentityWorldScale, c as assertUnitScale, m as claimBundleMount, _ as cloneKhrBundle, Qe as createKhrGltfPlugin, o as disposeKhrBundle, st as exportKhrGlb, tt as loadKhrGlb, we as patchGlbJsonChunk, d as releaseBundleMount, Dt as useKhrGlb };
1527
+ export { C as JointRegistryContext, vt 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, $e as createKhrGltfPlugin, o as disposeKhrBundle, ct as exportKhrGlb, nt as loadKhrGlb, Te as patchGlbJsonChunk, d as releaseBundleMount, Ot as useKhrGlb };