@khr3/core 0.1.0 → 0.1.2

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,70 +1,99 @@
1
- import { _ as e, a as t, b as n, c as r, d as i, f as a, g as o, h as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g, v as _, x as v, y } from "./BundleSceneHost-BXLH_LrO.js";
2
- import { useCallback as b, useContext as x, useImperativeHandle as S, useLayoutEffect as C, useMemo as w, useRef as T } from "react";
3
- import { useFrame as E, useLoader as D } from "@react-three/fiber";
4
- import { Physics as O, RigidBody as k, useRapier as A } from "@react-three/rapier";
5
- import * as j from "three";
6
- import { jsx as M, jsxs as N } from "react/jsx-runtime";
7
- import { GLTFLoader as P } from "three/examples/jsm/loaders/GLTFLoader.js";
8
- import { GLTFExporter as F } from "three/examples/jsm/exporters/GLTFExporter.js";
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";
9
9
  // src/jointDynamics.ts
10
- var I = new j.Vector3(), L = new j.Vector3(), R = new j.Quaternion(), z = new j.Matrix4(), B = new j.Matrix4(), ee = new j.Vector3(), te = new j.Quaternion(), ne = new j.Vector3();
11
- function re(e, t) {
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 = []) {
12
12
  if (t.kind === "fixed") return 0;
13
- if (t.kind === "prismatic") return e.mass;
14
- I.fromArray(t.axis).normalize(), R.fromArray(e.inertiaOrientation).invert();
15
- let n = I.clone().applyQuaternion(R), [r, i, a] = e.inertiaDiagonal, o = r * n.x * n.x + i * n.y * n.y + a * n.z * n.z;
16
- L.fromArray(e.centerOfMass);
17
- let s = L.dot(I);
18
- return o + e.mass * (L.lengthSq() - s * s);
13
+ let r = n.length > 0 ? [e, ...n] : [e];
14
+ if (t.kind === "prismatic") {
15
+ let t = 0;
16
+ for (let n of r) n.isKinematic && n !== e || (t += n.mass);
17
+ return t;
18
+ }
19
+ z.fromArray(t.axis).normalize(), n.length > 0 && x(e, ae).invert();
20
+ let i = 0;
21
+ for (let t of r) {
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);
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);
28
+ }
29
+ return i;
19
30
  }
20
- function ie(e, t) {
21
- if (e.kind === "fixed" || t <= 0) return;
22
- let n = e.drive, r = n?.mode === "force";
23
- if (r && !(e.inertia > 0)) throw new v(`Joint "${e.nodeName}" has force-mode drive but non-positive effective inertia ${e.inertia}`);
24
- let i = r ? 1 / e.inertia : 1, a = e.positionTarget !== null && n?.stiffness !== void 0 ? n.stiffness * i : 0, o = n?.damping === void 0 ? 0 : n.damping * i, s = 0, c = 0, l = 0;
25
- e.limits && e.limitStiffness !== null && (e.q < e.limits[0] ? l = e.limits[0] : e.q > e.limits[1] && (l = e.limits[1]), (e.q < e.limits[0] || e.q > e.limits[1]) && (s = e.limitStiffness * (r ? i : 1), c = e.limitDamping * (r ? i : 1)));
26
- let u = e.positionTarget ?? 0, d = (e.v + t * (a * (u - e.q) + o * e.velocityTarget + s * (l - e.q))) / (1 + t * (o + c) + t * t * (a + s));
27
- if (r && n?.maxForce !== void 0) {
28
- let r = n.maxForce / e.inertia, i = (d - e.v) / t;
29
- Math.abs(i) > r && (d = e.v + Math.sign(i) * r * t);
31
+ function de(t, n) {
32
+ if (t.kind === "fixed" || !(n > 0)) return;
33
+ let r = t.drive, i = r?.mode === "force", a = t.limits !== null && t.limitStiffness !== null;
34
+ if ((i || a) && !(t.inertia > 0)) throw new e(`Joint "${t.nodeName}" requires positive effective inertia (got ${t.inertia})`);
35
+ let o = i ? 1 / t.inertia : 1, s = t.positionTarget !== null && r?.stiffness !== void 0 ? r.stiffness * o : 0, c = r?.damping === void 0 ? 0 : r.damping * o, l = 0, u = 0, d = 0;
36
+ if (t.limits && t.limitStiffness !== null && (t.q < t.limits[0] || t.q > t.limits[1])) {
37
+ d = t.q < t.limits[0] ? t.limits[0] : t.limits[1];
38
+ let e = 1 / t.inertia;
39
+ l = t.limitStiffness * e, u = t.limitDamping * e;
40
+ }
41
+ let f = t.positionTarget ?? 0, p = (t.v + n * (s * (f - t.q) + c * t.velocityTarget + l * (d - t.q))) / (1 + n * (c + u) + n * n * (s + l));
42
+ if (r?.maxForce !== void 0) {
43
+ if (!(r.maxForce >= 0)) throw new e(`Joint "${t.nodeName}" has negative drive.maxForce ${r.maxForce}`);
44
+ let a = i ? r.maxForce / t.inertia : r.maxForce, o = s * (f - (t.q + n * p)) + c * (t.velocityTarget - p);
45
+ if (Math.abs(o) > a) {
46
+ let e = Math.sign(o) * a;
47
+ p = (t.v + n * (e + l * (d - t.q))) / (1 + n * u + n * n * l);
48
+ }
30
49
  }
31
- e.v = d, e.q += d * t, e.limits && (e.q < e.limits[0] ? (e.q = e.limits[0], e.v < 0 && (e.v = 0)) : e.q > e.limits[1] && (e.q = e.limits[1], e.v > 0 && (e.v = 0)));
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)));
32
51
  }
33
- var ae = 1e-7;
34
- function oe(e, t) {
52
+ var fe = 1e-7;
53
+ function pe(e, t) {
35
54
  if (e.stamp === t) return;
36
- e.parent && e.parent.stamp !== t && oe(e.parent, t), e.stamp = t;
55
+ e.parent && e.parent.stamp !== t && pe(e.parent, t), e.stamp = t;
37
56
  let n = e.parent !== null && e.parent.dirtyStamp === t, r = e.colliders.every((e) => e.ref.current !== null);
38
- if (e.lastWrittenQ === void 0 || Math.abs(e.q - e.lastWrittenQ) > ae || n) {
39
- e.dirtyStamp = t, r && (e.lastWrittenQ = e.q), e.kind === "revolute" ? (R.setFromAxisAngle(e.axis, e.q), e.object.quaternion.copy(e.restQuaternion).multiply(R), e.object.position.copy(e.restPosition), z.makeRotationFromQuaternion(R)) : e.kind === "prismatic" ? (I.copy(e.axis).multiplyScalar(e.q), e.object.quaternion.copy(e.restQuaternion), e.object.position.copy(I).applyQuaternion(e.restQuaternion).add(e.restPosition), z.makeTranslation(I.x, I.y, I.z)) : z.identity(), e.parent ? e.current.multiplyMatrices(e.parent.current, e.restRelParent) : e.current.copy(e.restRelParent), e.current.multiply(z);
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);
40
59
  for (let t of e.colliders) {
41
60
  let n = t.ref.current;
42
- n && (B.multiplyMatrices(e.current, t.local).decompose(ee, te, ne), n.setTranslationWrtParent(ee), n.setRotationWrtParent(te));
61
+ n && (ce.multiplyMatrices(e.current, t.local).decompose(V, H, le), n.setTranslationWrtParent(V), n.setRotationWrtParent(H));
43
62
  }
44
63
  }
45
64
  }
46
65
  // src/PhysicsWorld.tsx
47
- function se({ paused: e, timeScale: t, maxDelta: n, joints: r }) {
48
- let { step: i, world: a } = A(), o = T(0);
49
- return E((s, c) => {
50
- if (e || !(t > 0)) return;
51
- let l = Math.min(Math.max(c, 0), Math.max(0, n)) * t;
52
- if (l > 0) {
53
- if (r.size > 0) {
54
- let e = ++o.current;
55
- for (let e of r) ie(e, l);
56
- for (let t of r) oe(t, e);
57
- }
58
- a.timestep = l, i(l);
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;
77
+ else if (i.current = m, s.timestep = m, r.size > 0) {
78
+ let e = ++c.current;
79
+ for (let e of r) de(e, m);
80
+ for (let t of r) pe(t, e);
59
81
  }
60
- }), null;
82
+ }, -.5), null;
61
83
  }
62
- function ce({ paused: e = !1, timeScale: t = 1, maxDelta: r = 1 / 30, gravity: i = [
84
+ function ge({ dtRef: e }) {
85
+ let { step: t } = N();
86
+ return k(() => {
87
+ let n = e.current;
88
+ n > 0 && t(n);
89
+ }, 0), null;
90
+ }
91
+ function _e({ paused: e = !1, timeScale: n = 1, maxDelta: r = 1 / 30, gravity: i = [
63
92
  0,
64
93
  -9.81,
65
94
  0
66
- ], children: a, ...o }) {
67
- let s = w(() => /* @__PURE__ */ new Set(), []), c = w(() => [
95
+ ], 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(() => [
68
97
  i[0],
69
98
  i[1],
70
99
  i[2]
@@ -72,39 +101,52 @@ function ce({ paused: e = !1, timeScale: t = 1, maxDelta: r = 1 / 30, gravity: i
72
101
  i[0],
73
102
  i[1],
74
103
  i[2]
75
- ]);
76
- return /* @__PURE__ */ M(y.Provider, {
77
- value: s,
78
- children: /* @__PURE__ */ M(n.Provider, {
79
- value: c,
80
- children: /* @__PURE__ */ N(O, {
81
- ...o,
82
- paused: !0,
83
- timeStep: "vary",
84
- gravity: i,
85
- children: [/* @__PURE__ */ M(se, {
86
- paused: e,
87
- timeScale: t,
88
- maxDelta: r,
89
- joints: s
90
- }), a]
104
+ ]), m = !e && u && (typeof n != "number" || n > 0) && (typeof r != "number" || r > 0);
105
+ return /* @__PURE__ */ F(C.Provider, {
106
+ value: c,
107
+ children: /* @__PURE__ */ F(S.Provider, {
108
+ value: p,
109
+ children: /* @__PURE__ */ F(a.Provider, {
110
+ value: m,
111
+ children: /* @__PURE__ */ F(t.Provider, {
112
+ value: l,
113
+ children: /* @__PURE__ */ I(j, {
114
+ ...s,
115
+ paused: !0,
116
+ timeStep: "vary",
117
+ gravity: i,
118
+ children: [
119
+ /* @__PURE__ */ F(he, {
120
+ paused: e,
121
+ timeScale: n,
122
+ maxDelta: r,
123
+ joints: c,
124
+ dtRef: l,
125
+ refActiveRef: f,
126
+ setRefActive: d
127
+ }),
128
+ o,
129
+ /* @__PURE__ */ F(ge, { dtRef: l })
130
+ ]
131
+ })
132
+ })
91
133
  })
92
134
  })
93
135
  });
94
136
  }
95
137
  // src/khrGlb.ts
96
- var le = 1179937895, ue = 1313821514, de = 5130562;
97
- function fe(e) {
98
- if (e.byteLength < 20) throw new v("GLB buffer shorter than 20-byte header");
99
- let t = new DataView(e);
100
- if (t.getUint32(0, !0) !== 1179937895) throw new v("Invalid GLB magic");
101
- if (t.getUint32(4, !0) !== 2) throw new v("Unsupported glTF version");
102
- let n = t.getUint32(12, !0);
103
- if (t.getUint32(16, !0) !== 1313821514) throw new v("Missing GLB JSON chunk");
104
- if (20 + n > e.byteLength) throw new v("Truncated GLB JSON chunk");
105
- return n;
138
+ var ve = 1179937895, ye = 1313821514, be = 5130562;
139
+ function xe(t) {
140
+ if (t.byteLength < 20) throw new e("GLB buffer shorter than 20-byte header");
141
+ let n = new DataView(t);
142
+ if (n.getUint32(0, !0) !== 1179937895) throw new e("Invalid GLB magic");
143
+ if (n.getUint32(4, !0) !== 2) throw new e("Unsupported glTF version");
144
+ let r = n.getUint32(12, !0);
145
+ if (n.getUint32(16, !0) !== 1313821514) throw new e("Missing GLB JSON chunk");
146
+ if (20 + r > t.byteLength) throw new e("Truncated GLB JSON chunk");
147
+ return r;
106
148
  }
107
- function pe() {
149
+ function Se() {
108
150
  if (globalThis.FileReader !== void 0) return;
109
151
  class e {
110
152
  result = null;
@@ -131,28 +173,28 @@ function pe() {
131
173
  }
132
174
  globalThis.FileReader = e;
133
175
  }
134
- function me(e) {
176
+ function Ce(e) {
135
177
  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);
136
- return a.setUint32(0, le, !0), a.setUint32(4, 2, !0), a.setUint32(8, r, !0), a.setUint32(12, n, !0), a.setUint32(16, ue, !0), o.set(t, 20), o.fill(32, 20 + t.byteLength, 20 + n), 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;
137
179
  }
138
- function he(e, t) {
139
- let n = e instanceof ArrayBuffer ? e : e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), r = fe(n), i = new DataView(n), a;
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;
140
182
  try {
141
- a = JSON.parse(new TextDecoder().decode(new Uint8Array(n, 20, r)));
183
+ o = JSON.parse(new TextDecoder().decode(new Uint8Array(r, 20, i)));
142
184
  } catch {
143
- throw new v("Malformed GLB JSON chunk");
185
+ throw new e("Malformed GLB JSON chunk");
144
186
  }
145
- t(a);
146
- let o = new TextEncoder().encode(JSON.stringify(a)), s = o.byteLength + 3 & -4, c = 20 + r, l = c + 8 <= n.byteLength, u = l ? Math.min(i.getUint32(c, !0), n.byteLength - (c + 8)) : 0, d = l ? i.getUint32(c + 4, !0) : de, f = l ? new Uint8Array(n, c + 8, u) : /* @__PURE__ */ new Uint8Array(), p = f.byteLength + 3 & -4, m = 20 + s + (l ? 8 + p : 0), h = new ArrayBuffer(m), g = new DataView(h), _ = new Uint8Array(h);
147
- return g.setUint32(0, le, !0), g.setUint32(4, 2, !0), g.setUint32(8, m, !0), g.setUint32(12, s, !0), g.setUint32(16, ue, !0), _.set(o, 20), _.fill(32, 20 + o.byteLength, 20 + s), l && (g.setUint32(20 + s, p, !0), g.setUint32(24 + s, d, !0), _.set(f, 28 + s)), h;
187
+ 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;
148
190
  }
149
191
  // src/khrExtras.ts
150
- var ge = /* @__PURE__ */ new WeakMap();
151
- function _e(e, t) {
152
- ge.set(e, t);
192
+ var Te = /* @__PURE__ */ new WeakMap();
193
+ function Ee(e, t) {
194
+ Te.set(e, t);
153
195
  }
154
- function ve(e, t, n, r) {
155
- let i = ge.get(t.scene);
196
+ function De(e, t, n, r) {
197
+ let i = Te.get(t.scene);
156
198
  if (i) {
157
199
  if (n) for (let t = 0; t < e.bodies.length; t++) {
158
200
  let r = i.bodies[t], a = e.bodies[t];
@@ -175,264 +217,264 @@ function ve(e, t, n, r) {
175
217
  }
176
218
  }
177
219
  }
178
- var V = new j.Vector3(), H = new j.Quaternion(), ye = new j.Quaternion();
179
- function be(e, t) {
180
- return e.updateWorldMatrix(!0, !1), e.getWorldQuaternion(H), t && (t.updateWorldMatrix(!0, !1), H.premultiply(t.getWorldQuaternion(ye).invert())), H.lengthSq() > 0 ? H.normalize() : H.identity(), [
181
- H.x || 0,
182
- H.y || 0,
183
- H.z || 0,
184
- H.w || 0
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(), [
223
+ U.x || 0,
224
+ U.y || 0,
225
+ U.z || 0,
226
+ U.w || 0
185
227
  ];
186
228
  }
187
- var U = (e) => typeof e == "object" && !!e && !Array.isArray(e), W = (e) => typeof e == "number" && Number.isFinite(e);
188
- function G(e, t, n, r = !1) {
189
- let i = e[t];
190
- if (i !== void 0) {
191
- if (!W(i) || (r ? i <= 0 : i < 0)) throw new v(`ecctrlWheel "${n}" has invalid ${t}: ecctrlWheel.${t}`);
192
- return i;
229
+ var W = (e) => typeof e == "object" && !!e && !Array.isArray(e), G = (e) => typeof e == "number" && Number.isFinite(e);
230
+ function K(t, n, r, i = !1) {
231
+ let a = t[n];
232
+ if (a !== void 0) {
233
+ if (!G(a) || (i ? a <= 0 : a < 0)) throw new e(`ecctrlWheel "${r}" has invalid ${n}: ecctrlWheel.${n}`);
234
+ return a;
193
235
  }
194
236
  }
195
- function K(e, t, n, r) {
196
- let i = e[t];
197
- if (i !== void 0) {
198
- if (typeof i != "boolean") throw new v(`${n} "${r}" has non-boolean ${n}.${t}`);
199
- return i;
237
+ function je(t, n, r, i) {
238
+ let a = t[n];
239
+ if (a !== void 0) {
240
+ if (typeof a != "boolean") throw new e(`${r} "${i}" has non-boolean ${r}.${n}`);
241
+ return a;
200
242
  }
201
243
  }
202
- function xe(e, t, n) {
203
- if (e !== void 0) {
204
- if (!U(e) || !Array.isArray(e.points) || e.points.length === 0) throw new v(`ecctrlWheel "${n}" has invalid ecctrlWheel.${t}`);
205
- for (let r of e.points) if (!U(r) || !W(r.x) || !W(r.y)) throw new v(`ecctrlWheel "${n}" has invalid point in ecctrlWheel.${t}`);
206
- if (e.samples !== void 0 && (!W(e.samples) || e.samples <= 0)) throw new v(`ecctrlWheel "${n}" has invalid samples in ecctrlWheel.${t}`);
207
- return e;
244
+ function Me(t, n, r) {
245
+ if (t !== void 0) {
246
+ if (!W(t) || !Array.isArray(t.points) || t.points.length === 0) throw new e(`ecctrlWheel "${r}" has invalid ecctrlWheel.${n}`);
247
+ 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}`);
248
+ if (t.samples !== void 0 && (!G(t.samples) || t.samples <= 0)) throw new e(`ecctrlWheel "${r}" has invalid samples in ecctrlWheel.${n}`);
249
+ return t;
208
250
  }
209
251
  }
210
- function Se(e, t, n, r, i) {
211
- if (n.socketId !== void 0 && (typeof n.socketId != "string" || n.socketId.length === 0)) throw new v(`Node "${t}" has invalid extras.socketId`);
212
- let a = e.getWorldPosition(new j.Vector3()), o = [
213
- a.x,
214
- a.y,
215
- a.z
216
- ], s = i?.(t, n);
217
- if (s || n.isIkAnchor === !0 || typeof n.socketId == "string") {
218
- let e = typeof s == "string" && s.length > 0 ? s : n.socketId ?? t;
219
- r[e] = [...o];
252
+ function Ne(t, n, r, i, a) {
253
+ 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 = [
255
+ o.x,
256
+ o.y,
257
+ o.z
258
+ ], c = a?.(n, r);
259
+ if (c || r.isIkAnchor === !0 || typeof r.socketId == "string") {
260
+ let e = typeof c == "string" && c.length > 0 ? c : r.socketId ?? n;
261
+ i[e] = [...s];
220
262
  }
221
- let c;
222
- if (n.contactDots !== void 0) {
223
- if (!Array.isArray(n.contactDots)) throw new v(`Node "${t}" has invalid extras.contactDots (expected array)`);
224
- e.getWorldQuaternion(H), c = [];
225
- for (let e of n.contactDots) {
226
- if (!U(e) || typeof e.role != "string" || e.role.length === 0 || !Array.isArray(e.pos) || e.pos.length !== 3 || !e.pos.every(W)) throw new v(`Node "${t}" has invalid entry in extras.contactDots`);
227
- V.set(e.pos[0], e.pos[1], e.pos[2]).applyQuaternion(H).add(a);
228
- let n = [
229
- V.x,
230
- V.y,
231
- V.z
263
+ let l;
264
+ if (r.contactDots !== void 0) {
265
+ if (!Array.isArray(r.contactDots)) throw new e(`Node "${n}" has invalid extras.contactDots (expected array)`);
266
+ t.getWorldQuaternion(U), l = [];
267
+ for (let t of r.contactDots) {
268
+ 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);
270
+ let r = [
271
+ Oe.x,
272
+ Oe.y,
273
+ Oe.z
232
274
  ];
233
- r[e.role] = n, c.push([e.role, n]);
275
+ i[t.role] = r, l.push([t.role, r]);
234
276
  }
235
277
  }
236
278
  return {
237
- nodeName: t,
238
- extras: n,
239
- worldPosition: o,
240
- ...c ? { contactDots: c } : {}
279
+ nodeName: n,
280
+ extras: r,
281
+ worldPosition: s,
282
+ ...l ? { contactDots: l } : {}
241
283
  };
242
284
  }
243
- function Ce(e, t, n, r) {
244
- if (g(e, t), !U(n)) throw new v(`ecctrlWheel "${t}" must be an object`);
245
- let i = (e) => {
246
- let r = n[e];
247
- if (!W(r) || r <= 0) throw new v(`ecctrlWheel "${t}" is missing valid ecctrlWheel.${e}`);
248
- return r;
249
- }, a = (e) => {
250
- let r = n[e];
251
- if (!W(r) || r < 0) throw new v(`ecctrlWheel "${t}" is missing valid ecctrlWheel.${e}`);
252
- return r;
253
- }, o = (e) => {
254
- let r = n[e];
255
- if (typeof r != "boolean") throw new v(`ecctrlWheel "${t}" is missing boolean ecctrlWheel.${e}`);
256
- return r;
257
- }, s = i("radius"), c = i("width"), l = a("travel"), u = a("sag");
258
- if (u > l) throw new v(`ecctrlWheel "${t}" has invalid ecctrlWheel.sag (${u}) > ecctrlWheel.travel (${l})`);
259
- let d = o("steer"), f = o("drive"), p = o("brake"), m = new j.Box3().setFromObject(e), h = m.isEmpty() ? e.getWorldPosition(new j.Vector3()) : m.getCenter(new j.Vector3());
285
+ function Pe(t, n, r, i) {
286
+ if (y(t, n), !W(r)) throw new e(`ecctrlWheel "${n}" must be an object`);
287
+ let a = (t) => {
288
+ let i = r[t];
289
+ if (!G(i) || i <= 0) throw new e(`ecctrlWheel "${n}" is missing valid ecctrlWheel.${t}`);
290
+ return i;
291
+ }, o = (t) => {
292
+ let i = r[t];
293
+ if (!G(i) || i < 0) throw new e(`ecctrlWheel "${n}" is missing valid ecctrlWheel.${t}`);
294
+ return i;
295
+ }, s = (t) => {
296
+ let i = r[t];
297
+ if (typeof i != "boolean") throw new e(`ecctrlWheel "${n}" is missing boolean ecctrlWheel.${t}`);
298
+ return i;
299
+ }, c = a("radius"), l = a("width"), u = o("travel"), d = o("sag");
300
+ 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());
260
302
  return {
261
- nodeName: t,
262
- object: e,
303
+ nodeName: n,
304
+ object: t,
263
305
  position: [
264
- h.x,
265
- h.y,
266
- h.z
306
+ g.x,
307
+ g.y,
308
+ g.z
267
309
  ],
268
- quaternion: be(e, r),
269
- radius: s,
270
- width: c,
271
- steer: d,
272
- steerInvert: K(n, "steerInvert", "ecctrlWheel", t),
273
- drive: f,
274
- driveInvert: K(n, "driveInvert", "ecctrlWheel", t),
275
- brake: p,
276
- travel: l,
277
- sag: u,
278
- springK: G(n, "springK", t),
279
- dampingC: G(n, "dampingC", t),
280
- maxBrakeTorque: G(n, "maxBrakeTorque", t),
281
- rollingResistanceCoef: G(n, "rollingResistanceCoef", t),
282
- wheelDensity: G(n, "wheelDensity", t, !0),
283
- driveTorqueWeight: G(n, "driveTorqueWeight", t),
284
- tireGripFactor: G(n, "tireGripFactor", t),
285
- latFrictionEllipseScale: G(n, "latFrictionEllipseScale", t),
286
- relaxLngRate: G(n, "relaxLngRate", t),
287
- relaxLatRate: G(n, "relaxLatRate", t),
288
- lngSlipRatioCurveData: xe(n.lngSlipRatioCurveData, "lngSlipRatioCurveData", t),
289
- latSlipRatioCurveData: xe(n.latSlipRatioCurveData, "latSlipRatioCurveData", t)
310
+ quaternion: Ae(t, i),
311
+ radius: c,
312
+ width: l,
313
+ steer: f,
314
+ steerInvert: je(r, "steerInvert", "ecctrlWheel", n),
315
+ drive: p,
316
+ driveInvert: je(r, "driveInvert", "ecctrlWheel", n),
317
+ brake: m,
318
+ travel: u,
319
+ sag: d,
320
+ springK: K(r, "springK", n),
321
+ dampingC: K(r, "dampingC", n),
322
+ maxBrakeTorque: K(r, "maxBrakeTorque", n),
323
+ rollingResistanceCoef: K(r, "rollingResistanceCoef", n),
324
+ wheelDensity: K(r, "wheelDensity", n, !0),
325
+ driveTorqueWeight: K(r, "driveTorqueWeight", n),
326
+ tireGripFactor: K(r, "tireGripFactor", n),
327
+ latFrictionEllipseScale: K(r, "latFrictionEllipseScale", n),
328
+ relaxLngRate: K(r, "relaxLngRate", n),
329
+ relaxLatRate: K(r, "relaxLatRate", n),
330
+ lngSlipRatioCurveData: Me(r.lngSlipRatioCurveData, "lngSlipRatioCurveData", n),
331
+ latSlipRatioCurveData: Me(r.latSlipRatioCurveData, "latSlipRatioCurveData", n)
290
332
  };
291
333
  }
292
- function we(e, t, n, r) {
293
- if (g(e, t), !U(n)) throw new v(`ecctrlPropeller "${t}" must be an object`);
294
- if (!W(n.maxThrust) || n.maxThrust <= 0) throw new v(`ecctrlPropeller "${t}" is missing positive finite ecctrlPropeller.maxThrust`);
295
- let i;
296
- if (n.torqueRatio !== void 0) {
297
- if (!W(n.torqueRatio)) throw new v(`ecctrlPropeller "${t}" has invalid ecctrlPropeller.torqueRatio`);
298
- i = n.torqueRatio;
334
+ function Fe(t, n, r, i) {
335
+ if (y(t, n), !W(r)) throw new e(`ecctrlPropeller "${n}" must be an object`);
336
+ if (!G(r.maxThrust) || r.maxThrust <= 0) throw new e(`ecctrlPropeller "${n}" is missing positive finite ecctrlPropeller.maxThrust`);
337
+ let a;
338
+ if (r.torqueRatio !== void 0) {
339
+ if (!G(r.torqueRatio)) throw new e(`ecctrlPropeller "${n}" has invalid ecctrlPropeller.torqueRatio`);
340
+ a = r.torqueRatio;
299
341
  }
300
- let a = new j.Box3().setFromObject(e), o = a.isEmpty() ? e.getWorldPosition(new j.Vector3()) : a.getCenter(new j.Vector3());
342
+ let o = new P.Box3().setFromObject(t), s = o.isEmpty() ? t.getWorldPosition(new P.Vector3()) : o.getCenter(new P.Vector3());
301
343
  return {
302
- nodeName: t,
303
- object: e,
344
+ nodeName: n,
345
+ object: t,
304
346
  position: [
305
- o.x,
306
- o.y,
307
- o.z
347
+ s.x,
348
+ s.y,
349
+ s.z
308
350
  ],
309
- quaternion: be(e, r),
310
- maxThrust: n.maxThrust,
311
- torqueRatio: i,
312
- invertThrust: K(n, "invertThrust", "ecctrlPropeller", t),
313
- invertTorque: K(n, "invertTorque", "ecctrlPropeller", t)
351
+ quaternion: Ae(t, i),
352
+ maxThrust: r.maxThrust,
353
+ torqueRatio: a,
354
+ invertThrust: je(r, "invertThrust", "ecctrlPropeller", n),
355
+ invertTorque: je(r, "invertTorque", "ecctrlPropeller", n)
314
356
  };
315
357
  }
316
358
  // src/khrParsers.ts
317
- var Te = /* @__PURE__ */ new Map([["default", 0]]), Ee = 1, De = (e) => typeof e == "object" && !!e && !Array.isArray(e), q = (e) => typeof e == "number" && Number.isFinite(e) && e > 0, Oe = (e) => typeof e == "number" && Number.isFinite(e) && e >= 0;
318
- function J(e, t, n = !1) {
319
- if (e !== void 0) {
320
- if (typeof e != "number" || !Number.isFinite(e) || n && e < 0) throw new v(`Invalid ${t}`);
321
- return e;
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;
360
+ function J(t, n, r = !1) {
361
+ if (t !== void 0) {
362
+ if (typeof t != "number" || !Number.isFinite(t) || r && t < 0) throw new e(`Invalid ${n}`);
363
+ return t;
322
364
  }
323
365
  }
324
- function ke(e, t) {
325
- if (!De(e)) throw new v(`KHR_implicit_shapes[${t}] must be an object`);
326
- let n = e.type;
327
- if (n === "box" && e.box && typeof e.box == "object") {
328
- let n = e.box.size;
329
- if (!Array.isArray(n) || n.length !== 3 || !n.every(q)) throw new v(`KHR_implicit_shapes[${t}] invalid box.size`);
366
+ function Be(t, n) {
367
+ if (!Re(t)) throw new e(`KHR_implicit_shapes[${n}] must be an object`);
368
+ let r = t.type;
369
+ if (r === "box" && t.box && typeof t.box == "object") {
370
+ let r = t.box.size;
371
+ if (!Array.isArray(r) || r.length !== 3 || !r.every(q)) throw new e(`KHR_implicit_shapes[${n}] invalid box.size`);
330
372
  return {
331
373
  type: "box",
332
374
  size: [
333
- n[0],
334
- n[1],
335
- n[2]
375
+ r[0],
376
+ r[1],
377
+ r[2]
336
378
  ]
337
379
  };
338
380
  }
339
- if (n === "sphere" && e.sphere && typeof e.sphere == "object") {
340
- let n = e.sphere.radius;
341
- if (!q(n)) throw new v(`KHR_implicit_shapes[${t}] invalid sphere.radius`);
381
+ if (r === "sphere" && t.sphere && typeof t.sphere == "object") {
382
+ let r = t.sphere.radius;
383
+ if (!q(r)) throw new e(`KHR_implicit_shapes[${n}] invalid sphere.radius`);
342
384
  return {
343
385
  type: "sphere",
344
- radius: n
386
+ radius: r
345
387
  };
346
388
  }
347
- if ((n === "cylinder" || n === "capsule") && e[n] && typeof e[n] == "object") {
348
- let r = e[n];
349
- if (!q(r.height)) throw new v(`KHR_implicit_shapes[${t}] invalid ${n}.height`);
350
- if (!q(r.radiusTop)) throw new v(`KHR_implicit_shapes[${t}] invalid ${n}.radiusTop`);
351
- if (!q(r.radiusBottom)) throw new v(`KHR_implicit_shapes[${t}] invalid ${n}.radiusBottom`);
352
- if (Math.abs(r.radiusTop - r.radiusBottom) > 1e-6) throw new v(`KHR_implicit_shapes[${t}] tapered ${n} (${r.radiusTop} !== ${r.radiusBottom}) is unsupported`);
389
+ if ((r === "cylinder" || r === "capsule") && t[r] && typeof t[r] == "object") {
390
+ let i = t[r];
391
+ if (!q(i.height)) throw new e(`KHR_implicit_shapes[${n}] invalid ${r}.height`);
392
+ if (!q(i.radiusTop)) throw new e(`KHR_implicit_shapes[${n}] invalid ${r}.radiusTop`);
393
+ if (!q(i.radiusBottom)) throw new e(`KHR_implicit_shapes[${n}] invalid ${r}.radiusBottom`);
394
+ if (Math.abs(i.radiusTop - i.radiusBottom) > 1e-6) throw new e(`KHR_implicit_shapes[${n}] tapered ${r} (${i.radiusTop} !== ${i.radiusBottom}) is unsupported`);
353
395
  return {
354
- type: n,
355
- height: r.height,
356
- radiusTop: r.radiusTop,
357
- radiusBottom: r.radiusBottom
396
+ type: r,
397
+ height: i.height,
398
+ radiusTop: i.radiusTop,
399
+ radiusBottom: i.radiusBottom
358
400
  };
359
401
  }
360
- throw new v(`KHR_implicit_shapes[${t}] unsupported shape type "${n}"`);
402
+ throw new e(`KHR_implicit_shapes[${n}] unsupported shape type "${r}"`);
361
403
  }
362
- function Ae(e, t, n) {
363
- if (t === void 0) return {};
364
- if (typeof t != "number" || !Number.isInteger(t) || t < 0 || t >= e.length) throw new v(`Node "${n}" references out-of-bounds physicsMaterial ${String(t)}`);
365
- let r = e[t];
366
- if (!De(r)) throw new v(`Invalid physicsMaterials[${t}] on "${n}"`);
367
- let i = J(r.dynamicFriction, `physicsMaterials[${t}].dynamicFriction`, !0), a = J(r.staticFriction, `physicsMaterials[${t}].staticFriction`, !0), o = J(r.restitution, `physicsMaterials[${t}].restitution`, !0);
404
+ function Ve(t, n, r) {
405
+ if (n === void 0) return {};
406
+ 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
+ let i = t[n];
408
+ if (!Re(i)) throw new e(`Invalid physicsMaterials[${n}] on "${r}"`);
409
+ 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);
368
410
  return {
369
- ...i !== void 0 || a !== void 0 ? { friction: i ?? a } : {},
370
- ...o === void 0 ? {} : { restitution: o }
411
+ ...a !== void 0 || o !== void 0 ? { friction: a ?? o } : {},
412
+ ...s === void 0 ? {} : { restitution: s }
371
413
  };
372
414
  }
373
- function je(t, n, r) {
374
- if (t.isKinematic !== void 0 && typeof t.isKinematic != "boolean") throw new v(`Node "${r}" has non-boolean motion.isKinematic`);
375
- let i = !n || !!t.isKinematic, a = 0;
376
- if (!i) {
377
- if (!q(t.mass)) throw new v(`Dynamic node "${r}" is missing positive finite motion.mass`);
378
- a = t.mass;
415
+ function He(t, n, i) {
416
+ if (t.isKinematic !== void 0 && typeof t.isKinematic != "boolean") throw new e(`Node "${i}" has non-boolean motion.isKinematic`);
417
+ let a = !n || !!t.isKinematic, o = 0;
418
+ if (!a) {
419
+ if (!q(t.mass)) throw new e(`Dynamic node "${i}" is missing positive finite motion.mass`);
420
+ o = t.mass;
379
421
  } else if (t.mass !== void 0) {
380
- if (!Oe(t.mass)) throw new v(`Kinematic node "${r}" has invalid motion.mass`);
381
- a = t.mass;
422
+ if (!ze(t.mass)) throw new e(`Kinematic node "${i}" has invalid motion.mass`);
423
+ o = t.mass;
382
424
  }
383
- let o = t.centerOfMass === void 0 ? [
425
+ let s = t.centerOfMass === void 0 ? [
384
426
  0,
385
427
  0,
386
428
  0
387
- ] : e(t.centerOfMass, `${r}.motion.centerOfMass`), s = t.inertiaOrientation === void 0 ? [
429
+ ] : r(t.centerOfMass, `${i}.motion.centerOfMass`), c = t.inertiaOrientation === void 0 ? [
388
430
  0,
389
431
  0,
390
432
  0,
391
433
  1
392
- ] : _(t.inertiaOrientation, `${r}.motion.inertiaOrientation`), c = [
434
+ ] : b(t.inertiaOrientation, `${i}.motion.inertiaOrientation`), l = [
393
435
  0,
394
436
  0,
395
437
  0
396
- ], l = t.inertiaDiagonal !== void 0;
397
- if (l && (c = e(t.inertiaDiagonal, `${r}.motion.inertiaDiagonal`), c.some((e) => i ? e < 0 : e <= 0))) throw new v(`Node "${r}" has invalid motion.inertiaDiagonal`);
398
- let u = t.linearVelocity === void 0 ? void 0 : e(t.linearVelocity, `${r}.motion.linearVelocity`), d = t.angularVelocity === void 0 ? void 0 : e(t.angularVelocity, `${r}.motion.angularVelocity`), f = J(t.gravityFactor, `${r}.motion.gravityFactor`);
438
+ ], u = t.inertiaDiagonal !== void 0;
439
+ if (u && (l = r(t.inertiaDiagonal, `${i}.motion.inertiaDiagonal`), l.some((e) => a ? e < 0 : e <= 0))) throw new e(`Node "${i}" has invalid motion.inertiaDiagonal`);
440
+ let d = t.linearVelocity === void 0 ? void 0 : r(t.linearVelocity, `${i}.motion.linearVelocity`), f = t.angularVelocity === void 0 ? void 0 : r(t.angularVelocity, `${i}.motion.angularVelocity`), p = J(t.gravityFactor, `${i}.motion.gravityFactor`);
399
441
  return {
400
- isKinematic: i,
401
- mass: a,
402
- centerOfMass: o,
403
- inertiaDiagonal: c,
404
- inertiaOrientation: s,
405
- hasExplicitInertia: l,
406
- ...u ? { linearVelocity: u } : {},
407
- ...d ? { angularVelocity: d } : {},
408
- ...f === void 0 ? {} : { gravityFactor: f }
442
+ isKinematic: a,
443
+ mass: o,
444
+ centerOfMass: s,
445
+ inertiaDiagonal: l,
446
+ inertiaOrientation: c,
447
+ hasExplicitInertia: u,
448
+ ...d ? { linearVelocity: d } : {},
449
+ ...f ? { angularVelocity: f } : {},
450
+ ...p === void 0 ? {} : { gravityFactor: p }
409
451
  };
410
452
  }
411
- function Me(e) {
412
- let t = (e) => {
413
- let t = Te.get(e);
414
- if (t !== void 0) return t;
415
- if (Ee > 15) throw new v(`Exceeded Rapier 16-group limit for collisionSystem "${e}"`);
416
- let n = Ee++;
417
- return Te.set(e, n), n;
418
- }, n = (e, n) => {
419
- if (e === void 0) return 0;
420
- if (!Array.isArray(e)) throw new v(`collisionFilter.${n} must be an array`);
421
- let r = 0;
422
- for (let i of e) {
423
- if (typeof i != "string" || i.length === 0) throw new v(`collisionFilter.${n} has invalid system`);
424
- r |= 1 << t(i);
453
+ function Ue(t) {
454
+ let n = (t) => {
455
+ let n = Ie.get(t);
456
+ 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;
460
+ }, r = (t, r) => {
461
+ if (t === void 0) return 0;
462
+ if (!Array.isArray(t)) throw new e(`collisionFilter.${r} must be an array`);
463
+ let i = 0;
464
+ for (let a of t) {
465
+ if (typeof a != "string" || a.length === 0) throw new e(`collisionFilter.${r} has invalid system`);
466
+ i |= 1 << n(a);
425
467
  }
426
- return r;
468
+ return i;
427
469
  };
428
- return e.map((e, t) => {
429
- if (!e || typeof e != "object" || Array.isArray(e)) throw new v(`collisionFilters[${t}] must be an object`);
430
- if (e.collideWithSystems !== void 0 && e.notCollideWithSystems !== void 0) throw new v(`collisionFilters[${t}] cannot specify both collideWithSystems and notCollideWithSystems`);
431
- let r = n(e.collisionSystems, "collisionSystems"), i = e.collideWithSystems === void 0 ? 65535 & ~n(e.notCollideWithSystems, "notCollideWithSystems") : n(e.collideWithSystems, "collideWithSystems");
432
- return (r & 65535) << 16 | i & 65535;
470
+ return t.map((t, n) => {
471
+ if (!t || typeof t != "object" || Array.isArray(t)) throw new e(`collisionFilters[${n}] must be an object`);
472
+ if (t.collideWithSystems !== void 0 && t.notCollideWithSystems !== void 0) throw new e(`collisionFilters[${n}] cannot specify both collideWithSystems and notCollideWithSystems`);
473
+ let i = r(t.collisionSystems, "collisionSystems"), a = t.collideWithSystems === void 0 ? 65535 & ~r(t.notCollideWithSystems, "notCollideWithSystems") : r(t.collideWithSystems, "collideWithSystems");
474
+ return (i & 65535) << 16 | a & 65535;
433
475
  });
434
476
  }
435
- var Ne = (e) => e === 0 ? [
477
+ var We = (e) => e === 0 ? [
436
478
  1,
437
479
  0,
438
480
  0
@@ -445,102 +487,102 @@ var Ne = (e) => e === 0 ? [
445
487
  0,
446
488
  1
447
489
  ];
448
- function Pe(e, t, n) {
449
- return e.map((e, r) => {
450
- let i = `physicsJoints[${t}].drives[${r}] on "${n}"`;
451
- if (!e || typeof e != "object" || Array.isArray(e)) throw new v(`${i} must be an object`);
452
- if (e.mode !== "force" && e.mode !== "acceleration") throw new v(`${i} missing valid drive.mode`);
453
- if (e.axis !== 0 && e.axis !== 1 && e.axis !== 2) throw new v(`${i} missing valid drive.axis (0|1|2)`);
454
- if (e.type !== void 0 && e.type !== "linear" && e.type !== "angular") throw new v(`${i} invalid drive.type`);
455
- let a = J(e.positionTarget, `${i} drive.positionTarget`), o = J(e.velocityTarget, `${i} drive.velocityTarget`);
456
- if (a === void 0 && o === void 0) throw new v(`${i} requires finite drive.positionTarget or drive.velocityTarget`);
457
- let s = J(e.stiffness, `${i} drive.stiffness`, !0), c = J(e.damping, `${i} drive.damping`, !0), l = J(e.maxForce, `${i} drive.maxForce`, !0);
490
+ function Ge(t, n, r) {
491
+ return t.map((t, i) => {
492
+ let a = `physicsJoints[${n}].drives[${i}] on "${r}"`;
493
+ if (!t || typeof t != "object" || Array.isArray(t)) throw new e(`${a} must be an object`);
494
+ if (t.mode !== "force" && t.mode !== "acceleration") throw new e(`${a} missing valid drive.mode`);
495
+ if (t.axis !== 0 && t.axis !== 1 && t.axis !== 2) throw new e(`${a} missing valid drive.axis (0|1|2)`);
496
+ if (t.type !== void 0 && t.type !== "linear" && t.type !== "angular") throw new e(`${a} invalid drive.type`);
497
+ let o = J(t.positionTarget, `${a} drive.positionTarget`), s = J(t.velocityTarget, `${a} drive.velocityTarget`);
498
+ if (o === void 0 && s === void 0) throw new e(`${a} requires finite drive.positionTarget or drive.velocityTarget`);
499
+ let c = J(t.stiffness, `${a} drive.stiffness`, !0), l = J(t.damping, `${a} drive.damping`, !0), u = J(t.maxForce, `${a} drive.maxForce`, !0);
458
500
  return {
459
- ...e.type ? { type: e.type } : {},
460
- mode: e.mode,
461
- axis: e.axis,
462
- ...a === void 0 ? {} : { positionTarget: a },
463
- ...o === void 0 ? {} : { velocityTarget: o },
464
- ...s === void 0 ? {} : { stiffness: s },
465
- ...c === void 0 ? {} : { damping: c },
466
- ...l === void 0 ? {} : { maxForce: l }
501
+ ...t.type ? { type: t.type } : {},
502
+ mode: t.mode,
503
+ axis: t.axis,
504
+ ...o === void 0 ? {} : { positionTarget: o },
505
+ ...s === void 0 ? {} : { velocityTarget: s },
506
+ ...c === void 0 ? {} : { stiffness: c },
507
+ ...l === void 0 ? {} : { damping: l },
508
+ ...u === void 0 ? {} : { maxForce: u }
467
509
  };
468
510
  });
469
511
  }
470
- function Fe(e, t, n, r, i, a, o, s = r.name) {
471
- let c = e[t];
472
- if (!De(c)) throw new v(`physicsJoints[${t}] out of bounds for "${n}"`);
473
- if (c.limits !== void 0 && !Array.isArray(c.limits)) throw new v(`physicsJoints[${t}].limits on "${n}" must be an array`);
474
- if (c.drives !== void 0 && !Array.isArray(c.drives)) throw new v(`physicsJoints[${t}].drives on "${n}" must be an array`);
475
- let l = c.limits ?? [], u = c.drives ?? [], d = [
512
+ function Ke(t, n, r, i, a, o, s, c = i.name) {
513
+ let l = t[n];
514
+ if (!Re(l)) throw new e(`physicsJoints[${n}] out of bounds for "${r}"`);
515
+ if (l.limits !== void 0 && !Array.isArray(l.limits)) throw new e(`physicsJoints[${n}].limits on "${r}" must be an array`);
516
+ if (l.drives !== void 0 && !Array.isArray(l.drives)) throw new e(`physicsJoints[${n}].drives on "${r}" must be an array`);
517
+ let u = l.limits ?? [], d = l.drives ?? [], f = [
476
518
  "unlimited",
477
519
  "unlimited",
478
520
  "unlimited"
479
- ], f = [
521
+ ], p = [
480
522
  "unlimited",
481
523
  "unlimited",
482
524
  "unlimited"
483
- ], p = [
525
+ ], m = [
484
526
  void 0,
485
527
  void 0,
486
528
  void 0
487
- ], m = [
529
+ ], h = [
488
530
  void 0,
489
531
  void 0,
490
532
  void 0
491
- ], h = (e, r, i, a) => {
492
- if (e === void 0) return;
493
- if (!Array.isArray(e)) throw new v(`physicsJoints[${t}].limits axes on "${n}" must be an array`);
494
- let o = e.map((e) => {
495
- if (e !== 0 && e !== 1 && e !== 2) throw new v(`physicsJoints[${t}].limits invalid axis ${String(e)} on "${n}"`);
496
- return e;
497
- }), s = J(r.min, `physicsJoints[${t}] limit.min on "${n}"`), c = J(r.max, `physicsJoints[${t}] limit.max on "${n}"`);
498
- if ((r.min !== void 0 || r.max !== void 0) && (s === void 0 || c === void 0)) throw new v(`physicsJoints[${t}].limits on "${n}" must specify both min and max`);
499
- if (s !== void 0 && c !== void 0 && s > c) throw new v(`physicsJoints[${t}] limit.min > limit.max on "${n}"`);
500
- let l = J(r.stiffness, `physicsJoints[${t}] limit.stiffness on "${n}"`, !0), u = J(r.damping, `physicsJoints[${t}] limit.damping on "${n}"`, !0), d = s !== void 0 && c !== void 0 && c - s <= 1e-6;
501
- if (!d && o.length > 1) throw new v(`physicsJoints[${t}] coupled multi-axis limit on "${n}" is unsupported`);
502
- for (let e of o) i[e] = d ? "locked" : s !== void 0 && c !== void 0 ? [s, c] : "unlimited", d || l === void 0 && u === void 0 || (a[e] = {
503
- ...l === void 0 ? {} : { stiffness: l },
504
- ...u === void 0 ? {} : { damping: u }
533
+ ], g = (t, i, a, o) => {
534
+ if (t === void 0) return;
535
+ if (!Array.isArray(t)) throw new e(`physicsJoints[${n}].limits axes on "${r}" must be an array`);
536
+ let s = t.map((t) => {
537
+ if (t !== 0 && t !== 1 && t !== 2) throw new e(`physicsJoints[${n}].limits invalid axis ${String(t)} on "${r}"`);
538
+ return t;
539
+ }), c = J(i.min, `physicsJoints[${n}] limit.min on "${r}"`), l = J(i.max, `physicsJoints[${n}] limit.max on "${r}"`);
540
+ if ((i.min !== void 0 || i.max !== void 0) && (c === void 0 || l === void 0)) throw new e(`physicsJoints[${n}].limits on "${r}" must specify both min and max`);
541
+ if (c !== void 0 && l !== void 0 && c > l) throw new e(`physicsJoints[${n}] limit.min > limit.max on "${r}"`);
542
+ let u = J(i.stiffness, `physicsJoints[${n}] limit.stiffness on "${r}"`, !0), d = J(i.damping, `physicsJoints[${n}] limit.damping on "${r}"`, !0), f = c !== void 0 && l !== void 0 && l - c <= 1e-6;
543
+ if (!f && s.length > 1) throw new e(`physicsJoints[${n}] coupled multi-axis limit on "${r}" is unsupported`);
544
+ for (let e of s) a[e] = f ? "locked" : c !== void 0 && l !== void 0 ? [c, l] : "unlimited", f || u === void 0 && d === void 0 || (o[e] = {
545
+ ...u === void 0 ? {} : { stiffness: u },
546
+ ...d === void 0 ? {} : { damping: d }
505
547
  });
506
548
  };
507
- for (let e of l) {
508
- if (!De(e)) throw new v(`physicsJoints[${t}].limits entry on "${n}" must be an object`);
509
- h(e.linearAxes, e, d, p), h(e.angularAxes, e, f, m);
549
+ for (let t of u) {
550
+ if (!Re(t)) throw new e(`physicsJoints[${n}].limits entry on "${r}" must be an object`);
551
+ g(t.linearAxes, t, f, m), g(t.angularAxes, t, p, h);
510
552
  }
511
- let g = [
553
+ let _ = [
512
554
  0,
513
555
  1,
514
556
  2
515
- ].filter((e) => d[e] !== "locked"), _ = [
557
+ ].filter((e) => f[e] !== "locked"), v = [
516
558
  0,
517
559
  1,
518
560
  2
519
- ].filter((e) => f[e] !== "locked"), y, b = [
561
+ ].filter((e) => p[e] !== "locked"), y, b = [
520
562
  0,
521
563
  1,
522
564
  0
523
565
  ], x = null, S;
524
- if (g.length === 0 && _.length === 0) y = "fixed";
525
- else if (g.length === 0 && _.length === 1) {
526
- y = "revolute", b = Ne(_[0]);
566
+ if (_.length === 0 && v.length === 0) y = "fixed";
567
+ else if (_.length === 0 && v.length === 1) {
568
+ y = "revolute", b = We(v[0]);
569
+ let e = p[v[0]];
570
+ x = Array.isArray(e) ? e : null, S = h[v[0]];
571
+ } else if (v.length === 0 && _.length === 1) {
572
+ y = "prismatic", b = We(_[0]);
527
573
  let e = f[_[0]];
528
574
  x = Array.isArray(e) ? e : null, S = m[_[0]];
529
- } else if (_.length === 0 && g.length === 1) {
530
- y = "prismatic", b = Ne(g[0]);
531
- let e = d[g[0]];
532
- x = Array.isArray(e) ? e : null, S = p[g[0]];
533
- } else throw new v(`physicsJoints[${t}] unsupported DOF (${g.length} lin, ${_.length} ang) on "${n}"`);
534
- let C = Pe(u, t, n), w = i.getWorldPosition(new j.Vector3()).sub(r.getWorldPosition(new j.Vector3())).applyQuaternion(r.getWorldQuaternion(new j.Quaternion()).invert());
575
+ } 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());
535
577
  return {
536
- index: t,
537
- nodeName: n,
538
- connectedNodeName: s,
578
+ index: n,
579
+ nodeName: r,
580
+ connectedNodeName: c,
539
581
  kind: y,
540
582
  axis: b,
541
583
  limits: x,
542
- enableCollision: a,
543
- role: o,
584
+ enableCollision: o,
585
+ role: s,
544
586
  ...S?.stiffness === void 0 ? {} : { limitStiffness: S.stiffness },
545
587
  ...S?.damping === void 0 ? {} : { limitDamping: S.damping },
546
588
  drive: C[0] ?? null,
@@ -559,187 +601,187 @@ function Fe(e, t, n, r, i, a, o, s = r.name) {
559
601
  }
560
602
  // src/khrPluginHelpers.ts
561
603
  var Y = (e) => typeof e == "object" && !!e && !Array.isArray(e);
562
- function X(e, t) {
563
- if (e === void 0) return [];
564
- if (!Array.isArray(e)) throw new v(`${t} must be an array`);
565
- return e;
604
+ function X(t, n) {
605
+ if (t === void 0) return [];
606
+ if (!Array.isArray(t)) throw new e(`${n} must be an array`);
607
+ return t;
566
608
  }
567
- function Ie() {
609
+ function qe() {
568
610
  return (e) => ({
569
611
  name: "khr3_headless_texture",
570
612
  loadTexture(t) {
571
- let n = new j.Texture();
613
+ let n = new P.Texture();
572
614
  return n.flipY = !1, e.associations.set(n, { textures: t }), Promise.resolve(n);
573
615
  }
574
616
  });
575
617
  }
576
- function Le(e, t, n = e.parser?.json) {
577
- let r = new Int32Array(t.length).fill(-1);
578
- for (let e = 0; e < t.length; e++) {
579
- let n = t[e];
580
- if (!Y(n)) throw new v(`GLTF node[${e}] must be an object`);
581
- let r = typeof n.name == "string" && n.name.length > 0 ? n.name : e;
582
- if (n.children !== void 0) {
583
- if (!Array.isArray(n.children)) throw new v(`GLTF node "${r}" children must be an array`);
584
- for (let e of n.children) if (typeof e != "number" || !Number.isInteger(e) || e < 0 || e >= t.length) throw new v(`GLTF node "${r}" has out-of-bounds child index ${String(e)}`);
618
+ function Je(t, n, r = t.parser?.json) {
619
+ let i = new Int32Array(n.length).fill(-1);
620
+ for (let t = 0; t < n.length; t++) {
621
+ let r = n[t];
622
+ if (!Y(r)) throw new e(`GLTF node[${t}] must be an object`);
623
+ let i = typeof r.name == "string" && r.name.length > 0 ? r.name : t;
624
+ if (r.children !== void 0) {
625
+ if (!Array.isArray(r.children)) throw new e(`GLTF node "${i}" children must be an array`);
626
+ for (let t of r.children) if (typeof t != "number" || !Number.isInteger(t) || t < 0 || t >= n.length) throw new e(`GLTF node "${i}" has out-of-bounds child index ${String(t)}`);
585
627
  }
586
628
  }
587
- let i, a = /* @__PURE__ */ new Set();
588
- if (Array.isArray(n?.scenes)) {
589
- let e = n.scene ?? 0, r = n.scenes[e];
590
- if (!Y(r)) throw new v(`GLTF scene[${e}] must be an object`);
591
- if (r.nodes !== void 0 && !Array.isArray(r.nodes)) throw new v(`GLTF scene[${e}].nodes must be an array`);
592
- i = (r.nodes ?? []).map((n, r) => {
593
- if (typeof n != "number" || !Number.isInteger(n) || n < 0 || n >= t.length) throw new v(`GLTF scene[${e}].nodes[${r}] has invalid node index ${String(n)}`);
594
- return n;
629
+ let a, o = /* @__PURE__ */ new Set();
630
+ if (Array.isArray(r?.scenes)) {
631
+ let t = r.scene ?? 0, i = r.scenes[t];
632
+ if (!Y(i)) throw new e(`GLTF scene[${t}] must be an object`);
633
+ if (i.nodes !== void 0 && !Array.isArray(i.nodes)) throw new e(`GLTF scene[${t}].nodes must be an array`);
634
+ a = (i.nodes ?? []).map((r, i) => {
635
+ if (typeof r != "number" || !Number.isInteger(r) || r < 0 || r >= n.length) throw new e(`GLTF scene[${t}].nodes[${i}] has invalid node index ${String(r)}`);
636
+ return r;
595
637
  });
596
- let o = [...i];
597
- for (; o.length > 0;) {
598
- let e = o.pop();
599
- if (a.has(e)) continue;
600
- a.add(e);
601
- let n = t[e].children;
602
- if (n) for (let e of n) o.push(e);
638
+ let s = [...a];
639
+ for (; s.length > 0;) {
640
+ let e = s.pop();
641
+ if (o.has(e)) continue;
642
+ o.add(e);
643
+ let t = n[e].children;
644
+ if (t) for (let e of t) s.push(e);
603
645
  }
604
- } else for (let e = 0; e < t.length; e++) a.add(e);
605
- let o = i ? new Set(i) : void 0;
606
- for (let e of a) {
607
- let n = t[e].children;
608
- if (n) for (let i of n) {
609
- if (r[i] !== -1 || o?.has(i)) {
610
- let e = typeof t[i].name == "string" && t[i].name.length > 0 ? t[i].name : i;
611
- throw new v(`GLTF node "${e}" has multiple parents in active scene`);
646
+ } else for (let e = 0; e < n.length; e++) o.add(e);
647
+ let s = a ? new Set(a) : void 0;
648
+ for (let t of o) {
649
+ let r = n[t].children;
650
+ if (r) for (let a of r) {
651
+ if (i[a] !== -1 || s?.has(a)) {
652
+ let t = typeof n[a].name == "string" && n[a].name.length > 0 ? n[a].name : a;
653
+ throw new e(`GLTF node "${t}" has multiple parents in active scene`);
612
654
  }
613
- for (let n = e; n !== -1; n = r[n]) if (n === i) {
614
- let e = typeof t[i].name == "string" && t[i].name.length > 0 ? t[i].name : i;
615
- throw new v(`GLTF node "${e}" has cyclic parent in active scene`);
655
+ for (let r = t; r !== -1; r = i[r]) if (r === a) {
656
+ let t = typeof n[a].name == "string" && n[a].name.length > 0 ? n[a].name : a;
657
+ throw new e(`GLTF node "${t}" has cyclic parent in active scene`);
616
658
  }
617
- r[i] = e;
659
+ i[a] = t;
618
660
  }
619
661
  }
620
- let s = /* @__PURE__ */ new Set(), c = Array(t.length), l = (e, n) => {
621
- let r = t[e].name, i = typeof r == "string" && r.length > 0 ? r : `node_${e}`;
622
- if (n) {
623
- for (s.has(i) && (i = `${i}_${e}`); s.has(i);) i = `${i}_`;
624
- s.add(i);
662
+ let c = /* @__PURE__ */ new Set(), l = Array(n.length), u = (e, t) => {
663
+ let r = n[e].name, i = typeof r == "string" && r.length > 0 ? r : `node_${e}`;
664
+ if (t) {
665
+ for (c.has(i) && (i = `${i}_${e}`); c.has(i);) i = `${i}_`;
666
+ c.add(i);
625
667
  }
626
- c[e] = i;
668
+ l[e] = i;
627
669
  };
628
- for (let e = 0; e < t.length; e++) a.has(e) && l(e, !0);
629
- for (let e = 0; e < t.length; e++) a.has(e) || l(e, !1);
630
- let u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
631
- if (e.scene.traverse((t) => {
632
- let n = e.parser?.associations?.get(t)?.nodes;
633
- typeof n == "number" && a.has(n) && !u.has(n) && u.set(n, t), t.name && !d.has(t.name) && d.set(t.name, t);
634
- }), i && e.scene.children.length === i.length) {
635
- let n = /* @__PURE__ */ new Set(), r = (e, i) => {
636
- if (n.has(e)) return;
637
- n.add(e), u.has(e) || u.set(e, i);
638
- let a = t[e].children;
670
+ for (let e = 0; e < n.length; e++) o.has(e) && u(e, !0);
671
+ for (let e = 0; e < n.length; e++) o.has(e) || u(e, !1);
672
+ let d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
673
+ if (t.scene.traverse((e) => {
674
+ let n = t.parser?.associations?.get(e)?.nodes;
675
+ typeof n == "number" && o.has(n) && !d.has(n) && d.set(n, e), e.name && !f.has(e.name) && f.set(e.name, e);
676
+ }), a && t.scene.children.length === a.length) {
677
+ let e = /* @__PURE__ */ new Set(), r = (t, i) => {
678
+ if (e.has(t)) return;
679
+ e.add(t), d.has(t) || d.set(t, i);
680
+ let a = n[t].children;
639
681
  if (!a || a.length === 0) return;
640
682
  let o = i.children.length - a.length;
641
683
  if (!(o < 0)) for (let e = 0; e < a.length; e++) r(a[e], i.children[o + e]);
642
684
  };
643
- for (let t = 0; t < i.length; t++) r(i[t], e.scene.children[t]);
685
+ for (let e = 0; e < a.length; e++) r(a[e], t.scene.children[e]);
644
686
  }
645
687
  return {
646
- parentIdx: r,
647
- nodeNames: c,
648
- resolveObj: (n) => {
649
- if (n < 0 || n >= t.length || !a.has(n)) return;
650
- let r = u.get(n);
688
+ parentIdx: i,
689
+ nodeNames: l,
690
+ resolveObj: (e) => {
691
+ if (e < 0 || e >= n.length || !o.has(e)) return;
692
+ let r = d.get(e);
651
693
  if (r) return r;
652
- let i = c[n], o = j.PropertyBinding.sanitizeNodeName(i);
653
- return d.get(i) ?? d.get(o) ?? e.scene.getObjectByName(i);
694
+ let i = l[e], a = P.PropertyBinding.sanitizeNodeName(i);
695
+ return f.get(i) ?? f.get(a) ?? t.scene.getObjectByName(i);
654
696
  }
655
697
  };
656
698
  }
657
- function Re(e, t, n, r, i) {
658
- if (!Y(e)) throw new v(`Node "${t}" has invalid collider (expected object)`);
659
- let a = e.geometry;
660
- if (!Y(a)) throw new v(`Node "${t}" is missing collider.geometry object`);
661
- if (a.shape !== void 0) {
662
- if (typeof a.shape != "number" || !Number.isInteger(a.shape) || a.shape < 0 || a.shape >= n.length) throw new v(`Node "${t}" references missing collider.geometry.shape ${String(a.shape)}`);
663
- return n[a.shape];
699
+ function Ye(t, n, r, i, a) {
700
+ if (!Y(t)) throw new e(`Node "${n}" has invalid collider (expected object)`);
701
+ let o = t.geometry;
702
+ if (!Y(o)) throw new e(`Node "${n}" is missing collider.geometry object`);
703
+ if (o.shape !== void 0) {
704
+ if (typeof o.shape != "number" || !Number.isInteger(o.shape) || o.shape < 0 || o.shape >= r.length) throw new e(`Node "${n}" references missing collider.geometry.shape ${String(o.shape)}`);
705
+ return r[o.shape];
664
706
  }
665
- if (a.node !== void 0) {
666
- if (typeof a.node != "number" || !Number.isInteger(a.node)) throw new v(`Node "${t}" has invalid collider.geometry.node`);
667
- if (a.convexHull !== void 0 && typeof a.convexHull != "boolean") throw new v(`Node "${t}" has non-boolean collider.geometry.convexHull`);
668
- let e = i(a.node), n = r[a.node] ?? `node_${a.node}`;
669
- if (!e) throw new v(`Node "${t}" references missing mesh node "${n}"`);
670
- return o(e, n, !!a.convexHull);
707
+ if (o.node !== void 0) {
708
+ if (typeof o.node != "number" || !Number.isInteger(o.node)) throw new e(`Node "${n}" has invalid collider.geometry.node`);
709
+ if (o.convexHull !== void 0 && typeof o.convexHull != "boolean") throw new e(`Node "${n}" has non-boolean collider.geometry.convexHull`);
710
+ let t = a(o.node), r = i[o.node] ?? `node_${o.node}`;
711
+ if (!t) throw new e(`Node "${n}" references missing mesh node "${r}"`);
712
+ return l(t, r, !!o.convexHull);
671
713
  }
672
- throw new v(`Node "${t}" collider.geometry must specify shape or node`);
714
+ throw new e(`Node "${n}" collider.geometry must specify shape or node`);
673
715
  }
674
716
  // src/khrPlugin.ts
675
- var ze = "khrBundle";
676
- function Be(t, n) {
677
- if (!t.scene) throw new v("GLTF asset has no active scene");
678
- t.scene.updateMatrixWorld(!0), i(t.scene);
679
- let r = t.parser?.json;
680
- if (!r) throw new v("GLTFParser is missing parsed JSON");
681
- if (r.extensions !== void 0 && !Y(r.extensions)) throw new v("glTF extensions must be an object");
682
- let a = r.extensions?.KHR_physics_rigid_bodies;
683
- if (a !== void 0 && !Y(a)) throw new v("KHR_physics_rigid_bodies extension must be an object");
684
- let o = r.extensions?.KHR_implicit_shapes;
685
- if (o !== void 0 && !Y(o)) throw new v("KHR_implicit_shapes extension must be an object");
686
- let c = X(o?.shapes, "KHR_implicit_shapes.shapes").map((e, t) => ke(e, t)), u = X(a?.physicsMaterials, "KHR_physics_rigid_bodies.physicsMaterials"), d = Me(X(a?.collisionFilters, "KHR_physics_rigid_bodies.collisionFilters")), p = X(a?.physicsJoints, "KHR_physics_rigid_bodies.physicsJoints"), m = X(r.nodes, "glTF nodes"), { parentIdx: h, nodeNames: g, resolveObj: _ } = Le(t, m, r), y = [], b = {};
717
+ var Xe = "khrBundle";
718
+ function Ze(t, n) {
719
+ if (!t.scene) throw new e("GLTF asset has no active scene");
720
+ t.scene.updateMatrixWorld(!0), s(t.scene);
721
+ let i = t.parser?.json;
722
+ if (!i) throw new e("GLTFParser is missing parsed JSON");
723
+ if (i.extensions !== void 0 && !Y(i.extensions)) throw new e("glTF extensions must be an object");
724
+ let a = i.extensions?.KHR_physics_rigid_bodies;
725
+ if (a !== void 0 && !Y(a)) throw new e("KHR_physics_rigid_bodies extension must be an object");
726
+ let o = i.extensions?.KHR_implicit_shapes;
727
+ 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 = {};
687
729
  for (let e = 0; e < m.length; e++) {
688
- let t = _(e);
730
+ let t = v(e);
689
731
  if (!t) continue;
690
732
  let r = Y(m[e].extras) ? m[e].extras : {};
691
- y.push(Se(t, g[e], r, b, n?.isSocketNode));
733
+ y.push(Ne(t, _[e], r, b, n?.isSocketNode));
692
734
  }
693
- let x = [], S = [], C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Set(), T = [], E = [], D = (e) => {
694
- for (let t = h[e]; t !== -1; t = h[t]) if (m[t].extensions?.KHR_physics_rigid_bodies?.motion) return t;
735
+ let x = [], S = [], C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Set(), T = [], ee = [], E = (e) => {
736
+ for (let t = g[e]; t !== -1; t = g[t]) if (m[t].extensions?.KHR_physics_rigid_bodies?.motion) return t;
695
737
  return -1;
696
- }, O = (e) => {
697
- for (let t = e; t !== -1; t = h[t]) {
738
+ }, D = (e) => {
739
+ for (let t = e; t !== -1; t = g[t]) {
698
740
  let e = m[t].extras;
699
741
  if (Y(e) && (e.ecctrlWheel !== void 0 || e.ecctrlPropeller !== void 0)) return !0;
700
742
  }
701
743
  return !1;
702
744
  };
703
- for (let e = 0; e < m.length; e++) {
704
- let r = m[e], i = g[e], a = _(e);
705
- if (!a) continue;
706
- let o = Y(r.extras) ? r.extras : {};
707
- if (o.ecctrlWheel !== void 0 || o.ecctrlPropeller !== void 0) {
708
- if (h[e] !== -1 && O(h[e])) throw new v(`Nested rotor "${i}" inside detached rotor is unsupported`);
709
- o.ecctrlWheel === void 0 ? E.push(we(a, i, o.ecctrlPropeller, t.scene)) : T.push(Ce(a, i, o.ecctrlWheel, t.scene));
745
+ for (let r = 0; r < m.length; r++) {
746
+ let i = m[r], a = _[r], o = v(r);
747
+ if (!o) continue;
748
+ let s = Y(i.extras) ? i.extras : {};
749
+ if (s.ecctrlWheel !== void 0 || s.ecctrlPropeller !== void 0) {
750
+ 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));
710
752
  continue;
711
753
  }
712
- if (O(e)) continue;
713
- let s = r.extensions?.KHR_physics_rigid_bodies;
714
- if (s === void 0) continue;
715
- if (!Y(s)) throw new v(`Node "${i}" has invalid KHR_physics_rigid_bodies`);
716
- if (s.motion === void 0 && s.collider === void 0 && s.joint === void 0) continue;
717
- if (s.motion === void 0 && D(e) !== -1) {
718
- if (s.joint !== void 0) throw new v(`Node "${i}" has joint without motion`);
754
+ if (D(r)) continue;
755
+ let c = i.extensions?.KHR_physics_rigid_bodies;
756
+ if (c === void 0) continue;
757
+ if (!Y(c)) throw new e(`Node "${a}" has invalid KHR_physics_rigid_bodies`);
758
+ if (c.motion === void 0 && c.collider === void 0 && c.joint === void 0) continue;
759
+ if (c.motion === void 0 && E(r) !== -1) {
760
+ if (c.joint !== void 0) throw new e(`Node "${a}" has joint without motion`);
719
761
  continue;
720
762
  }
721
- if (s.motion !== void 0 && !Y(s.motion)) throw new v(`Node "${i}" has invalid motion`);
722
- let { hasExplicitInertia: c, ...l } = je(s.motion ?? {}, s.motion !== void 0, i);
723
- c && w.add(e);
724
- let u = n?.extractRole?.(i, o) ?? (typeof o.role == "string" ? o.role : null), d = null;
725
- if (s.joint !== void 0) {
726
- if (!Y(s.joint)) throw new v(`Node "${i}" has invalid joint`);
727
- let e = s.joint;
728
- if (typeof e.joint != "number" || !Number.isInteger(e.joint)) throw new v(`Joint on "${i}" is missing numeric joint index`);
729
- if (typeof e.connectedNode != "number" || !Number.isInteger(e.connectedNode)) throw new v(`Joint on "${i}" is missing numeric connectedNode index`);
730
- if (e.enableCollision !== void 0 && typeof e.enableCollision != "boolean") throw new v(`Joint on "${i}" has non-boolean enableCollision`);
731
- let t = e.connectedNode, n = g[t] ?? `node_${t}`, r = _(t);
732
- if (!r) throw new v(`Joint on "${i}" targets missing connectedNode "${n}"`);
733
- if (O(t)) throw new v(`Joint on "${i}" cannot target detached rotor "${n}"`);
734
- d = Fe(p, e.joint, i, r, a, !!e.enableCollision, u, n);
763
+ 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);
765
+ l && w.add(r);
766
+ let d = n?.extractRole?.(a, s) ?? (typeof s.role == "string" ? s.role : null), f = null;
767
+ if (c.joint !== void 0) {
768
+ if (!Y(c.joint)) throw new e(`Node "${a}" has invalid joint`);
769
+ let t = c.joint;
770
+ if (typeof t.joint != "number" || !Number.isInteger(t.joint)) throw new e(`Joint on "${a}" is missing numeric joint index`);
771
+ if (typeof t.connectedNode != "number" || !Number.isInteger(t.connectedNode)) throw new e(`Joint on "${a}" is missing numeric connectedNode index`);
772
+ if (t.enableCollision !== void 0 && typeof t.enableCollision != "boolean") throw new e(`Joint on "${a}" has non-boolean enableCollision`);
773
+ let n = t.connectedNode, r = _[n] ?? `node_${n}`, i = v(n);
774
+ if (!i) throw new e(`Joint on "${a}" targets missing connectedNode "${r}"`);
775
+ 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);
735
777
  }
736
- let f = a.getWorldPosition(new j.Vector3()), y = a.getWorldQuaternion(new j.Quaternion()), b = {
737
- nodeName: i,
738
- ...l,
778
+ let h = o.getWorldPosition(new P.Vector3()), y = o.getWorldQuaternion(new P.Quaternion()), b = {
779
+ nodeName: a,
780
+ ...u,
739
781
  localPosition: [
740
- f.x,
741
- f.y,
742
- f.z
782
+ h.x,
783
+ h.y,
784
+ h.z
743
785
  ],
744
786
  localQuaternion: [
745
787
  y.x,
@@ -748,24 +790,24 @@ function Be(t, n) {
748
790
  y.w
749
791
  ],
750
792
  colliders: [],
751
- joint: d,
752
- object: a,
753
- role: u
793
+ joint: f,
794
+ object: o,
795
+ role: d
754
796
  };
755
797
  x.push(b), S.push({
756
- nodeName: i,
757
- extras: o
758
- }), C.set(e, b);
798
+ nodeName: a,
799
+ extras: s
800
+ }), C.set(r, b);
759
801
  }
760
- for (let e = 0; e < m.length; e++) {
761
- if (O(e)) continue;
762
- let t = m[e].extensions?.KHR_physics_rigid_bodies?.collider;
763
- if (t === void 0) continue;
764
- let n = _(e);
765
- if (!n) continue;
766
- let r = C.has(e) ? e : D(e), i = C.get(r);
767
- if (!i) continue;
768
- let a = Re(t, g[e], c, g, _), o = t, l = r === e ? {
802
+ for (let t = 0; t < m.length; t++) {
803
+ if (D(t)) continue;
804
+ let n = m[t].extensions?.KHR_physics_rigid_bodies?.collider;
805
+ if (n === void 0) continue;
806
+ let r = v(t);
807
+ if (!r) continue;
808
+ let i = C.has(t) ? t : E(t), a = C.get(i);
809
+ if (!a) continue;
810
+ let o = Ye(n, _[t], c, _, v), s = n, f = i === t ? {
769
811
  localPosition: [
770
812
  0,
771
813
  0,
@@ -777,144 +819,144 @@ function Be(t, n) {
777
819
  0,
778
820
  1
779
821
  ]
780
- } : s(i.object, n), f = Ae(u, o.physicsMaterial, g[e]), p;
781
- if (o.collisionFilter !== void 0) {
782
- if (typeof o.collisionFilter != "number" || !Number.isInteger(o.collisionFilter) || o.collisionFilter < 0 || o.collisionFilter >= d.length) throw new v(`Node "${g[e]}" references out-of-bounds collisionFilter ${String(o.collisionFilter)}`);
783
- p = d[o.collisionFilter];
822
+ } : u(a.object, r), p = Ve(l, s.physicsMaterial, _[t]), h;
823
+ if (s.collisionFilter !== void 0) {
824
+ 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
+ h = d[s.collisionFilter];
784
826
  }
785
- i.colliders.push({
786
- shape: a,
787
- localPosition: l.localPosition,
788
- localQuaternion: l.localQuaternion,
789
- ...f,
790
- ...p === void 0 ? {} : { collisionGroups: p }
827
+ a.colliders.push({
828
+ shape: o,
829
+ localPosition: f.localPosition,
830
+ localQuaternion: f.localQuaternion,
831
+ ...p,
832
+ ...h === void 0 ? {} : { collisionGroups: h }
791
833
  });
792
834
  }
793
- for (let [e, t] of C) w.has(e) || t.isKinematic || (t.inertiaDiagonal = l(t.colliders, t.mass, t.centerOfMass, t.inertiaOrientation, t.nodeName));
794
- let { totalDynamicMass: k, centerOfMass: A } = f(x), M = [], N = r.scenes?.[r.scene ?? 0]?.extras ?? r.extras;
795
- if (N?.ikSockets !== void 0) {
796
- if (!Y(N.ikSockets)) throw new v("scene.extras.ikSockets must be an object");
797
- for (let [t, n] of Object.entries(N.ikSockets)) {
798
- let r = e(n, `scene.extras.ikSockets.${t}`);
799
- b[t] = r, M.push([t, r]);
835
+ 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)) {
840
+ let n = r(t, `scene.extras.ikSockets.${e}`);
841
+ b[e] = n, k.push([e, n]);
800
842
  }
801
843
  }
802
- let P = Y(N?.tune) ? N.tune : void 0, F = Y(N?.droneTune) ? N.droneTune : void 0;
803
- return _e(t.scene, {
844
+ let j = Y(A?.tune) ? A.tune : void 0, M = Y(A?.droneTune) ? A.droneTune : void 0;
845
+ return Ee(t.scene, {
804
846
  nodes: y,
805
847
  bodies: S,
806
- ikSockets: M
848
+ ikSockets: k
807
849
  }), {
808
850
  scene: t.scene,
809
851
  bodies: x,
810
852
  wheels: T,
811
- propellers: E,
853
+ propellers: ee,
812
854
  sockets: b,
813
- totalDynamicMass: k,
814
- centerOfMass: A,
815
- tune: P,
816
- droneTune: F
855
+ totalDynamicMass: O,
856
+ centerOfMass: te,
857
+ tune: j,
858
+ droneTune: M
817
859
  };
818
860
  }
819
- function Ve(e) {
861
+ function Qe(e) {
820
862
  let t = typeof document > "u" && typeof createImageBitmap > "u";
821
863
  return (n) => ({
822
864
  name: "KHR_physics_rigid_bodies",
823
865
  ...t ? { loadTexture(e) {
824
- let t = new j.Texture();
866
+ let t = new P.Texture();
825
867
  return t.flipY = !1, n.associations.set(t, { textures: e }), Promise.resolve(t);
826
868
  } } : {},
827
869
  afterRoot(t) {
828
- return t.userData[ze] = Be(t, e), null;
870
+ return t.userData[Xe] = Ze(t, e), null;
829
871
  }
830
872
  });
831
873
  }
832
874
  // src/khrLoader.ts
833
- var He = Ie();
834
- function Ue() {
835
- let e = new P();
836
- return typeof document > "u" && typeof createImageBitmap > "u" && e.register(He), e;
875
+ var $e = qe();
876
+ function et() {
877
+ let e = new L();
878
+ return typeof document > "u" && typeof createImageBitmap > "u" && e.register($e), e;
837
879
  }
838
- async function We(e, t) {
839
- let n = e instanceof Uint8Array ? e : new Uint8Array(e), r = new ArrayBuffer(n.byteLength);
840
- new Uint8Array(r).set(n), fe(r);
841
- let i = t?.loader ?? Ue(), a = Ve(t);
842
- i.register(a);
880
+ async function tt(t, n) {
881
+ 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);
884
+ a.register(o);
843
885
  try {
844
- let e = (e) => e instanceof v ? e : new v(e instanceof Error ? e.message : "Failed to parse GLB"), t = (await new Promise((t, n) => {
845
- i.parse(r, "", t, (t) => n(e(t)));
846
- }).catch((t) => {
847
- throw e(t);
848
- })).userData[ze];
849
- if (!t) throw new v("Missing parsed KHR bundle on GLTF userData");
850
- return t;
886
+ 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
+ a.parse(i, "", e, (e) => n(t(e)));
888
+ }).catch((e) => {
889
+ throw t(e);
890
+ })).userData[Xe];
891
+ if (!n) throw new e("Missing parsed KHR bundle on GLTF userData");
892
+ return n;
851
893
  } finally {
852
- i.unregister(a);
894
+ a.unregister(o);
853
895
  }
854
896
  }
855
897
  // src/khrExporter.ts
856
898
  var Z = (e) => typeof e == "number" && Number.isFinite(e) && e > 0;
857
- function Q(e, t, n = !1) {
858
- if (e !== void 0) {
859
- if (typeof e != "number" || !Number.isFinite(e) || n && e < 0) throw new v(`exportKhrGlb: ${t} must be finite${n ? " >= 0" : ""}`);
860
- return e;
899
+ function Q(t, n, r = !1) {
900
+ if (t !== void 0) {
901
+ if (typeof t != "number" || !Number.isFinite(t) || r && t < 0) throw new e(`exportKhrGlb: ${n} must be finite${r ? " >= 0" : ""}`);
902
+ return t;
861
903
  }
862
904
  }
863
- function Ge(e, t) {
864
- if (e.type === "box") {
865
- if (!Array.isArray(e.size) || e.size.length !== 3 || !e.size.every(Z)) throw new v(`exportKhrGlb: invalid box.size on "${t}"`);
905
+ function nt(t, n) {
906
+ if (t.type === "box") {
907
+ if (!Array.isArray(t.size) || t.size.length !== 3 || !t.size.every(Z)) throw new e(`exportKhrGlb: invalid box.size on "${n}"`);
866
908
  return {
867
909
  type: "box",
868
- box: { size: e.size }
910
+ box: { size: t.size }
869
911
  };
870
912
  }
871
- if (e.type === "sphere") {
872
- if (!Z(e.radius)) throw new v(`exportKhrGlb: invalid sphere.radius on "${t}"`);
913
+ if (t.type === "sphere") {
914
+ if (!Z(t.radius)) throw new e(`exportKhrGlb: invalid sphere.radius on "${n}"`);
873
915
  return {
874
916
  type: "sphere",
875
- sphere: { radius: e.radius }
917
+ sphere: { radius: t.radius }
876
918
  };
877
919
  }
878
- if (!Z(e.height) || !Z(e.radiusTop) || !Z(e.radiusBottom)) throw new v(`exportKhrGlb: invalid ${e.type} dimensions on "${t}"`);
879
- if (Math.abs(e.radiusTop - e.radiusBottom) > 1e-6) throw new v(`exportKhrGlb: tapered ${e.type} (${e.radiusTop} !== ${e.radiusBottom}) on "${t}" is unsupported`);
920
+ if (!Z(t.height) || !Z(t.radiusTop) || !Z(t.radiusBottom)) throw new e(`exportKhrGlb: invalid ${t.type} dimensions on "${n}"`);
921
+ if (Math.abs(t.radiusTop - t.radiusBottom) > 1e-6) throw new e(`exportKhrGlb: tapered ${t.type} (${t.radiusTop} !== ${t.radiusBottom}) on "${n}" is unsupported`);
880
922
  return {
881
- type: e.type,
882
- [e.type]: {
883
- height: e.height,
884
- radiusTop: e.radiusTop,
885
- radiusBottom: e.radiusBottom
923
+ type: t.type,
924
+ [t.type]: {
925
+ height: t.height,
926
+ radiusTop: t.radiusTop,
927
+ radiusBottom: t.radiusBottom
886
928
  }
887
929
  };
888
930
  }
889
- function Ke(e, t, n) {
890
- if (!Array.isArray(e) || e.length !== 3 || !e.every((e) => typeof e == "number" && Number.isFinite(e))) throw new v(`exportKhrGlb: ${t} joint on "${n}" requires a finite axis`);
891
- let r = Math.abs(e[0]), i = Math.abs(e[1]), a = Math.abs(e[2]);
892
- if (Math.hypot(r, i, a) <= 1e-8) throw new v(`exportKhrGlb: ${t} joint on "${n}" requires non-zero axis`);
893
- return r >= i && r >= a ? 0 : i >= a ? 1 : 2;
931
+ function rt(t, n, r) {
932
+ 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
+ let i = Math.abs(t[0]), a = Math.abs(t[1]), o = Math.abs(t[2]);
934
+ if (Math.hypot(i, a, o) <= 1e-8) throw new e(`exportKhrGlb: ${n} joint on "${r}" requires non-zero axis`);
935
+ return i >= a && i >= o ? 0 : a >= o ? 1 : 2;
894
936
  }
895
- function qe(e, t, n, r) {
896
- if (!e || typeof e != "object" || Array.isArray(e)) throw new v(`exportKhrGlb: joint drive on "${r}" must be an object`);
897
- if (e.mode !== "force" && e.mode !== "acceleration") throw new v(`exportKhrGlb: joint drive on "${r}" requires drive.mode ("force" | "acceleration")`);
898
- if (e.type !== void 0 && e.type !== "linear" && e.type !== "angular") throw new v(`exportKhrGlb: joint drive on "${r}" has invalid drive.type`);
899
- if (e.axis !== void 0 && e.axis !== 0 && e.axis !== 1 && e.axis !== 2) throw new v(`exportKhrGlb: joint drive on "${r}" has invalid drive.axis`);
900
- let i = Q(e.positionTarget, `joint drive.positionTarget on "${r}"`), a = Q(e.velocityTarget, `joint drive.velocityTarget on "${r}"`);
901
- if (i === void 0 && a === void 0) throw new v(`exportKhrGlb: joint drive on "${r}" requires finite positionTarget or velocityTarget`);
902
- let o = Q(e.stiffness, `joint drive.stiffness on "${r}"`, !0), s = Q(e.damping, `joint drive.damping on "${r}"`, !0), c = Q(e.maxForce, `joint drive.maxForce on "${r}"`, !0);
937
+ function it(t, n, r, i) {
938
+ if (!t || typeof t != "object" || Array.isArray(t)) throw new e(`exportKhrGlb: joint drive on "${i}" must be an object`);
939
+ if (t.mode !== "force" && t.mode !== "acceleration") throw new e(`exportKhrGlb: joint drive on "${i}" requires drive.mode ("force" | "acceleration")`);
940
+ if (t.type !== void 0 && t.type !== "linear" && t.type !== "angular") throw new e(`exportKhrGlb: joint drive on "${i}" has invalid drive.type`);
941
+ if (t.axis !== void 0 && t.axis !== 0 && t.axis !== 1 && t.axis !== 2) throw new e(`exportKhrGlb: joint drive on "${i}" has invalid drive.axis`);
942
+ let a = Q(t.positionTarget, `joint drive.positionTarget on "${i}"`), o = Q(t.velocityTarget, `joint drive.velocityTarget on "${i}"`);
943
+ if (a === void 0 && o === void 0) throw new e(`exportKhrGlb: joint drive on "${i}" requires finite positionTarget or velocityTarget`);
944
+ let s = Q(t.stiffness, `joint drive.stiffness on "${i}"`, !0), c = Q(t.damping, `joint drive.damping on "${i}"`, !0), l = Q(t.maxForce, `joint drive.maxForce on "${i}"`, !0);
903
945
  return {
904
- type: e.type ?? t,
905
- mode: e.mode,
906
- axis: e.axis ?? n,
907
- ...i === void 0 ? {} : { positionTarget: i },
908
- ...a === void 0 ? {} : { velocityTarget: a },
909
- ...o === void 0 ? {} : { stiffness: o },
910
- ...s === void 0 ? {} : { damping: s },
911
- ...c === void 0 ? {} : { maxForce: c }
946
+ type: t.type ?? n,
947
+ mode: t.mode,
948
+ axis: t.axis ?? r,
949
+ ...a === void 0 ? {} : { positionTarget: a },
950
+ ...o === void 0 ? {} : { velocityTarget: o },
951
+ ...s === void 0 ? {} : { stiffness: s },
952
+ ...c === void 0 ? {} : { damping: c },
953
+ ...l === void 0 ? {} : { maxForce: l }
912
954
  };
913
955
  }
914
- function Je(e, t) {
915
- if (e.kind !== "fixed" && e.kind !== "revolute" && e.kind !== "prismatic") throw new v(`exportKhrGlb: invalid joint.kind "${String(e.kind)}" on "${t}"`);
916
- if (e.kind === "fixed") {
917
- if (e.drive || e.drives && e.drives.length > 0) throw new v(`exportKhrGlb: fixed joint on "${t}" cannot define drives`);
956
+ function at(t, n) {
957
+ if (t.kind !== "fixed" && t.kind !== "revolute" && t.kind !== "prismatic") throw new e(`exportKhrGlb: invalid joint.kind "${String(t.kind)}" on "${n}"`);
958
+ if (t.kind === "fixed") {
959
+ if (t.drive || t.drives && t.drives.length > 0) throw new e(`exportKhrGlb: fixed joint on "${n}" cannot define drives`);
918
960
  return { limits: [{
919
961
  linearAxes: [
920
962
  0,
@@ -933,21 +975,21 @@ function Je(e, t) {
933
975
  max: 0
934
976
  }] };
935
977
  }
936
- let n = Ke(e.axis, e.kind, t), r = [
978
+ let r = rt(t.axis, t.kind, n), i = [
937
979
  0,
938
980
  1,
939
981
  2
940
- ].filter((e) => e !== n);
941
- if (e.limits && (!Number.isFinite(e.limits[0]) || !Number.isFinite(e.limits[1]) || e.limits[0] > e.limits[1])) throw new v(`exportKhrGlb: joint on "${t}" has invalid joint.limits`);
942
- let i = Q(e.limitStiffness, `joint.limitStiffness on "${t}"`, !0), a = Q(e.limitDamping, `joint.limitDamping on "${t}"`, !0), o = e.kind === "revolute" ? "angularAxes" : "linearAxes", s = e.limits || i !== void 0 || a !== void 0 ? [{
943
- [o]: [n],
944
- ...e.limits ? {
945
- min: e.limits[0],
946
- max: e.limits[1]
982
+ ].filter((e) => e !== r);
983
+ if (t.limits && (!Number.isFinite(t.limits[0]) || !Number.isFinite(t.limits[1]) || t.limits[0] > t.limits[1])) throw new e(`exportKhrGlb: joint on "${n}" has invalid joint.limits`);
984
+ let a = Q(t.limitStiffness, `joint.limitStiffness on "${n}"`, !0), o = Q(t.limitDamping, `joint.limitDamping on "${n}"`, !0), s = t.kind === "revolute" ? "angularAxes" : "linearAxes", c = t.limits || a !== void 0 || o !== void 0 ? [{
985
+ [s]: [r],
986
+ ...t.limits ? {
987
+ min: t.limits[0],
988
+ max: t.limits[1]
947
989
  } : {},
948
- ...i === void 0 ? {} : { stiffness: i },
949
- ...a === void 0 ? {} : { damping: a }
950
- }] : [], c = { limits: e.kind === "revolute" ? [
990
+ ...a === void 0 ? {} : { stiffness: a },
991
+ ...o === void 0 ? {} : { damping: o }
992
+ }] : [], l = { limits: t.kind === "revolute" ? [
951
993
  {
952
994
  linearAxes: [
953
995
  0,
@@ -958,11 +1000,11 @@ function Je(e, t) {
958
1000
  max: 0
959
1001
  },
960
1002
  {
961
- angularAxes: r,
1003
+ angularAxes: i,
962
1004
  min: 0,
963
1005
  max: 0
964
1006
  },
965
- ...s
1007
+ ...c
966
1008
  ] : [
967
1009
  {
968
1010
  angularAxes: [
@@ -974,126 +1016,125 @@ function Je(e, t) {
974
1016
  max: 0
975
1017
  },
976
1018
  {
977
- linearAxes: r,
1019
+ linearAxes: i,
978
1020
  min: 0,
979
1021
  max: 0
980
1022
  },
981
- ...s
982
- ] }, l = e.drives ?? (e.drive ? [e.drive] : []);
983
- return l.length > 0 && (c.drives = l.map((r) => qe(r, e.kind === "revolute" ? "angular" : "linear", n, t))), c;
1023
+ ...c
1024
+ ] }, 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;
984
1026
  }
985
- function Ye(t, n) {
986
- let r = !!t.isKinematic;
987
- if (!r && !Z(t.mass)) throw new v(`exportKhrGlb: dynamic node "${n}" requires positive finite motion.mass`);
988
- if (r && t.mass !== void 0 && Q(t.mass, `kinematic motion.mass on "${n}"`, !0), t.inertiaDiagonal && e(t.inertiaDiagonal, `${n}.motion.inertiaDiagonal`).some((e) => r ? e < 0 : e <= 0)) throw new v(`exportKhrGlb: invalid motion.inertiaDiagonal on "${n}"`);
989
- if (t.gravityFactor !== void 0 && (typeof t.gravityFactor != "number" || !Number.isFinite(t.gravityFactor))) throw new v(`exportKhrGlb: invalid motion.gravityFactor on "${n}"`);
1027
+ function ot(t, n) {
1028
+ let i = !!t.isKinematic;
1029
+ if (!i && !Z(t.mass)) throw new e(`exportKhrGlb: dynamic node "${n}" requires positive finite motion.mass`);
1030
+ 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}"`);
1031
+ if (t.gravityFactor !== void 0 && (typeof t.gravityFactor != "number" || !Number.isFinite(t.gravityFactor))) throw new e(`exportKhrGlb: invalid motion.gravityFactor on "${n}"`);
990
1032
  return {
991
- isKinematic: r,
1033
+ isKinematic: i,
992
1034
  ...t.mass === void 0 ? {} : { mass: t.mass },
993
- ...t.centerOfMass ? { centerOfMass: e(t.centerOfMass, `${n}.motion.centerOfMass`) } : {},
1035
+ ...t.centerOfMass ? { centerOfMass: r(t.centerOfMass, `${n}.motion.centerOfMass`) } : {},
994
1036
  ...t.inertiaDiagonal ? { inertiaDiagonal: t.inertiaDiagonal } : {},
995
- ...t.inertiaOrientation ? { inertiaOrientation: _(t.inertiaOrientation, `${n}.motion.inertiaOrientation`) } : {},
996
- ...t.linearVelocity ? { linearVelocity: e(t.linearVelocity, `${n}.motion.linearVelocity`) } : {},
997
- ...t.angularVelocity ? { angularVelocity: e(t.angularVelocity, `${n}.motion.angularVelocity`) } : {},
1037
+ ...t.inertiaOrientation ? { inertiaOrientation: b(t.inertiaOrientation, `${n}.motion.inertiaOrientation`) } : {},
1038
+ ...t.linearVelocity ? { linearVelocity: r(t.linearVelocity, `${n}.motion.linearVelocity`) } : {},
1039
+ ...t.angularVelocity ? { angularVelocity: r(t.angularVelocity, `${n}.motion.angularVelocity`) } : {},
998
1040
  ...t.gravityFactor === void 0 ? {} : { gravityFactor: t.gravityFactor }
999
1041
  };
1000
1042
  }
1001
- async function Xe(e, t, n) {
1002
- pe(), e.updateMatrixWorld(!0);
1003
- let r = new F();
1004
- return he(await new Promise((t, n) => {
1005
- r.parse(e, (e) => t(e instanceof ArrayBuffer ? e : me(e)), n, { binary: !0 });
1006
- }), (e) => {
1007
- let r = e.nodes ?? [], i = /* @__PURE__ */ new Map();
1008
- r.forEach((e, t) => {
1009
- e.name && i.set(e.name, t);
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 });
1048
+ }), (t) => {
1049
+ let i = t.nodes ?? [], a = /* @__PURE__ */ new Map();
1050
+ i.forEach((e, t) => {
1051
+ e.name && a.set(e.name, t);
1010
1052
  });
1011
- let a = (e) => {
1012
- let t = i.get(e);
1013
- if (t === void 0) throw new v(`exportKhrGlb: missing scene node "${e}"`);
1014
- return t;
1015
- }, o = [], s = /* @__PURE__ */ new Map(), c = [], l = [], u = [], d = !1;
1016
- for (let e of t) {
1017
- let t = r[a(e.nodeName)];
1018
- e.extras && (t.extras = {
1019
- ...t.extras,
1020
- ...e.extras
1053
+ let o = (t) => {
1054
+ let n = a.get(t);
1055
+ if (n === void 0) throw new e(`exportKhrGlb: missing scene node "${t}"`);
1056
+ return n;
1057
+ }, s = [], c = /* @__PURE__ */ new Map(), l = [], u = [], d = [], f = !1;
1058
+ for (let t of n) {
1059
+ let n = i[o(t.nodeName)];
1060
+ t.extras && (n.extras = {
1061
+ ...n.extras,
1062
+ ...t.extras
1021
1063
  });
1022
- let n = {};
1023
- if (e.motion && (d = !0, n.motion = Ye(e.motion, e.nodeName)), e.collider) {
1024
- d = !0;
1025
- let t = {};
1026
- if (e.collider.shape) {
1027
- let n = Ge(e.collider.shape, e.nodeName), r = JSON.stringify(n), i = s.get(r);
1028
- i === void 0 && (i = o.length, o.push(n), s.set(r, i)), t.geometry = { shape: i };
1029
- } else if (e.collider.meshNodeName) {
1030
- if (typeof e.collider.convexHull != "boolean") throw new v(`exportKhrGlb: mesh collider on "${e.nodeName}" requires explicit boolean convexHull`);
1031
- t.geometry = {
1032
- node: a(e.collider.meshNodeName),
1033
- convexHull: e.collider.convexHull
1064
+ let r = {};
1065
+ if (t.motion && (f = !0, r.motion = ot(t.motion, t.nodeName)), t.collider) {
1066
+ f = !0;
1067
+ let n = {};
1068
+ if (t.collider.shape) {
1069
+ let e = nt(t.collider.shape, t.nodeName), r = JSON.stringify(e), i = c.get(r);
1070
+ i === void 0 && (i = s.length, s.push(e), c.set(r, i)), n.geometry = { shape: i };
1071
+ } else if (t.collider.meshNodeName) {
1072
+ if (typeof t.collider.convexHull != "boolean") throw new e(`exportKhrGlb: mesh collider on "${t.nodeName}" requires explicit boolean convexHull`);
1073
+ n.geometry = {
1074
+ node: o(t.collider.meshNodeName),
1075
+ convexHull: t.collider.convexHull
1034
1076
  };
1035
- } else throw new v(`exportKhrGlb: collider on "${e.nodeName}" requires shape or meshNodeName`);
1036
- let r = Q(e.collider.friction, `collider.friction on "${e.nodeName}"`, !0), i = Q(e.collider.restitution, `collider.restitution on "${e.nodeName}"`, !0);
1037
- if ((r !== void 0 || i !== void 0) && (t.physicsMaterial = c.length, c.push({
1038
- ...r === void 0 ? {} : {
1039
- staticFriction: r,
1040
- dynamicFriction: r
1077
+ } else throw new e(`exportKhrGlb: collider on "${t.nodeName}" requires shape or meshNodeName`);
1078
+ let i = Q(t.collider.friction, `collider.friction on "${t.nodeName}"`, !0), a = Q(t.collider.restitution, `collider.restitution on "${t.nodeName}"`, !0);
1079
+ if ((i !== void 0 || a !== void 0) && (n.physicsMaterial = l.length, l.push({
1080
+ ...i === void 0 ? {} : {
1081
+ staticFriction: i,
1082
+ dynamicFriction: i
1041
1083
  },
1042
- ...i === void 0 ? {} : { restitution: i }
1043
- })), e.collider.collideWithSystems !== void 0 && e.collider.notCollideWithSystems !== void 0) throw new v(`exportKhrGlb: collider on "${e.nodeName}" cannot specify both collideWithSystems and notCollideWithSystems`);
1044
- if (e.collider.collisionSystems !== void 0 || e.collider.collideWithSystems !== void 0 || e.collider.notCollideWithSystems !== void 0) {
1045
- if (!Array.isArray(e.collider.collisionSystems) || e.collider.collisionSystems.length === 0) throw new v(`exportKhrGlb: collision filter on "${e.nodeName}" requires non-empty collisionSystems`);
1046
- t.collisionFilter = l.length, l.push({
1047
- collisionSystems: e.collider.collisionSystems,
1048
- ...e.collider.collideWithSystems ? { collideWithSystems: e.collider.collideWithSystems } : {},
1049
- ...e.collider.notCollideWithSystems ? { notCollideWithSystems: e.collider.notCollideWithSystems } : {}
1084
+ ...a === void 0 ? {} : { restitution: a }
1085
+ })), t.collider.collideWithSystems !== void 0 && t.collider.notCollideWithSystems !== void 0) throw new e(`exportKhrGlb: collider on "${t.nodeName}" cannot specify both collideWithSystems and notCollideWithSystems`);
1086
+ if (t.collider.collisionSystems !== void 0 || t.collider.collideWithSystems !== void 0 || t.collider.notCollideWithSystems !== void 0) {
1087
+ if (!Array.isArray(t.collider.collisionSystems) || t.collider.collisionSystems.length === 0) throw new e(`exportKhrGlb: collision filter on "${t.nodeName}" requires non-empty collisionSystems`);
1088
+ n.collisionFilter = u.length, u.push({
1089
+ collisionSystems: t.collider.collisionSystems,
1090
+ ...t.collider.collideWithSystems ? { collideWithSystems: t.collider.collideWithSystems } : {},
1091
+ ...t.collider.notCollideWithSystems ? { notCollideWithSystems: t.collider.notCollideWithSystems } : {}
1050
1092
  });
1051
1093
  }
1052
- n.collider = t;
1094
+ r.collider = n;
1053
1095
  }
1054
- if (e.joint) {
1055
- d = !0;
1056
- let t = a(e.joint.connectedNodeName);
1057
- u.push(Je(e.joint, e.nodeName)), n.joint = {
1058
- joint: u.length - 1,
1059
- connectedNode: t,
1060
- enableCollision: !!e.joint.enableCollision
1096
+ if (t.joint) {
1097
+ f = !0;
1098
+ let e = o(t.joint.connectedNodeName);
1099
+ d.push(at(t.joint, t.nodeName)), r.joint = {
1100
+ joint: d.length - 1,
1101
+ connectedNode: e,
1102
+ enableCollision: !!t.joint.enableCollision
1061
1103
  };
1062
1104
  }
1063
- Object.keys(n).length > 0 && (t.extensions = {
1064
- ...t.extensions,
1065
- KHR_physics_rigid_bodies: n
1105
+ Object.keys(r).length > 0 && (n.extensions = {
1106
+ ...n.extensions,
1107
+ KHR_physics_rigid_bodies: r
1066
1108
  });
1067
1109
  }
1068
- if (n) {
1069
- let t = e.scenes?.[e.scene ?? 0];
1070
- t ? t.extras = {
1071
- ...t.extras,
1072
- ...n
1073
- } : e.extras = {
1110
+ if (r) {
1111
+ let e = t.scenes?.[t.scene ?? 0];
1112
+ e ? e.extras = {
1074
1113
  ...e.extras,
1075
- ...n
1114
+ ...r
1115
+ } : t.extras = {
1116
+ ...t.extras,
1117
+ ...r
1076
1118
  };
1077
1119
  }
1078
- let f = new Set(e.extensionsUsed ?? []);
1079
- e.extensions ??= {}, o.length > 0 && (f.add("KHR_implicit_shapes"), e.extensions.KHR_implicit_shapes = { shapes: o }), d && (f.add("KHR_physics_rigid_bodies"), e.extensions.KHR_physics_rigid_bodies = {
1080
- ...c.length > 0 ? { physicsMaterials: c } : {},
1081
- ...l.length > 0 ? { collisionFilters: l } : {},
1082
- ...u.length > 0 ? { physicsJoints: u } : {}
1083
- }), f.size > 0 && (e.extensionsUsed = [...f]);
1120
+ let p = new Set(t.extensionsUsed ?? []);
1121
+ t.extensions ??= {}, s.length > 0 && (p.add("KHR_implicit_shapes"), t.extensions.KHR_implicit_shapes = { shapes: s }), f && (p.add("KHR_physics_rigid_bodies"), t.extensions.KHR_physics_rigid_bodies = {
1122
+ ...l.length > 0 ? { physicsMaterials: l } : {},
1123
+ ...u.length > 0 ? { collisionFilters: u } : {},
1124
+ ...d.length > 0 ? { physicsJoints: d } : {}
1125
+ }), p.size > 0 && (t.extensionsUsed = [...p]);
1084
1126
  });
1085
1127
  }
1086
1128
  // src/assemblyPlan.ts
1087
- var Ze = (e) => new j.Matrix4().compose(new j.Vector3().fromArray(e.localPosition), new j.Quaternion().fromArray(e.localQuaternion), new j.Vector3(1, 1, 1));
1088
- function Qe(e, t) {
1089
- let n = new j.Matrix4();
1090
- for (let r = e; r && r !== t; r = r.parent) {
1091
- if (!r.parent) throw new v(`Node "${e.name}" is detached from bundle.scene`);
1092
- r.updateMatrix(), n.premultiply(r.matrix);
1129
+ function ct(t, n) {
1130
+ let r = new P.Matrix4();
1131
+ for (let i = t; i && i !== n; i = i.parent) {
1132
+ if (!i.parent) throw new e(`Node "${t.name}" is detached from bundle.scene`);
1133
+ i.updateMatrix(), r.premultiply(i.matrix);
1093
1134
  }
1094
- return n;
1135
+ return r;
1095
1136
  }
1096
- function $e(e, t) {
1137
+ function lt(e, t) {
1097
1138
  let n = (e) => {
1098
1139
  let n = [];
1099
1140
  for (let r = e; r && (n.push(r), r !== t); r = r.parent);
@@ -1106,127 +1147,134 @@ function $e(e, t) {
1106
1147
  for (let t of n(e[0])) if (r.has(t)) return t;
1107
1148
  return t;
1108
1149
  }
1109
- function et(e, t, n) {
1110
- if (n && e.mass > 0 && e.colliders.length === 0) throw new v(`Dynamic body "${e.nodeName}" has mass ${e.mass} but no colliders to carry it`);
1111
- return e.colliders.map((r, i) => {
1112
- let a = new j.Quaternion().fromArray(r.localQuaternion), o = new j.Matrix4().compose(new j.Vector3().fromArray(r.localPosition), a, new j.Vector3(1, 1, 1)), s = new j.Vector3(), c = new j.Quaternion(), l = new j.Vector3();
1113
- new j.Matrix4().multiplyMatrices(t, o).decompose(s, c, l);
1114
- let u = {
1115
- spec: r,
1116
- local: o,
1150
+ function ut(e, t, n) {
1151
+ let r = new P.Vector3().fromArray(e.com), i = new P.Quaternion().fromArray(e.inertiaFrame);
1152
+ return t && n && (r.applyMatrix4(t.clone().invert()), i.premultiply(n.clone().invert()).normalize()), {
1153
+ mass: e.mass,
1154
+ centerOfMass: {
1155
+ x: r.x,
1156
+ y: r.y,
1157
+ z: r.z
1158
+ },
1159
+ principalAngularInertia: {
1160
+ x: e.inertia[0],
1161
+ y: e.inertia[1],
1162
+ z: e.inertia[2]
1163
+ },
1164
+ angularInertiaLocalFrame: {
1165
+ x: i.x,
1166
+ y: i.y,
1167
+ z: i.z,
1168
+ w: i.w
1169
+ }
1170
+ };
1171
+ }
1172
+ function dt(e, t, n) {
1173
+ 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);
1176
+ let l = {
1177
+ spec: e,
1178
+ local: a,
1117
1179
  position: [
1118
- s.x,
1119
- s.y,
1120
- s.z
1180
+ o.x,
1181
+ o.y,
1182
+ o.z
1121
1183
  ],
1122
1184
  quaternion: [
1123
- c.x,
1124
- c.y,
1125
- c.z,
1126
- c.w
1185
+ s.x,
1186
+ s.y,
1187
+ s.z,
1188
+ s.w
1127
1189
  ]
1128
1190
  };
1129
- if (i === 0 && n) {
1130
- let t = o.clone().invert(), n = new j.Vector3().fromArray(e.centerOfMass).applyMatrix4(t), r = a.clone().invert().multiply(new j.Quaternion().fromArray(e.inertiaOrientation)), [i, s, c] = e.inertiaDiagonal;
1131
- u.massProperties = {
1132
- mass: e.mass,
1133
- centerOfMass: {
1134
- x: n.x,
1135
- y: n.y,
1136
- z: n.z
1137
- },
1138
- principalAngularInertia: {
1139
- x: i,
1140
- y: s,
1141
- z: c
1142
- },
1143
- angularInertiaLocalFrame: {
1144
- x: r.x,
1145
- y: r.y,
1146
- z: r.z,
1147
- w: r.w
1148
- }
1149
- };
1150
- }
1151
- return u;
1191
+ return r === 0 && n && (l.massProperties = ut(n, a, i)), l;
1152
1192
  });
1153
1193
  }
1154
- function tt(e) {
1155
- let t = new Map(e.bodies.map((e) => [e.nodeName, e])), n = (e, r = /* @__PURE__ */ new Set()) => {
1156
- if (!e.joint) return e;
1157
- if (r.has(e.nodeName)) throw new v(`Joint cycle through "${e.nodeName}"`);
1158
- r.add(e.nodeName);
1159
- let i = t.get(e.joint.connectedNodeName);
1160
- if (!i) throw new v(`Joint on "${e.nodeName}" targets "${e.joint.connectedNodeName}", which is not a KHR body`);
1161
- return n(i, r);
1162
- }, r = e.bodies.filter((e) => !e.joint).map((r) => {
1163
- let i = Ze(r).clone().invert(), a = e.bodies.filter((e) => e.joint && n(e) === r), o = (e) => e.joint ? 1 + o(t.get(e.joint.connectedNodeName)) : 0;
1164
- a.sort((e, t) => o(e) - o(t));
1165
- let s = /* @__PURE__ */ new Map(), c = a.map((e) => {
1166
- let t = e.joint, n = s.get(t.connectedNodeName) ?? null;
1167
- if (n && !nt(e.object, n.spec.object)) throw new v(`Jointed node "${e.nodeName}" must be a scene-graph descendant of its jointed parent "${t.connectedNodeName}"`);
1168
- let r = i.clone().multiply(Ze(e)), a = {
1169
- spec: e,
1170
- joint: t,
1171
- parent: n,
1172
- restRelParent: n ? Ze(n.spec).invert().multiply(Ze(e)) : r,
1173
- inertia: re(e, t),
1174
- colliders: et(e, r, !0)
1194
+ function ft(e, t, n) {
1195
+ 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
+ return !1;
1197
+ }
1198
+ function pt(t) {
1199
+ let r = new Map(t.bodies.map((e) => [e.nodeName, e])), i = (t, n = /* @__PURE__ */ new Set()) => {
1200
+ if (!t.joint) return t;
1201
+ if (n.has(t.nodeName)) throw new e(`Joint cycle through "${t.nodeName}"`);
1202
+ n.add(t.nodeName);
1203
+ let a = r.get(t.joint.connectedNodeName);
1204
+ if (!a) throw new e(`Joint on "${t.nodeName}" targets "${t.joint.connectedNodeName}", which is not a KHR body`);
1205
+ return i(a, n);
1206
+ }, a = t.bodies.filter((e) => !e.joint).map((a) => {
1207
+ let o = x(a).clone().invert(), s = t.bodies.filter((e) => e.joint && i(e) === a), c = (e) => e.joint ? 1 + c(r.get(e.joint.connectedNodeName)) : 0;
1208
+ s.sort((e, t) => c(e) - c(t));
1209
+ let l = /* @__PURE__ */ new Map(), u = s.map((t) => {
1210
+ 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}"`);
1212
+ let a = o.clone().multiply(x(t)), c = {
1213
+ spec: t,
1214
+ joint: n,
1215
+ parent: i,
1216
+ 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)
1175
1219
  };
1176
- return s.set(e.nodeName, a), a;
1177
- }), l = $e([r.object, ...a.map((e) => e.object)], e.scene), u = i.clone().multiply(Qe(l, e.scene)), d = new j.Vector3(), f = new j.Quaternion(), p = new j.Vector3();
1178
- i.decompose(d, f, p), f.normalize();
1179
- let m = new j.Vector3(), h = new j.Quaternion(), g = new j.Vector3();
1180
- return u.decompose(m, h, g), h.normalize(), {
1181
- spec: r,
1220
+ 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();
1222
+ o.decompose(g, _, v), _.normalize();
1223
+ let y = new P.Vector3(), b = new P.Quaternion(), S = new P.Vector3();
1224
+ return h.decompose(y, b, S), b.normalize(), {
1225
+ spec: a,
1182
1226
  sceneInRootPos: [
1183
- d.x,
1184
- d.y,
1185
- d.z
1227
+ g.x,
1228
+ g.y,
1229
+ g.z
1186
1230
  ],
1187
1231
  sceneInRootQuat: [
1188
- f.x,
1189
- f.y,
1190
- f.z,
1191
- f.w
1232
+ _.x,
1233
+ _.y,
1234
+ _.z,
1235
+ _.w
1192
1236
  ],
1193
- mountNode: l,
1194
- mountInRoot: u,
1237
+ mountNode: m,
1238
+ mountInRoot: h,
1195
1239
  mountPosition: [
1196
- m.x,
1197
- m.y,
1198
- m.z
1240
+ y.x,
1241
+ y.y,
1242
+ y.z
1199
1243
  ],
1200
1244
  mountQuaternion: [
1201
- h.x,
1202
- h.y,
1203
- h.z,
1204
- h.w
1245
+ b.x,
1246
+ b.y,
1247
+ b.z,
1248
+ b.w
1205
1249
  ],
1206
- colliders: et(r, new j.Matrix4(), !r.isKinematic),
1207
- parts: c
1250
+ ...p ? { rootMass: p } : {},
1251
+ colliders: f,
1252
+ parts: u
1208
1253
  };
1209
1254
  });
1210
- for (let e of r) for (let t of r) if (e !== t && nt(t.mountNode, e.mountNode)) throw new v(`Root bodies "${e.spec.nodeName}" and "${t.spec.nodeName}" share scene subtree "${e.mountNode.name}"; split them into separate glTF branches`);
1211
- return r;
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`);
1256
+ return a;
1212
1257
  }
1213
- function nt(e, t) {
1258
+ function mt(e, t) {
1214
1259
  for (let n = e; n; n = n.parent) if (n === t) return !0;
1215
1260
  return !1;
1216
1261
  }
1217
1262
  // src/AssemblyRootBody.tsx
1218
- function rt({ plan: e, assemblyId: n, position: r, quaternion: i, fixedRoot: a, rigidBodyProps: o, onBody: s, onJoints: c, children: l }) {
1219
- let u = x(y), d = T(null), f = w(() => e.parts.map((e) => e.colliders.map(() => ({ current: null }))), [e]), p = e.spec;
1220
- C(() => (s(p.nodeName, d), () => s(p.nodeName, null)), [p, s]), C(() => {
1221
- let t = /* @__PURE__ */ new Map();
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;
1265
+ E(() => (s(p.nodeName, d), () => s(p.nodeName, null)), [p, s]), E(() => {
1266
+ let t = d.current, n = e.rootMass;
1267
+ t && n && (t.setAdditionalMassProperties(n.mass, n.centerOfMass, n.principalAngularInertia, n.angularInertiaLocalFrame, !0), t.recomputeMassPropertiesFromColliders());
1268
+ }, [e.rootMass]), E(() => {
1269
+ let n = /* @__PURE__ */ new Map();
1222
1270
  for (let r = 0; r < e.parts.length; r++) {
1223
1271
  let i = e.parts[r], a = i.joint.drive, o = {
1224
- assemblyId: n,
1272
+ assemblyId: t,
1225
1273
  nodeName: i.spec.nodeName,
1226
1274
  role: i.joint.role,
1227
1275
  kind: i.joint.kind,
1228
1276
  object: i.spec.object,
1229
- axis: new j.Vector3().fromArray(i.joint.axis).normalize(),
1277
+ axis: new P.Vector3().fromArray(i.joint.axis).normalize(),
1230
1278
  restPosition: i.spec.object.position.clone(),
1231
1279
  restQuaternion: i.spec.object.quaternion.clone(),
1232
1280
  q: 0,
@@ -1238,7 +1286,7 @@ function rt({ plan: e, assemblyId: n, position: r, quaternion: i, fixedRoot: a,
1238
1286
  limitStiffness: i.joint.limitStiffness ?? null,
1239
1287
  limitDamping: i.joint.limitDamping ?? 0,
1240
1288
  inertia: i.inertia,
1241
- parent: i.parent ? t.get(i.parent.spec.nodeName) : null,
1289
+ parent: i.parent ? n.get(i.parent.spec.nodeName) : null,
1242
1290
  restRelParent: i.restRelParent,
1243
1291
  current: i.restRelParent.clone(),
1244
1292
  stamp: -1,
@@ -1247,76 +1295,76 @@ function rt({ plan: e, assemblyId: n, position: r, quaternion: i, fixedRoot: a,
1247
1295
  local: e.local
1248
1296
  }))
1249
1297
  };
1250
- t.set(o.nodeName, o), u?.add(o);
1298
+ n.set(o.nodeName, o), u?.add(o);
1251
1299
  }
1252
- return c(p.nodeName, t), () => {
1300
+ return c(p.nodeName, n), () => {
1253
1301
  c(p.nodeName, null);
1254
- for (let e of t.values()) u?.delete(e), e.object.position.copy(e.restPosition), e.object.quaternion.copy(e.restQuaternion);
1302
+ for (let e of n.values()) u?.delete(e), e.object.position.copy(e.restPosition), e.object.quaternion.copy(e.restQuaternion);
1255
1303
  };
1256
1304
  }, [
1257
1305
  e,
1258
1306
  u,
1259
- n,
1307
+ t,
1260
1308
  f,
1261
1309
  p,
1262
1310
  c
1263
1311
  ]);
1264
1312
  let m = p.isKinematic ? a ? "fixed" : "kinematicPosition" : "dynamic";
1265
- return /* @__PURE__ */ N(k, {
1313
+ return /* @__PURE__ */ I(M, {
1266
1314
  ...o,
1267
1315
  ref: d,
1268
1316
  type: m,
1269
- position: r,
1270
- quaternion: i,
1317
+ position: n,
1318
+ quaternion: r,
1271
1319
  colliders: !1,
1272
1320
  ...p.linearVelocity ? { linearVelocity: p.linearVelocity } : {},
1273
1321
  ...p.angularVelocity ? { angularVelocity: p.angularVelocity } : {},
1274
1322
  ...p.gravityFactor === void 0 ? {} : { gravityScale: p.gravityFactor },
1275
1323
  children: [
1276
1324
  l,
1277
- e.colliders.map((e, n) => /* @__PURE__ */ M(t, {
1325
+ e.colliders.map((e, t) => /* @__PURE__ */ F(i, {
1278
1326
  c: e.spec,
1279
1327
  position: e.position,
1280
1328
  quaternion: e.quaternion,
1281
1329
  massProperties: e.massProperties
1282
- }, `r${n}`)),
1283
- e.parts.map((e, n) => e.colliders.map((r, i) => /* @__PURE__ */ M(t, {
1284
- ref: f[n][i],
1285
- c: r.spec,
1286
- position: r.position,
1287
- quaternion: r.quaternion,
1288
- massProperties: r.massProperties
1289
- }, `${e.spec.nodeName}:${i}`)))
1330
+ }, `r${t}`)),
1331
+ e.parts.map((e, t) => e.colliders.map((n, r) => /* @__PURE__ */ F(i, {
1332
+ ref: f[t][r],
1333
+ c: n.spec,
1334
+ position: n.position,
1335
+ quaternion: n.quaternion,
1336
+ massProperties: n.massProperties
1337
+ }, `${e.spec.nodeName}:${r}`)))
1290
1338
  ]
1291
1339
  });
1292
1340
  }
1293
1341
  // src/KhrAssembly.tsx
1294
- var it = 0;
1295
- function at({ ref: e, bundle: t, position: n = [
1342
+ var gt = 0;
1343
+ function _t({ ref: t, bundle: n, position: r = [
1296
1344
  0,
1297
1345
  0,
1298
1346
  0
1299
- ], rotation: r, quaternion: o, scale: s, fixedRoot: c = !1, rigidBodyProps: l, children: d, ...f }) {
1300
- a(s, "KhrAssembly"), t.scene.updateMatrixWorld(!0), i(t.scene);
1301
- let m = w(() => it++, []), g = w(() => tt(t), [t]), _ = w(() => g.length > 1 ? p(g.map((e) => e.mountNode)) : null, [g]), [y, x, C] = n, [E, D, O] = r ?? [
1347
+ ], rotation: i, quaternion: a, scale: o, fixedRoot: l = !1, rigidBodyProps: u, children: d, ...f }) {
1348
+ 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 ?? [
1302
1350
  0,
1303
1351
  0,
1304
1352
  0
1305
- ], [k, A, P, F] = o ?? [
1353
+ ], [E, te, k, A] = a ?? [
1306
1354
  NaN,
1307
1355
  NaN,
1308
1356
  NaN,
1309
1357
  NaN
1310
- ], I = w(() => o ? new j.Quaternion(k, A, P, F) : new j.Quaternion().setFromEuler(new j.Euler(E, D, O)), [
1358
+ ], j = D(() => a ? new P.Quaternion(E, te, k, A) : new P.Quaternion().setFromEuler(new P.Euler(S, C, T)), [
1359
+ E,
1360
+ te,
1311
1361
  k,
1312
1362
  A,
1313
- P,
1314
- F,
1315
- E,
1316
- D,
1317
- O
1318
- ]), L = w(() => g.map((e) => {
1319
- let t = new j.Vector3().fromArray(e.spec.localPosition).applyQuaternion(I).add(new j.Vector3(y, x, C)), n = I.clone().multiply(new j.Quaternion().fromArray(e.spec.localQuaternion));
1363
+ S,
1364
+ C,
1365
+ 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));
1320
1368
  return {
1321
1369
  position: [
1322
1370
  t.x,
@@ -1331,117 +1379,117 @@ function at({ ref: e, bundle: t, position: n = [
1331
1379
  ]
1332
1380
  };
1333
1381
  }), [
1334
- g,
1335
- I,
1382
+ h,
1383
+ j,
1336
1384
  y,
1337
- x,
1338
- C
1339
- ]), R = T(/* @__PURE__ */ new Map()), z = T(/* @__PURE__ */ new Map()), B = w(() => {
1385
+ b,
1386
+ x
1387
+ ]), N = O(/* @__PURE__ */ new Map()), L = O(/* @__PURE__ */ new Map()), R = D(() => {
1340
1388
  let e = /* @__PURE__ */ new Map();
1341
- for (let t of g) {
1389
+ for (let t of h) {
1342
1390
  e.set(t.spec.nodeName, t.spec.nodeName);
1343
1391
  for (let n of t.parts) e.set(n.spec.nodeName, t.spec.nodeName);
1344
1392
  }
1345
1393
  return e;
1346
- }, [g]), ee = b((e, t) => {
1347
- t ? R.current.set(e, t) : R.current.delete(e);
1348
- }, []), te = b((e, t) => {
1349
- t ? z.current.set(e, t) : z.current.delete(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);
1350
1398
  }, []);
1351
- if (S(e, () => {
1352
- let e = (e, t) => {
1353
- if (!e.drive || e.drive.stiffness === void 0) throw new v(`Joint "${e.nodeName}" has no authored drive stiffness; cannot set a position target`);
1354
- e.positionTarget = t;
1355
- let n = R.current.get(B.get(e.nodeName))?.current;
1356
- n && n.isDynamic() && n.wakeUp();
1399
+ if (ee(t, () => {
1400
+ let t = (t, n) => {
1401
+ 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
+ t.positionTarget = n;
1403
+ let r = N.current.get(R.get(t.nodeName))?.current;
1404
+ r && r.isDynamic() && r.wakeUp();
1357
1405
  };
1358
1406
  return {
1359
1407
  getBody: (e) => {
1360
- let t = B.get(e);
1361
- return t ? R.current.get(t)?.current ?? null : null;
1408
+ let t = R.get(e);
1409
+ return t ? N.current.get(t)?.current ?? null : null;
1362
1410
  },
1363
- setJointTarget: (t, n) => {
1364
- let r = z.current.get(B.get(t) ?? "")?.get(t);
1365
- r && e(r, n);
1411
+ setJointTarget: (e, n) => {
1412
+ let r = L.current.get(R.get(e) ?? "")?.get(e);
1413
+ r && t(r, n);
1366
1414
  },
1367
- setRoleTarget: (t, n) => {
1368
- for (let r of z.current.values()) for (let i of r.values()) i.role === t && e(i, n);
1415
+ setRoleTarget: (e, n) => {
1416
+ for (let r of L.current.values()) for (let i of r.values()) i.role === e && t(i, n);
1369
1417
  }
1370
1418
  };
1371
- }, [B]), g.length === 1) {
1372
- let e = g[0];
1373
- return /* @__PURE__ */ M("group", {
1419
+ }, [R]), h.length === 1) {
1420
+ let e = h[0];
1421
+ return /* @__PURE__ */ F("group", {
1374
1422
  ...f,
1375
- children: /* @__PURE__ */ M(rt, {
1423
+ children: /* @__PURE__ */ F(ht, {
1376
1424
  plan: e,
1377
1425
  assemblyId: m,
1378
- position: L[0].position,
1379
- quaternion: L[0].quaternion,
1380
- fixedRoot: c,
1381
- rigidBodyProps: l,
1382
- onBody: ee,
1383
- onJoints: te,
1384
- children: /* @__PURE__ */ N("group", {
1426
+ position: M[0].position,
1427
+ quaternion: M[0].quaternion,
1428
+ fixedRoot: l,
1429
+ rigidBodyProps: u,
1430
+ onBody: z,
1431
+ onJoints: B,
1432
+ children: /* @__PURE__ */ I("group", {
1385
1433
  position: e.sceneInRootPos,
1386
1434
  quaternion: e.sceneInRootQuat,
1387
- children: [/* @__PURE__ */ M(h, {
1388
- bundle: t,
1435
+ children: [/* @__PURE__ */ F(v, {
1436
+ bundle: n,
1389
1437
  owner: "KhrAssembly"
1390
1438
  }), d]
1391
1439
  })
1392
- }, `${t.scene.uuid}:${e.spec.nodeName}`)
1440
+ }, `${n.scene.uuid}:${e.spec.nodeName}`)
1393
1441
  });
1394
1442
  }
1395
- return /* @__PURE__ */ N("group", {
1443
+ return /* @__PURE__ */ I("group", {
1396
1444
  ...f,
1397
- children: [/* @__PURE__ */ N("group", {
1398
- position: n,
1399
- quaternion: I,
1400
- children: [/* @__PURE__ */ M(h, {
1401
- bundle: t,
1445
+ children: [/* @__PURE__ */ I("group", {
1446
+ position: r,
1447
+ quaternion: j,
1448
+ children: [/* @__PURE__ */ F(v, {
1449
+ bundle: n,
1402
1450
  owner: "KhrAssembly"
1403
1451
  }), d]
1404
- }), g.map((e, n) => /* @__PURE__ */ M(rt, {
1452
+ }), h.map((e, t) => /* @__PURE__ */ F(ht, {
1405
1453
  plan: e,
1406
1454
  assemblyId: m,
1407
- position: L[n].position,
1408
- quaternion: L[n].quaternion,
1409
- fixedRoot: c,
1410
- rigidBodyProps: l,
1411
- onBody: ee,
1412
- onJoints: te,
1413
- children: /* @__PURE__ */ M(u, {
1455
+ position: M[t].position,
1456
+ quaternion: M[t].quaternion,
1457
+ fixedRoot: l,
1458
+ rigidBodyProps: u,
1459
+ onBody: z,
1460
+ onJoints: B,
1461
+ children: /* @__PURE__ */ F(p, {
1414
1462
  object: e.mountNode,
1415
1463
  position: e.mountPosition,
1416
1464
  quaternion: e.mountQuaternion,
1417
1465
  origin: _.get(e.mountNode)
1418
1466
  })
1419
- }, `${t.scene.uuid}:${e.spec.nodeName}`))]
1467
+ }, `${n.scene.uuid}:${e.spec.nodeName}`))]
1420
1468
  });
1421
1469
  }
1422
1470
  // src/useKhrGlb.ts
1423
- var ot = class extends P {
1471
+ var vt = class extends L {
1424
1472
  static khrLoaderScope = Symbol("KhrGLTFLoader");
1425
- }, st = Ie(), ct = Ve(), lt = /* @__PURE__ */ new WeakSet(), ut = /* @__PURE__ */ new WeakSet(), $ = /* @__PURE__ */ new Map();
1426
- function dt(e) {
1427
- lt.has(e) || (lt.add(e), typeof document > "u" && typeof createImageBitmap > "u" && e.register(st), e.register(ct));
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));
1428
1476
  }
1429
- function ft(e) {
1477
+ function wt(e) {
1430
1478
  return !!(e?.extendLoader || e?.cacheKey !== void 0);
1431
1479
  }
1432
- function pt(e) {
1480
+ function Tt(e) {
1433
1481
  return e.cacheKey === void 0 ? `src:${Function.prototype.toString.call(e.extendLoader)}` : `key:${e.cacheKey}`;
1434
1482
  }
1435
- function mt(e, t) {
1436
- let n = pt(t), r = $.get(e);
1483
+ function Et(e, t) {
1484
+ let n = Tt(t), r = $.get(e);
1437
1485
  r || (r = /* @__PURE__ */ new Map(), $.set(e, r));
1438
1486
  let i = r.get(n);
1439
1487
  if (!i) {
1440
- let a = new P(), o = t.extendLoader, s = {
1488
+ let a = new L(), o = t.extendLoader, s = {
1441
1489
  loader: a,
1442
1490
  registerExtensions: (t) => {
1443
- if (dt(t), o && !ut.has(t)) try {
1444
- o(t), ut.add(t);
1491
+ if (Ct(t), o && !St.has(t)) try {
1492
+ o(t), St.add(t);
1445
1493
  } catch (t) {
1446
1494
  let r = $.get(e);
1447
1495
  throw r?.get(n) === s && (r.delete(n), r.size === 0 && $.delete(e)), t;
@@ -1452,33 +1500,33 @@ function mt(e, t) {
1452
1500
  }
1453
1501
  return i;
1454
1502
  }
1455
- function ht(e, t) {
1456
- let n = t?.extractRole, r = t?.isSocketNode, i = ft(t) ? mt(e, t) : null, a = i ? i.loader : ot, o = i ? i.registerExtensions : dt, s = D(a, e, o).userData[ze];
1457
- if (!s) throw new v(`useKhrGlb: missing "${ze}" on loaded GLTF for "${e}"`);
1458
- return w(() => {
1459
- let e = m(s);
1460
- return (n || r) && ve(e, s, n, r), e;
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(() => {
1507
+ let e = _(c);
1508
+ return (r || i) && De(e, c, r, i), e;
1461
1509
  }, [
1462
- s,
1463
- n,
1464
- r
1510
+ c,
1511
+ r,
1512
+ i
1465
1513
  ]);
1466
1514
  }
1467
- ht.preload = (e, t) => {
1468
- let n = ft(t) ? mt(e, t) : null, r = n ? n.loader : ot, i = n ? n.registerExtensions : dt;
1469
- D.preload(r, e, i);
1470
- }, ht.clear = (e, t) => {
1471
- if (ft(t)) {
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)) {
1472
1520
  let n = $.get(e);
1473
1521
  if (!n) return;
1474
- let r = pt(t), i = n.get(r);
1475
- i && (D.clear(i.loader, e), n.delete(r), n.size === 0 && $.delete(e));
1476
- } else if (D.clear(ot, e), t === void 0) {
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) {
1477
1525
  let t = $.get(e);
1478
1526
  if (t) {
1479
- for (let n of t.values()) D.clear(n.loader, e);
1527
+ for (let n of t.values()) A.clear(n.loader, e);
1480
1528
  $.delete(e);
1481
1529
  }
1482
1530
  }
1483
1531
  };
1484
- export { y as JointRegistryContext, at as KhrAssembly, t as KhrCollider, v as KhrValidationError, ce as PhysicsWorld, g as assertIdentityWorldScale, d as claimBundleMount, m as cloneKhrBundle, Ve as createKhrGltfPlugin, r as disposeKhrBundle, Xe as exportKhrGlb, We as loadKhrGlb, he as patchGlbJsonChunk, c as releaseBundleMount, ht as useKhrGlb };
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 };