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