@nebula-spatial/viewer 0.5.9 → 0.5.11
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/CHANGELOG.md +94 -40
- package/README.md +22 -11
- package/USD-VISUAL-MATERIAL-SUPPORT.md +59 -15
- package/dist/assets/types.d.ts +1 -1
- package/dist/assets/{usd-worker-B9O1idq-.js → usd-worker-CPCXyXkl.js} +3 -3
- package/dist/collision-debug-COTEHr4t.js +2935 -0
- package/dist/{index-BQn4yVNd.js → index-BStaY4GZ.js} +2723 -2562
- package/dist/index.js +3 -3
- package/dist/{mjcf-visual-BxcQ3hIg.js → mjcf-visual-CD52zbv0.js} +1 -1
- package/dist/{mujoco-runtime-DNqHIXvQ.js → mujoco-runtime-sHgzRbpf.js} +1 -1
- package/dist/{session-S3ZuhqY8.js → session-CU4-Zy1h.js} +7 -7
- package/dist/{session-9j-PNz4O.js → session-HOTFzdIP.js} +2 -2
- package/dist/{stage-Ck2xORK4.js → stage-BwDT2iC9.js} +1 -1
- package/dist/types.d.ts +11 -0
- package/dist/{urdf-session-DJs9oT_G.js → urdf-session-D-o78xoS.js} +5 -5
- package/dist/usd-session-CxFNEMic.js +8374 -0
- package/dist/version.d.ts +1 -1
- package/dist/{xacro-CFFshEJJ.js → xacro-Bpz-UyEX.js} +1 -1
- package/openusd/openusd-runtime-manifest.json +4 -4
- package/openusd/openusd_probe.wasm +0 -0
- package/package.json +1 -1
- package/dist/collision-debug-FutuxXPm.js +0 -2896
- package/dist/usd-session-BEjswMmU.js +0 -7461
|
@@ -1,2896 +0,0 @@
|
|
|
1
|
-
var Dn = Object.defineProperty;
|
|
2
|
-
var Cn = (n, t, e) => t in n ? Dn(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
-
var it = (n, t, e) => Cn(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { Vector3 as U, Box3 as st, Matrix4 as mt, BufferAttribute as xn, Line3 as ct, Plane as bn, Vector2 as yt, Triangle as Et, BackSide as On, DoubleSide as _n, REVISION as An, Ray as Fn, FrontSide as Je, Mesh as jt, LineSegments as ze, LineLoop as Sn, Line as Bn, Points as Tn, Sphere as zn, BatchedMesh as Vn, LineBasicMaterial as jn, MeshBasicMaterial as $n, WireframeGeometry as kn, EdgesGeometry as ge } from "three";
|
|
5
|
-
import { disposeModelResources as qn } from "./resources-CHhCm2f7.js";
|
|
6
|
-
import { s as He, t as Jn, u as Hn, v as Wn, U as Yn, n as Xn } from "./index-BQn4yVNd.js";
|
|
7
|
-
const Gn = /* @__PURE__ */ new Set([
|
|
8
|
-
"E_MJCF_INCLUDE_CYCLE",
|
|
9
|
-
"E_MJCF_PARSE",
|
|
10
|
-
"E_URDF_COMPILE",
|
|
11
|
-
"E_URDF_INERTIA",
|
|
12
|
-
"E_USD_INVALID_COLLISION_GEOMETRY",
|
|
13
|
-
"E_USD_INVALID_COLLISION_GROUP",
|
|
14
|
-
"E_USD_INVALID_EQUALITY_CONNECT",
|
|
15
|
-
"E_USD_INVALID_JOINT_REFERENCE",
|
|
16
|
-
"E_USD_INVALID_MASS",
|
|
17
|
-
"E_USD_INVALID_MIMIC",
|
|
18
|
-
"E_USD_INVALID_UNITS",
|
|
19
|
-
"E_USD_MISSING_COLLISION_GEOMETRY",
|
|
20
|
-
"E_USD_MULTIPLE_PHYSICS_SCENES",
|
|
21
|
-
"E_USD_PARTIAL_INERTIA",
|
|
22
|
-
"E_USD_UNREACHABLE_BODIES"
|
|
23
|
-
]), Zn = /* @__PURE__ */ new Set(["step", "reset", "grab", "up-axis"]), Kn = Object.freeze({
|
|
24
|
-
kind: "visual-adaptation",
|
|
25
|
-
title: "视觉适配信息",
|
|
26
|
-
summary: "部分材质细节采用近似表示,不影响资产结构与模型查看。",
|
|
27
|
-
tone: "info"
|
|
28
|
-
}), Qn = Object.freeze({
|
|
29
|
-
kind: "unsupported-by-viewer",
|
|
30
|
-
title: "视觉预览模式",
|
|
31
|
-
summary: "当前仿真链路未能建立物理模型,资产视觉内容仍可正常查看。",
|
|
32
|
-
tone: "info"
|
|
33
|
-
});
|
|
34
|
-
function Ee(n, t) {
|
|
35
|
-
return n === "E_URDF_INERTIA" ? {
|
|
36
|
-
kind: "invalid-asset",
|
|
37
|
-
title: "物理定义无效",
|
|
38
|
-
summary: "该 URDF 未声明动力学仿真所需的有效惯性数据,动力学模型无法建立。",
|
|
39
|
-
tone: "warning"
|
|
40
|
-
} : {
|
|
41
|
-
kind: "invalid-asset",
|
|
42
|
-
title: "物理定义无效",
|
|
43
|
-
summary: t === "usd-physics" ? "该 USD 资产的物理参数或关节定义无效,物理模型无法建立。" : "该资产的物理参数缺失或无效,物理模型无法建立。",
|
|
44
|
-
tone: "warning"
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function ti(n) {
|
|
48
|
-
return n === "visual-material" ? {
|
|
49
|
-
kind: "visual-adaptation",
|
|
50
|
-
title: "视觉材质近似",
|
|
51
|
-
summary: "部分材质信息未完整转换,当前显示使用近似材质。",
|
|
52
|
-
tone: "info"
|
|
53
|
-
} : Kn;
|
|
54
|
-
}
|
|
55
|
-
function Pn(n, t) {
|
|
56
|
-
const e = t.split(":").at(-1);
|
|
57
|
-
if (e && Zn.has(e))
|
|
58
|
-
return {
|
|
59
|
-
kind: "runtime-failure",
|
|
60
|
-
title: "仿真运行异常",
|
|
61
|
-
summary: "仿真初始化或运行过程中发生异常,物理仿真已停止;资产视觉内容仍可正常查看。",
|
|
62
|
-
tone: "warning"
|
|
63
|
-
};
|
|
64
|
-
if (n === "E_MUJOCO_INITIALIZE") {
|
|
65
|
-
if (t === "mjcf-physics")
|
|
66
|
-
return {
|
|
67
|
-
kind: "runtime-failure",
|
|
68
|
-
title: "物理模型初始化失败",
|
|
69
|
-
summary: "MuJoCo 物理模型初始化失败,资产仍可进行视觉预览。",
|
|
70
|
-
tone: "warning"
|
|
71
|
-
};
|
|
72
|
-
if (t === "urdf-physics")
|
|
73
|
-
return {
|
|
74
|
-
kind: "runtime-failure",
|
|
75
|
-
title: "动力学初始化失败",
|
|
76
|
-
summary: "URDF 动力学初始化失败,当前保留运动学预览。",
|
|
77
|
-
tone: "warning"
|
|
78
|
-
};
|
|
79
|
-
if (t === "usd-physics")
|
|
80
|
-
return {
|
|
81
|
-
kind: "runtime-failure",
|
|
82
|
-
title: "物理模型初始化失败",
|
|
83
|
-
summary: "当前 USD 物理模型未能完成 MuJoCo 初始化,资产视觉内容仍可正常查看。",
|
|
84
|
-
tone: "warning"
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
return Gn.has(n) ? Ee(n, t) : t === "usd-physics" || n.startsWith("E_USD_") ? {
|
|
88
|
-
kind: "unsupported-by-viewer",
|
|
89
|
-
title: "视觉预览模式",
|
|
90
|
-
summary: "当前 Viewer 未覆盖该 USD 资产使用的部分物理语义,视觉与结构信息可正常查看,物理仿真未启动。",
|
|
91
|
-
tone: "info"
|
|
92
|
-
} : n.startsWith("E_MJCF_") || n.startsWith("E_URDF_") ? Ee(n, t) : Qn;
|
|
93
|
-
}
|
|
94
|
-
function Es(n, t) {
|
|
95
|
-
const e = n.notice ?? (t === "physics-validation" ? Ee(n.code, n.source) : t === "visual-adaptation" || t === "visual-material" ? ti(t) : Pn(n.code, n.source ?? t));
|
|
96
|
-
return { ...n, stage: t, notice: e };
|
|
97
|
-
}
|
|
98
|
-
function Ms(n, t, e) {
|
|
99
|
-
if (t.throwIfAborted(), n instanceof Error && (n.name === "AbortError" || ["E_ABORTED", "E_SUPERSEDED"].includes(String(n.code)))) throw n;
|
|
100
|
-
const s = n && typeof n == "object" && "code" in n && typeof n.code == "string" ? n.code : "E_PHYSICS_INITIALIZE", i = n instanceof Error ? n.message : String(n);
|
|
101
|
-
return { code: s, source: e, message: i, notice: Pn(s, e) };
|
|
102
|
-
}
|
|
103
|
-
function ei(n, t, e) {
|
|
104
|
-
const s = new Map(n.map((y) => [y.id, y])), i = /* @__PURE__ */ new Map(), o = (y, _ = /* @__PURE__ */ new Set()) => {
|
|
105
|
-
if (i.has(y)) return i.get(y);
|
|
106
|
-
const B = s.get(y);
|
|
107
|
-
if (!B) return null;
|
|
108
|
-
if (!B.mimic) {
|
|
109
|
-
const x = { root: y, multiplier: 1, offset: 0 };
|
|
110
|
-
return i.set(y, x), x;
|
|
111
|
-
}
|
|
112
|
-
if (_.has(y) || !s.has(B.mimic.joint) || !Number.isFinite(B.mimic.multiplier) || !Number.isFinite(B.mimic.offset))
|
|
113
|
-
return i.set(y, null), null;
|
|
114
|
-
_.add(y);
|
|
115
|
-
const b = o(B.mimic.joint, _);
|
|
116
|
-
if (_.delete(y), !b)
|
|
117
|
-
return i.set(y, null), null;
|
|
118
|
-
const T = {
|
|
119
|
-
root: b.root,
|
|
120
|
-
multiplier: B.mimic.multiplier * b.multiplier,
|
|
121
|
-
offset: B.mimic.multiplier * b.offset + B.mimic.offset
|
|
122
|
-
};
|
|
123
|
-
return i.set(y, T), T;
|
|
124
|
-
}, r = new Map(n.map((y) => {
|
|
125
|
-
const _ = o(y.id);
|
|
126
|
-
return [y.id, _ ?? { root: y.id, multiplier: 1, offset: 0 }];
|
|
127
|
-
})), a = /* @__PURE__ */ new Map();
|
|
128
|
-
for (const y of n) {
|
|
129
|
-
const _ = r.get(y.id);
|
|
130
|
-
a.has(_.root) || a.set(_.root, { lower: -1 / 0, upper: 1 / 0, feasible: !0 });
|
|
131
|
-
const B = y.limits;
|
|
132
|
-
if (!B || Number.isNaN(B.lower) || Number.isNaN(B.upper) || B.lower > B.upper) continue;
|
|
133
|
-
const b = a.get(_.root);
|
|
134
|
-
if (_.multiplier === 0) {
|
|
135
|
-
(_.offset < B.lower || _.offset > B.upper) && (b.feasible = !1);
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
const T = (B.lower - _.offset) / _.multiplier, x = (B.upper - _.offset) / _.multiplier;
|
|
139
|
-
b.lower = Math.max(b.lower, Math.min(T, x)), b.upper = Math.min(b.upper, Math.max(T, x)), b.lower > b.upper && (b.feasible = !1);
|
|
140
|
-
}
|
|
141
|
-
const c = Object.fromEntries(n.map((y) => [y.id, y.defaultValue])), d = n.map((y) => {
|
|
142
|
-
if (r.get(y.id).root !== y.id) return y;
|
|
143
|
-
if (y.mimic && !i.get(y.id)) {
|
|
144
|
-
const { mimic: T, ...x } = y;
|
|
145
|
-
return x;
|
|
146
|
-
}
|
|
147
|
-
const B = a.get(y.id);
|
|
148
|
-
let b;
|
|
149
|
-
return B.feasible ? (Number.isFinite(B.lower) || Number.isFinite(B.upper)) && (b = { lower: B.lower, upper: B.upper }) : b = { lower: y.defaultValue, upper: y.defaultValue }, b ? { ...y, controlLimits: b } : y;
|
|
150
|
-
}), f = new Map(d.map((y) => [y.id, y])), u = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set();
|
|
151
|
-
let S = !1;
|
|
152
|
-
const P = () => {
|
|
153
|
-
for (const y of l) y();
|
|
154
|
-
};
|
|
155
|
-
let A = !1, I = [], m = Object.freeze({
|
|
156
|
-
kind: "joints",
|
|
157
|
-
revision: 0,
|
|
158
|
-
format: t,
|
|
159
|
-
joints: d,
|
|
160
|
-
jointValues: Object.freeze({ ...c }),
|
|
161
|
-
selectedJointId: null,
|
|
162
|
-
playing: !1,
|
|
163
|
-
...e.controlMode ? { controlMode: e.controlMode } : {},
|
|
164
|
-
...e.controlMode === "physics" ? { jointTargets: Object.freeze({ ...c }) } : {}
|
|
165
|
-
});
|
|
166
|
-
const g = (y) => {
|
|
167
|
-
if (!A) {
|
|
168
|
-
m = Object.freeze({ ...m, ...y, revision: m.revision + 1 });
|
|
169
|
-
for (const _ of u) _(m);
|
|
170
|
-
}
|
|
171
|
-
}, h = () => m.playing && !(e.controlMode === "kinematic" && m.previewing === !0), w = (y, _) => {
|
|
172
|
-
const B = y.controlLimits ?? y.limits;
|
|
173
|
-
return B && !Number.isNaN(B.lower) && !Number.isNaN(B.upper) && B.lower <= B.upper ? Math.max(B.lower, Math.min(B.upper, _)) : _;
|
|
174
|
-
}, E = (y, _, B = !1) => {
|
|
175
|
-
var v, N, L;
|
|
176
|
-
I = _;
|
|
177
|
-
const b = {}, T = /* @__PURE__ */ new Map();
|
|
178
|
-
for (const R of n) {
|
|
179
|
-
if (r.get(R.id).root !== R.id) continue;
|
|
180
|
-
const q = f.get(R.id);
|
|
181
|
-
T.set(R.id, w(q, y[R.id] ?? q.defaultValue));
|
|
182
|
-
}
|
|
183
|
-
for (const R of n) {
|
|
184
|
-
const j = r.get(R.id), q = T.get(j.root) ?? ((v = s.get(j.root)) == null ? void 0 : v.defaultValue) ?? R.defaultValue;
|
|
185
|
-
b[R.id] = j.multiplier * q + j.offset;
|
|
186
|
-
}
|
|
187
|
-
B && Object.assign(b, c);
|
|
188
|
-
const x = e.apply(b, _), M = e.controlMode === "physics" && ((N = e.isDriveActive) == null ? void 0 : N.call(e)) === !1 ? x ?? b : b;
|
|
189
|
-
e.controlMode === "physics" && ((L = e.isDriveActive) == null ? void 0 : L.call(e)) === !1 && (I = []), g({
|
|
190
|
-
jointValues: Object.freeze({ ...x ?? b }),
|
|
191
|
-
...e.controlMode === "physics" ? { jointTargets: Object.freeze({ ...M }) } : {}
|
|
192
|
-
}), e.requestRender();
|
|
193
|
-
};
|
|
194
|
-
return {
|
|
195
|
-
kind: "joints",
|
|
196
|
-
getSnapshot: () => m,
|
|
197
|
-
subscribe(y) {
|
|
198
|
-
return A ? () => {
|
|
199
|
-
} : (u.add(y), () => u.delete(y));
|
|
200
|
-
},
|
|
201
|
-
onManualInput(y) {
|
|
202
|
-
return A ? () => {
|
|
203
|
-
} : (l.add(y), () => l.delete(y));
|
|
204
|
-
},
|
|
205
|
-
onIntroFinished(y) {
|
|
206
|
-
return A ? () => {
|
|
207
|
-
} : S ? (y(), () => {
|
|
208
|
-
}) : (p.add(y), () => p.delete(y));
|
|
209
|
-
},
|
|
210
|
-
notifyIntroFinished() {
|
|
211
|
-
if (!(A || S)) {
|
|
212
|
-
S = !0;
|
|
213
|
-
for (const y of p) y();
|
|
214
|
-
p.clear();
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
setPreviewPose(y) {
|
|
218
|
-
if (A || h() || e.controlMode !== "kinematic") return;
|
|
219
|
-
const _ = d.filter((b) => !b.mimic && Number.isFinite(y[b.id]) && ["revolute", "continuous", "prismatic"].includes(b.type));
|
|
220
|
-
if (!_.length) return;
|
|
221
|
-
const B = { ...m.jointValues };
|
|
222
|
-
for (const b of _) B[b.id] = y[b.id];
|
|
223
|
-
E(B, _.map((b) => b.id));
|
|
224
|
-
},
|
|
225
|
-
resetPreviewPose() {
|
|
226
|
-
!A && !m.playing && e.controlMode === "kinematic" && E({ ...c }, [], !0);
|
|
227
|
-
},
|
|
228
|
-
setPreviewing(y) {
|
|
229
|
-
!A && !!m.previewing !== y && g({ previewing: y });
|
|
230
|
-
},
|
|
231
|
-
select(y) {
|
|
232
|
-
A || y !== null && !s.has(y) || y === m.selectedJointId || g({ selectedJointId: y });
|
|
233
|
-
},
|
|
234
|
-
setJointValue(y, _) {
|
|
235
|
-
const B = f.get(y);
|
|
236
|
-
if (A || h() || !B || B.mimic || !Number.isFinite(_) || !["revolute", "continuous", "prismatic"].includes(B.type) || (P(), A || m.playing)) return;
|
|
237
|
-
const b = w(B, _), T = m.jointTargets ?? m.jointValues;
|
|
238
|
-
b !== T[y] && E({ ...m.jointValues, [y]: b }, [y]);
|
|
239
|
-
},
|
|
240
|
-
resetJoint(y) {
|
|
241
|
-
const _ = f.get(y);
|
|
242
|
-
A || h() || !_ || _.mimic || (P(), !(A || m.playing) && E({ ...m.jointValues, [y]: _.defaultValue }, [y]));
|
|
243
|
-
},
|
|
244
|
-
resetPose() {
|
|
245
|
-
A || h() || (P(), !A && !m.playing && E({ ...c }, n.filter((y) => r.get(y.id).root === y.id).map((y) => y.id), !0));
|
|
246
|
-
},
|
|
247
|
-
setPlaying(y) {
|
|
248
|
-
!A && m.playing !== y && g({
|
|
249
|
-
playing: y,
|
|
250
|
-
...e.controlMode === "physics" ? { jointTargets: Object.freeze({ ...m.jointValues }) } : {}
|
|
251
|
-
});
|
|
252
|
-
},
|
|
253
|
-
syncValues(y, _ = !1) {
|
|
254
|
-
var T;
|
|
255
|
-
if (A) return;
|
|
256
|
-
const B = { ...m.jointValues };
|
|
257
|
-
let b = !1;
|
|
258
|
-
for (const x of n) {
|
|
259
|
-
const M = y[x.id];
|
|
260
|
-
M !== void 0 && Number.isFinite(M) && M !== B[x.id] && (B[x.id] = M, b = !0);
|
|
261
|
-
}
|
|
262
|
-
if ((_ || m.playing) && (I = []), b || _) {
|
|
263
|
-
const x = { ...B };
|
|
264
|
-
for (const M of I) x[M] = ((T = m.jointTargets) == null ? void 0 : T[M]) ?? B[M];
|
|
265
|
-
g({
|
|
266
|
-
jointValues: Object.freeze(B),
|
|
267
|
-
...e.controlMode === "physics" ? { jointTargets: Object.freeze(x) } : {}
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
dispose() {
|
|
272
|
-
A = !0, u.clear(), l.clear(), p.clear();
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function vs(n, t, e, s, i, o) {
|
|
277
|
-
try {
|
|
278
|
-
return ni(n, t, e, s, o);
|
|
279
|
-
} catch (r) {
|
|
280
|
-
try {
|
|
281
|
-
i == null || i(r);
|
|
282
|
-
} catch {
|
|
283
|
-
}
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
function ni(n, t, e, s, i) {
|
|
288
|
-
var y, _, B, b;
|
|
289
|
-
const o = n.model, r = n.mujoco, a = n.data;
|
|
290
|
-
if (!o || !r || !a) return;
|
|
291
|
-
const c = [], d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), p = (T) => {
|
|
292
|
-
try {
|
|
293
|
-
const x = Number(o.nu ?? 0);
|
|
294
|
-
if (!Number.isFinite(x) || x <= 0) return {};
|
|
295
|
-
const M = o.actuator_trntype, v = o.actuator_trnid, N = o.actuator_forcerange, L = o.actuator_biasprm;
|
|
296
|
-
if (!M || !v) return {};
|
|
297
|
-
for (let R = 0; R < x; R++) {
|
|
298
|
-
if (M[R] !== r.mjtTrn.mjTRN_JOINT.value || v[R * 2] !== T) continue;
|
|
299
|
-
const j = Number(o.actuator_gear[R * 6]);
|
|
300
|
-
if (!Number.isFinite(j)) continue;
|
|
301
|
-
const q = o.actuator_biastype[R] === r.mjtBias.mjBIAS_AFFINE.value, tt = o.actuator_gaintype[R] === r.mjtGain.mjGAIN_FIXED.value, C = q ? -Number(L == null ? void 0 : L[R * 10 + 1]) + 0 : void 0, Z = q ? -Number(L == null ? void 0 : L[R * 10 + 2]) + 0 : void 0, Ut = Number(o.actuator_gainprm[R * 10]), lt = {
|
|
302
|
-
type: tt && q && C != null && C > 0 && Ut === C ? "position" : tt && q && C === 0 && Z != null && Z > 0 && Ut === Z ? "velocity" : tt && o.actuator_biastype[R] === r.mjtBias.mjBIAS_NONE.value ? "motor" : "general",
|
|
303
|
-
...Number.isFinite(C) ? { stiffness: C * j * j } : {},
|
|
304
|
-
...Number.isFinite(Z) ? { damping: Z * j * j } : {}
|
|
305
|
-
}, $t = o.actuator(R);
|
|
306
|
-
let kt;
|
|
307
|
-
try {
|
|
308
|
-
kt = !!$t.forcelimited;
|
|
309
|
-
} finally {
|
|
310
|
-
$t.delete();
|
|
311
|
-
}
|
|
312
|
-
const qt = Number(N == null ? void 0 : N[R * 2]), Jt = Number(N == null ? void 0 : N[R * 2 + 1]), Ht = kt && Number.isFinite(qt) && Number.isFinite(Jt) ? Math.max(Math.abs(qt), Math.abs(Jt)) * Math.abs(j) : void 0;
|
|
313
|
-
return { drive: lt, ...Ht != null ? { maxEffort: Ht } : {} };
|
|
314
|
-
}
|
|
315
|
-
} catch {
|
|
316
|
-
}
|
|
317
|
-
return {};
|
|
318
|
-
};
|
|
319
|
-
for (let T = 0; T < o.njnt; T++) {
|
|
320
|
-
const x = o.jnt_type[T], M = x === r.mjtJoint.mjJNT_HINGE.value;
|
|
321
|
-
if (!M && x !== r.mjtJoint.mjJNT_SLIDE.value) continue;
|
|
322
|
-
const v = r.mj_id2name(o, r.mjtObj.mjOBJ_JOINT.value, T);
|
|
323
|
-
if (!v) continue;
|
|
324
|
-
const N = o.jnt_bodyid[T], L = o.body_parentid[N], R = o.jnt(T);
|
|
325
|
-
try {
|
|
326
|
-
const j = (y = i == null ? void 0 : i.mimics) == null ? void 0 : y.get(v), q = p(T), tt = Number((_ = o.body_mass) == null ? void 0 : _[N]), C = (B = i == null ? void 0 : i.metadata) == null ? void 0 : B.get(v), Z = ((b = i == null ? void 0 : i.limits) == null ? void 0 : b.get(v)) ?? (R.limited ? { lower: o.jnt_range[T * 2], upper: o.jnt_range[T * 2 + 1] } : void 0);
|
|
327
|
-
c.push({
|
|
328
|
-
id: v,
|
|
329
|
-
name: v.split("/").pop() || v,
|
|
330
|
-
type: M ? "revolute" : "prismatic",
|
|
331
|
-
parent: L > 0 ? r.mj_id2name(o, r.mjtObj.mjOBJ_BODY.value, L) : null,
|
|
332
|
-
child: r.mj_id2name(o, r.mjtObj.mjOBJ_BODY.value, N),
|
|
333
|
-
axis: Array.from(o.jnt_axis.slice(T * 3, T * 3 + 3)),
|
|
334
|
-
unit: M ? "rad" : "m",
|
|
335
|
-
defaultValue: a.qpos[o.jnt_qposadr[T]],
|
|
336
|
-
...Z ? { limits: Z } : {},
|
|
337
|
-
...(C == null ? void 0 : C.movingMass) != null ? { movingMass: C.movingMass } : Number.isFinite(tt) && tt > 0 ? { movingMass: tt } : {},
|
|
338
|
-
...C != null && C.drive ? { drive: C.drive } : q.drive ? { drive: q.drive } : {},
|
|
339
|
-
...(C == null ? void 0 : C.maxEffort) != null ? { maxEffort: C.maxEffort } : q.maxEffort != null ? { maxEffort: q.maxEffort } : {},
|
|
340
|
-
...j ? { mimic: { ...j } } : {}
|
|
341
|
-
}), d.set(v, T), f.set(v, N), u.has(N) || u.set(N, v), l.set(N, v);
|
|
342
|
-
} finally {
|
|
343
|
-
R.delete();
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
if (!c.length) return;
|
|
347
|
-
const S = /* @__PURE__ */ new Map(), P = c.map((T) => {
|
|
348
|
-
const x = f.get(T.id);
|
|
349
|
-
let M = S.get(x);
|
|
350
|
-
if (!M) {
|
|
351
|
-
let v = o.body_parentid[x];
|
|
352
|
-
for (; v > 0 && !u.has(v); ) v = o.body_parentid[v];
|
|
353
|
-
M = l.get(v);
|
|
354
|
-
}
|
|
355
|
-
return S.set(x, T.id), { ...T, parentJointId: M ?? null };
|
|
356
|
-
}), A = ei(P, t, {
|
|
357
|
-
controlMode: t === "usd" ? "kinematic" : "physics",
|
|
358
|
-
apply(T, x) {
|
|
359
|
-
if (t === "usd")
|
|
360
|
-
n.setJointValuesKinematic(T);
|
|
361
|
-
else {
|
|
362
|
-
const M = Object.fromEntries(x.map((v) => [v, T[v]]));
|
|
363
|
-
n.setJointTargets(M);
|
|
364
|
-
}
|
|
365
|
-
return e(), n.getJointValues(c.map((M) => M.id));
|
|
366
|
-
},
|
|
367
|
-
...t === "mjcf" ? { isDriveActive: () => n.isJointDriveActive } : {},
|
|
368
|
-
requestRender: s
|
|
369
|
-
}), I = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
370
|
-
for (let T = 1; T < o.nbody; T++) {
|
|
371
|
-
const x = r.mj_id2name(o, r.mjtObj.mjOBJ_BODY.value, T);
|
|
372
|
-
if (!x) continue;
|
|
373
|
-
I.set(x, T), m.set(T, x);
|
|
374
|
-
let M = T;
|
|
375
|
-
for (; M > 0 && !u.has(M); ) M = o.body_parentid[M];
|
|
376
|
-
g.set(x, u.get(M) ?? null);
|
|
377
|
-
}
|
|
378
|
-
for (const [T, x] of f) {
|
|
379
|
-
const M = [];
|
|
380
|
-
for (const [v, N] of m) {
|
|
381
|
-
let L = v;
|
|
382
|
-
for (; L > 0 && L !== x; ) L = o.body_parentid[L];
|
|
383
|
-
L === x && M.push(N);
|
|
384
|
-
}
|
|
385
|
-
h.set(T, Object.freeze(M));
|
|
386
|
-
}
|
|
387
|
-
let w = !1;
|
|
388
|
-
const E = () => !w && n.model === o && n.data === a;
|
|
389
|
-
return {
|
|
390
|
-
...A,
|
|
391
|
-
pickRoots() {
|
|
392
|
-
return E() && (i != null && i.root) ? [i.root] : [];
|
|
393
|
-
},
|
|
394
|
-
objectForBody(T) {
|
|
395
|
-
var x;
|
|
396
|
-
return E() && I.has(T) ? ((x = i == null ? void 0 : i.objectForBody) == null ? void 0 : x.call(i, T)) ?? null : null;
|
|
397
|
-
},
|
|
398
|
-
jointForBody(T) {
|
|
399
|
-
return E() ? g.get(T) ?? null : null;
|
|
400
|
-
},
|
|
401
|
-
bodiesForJoint(T) {
|
|
402
|
-
return E() ? h.get(T) ?? [] : [];
|
|
403
|
-
},
|
|
404
|
-
jointWorldFrame(T) {
|
|
405
|
-
const x = d.get(T);
|
|
406
|
-
if (!E() || x === void 0) return null;
|
|
407
|
-
const M = new U().fromArray(a.xanchor, x * 3), v = new U().fromArray(a.xaxis, x * 3);
|
|
408
|
-
return !M.toArray().every(Number.isFinite) || !v.toArray().every(Number.isFinite) || v.lengthSq() < 1e-12 ? null : (i != null && i.root ? (i.root.updateWorldMatrix(!0, !1), M.applyMatrix4(i.root.matrixWorld), v.transformDirection(i.root.matrixWorld)) : v.normalize(), { position: M, axis: v });
|
|
409
|
-
},
|
|
410
|
-
dispose() {
|
|
411
|
-
w || (w = !0, A.dispose());
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
const In = 0, ii = 1, si = 2, We = 2, we = 1.25, Ye = 1, H = 6 * 4 + 4 + 4, z = H / 4, En = 65535, ue = Math.pow(2, -24), Ve = Symbol("SKIP_GENERATION"), Mn = {
|
|
416
|
-
strategy: In,
|
|
417
|
-
maxDepth: 40,
|
|
418
|
-
maxLeafSize: 10,
|
|
419
|
-
useSharedArrayBuffer: !1,
|
|
420
|
-
setBoundingBox: !0,
|
|
421
|
-
onProgress: null,
|
|
422
|
-
indirect: !1,
|
|
423
|
-
verbose: !0,
|
|
424
|
-
range: null,
|
|
425
|
-
[Ve]: !1
|
|
426
|
-
};
|
|
427
|
-
function O(n, t, e) {
|
|
428
|
-
return e.min.x = t[n], e.min.y = t[n + 1], e.min.z = t[n + 2], e.max.x = t[n + 3], e.max.y = t[n + 4], e.max.z = t[n + 5], e;
|
|
429
|
-
}
|
|
430
|
-
function Xe(n) {
|
|
431
|
-
let t = -1, e = -1 / 0;
|
|
432
|
-
for (let s = 0; s < 3; s++) {
|
|
433
|
-
const i = n[s + 3] - n[s];
|
|
434
|
-
i > e && (e = i, t = s);
|
|
435
|
-
}
|
|
436
|
-
return t;
|
|
437
|
-
}
|
|
438
|
-
function Ge(n, t) {
|
|
439
|
-
t.set(n);
|
|
440
|
-
}
|
|
441
|
-
function Ze(n, t, e) {
|
|
442
|
-
let s, i;
|
|
443
|
-
for (let o = 0; o < 3; o++) {
|
|
444
|
-
const r = o + 3;
|
|
445
|
-
s = n[o], i = t[o], e[o] = s < i ? s : i, s = n[r], i = t[r], e[r] = s > i ? s : i;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
function Wt(n, t, e) {
|
|
449
|
-
for (let s = 0; s < 3; s++) {
|
|
450
|
-
const i = t[n + 2 * s], o = t[n + 2 * s + 1], r = i - o, a = i + o;
|
|
451
|
-
r < e[s] && (e[s] = r), a > e[s + 3] && (e[s + 3] = a);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
function Lt(n) {
|
|
455
|
-
const t = n[3] - n[0], e = n[4] - n[1], s = n[5] - n[2];
|
|
456
|
-
return 2 * (t * e + e * s + s * t);
|
|
457
|
-
}
|
|
458
|
-
function V(n, t) {
|
|
459
|
-
return t[n + 15] === En;
|
|
460
|
-
}
|
|
461
|
-
function W(n, t) {
|
|
462
|
-
return t[n + 6];
|
|
463
|
-
}
|
|
464
|
-
function X(n, t) {
|
|
465
|
-
return t[n + 14];
|
|
466
|
-
}
|
|
467
|
-
function $(n) {
|
|
468
|
-
return n + z;
|
|
469
|
-
}
|
|
470
|
-
function k(n, t) {
|
|
471
|
-
const e = t[n + 6];
|
|
472
|
-
return n + e * z;
|
|
473
|
-
}
|
|
474
|
-
function je(n, t) {
|
|
475
|
-
return t[n + 7];
|
|
476
|
-
}
|
|
477
|
-
function xe(n, t, e, s, i) {
|
|
478
|
-
let o = 1 / 0, r = 1 / 0, a = 1 / 0, c = -1 / 0, d = -1 / 0, f = -1 / 0, u = 1 / 0, l = 1 / 0, p = 1 / 0, S = -1 / 0, P = -1 / 0, A = -1 / 0;
|
|
479
|
-
const I = n.offset || 0;
|
|
480
|
-
for (let m = (t - I) * 6, g = (t + e - I) * 6; m < g; m += 6) {
|
|
481
|
-
const h = n[m + 0], w = n[m + 1], E = h - w, y = h + w;
|
|
482
|
-
E < o && (o = E), y > c && (c = y), h < u && (u = h), h > S && (S = h);
|
|
483
|
-
const _ = n[m + 2], B = n[m + 3], b = _ - B, T = _ + B;
|
|
484
|
-
b < r && (r = b), T > d && (d = T), _ < l && (l = _), _ > P && (P = _);
|
|
485
|
-
const x = n[m + 4], M = n[m + 5], v = x - M, N = x + M;
|
|
486
|
-
v < a && (a = v), N > f && (f = N), x < p && (p = x), x > A && (A = x);
|
|
487
|
-
}
|
|
488
|
-
s[0] = o, s[1] = r, s[2] = a, s[3] = c, s[4] = d, s[5] = f, i[0] = u, i[1] = l, i[2] = p, i[3] = S, i[4] = P, i[5] = A;
|
|
489
|
-
}
|
|
490
|
-
const rt = 32, ri = (n, t) => n.candidate - t.candidate, ut = /* @__PURE__ */ new Array(rt).fill().map(() => ({
|
|
491
|
-
count: 0,
|
|
492
|
-
bounds: new Float32Array(6),
|
|
493
|
-
rightCacheBounds: new Float32Array(6),
|
|
494
|
-
leftCacheBounds: new Float32Array(6),
|
|
495
|
-
candidate: 0
|
|
496
|
-
})), Yt = /* @__PURE__ */ new Float32Array(6);
|
|
497
|
-
function oi(n, t, e, s, i, o) {
|
|
498
|
-
let r = -1, a = 0;
|
|
499
|
-
if (o === In)
|
|
500
|
-
r = Xe(t), r !== -1 && (a = (t[r] + t[r + 3]) / 2);
|
|
501
|
-
else if (o === ii)
|
|
502
|
-
r = Xe(n), r !== -1 && (a = ci(e, s, i, r));
|
|
503
|
-
else if (o === si) {
|
|
504
|
-
const c = Lt(n);
|
|
505
|
-
let d = we * i;
|
|
506
|
-
const f = e.offset || 0, u = (s - f) * 6, l = (s + i - f) * 6;
|
|
507
|
-
for (let p = 0; p < 3; p++) {
|
|
508
|
-
const S = t[p], I = (t[p + 3] - S) / rt;
|
|
509
|
-
if (i < rt / 4) {
|
|
510
|
-
const m = [...ut];
|
|
511
|
-
m.length = i;
|
|
512
|
-
let g = 0;
|
|
513
|
-
for (let w = u; w < l; w += 6, g++) {
|
|
514
|
-
const E = m[g];
|
|
515
|
-
E.candidate = e[w + 2 * p], E.count = 0;
|
|
516
|
-
const {
|
|
517
|
-
bounds: y,
|
|
518
|
-
leftCacheBounds: _,
|
|
519
|
-
rightCacheBounds: B
|
|
520
|
-
} = E;
|
|
521
|
-
for (let b = 0; b < 3; b++)
|
|
522
|
-
B[b] = 1 / 0, B[b + 3] = -1 / 0, _[b] = 1 / 0, _[b + 3] = -1 / 0, y[b] = 1 / 0, y[b + 3] = -1 / 0;
|
|
523
|
-
Wt(w, e, y);
|
|
524
|
-
}
|
|
525
|
-
m.sort(ri);
|
|
526
|
-
let h = i;
|
|
527
|
-
for (let w = 0; w < h; w++) {
|
|
528
|
-
const E = m[w];
|
|
529
|
-
for (; w + 1 < h && m[w + 1].candidate === E.candidate; )
|
|
530
|
-
m.splice(w + 1, 1), h--;
|
|
531
|
-
}
|
|
532
|
-
for (let w = u; w < l; w += 6) {
|
|
533
|
-
const E = e[w + 2 * p];
|
|
534
|
-
for (let y = 0; y < h; y++) {
|
|
535
|
-
const _ = m[y];
|
|
536
|
-
E >= _.candidate ? Wt(w, e, _.rightCacheBounds) : (Wt(w, e, _.leftCacheBounds), _.count++);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
for (let w = 0; w < h; w++) {
|
|
540
|
-
const E = m[w], y = E.count, _ = i - E.count, B = E.leftCacheBounds, b = E.rightCacheBounds;
|
|
541
|
-
let T = 0;
|
|
542
|
-
y !== 0 && (T = Lt(B) / c);
|
|
543
|
-
let x = 0;
|
|
544
|
-
_ !== 0 && (x = Lt(b) / c);
|
|
545
|
-
const M = Ye + we * (T * y + x * _);
|
|
546
|
-
M < d && (r = p, d = M, a = E.candidate);
|
|
547
|
-
}
|
|
548
|
-
} else {
|
|
549
|
-
for (let h = 0; h < rt; h++) {
|
|
550
|
-
const w = ut[h];
|
|
551
|
-
w.count = 0, w.candidate = S + I + h * I;
|
|
552
|
-
const E = w.bounds;
|
|
553
|
-
for (let y = 0; y < 3; y++)
|
|
554
|
-
E[y] = 1 / 0, E[y + 3] = -1 / 0;
|
|
555
|
-
}
|
|
556
|
-
for (let h = u; h < l; h += 6) {
|
|
557
|
-
let y = ~~((e[h + 2 * p] - S) / I);
|
|
558
|
-
y >= rt && (y = rt - 1);
|
|
559
|
-
const _ = ut[y];
|
|
560
|
-
_.count++, Wt(h, e, _.bounds);
|
|
561
|
-
}
|
|
562
|
-
const m = ut[rt - 1];
|
|
563
|
-
Ge(m.bounds, m.rightCacheBounds);
|
|
564
|
-
for (let h = rt - 2; h >= 0; h--) {
|
|
565
|
-
const w = ut[h], E = ut[h + 1];
|
|
566
|
-
Ze(w.bounds, E.rightCacheBounds, w.rightCacheBounds);
|
|
567
|
-
}
|
|
568
|
-
let g = 0;
|
|
569
|
-
for (let h = 0; h < rt - 1; h++) {
|
|
570
|
-
const w = ut[h], E = w.count, y = w.bounds, B = ut[h + 1].rightCacheBounds;
|
|
571
|
-
E !== 0 && (g === 0 ? Ge(y, Yt) : Ze(y, Yt, Yt)), g += E;
|
|
572
|
-
let b = 0, T = 0;
|
|
573
|
-
g !== 0 && (b = Lt(Yt) / c);
|
|
574
|
-
const x = i - g;
|
|
575
|
-
x !== 0 && (T = Lt(B) / c);
|
|
576
|
-
const M = Ye + we * (b * g + T * x);
|
|
577
|
-
M < d && (r = p, d = M, a = w.candidate);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
} else
|
|
582
|
-
console.warn(`BVH: Invalid build strategy value ${o} used.`);
|
|
583
|
-
return { axis: r, pos: a };
|
|
584
|
-
}
|
|
585
|
-
function ci(n, t, e, s) {
|
|
586
|
-
let i = 0;
|
|
587
|
-
const o = n.offset;
|
|
588
|
-
for (let r = t, a = t + e; r < a; r++)
|
|
589
|
-
i += n[(r - o) * 6 + s * 2];
|
|
590
|
-
return i / e;
|
|
591
|
-
}
|
|
592
|
-
class be {
|
|
593
|
-
constructor() {
|
|
594
|
-
this.boundingData = new Float32Array(6);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
function ai(n, t, e, s, i, o) {
|
|
598
|
-
let r = s, a = s + i - 1;
|
|
599
|
-
const c = o.pos, d = o.axis * 2, f = e.offset || 0;
|
|
600
|
-
for (; ; ) {
|
|
601
|
-
for (; r <= a && e[(r - f) * 6 + d] < c; )
|
|
602
|
-
r++;
|
|
603
|
-
for (; r <= a && e[(a - f) * 6 + d] >= c; )
|
|
604
|
-
a--;
|
|
605
|
-
if (r < a) {
|
|
606
|
-
for (let u = 0; u < t; u++) {
|
|
607
|
-
let l = n[r * t + u];
|
|
608
|
-
n[r * t + u] = n[a * t + u], n[a * t + u] = l;
|
|
609
|
-
}
|
|
610
|
-
for (let u = 0; u < 6; u++) {
|
|
611
|
-
const l = r - f, p = a - f, S = e[l * 6 + u];
|
|
612
|
-
e[l * 6 + u] = e[p * 6 + u], e[p * 6 + u] = S;
|
|
613
|
-
}
|
|
614
|
-
r++, a--;
|
|
615
|
-
} else
|
|
616
|
-
return r;
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
let vn, fe, Me, Nn;
|
|
620
|
-
const li = Math.pow(2, 32);
|
|
621
|
-
function ve(n) {
|
|
622
|
-
return "count" in n ? 1 : 1 + ve(n.left) + ve(n.right);
|
|
623
|
-
}
|
|
624
|
-
function ui(n, t, e) {
|
|
625
|
-
return vn = new Float32Array(e), fe = new Uint32Array(e), Me = new Uint16Array(e), Nn = new Uint8Array(e), Ne(n, t);
|
|
626
|
-
}
|
|
627
|
-
function Ne(n, t) {
|
|
628
|
-
const e = n / 4, s = n / 2, i = "count" in t, o = t.boundingData;
|
|
629
|
-
for (let r = 0; r < 6; r++)
|
|
630
|
-
vn[e + r] = o[r];
|
|
631
|
-
if (i)
|
|
632
|
-
return t.buffer ? (Nn.set(new Uint8Array(t.buffer), n), n + t.buffer.byteLength) : (fe[e + 6] = t.offset, Me[s + 14] = t.count, Me[s + 15] = En, n + H);
|
|
633
|
-
{
|
|
634
|
-
const { left: r, right: a, splitAxis: c } = t, d = n + H;
|
|
635
|
-
let f = Ne(d, r);
|
|
636
|
-
const u = n / H, p = f / H - u;
|
|
637
|
-
if (p > li)
|
|
638
|
-
throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");
|
|
639
|
-
return fe[e + 6] = p, fe[e + 7] = c, Ne(f, a);
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
function fi(n, t, e, s, i, o) {
|
|
643
|
-
const {
|
|
644
|
-
maxDepth: r,
|
|
645
|
-
verbose: a,
|
|
646
|
-
maxLeafSize: c,
|
|
647
|
-
strategy: d,
|
|
648
|
-
onProgress: f
|
|
649
|
-
} = i, u = n.primitiveBuffer, l = n.primitiveBufferStride, p = new Float32Array(6);
|
|
650
|
-
let S = !1;
|
|
651
|
-
const P = new be();
|
|
652
|
-
return xe(t, e, s, P.boundingData, p), I(P, e, s, p), P;
|
|
653
|
-
function A(m) {
|
|
654
|
-
f && f((m - o.offset) / o.count);
|
|
655
|
-
}
|
|
656
|
-
function I(m, g, h, w = null, E = 0) {
|
|
657
|
-
if (!S && E >= r && (S = !0, a && console.warn(`BVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`)), h <= c || E >= r)
|
|
658
|
-
return A(g + h), m.offset = g, m.count = h, m;
|
|
659
|
-
const y = oi(m.boundingData, w, t, g, h, d);
|
|
660
|
-
if (y.axis === -1)
|
|
661
|
-
return A(g + h), m.offset = g, m.count = h, m;
|
|
662
|
-
const _ = ai(u, l, t, g, h, y);
|
|
663
|
-
if (_ === g || _ === g + h)
|
|
664
|
-
A(g + h), m.offset = g, m.count = h;
|
|
665
|
-
else {
|
|
666
|
-
m.splitAxis = y.axis;
|
|
667
|
-
const B = new be(), b = g, T = _ - g;
|
|
668
|
-
m.left = B, xe(t, b, T, B.boundingData, p), I(B, b, T, p, E + 1);
|
|
669
|
-
const x = new be(), M = _, v = h - T;
|
|
670
|
-
m.right = x, xe(t, M, v, x.boundingData, p), I(x, M, v, p, E + 1);
|
|
671
|
-
}
|
|
672
|
-
return m;
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
function di(n, t) {
|
|
676
|
-
const e = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, s = n.getRootRanges(t.range), i = s[0], o = s[s.length - 1], r = {
|
|
677
|
-
offset: i.offset,
|
|
678
|
-
count: o.offset + o.count - i.offset
|
|
679
|
-
}, a = new Float32Array(6 * r.count);
|
|
680
|
-
a.offset = r.offset, n.computePrimitiveBounds(r.offset, r.count, a), n._roots = s.map((c) => {
|
|
681
|
-
const d = fi(n, a, c.offset, c.count, t, r), f = ve(d), u = new e(H * f);
|
|
682
|
-
return ui(0, d, u), u;
|
|
683
|
-
});
|
|
684
|
-
}
|
|
685
|
-
class $e {
|
|
686
|
-
constructor(t) {
|
|
687
|
-
this._getNewPrimitive = t, this._primitives = [];
|
|
688
|
-
}
|
|
689
|
-
getPrimitive() {
|
|
690
|
-
const t = this._primitives;
|
|
691
|
-
return t.length === 0 ? this._getNewPrimitive() : t.pop();
|
|
692
|
-
}
|
|
693
|
-
releasePrimitive(t) {
|
|
694
|
-
this._primitives.push(t);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
class pi {
|
|
698
|
-
constructor() {
|
|
699
|
-
this.float32Array = null, this.uint16Array = null, this.uint32Array = null;
|
|
700
|
-
const t = [];
|
|
701
|
-
let e = null;
|
|
702
|
-
this.setBuffer = (s) => {
|
|
703
|
-
e && t.push(e), e = s, this.float32Array = new Float32Array(s), this.uint16Array = new Uint16Array(s), this.uint32Array = new Uint32Array(s);
|
|
704
|
-
}, this.clearBuffer = () => {
|
|
705
|
-
e = null, this.float32Array = null, this.uint16Array = null, this.uint32Array = null, t.length !== 0 && this.setBuffer(t.pop());
|
|
706
|
-
};
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
const D = /* @__PURE__ */ new pi();
|
|
710
|
-
let pt, vt;
|
|
711
|
-
const bt = [], Xt = /* @__PURE__ */ new $e(() => new st());
|
|
712
|
-
function mi(n, t, e, s, i, o) {
|
|
713
|
-
pt = Xt.getPrimitive(), vt = Xt.getPrimitive(), bt.push(pt, vt), D.setBuffer(n._roots[t]);
|
|
714
|
-
const r = Ue(0, n.geometry, e, s, i, o);
|
|
715
|
-
D.clearBuffer(), Xt.releasePrimitive(pt), Xt.releasePrimitive(vt), bt.pop(), bt.pop();
|
|
716
|
-
const a = bt.length;
|
|
717
|
-
return a > 0 && (vt = bt[a - 1], pt = bt[a - 2]), r;
|
|
718
|
-
}
|
|
719
|
-
function Ue(n, t, e, s, i = null, o = 0, r = 0) {
|
|
720
|
-
const { float32Array: a, uint16Array: c, uint32Array: d } = D;
|
|
721
|
-
let f = n * 2;
|
|
722
|
-
if (V(f, c)) {
|
|
723
|
-
const l = W(n, d), p = X(f, c);
|
|
724
|
-
return O(n, a, pt), s(l, p, !1, r, o + n / z, pt);
|
|
725
|
-
} else {
|
|
726
|
-
let b = function(x) {
|
|
727
|
-
const { uint16Array: M, uint32Array: v } = D;
|
|
728
|
-
let N = x * 2;
|
|
729
|
-
for (; !V(N, M); )
|
|
730
|
-
x = $(x), N = x * 2;
|
|
731
|
-
return W(x, v);
|
|
732
|
-
}, T = function(x) {
|
|
733
|
-
const { uint16Array: M, uint32Array: v } = D;
|
|
734
|
-
let N = x * 2;
|
|
735
|
-
for (; !V(N, M); )
|
|
736
|
-
x = k(x, v), N = x * 2;
|
|
737
|
-
return W(x, v) + X(N, M);
|
|
738
|
-
};
|
|
739
|
-
const l = $(n), p = k(n, d);
|
|
740
|
-
let S = l, P = p, A, I, m, g;
|
|
741
|
-
if (i && (m = pt, g = vt, O(S, a, m), O(P, a, g), A = i(m), I = i(g), I < A)) {
|
|
742
|
-
S = p, P = l;
|
|
743
|
-
const x = A;
|
|
744
|
-
A = I, I = x, m = g;
|
|
745
|
-
}
|
|
746
|
-
m || (m = pt, O(S, a, m));
|
|
747
|
-
const h = V(S * 2, c), w = e(m, h, A, r + 1, o + S / z);
|
|
748
|
-
let E;
|
|
749
|
-
if (w === We) {
|
|
750
|
-
const x = b(S), v = T(S) - x;
|
|
751
|
-
E = s(x, v, !0, r + 1, o + S / z, m);
|
|
752
|
-
} else
|
|
753
|
-
E = w && Ue(
|
|
754
|
-
S,
|
|
755
|
-
t,
|
|
756
|
-
e,
|
|
757
|
-
s,
|
|
758
|
-
i,
|
|
759
|
-
o,
|
|
760
|
-
r + 1
|
|
761
|
-
);
|
|
762
|
-
if (E) return !0;
|
|
763
|
-
g = vt, O(P, a, g);
|
|
764
|
-
const y = V(P * 2, c), _ = e(g, y, I, r + 1, o + P / z);
|
|
765
|
-
let B;
|
|
766
|
-
if (_ === We) {
|
|
767
|
-
const x = b(P), v = T(P) - x;
|
|
768
|
-
B = s(x, v, !0, r + 1, o + P / z, g);
|
|
769
|
-
} else
|
|
770
|
-
B = _ && Ue(
|
|
771
|
-
P,
|
|
772
|
-
t,
|
|
773
|
-
e,
|
|
774
|
-
s,
|
|
775
|
-
i,
|
|
776
|
-
o,
|
|
777
|
-
r + 1
|
|
778
|
-
);
|
|
779
|
-
return !!B;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
const Vt = /* @__PURE__ */ new D.constructor(), de = /* @__PURE__ */ new D.constructor(), dt = /* @__PURE__ */ new $e(() => new st()), _t = /* @__PURE__ */ new st(), At = /* @__PURE__ */ new st(), _e = /* @__PURE__ */ new st(), Ae = /* @__PURE__ */ new st();
|
|
783
|
-
let Se = !1;
|
|
784
|
-
function yi(n, t, e, s) {
|
|
785
|
-
if (Se)
|
|
786
|
-
throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");
|
|
787
|
-
Se = !0;
|
|
788
|
-
const i = n._roots, o = t._roots;
|
|
789
|
-
let r, a = 0, c = 0;
|
|
790
|
-
const d = new mt().copy(e).invert();
|
|
791
|
-
for (let f = 0, u = i.length; f < u; f++) {
|
|
792
|
-
Vt.setBuffer(i[f]), c = 0;
|
|
793
|
-
const l = dt.getPrimitive();
|
|
794
|
-
O(0, Vt.float32Array, l), l.applyMatrix4(d);
|
|
795
|
-
for (let p = 0, S = o.length; p < S && (de.setBuffer(o[p]), r = et(
|
|
796
|
-
0,
|
|
797
|
-
0,
|
|
798
|
-
e,
|
|
799
|
-
d,
|
|
800
|
-
s,
|
|
801
|
-
a,
|
|
802
|
-
c,
|
|
803
|
-
0,
|
|
804
|
-
0,
|
|
805
|
-
l
|
|
806
|
-
), de.clearBuffer(), c += o[p].byteLength / H, !r); p++)
|
|
807
|
-
;
|
|
808
|
-
if (dt.releasePrimitive(l), Vt.clearBuffer(), a += i[f].byteLength / H, r)
|
|
809
|
-
break;
|
|
810
|
-
}
|
|
811
|
-
return Se = !1, r;
|
|
812
|
-
}
|
|
813
|
-
function et(n, t, e, s, i, o = 0, r = 0, a = 0, c = 0, d = null, f = !1) {
|
|
814
|
-
let u, l;
|
|
815
|
-
f ? (u = de, l = Vt) : (u = Vt, l = de);
|
|
816
|
-
const p = u.float32Array, S = u.uint32Array, P = u.uint16Array, A = l.float32Array, I = l.uint32Array, m = l.uint16Array, g = n * 2, h = t * 2, w = V(g, P), E = V(h, m);
|
|
817
|
-
let y = !1;
|
|
818
|
-
if (E && w)
|
|
819
|
-
f ? y = i(
|
|
820
|
-
W(t, I),
|
|
821
|
-
X(t * 2, m),
|
|
822
|
-
W(n, S),
|
|
823
|
-
X(n * 2, P),
|
|
824
|
-
c,
|
|
825
|
-
r + t / z,
|
|
826
|
-
a,
|
|
827
|
-
o + n / z
|
|
828
|
-
) : y = i(
|
|
829
|
-
W(n, S),
|
|
830
|
-
X(n * 2, P),
|
|
831
|
-
W(t, I),
|
|
832
|
-
X(t * 2, m),
|
|
833
|
-
a,
|
|
834
|
-
o + n / z,
|
|
835
|
-
c,
|
|
836
|
-
r + t / z
|
|
837
|
-
);
|
|
838
|
-
else if (E) {
|
|
839
|
-
const _ = dt.getPrimitive();
|
|
840
|
-
O(t, A, _), _.applyMatrix4(e);
|
|
841
|
-
const B = $(n), b = k(n, S);
|
|
842
|
-
O(B, p, _t), O(b, p, At);
|
|
843
|
-
const T = _.intersectsBox(_t), x = _.intersectsBox(At);
|
|
844
|
-
y = T && et(
|
|
845
|
-
t,
|
|
846
|
-
B,
|
|
847
|
-
s,
|
|
848
|
-
e,
|
|
849
|
-
i,
|
|
850
|
-
r,
|
|
851
|
-
o,
|
|
852
|
-
c,
|
|
853
|
-
a + 1,
|
|
854
|
-
_,
|
|
855
|
-
!f
|
|
856
|
-
) || x && et(
|
|
857
|
-
t,
|
|
858
|
-
b,
|
|
859
|
-
s,
|
|
860
|
-
e,
|
|
861
|
-
i,
|
|
862
|
-
r,
|
|
863
|
-
o,
|
|
864
|
-
c,
|
|
865
|
-
a + 1,
|
|
866
|
-
_,
|
|
867
|
-
!f
|
|
868
|
-
), dt.releasePrimitive(_);
|
|
869
|
-
} else {
|
|
870
|
-
const _ = $(t), B = k(t, I);
|
|
871
|
-
O(_, A, _e), O(B, A, Ae);
|
|
872
|
-
const b = d.intersectsBox(_e), T = d.intersectsBox(Ae);
|
|
873
|
-
if (b && T)
|
|
874
|
-
y = et(
|
|
875
|
-
n,
|
|
876
|
-
_,
|
|
877
|
-
e,
|
|
878
|
-
s,
|
|
879
|
-
i,
|
|
880
|
-
o,
|
|
881
|
-
r,
|
|
882
|
-
a,
|
|
883
|
-
c + 1,
|
|
884
|
-
d,
|
|
885
|
-
f
|
|
886
|
-
) || et(
|
|
887
|
-
n,
|
|
888
|
-
B,
|
|
889
|
-
e,
|
|
890
|
-
s,
|
|
891
|
-
i,
|
|
892
|
-
o,
|
|
893
|
-
r,
|
|
894
|
-
a,
|
|
895
|
-
c + 1,
|
|
896
|
-
d,
|
|
897
|
-
f
|
|
898
|
-
);
|
|
899
|
-
else if (b)
|
|
900
|
-
if (w)
|
|
901
|
-
y = et(
|
|
902
|
-
n,
|
|
903
|
-
_,
|
|
904
|
-
e,
|
|
905
|
-
s,
|
|
906
|
-
i,
|
|
907
|
-
o,
|
|
908
|
-
r,
|
|
909
|
-
a,
|
|
910
|
-
c + 1,
|
|
911
|
-
d,
|
|
912
|
-
f
|
|
913
|
-
);
|
|
914
|
-
else {
|
|
915
|
-
const x = dt.getPrimitive();
|
|
916
|
-
x.copy(_e).applyMatrix4(e);
|
|
917
|
-
const M = $(n), v = k(n, S);
|
|
918
|
-
O(M, p, _t), O(v, p, At);
|
|
919
|
-
const N = x.intersectsBox(_t), L = x.intersectsBox(At);
|
|
920
|
-
y = N && et(
|
|
921
|
-
_,
|
|
922
|
-
M,
|
|
923
|
-
s,
|
|
924
|
-
e,
|
|
925
|
-
i,
|
|
926
|
-
r,
|
|
927
|
-
o,
|
|
928
|
-
c,
|
|
929
|
-
a + 1,
|
|
930
|
-
x,
|
|
931
|
-
!f
|
|
932
|
-
) || L && et(
|
|
933
|
-
_,
|
|
934
|
-
v,
|
|
935
|
-
s,
|
|
936
|
-
e,
|
|
937
|
-
i,
|
|
938
|
-
r,
|
|
939
|
-
o,
|
|
940
|
-
c,
|
|
941
|
-
a + 1,
|
|
942
|
-
x,
|
|
943
|
-
!f
|
|
944
|
-
), dt.releasePrimitive(x);
|
|
945
|
-
}
|
|
946
|
-
else if (T)
|
|
947
|
-
if (w)
|
|
948
|
-
y = et(
|
|
949
|
-
n,
|
|
950
|
-
B,
|
|
951
|
-
e,
|
|
952
|
-
s,
|
|
953
|
-
i,
|
|
954
|
-
o,
|
|
955
|
-
r,
|
|
956
|
-
a,
|
|
957
|
-
c + 1,
|
|
958
|
-
d,
|
|
959
|
-
f
|
|
960
|
-
);
|
|
961
|
-
else {
|
|
962
|
-
const x = dt.getPrimitive();
|
|
963
|
-
x.copy(Ae).applyMatrix4(e);
|
|
964
|
-
const M = $(n), v = k(n, S);
|
|
965
|
-
O(M, p, _t), O(v, p, At);
|
|
966
|
-
const N = x.intersectsBox(_t), L = x.intersectsBox(At);
|
|
967
|
-
y = N && et(
|
|
968
|
-
B,
|
|
969
|
-
M,
|
|
970
|
-
s,
|
|
971
|
-
e,
|
|
972
|
-
i,
|
|
973
|
-
r,
|
|
974
|
-
o,
|
|
975
|
-
c,
|
|
976
|
-
a + 1,
|
|
977
|
-
x,
|
|
978
|
-
!f
|
|
979
|
-
) || L && et(
|
|
980
|
-
B,
|
|
981
|
-
v,
|
|
982
|
-
s,
|
|
983
|
-
e,
|
|
984
|
-
i,
|
|
985
|
-
r,
|
|
986
|
-
o,
|
|
987
|
-
c,
|
|
988
|
-
a + 1,
|
|
989
|
-
x,
|
|
990
|
-
!f
|
|
991
|
-
), dt.releasePrimitive(x);
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
return y;
|
|
995
|
-
}
|
|
996
|
-
const Ke = /* @__PURE__ */ new st(), St = /* @__PURE__ */ new Float32Array(6);
|
|
997
|
-
class hi {
|
|
998
|
-
constructor() {
|
|
999
|
-
this._roots = null, this.primitiveBuffer = null, this.primitiveBufferStride = null;
|
|
1000
|
-
}
|
|
1001
|
-
init(t) {
|
|
1002
|
-
t = {
|
|
1003
|
-
...Mn,
|
|
1004
|
-
...t
|
|
1005
|
-
}, di(this, t);
|
|
1006
|
-
}
|
|
1007
|
-
getRootRanges() {
|
|
1008
|
-
throw new Error("BVH: getRootRanges() not implemented");
|
|
1009
|
-
}
|
|
1010
|
-
// write the i-th primitive bounds in a 6-value min / max format to the buffer
|
|
1011
|
-
// starting at the given "writeOffset"
|
|
1012
|
-
writePrimitiveBounds() {
|
|
1013
|
-
throw new Error("BVH: writePrimitiveBounds() not implemented");
|
|
1014
|
-
}
|
|
1015
|
-
// writes the union bounds of all primitives in the given range in a min / max format
|
|
1016
|
-
// to the buffer
|
|
1017
|
-
writePrimitiveRangeBounds(t, e, s, i) {
|
|
1018
|
-
let o = 1 / 0, r = 1 / 0, a = 1 / 0, c = -1 / 0, d = -1 / 0, f = -1 / 0;
|
|
1019
|
-
for (let u = t, l = t + e; u < l; u++) {
|
|
1020
|
-
this.writePrimitiveBounds(u, St, 0);
|
|
1021
|
-
const [p, S, P, A, I, m] = St;
|
|
1022
|
-
p < o && (o = p), A > c && (c = A), S < r && (r = S), I > d && (d = I), P < a && (a = P), m > f && (f = m);
|
|
1023
|
-
}
|
|
1024
|
-
return s[i + 0] = o, s[i + 1] = r, s[i + 2] = a, s[i + 3] = c, s[i + 4] = d, s[i + 5] = f, s;
|
|
1025
|
-
}
|
|
1026
|
-
computePrimitiveBounds(t, e, s) {
|
|
1027
|
-
const i = s.offset || 0;
|
|
1028
|
-
for (let o = t, r = t + e; o < r; o++) {
|
|
1029
|
-
this.writePrimitiveBounds(o, St, 0);
|
|
1030
|
-
const [a, c, d, f, u, l] = St, p = (a + f) / 2, S = (c + u) / 2, P = (d + l) / 2, A = (f - a) / 2, I = (u - c) / 2, m = (l - d) / 2, g = (o - i) * 6;
|
|
1031
|
-
s[g + 0] = p, s[g + 1] = A + (Math.abs(p) + A) * ue, s[g + 2] = S, s[g + 3] = I + (Math.abs(S) + I) * ue, s[g + 4] = P, s[g + 5] = m + (Math.abs(P) + m) * ue;
|
|
1032
|
-
}
|
|
1033
|
-
return s;
|
|
1034
|
-
}
|
|
1035
|
-
shiftPrimitiveOffsets(t) {
|
|
1036
|
-
const e = this._indirectBuffer;
|
|
1037
|
-
if (e)
|
|
1038
|
-
for (let s = 0, i = e.length; s < i; s++)
|
|
1039
|
-
e[s] += t;
|
|
1040
|
-
else {
|
|
1041
|
-
const s = this._roots;
|
|
1042
|
-
for (let i = 0; i < s.length; i++) {
|
|
1043
|
-
const o = s[i], r = new Uint32Array(o), a = new Uint16Array(o), c = o.byteLength / H;
|
|
1044
|
-
for (let d = 0; d < c; d++) {
|
|
1045
|
-
const f = z * d, u = 2 * f;
|
|
1046
|
-
V(u, a) && (r[f + 6] += t);
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
traverse(t, e = 0) {
|
|
1052
|
-
const s = this._roots[e], i = new Uint32Array(s), o = new Uint16Array(s);
|
|
1053
|
-
r(0);
|
|
1054
|
-
function r(a, c = 0) {
|
|
1055
|
-
const d = a * 2, f = V(d, o);
|
|
1056
|
-
if (f) {
|
|
1057
|
-
const u = i[a + 6], l = o[d + 14];
|
|
1058
|
-
t(c, f, new Float32Array(s, a * 4, 6), u, l);
|
|
1059
|
-
} else {
|
|
1060
|
-
const u = $(a), l = k(a, i), p = je(a, i);
|
|
1061
|
-
t(c, f, new Float32Array(s, a * 4, 6), p) || (r(u, c + 1), r(l, c + 1));
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
refit() {
|
|
1066
|
-
const t = this._roots;
|
|
1067
|
-
for (let e = 0, s = t.length; e < s; e++) {
|
|
1068
|
-
const i = t[e], o = new Uint32Array(i), r = new Uint16Array(i), a = new Float32Array(i), c = i.byteLength / H;
|
|
1069
|
-
for (let d = c - 1; d >= 0; d--) {
|
|
1070
|
-
const f = d * z, u = f * 2;
|
|
1071
|
-
if (V(u, r)) {
|
|
1072
|
-
const p = W(f, o), S = X(u, r);
|
|
1073
|
-
this.writePrimitiveRangeBounds(p, S, St, 0), a.set(St, f);
|
|
1074
|
-
} else {
|
|
1075
|
-
const p = $(f), S = k(f, o);
|
|
1076
|
-
for (let P = 0; P < 3; P++) {
|
|
1077
|
-
const A = a[p + P], I = a[p + P + 3], m = a[S + P], g = a[S + P + 3];
|
|
1078
|
-
a[f + P] = A < m ? A : m, a[f + P + 3] = I > g ? I : g;
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
getBoundingBox(t) {
|
|
1085
|
-
return t.makeEmpty(), this._roots.forEach((s) => {
|
|
1086
|
-
O(0, new Float32Array(s), Ke), t.union(Ke);
|
|
1087
|
-
}), t;
|
|
1088
|
-
}
|
|
1089
|
-
// Base shapecast implementation that can be used by subclasses
|
|
1090
|
-
// TODO: see if we can get rid of "iterateFunc" here as well as the primitive so the function
|
|
1091
|
-
// API aligns with the "shapecast" implementation
|
|
1092
|
-
shapecast(t) {
|
|
1093
|
-
let {
|
|
1094
|
-
boundsTraverseOrder: e,
|
|
1095
|
-
intersectsBounds: s,
|
|
1096
|
-
intersectsRange: i,
|
|
1097
|
-
intersectsPrimitive: o,
|
|
1098
|
-
scratchPrimitive: r,
|
|
1099
|
-
iterate: a
|
|
1100
|
-
} = t;
|
|
1101
|
-
if (i && o) {
|
|
1102
|
-
const u = i;
|
|
1103
|
-
i = (l, p, S, P, A) => u(l, p, S, P, A) ? !0 : a(l, p, this, o, S, P, r);
|
|
1104
|
-
} else i || (o ? i = (u, l, p, S) => a(u, l, this, o, p, S, r) : i = (u, l, p) => p);
|
|
1105
|
-
let c = !1, d = 0;
|
|
1106
|
-
const f = this._roots;
|
|
1107
|
-
for (let u = 0, l = f.length; u < l; u++) {
|
|
1108
|
-
const p = f[u];
|
|
1109
|
-
if (c = mi(this, u, s, i, e, d), c)
|
|
1110
|
-
break;
|
|
1111
|
-
d += p.byteLength / H;
|
|
1112
|
-
}
|
|
1113
|
-
return c;
|
|
1114
|
-
}
|
|
1115
|
-
bvhcast(t, e, s) {
|
|
1116
|
-
let { intersectsRanges: i } = s;
|
|
1117
|
-
return yi(this, t, e, i);
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
function gi() {
|
|
1121
|
-
return typeof SharedArrayBuffer < "u";
|
|
1122
|
-
}
|
|
1123
|
-
function ke(n) {
|
|
1124
|
-
return n.index ? n.index.count : n.attributes.position.count;
|
|
1125
|
-
}
|
|
1126
|
-
function me(n) {
|
|
1127
|
-
return ke(n) / 3;
|
|
1128
|
-
}
|
|
1129
|
-
function wi(n, t = ArrayBuffer) {
|
|
1130
|
-
return n > 65535 ? new Uint32Array(new t(4 * n)) : new Uint16Array(new t(2 * n));
|
|
1131
|
-
}
|
|
1132
|
-
function xi(n, t) {
|
|
1133
|
-
if (!n.index) {
|
|
1134
|
-
const e = n.attributes.position.count, s = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, i = wi(e, s);
|
|
1135
|
-
n.setIndex(new xn(i, 1));
|
|
1136
|
-
for (let o = 0; o < e; o++)
|
|
1137
|
-
i[o] = o;
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
function bi(n, t, e) {
|
|
1141
|
-
const s = ke(n) / e, i = t || n.drawRange, o = i.start / e, r = (i.start + i.count) / e, a = Math.max(0, o), c = Math.min(s, r) - a;
|
|
1142
|
-
return {
|
|
1143
|
-
offset: Math.floor(a),
|
|
1144
|
-
count: Math.floor(c)
|
|
1145
|
-
};
|
|
1146
|
-
}
|
|
1147
|
-
function _i(n, t) {
|
|
1148
|
-
return n.groups.map((e) => ({
|
|
1149
|
-
offset: e.start / t,
|
|
1150
|
-
count: e.count / t
|
|
1151
|
-
}));
|
|
1152
|
-
}
|
|
1153
|
-
function Qe(n, t, e) {
|
|
1154
|
-
const s = bi(n, t, e), i = _i(n, e);
|
|
1155
|
-
if (!i.length)
|
|
1156
|
-
return [s];
|
|
1157
|
-
const o = [], r = s.offset, a = s.offset + s.count, c = ke(n) / e, d = [];
|
|
1158
|
-
for (const l of i) {
|
|
1159
|
-
const { offset: p, count: S } = l, P = p, A = isFinite(S) ? S : c - p, I = p + A;
|
|
1160
|
-
P < a && I > r && (d.push({ pos: Math.max(r, P), isStart: !0 }), d.push({ pos: Math.min(a, I), isStart: !1 }));
|
|
1161
|
-
}
|
|
1162
|
-
d.sort((l, p) => l.pos !== p.pos ? l.pos - p.pos : l.type === "end" ? -1 : 1);
|
|
1163
|
-
let f = 0, u = null;
|
|
1164
|
-
for (const l of d) {
|
|
1165
|
-
const p = l.pos;
|
|
1166
|
-
f !== 0 && p !== u && o.push({
|
|
1167
|
-
offset: u,
|
|
1168
|
-
count: p - u
|
|
1169
|
-
}), f += l.isStart ? 1 : -1, u = p;
|
|
1170
|
-
}
|
|
1171
|
-
return o;
|
|
1172
|
-
}
|
|
1173
|
-
function Ai(n, t) {
|
|
1174
|
-
const e = n[n.length - 1], s = e.offset + e.count > 2 ** 16, i = n.reduce((d, f) => d + f.count, 0), o = s ? 4 : 2, r = t ? new SharedArrayBuffer(i * o) : new ArrayBuffer(i * o), a = s ? new Uint32Array(r) : new Uint16Array(r);
|
|
1175
|
-
let c = 0;
|
|
1176
|
-
for (let d = 0; d < n.length; d++) {
|
|
1177
|
-
const { offset: f, count: u } = n[d];
|
|
1178
|
-
for (let l = 0; l < u; l++)
|
|
1179
|
-
a[c + l] = f + l;
|
|
1180
|
-
c += u;
|
|
1181
|
-
}
|
|
1182
|
-
return a;
|
|
1183
|
-
}
|
|
1184
|
-
class Si extends hi {
|
|
1185
|
-
get indirect() {
|
|
1186
|
-
return !!this._indirectBuffer;
|
|
1187
|
-
}
|
|
1188
|
-
get primitiveStride() {
|
|
1189
|
-
return null;
|
|
1190
|
-
}
|
|
1191
|
-
get primitiveBufferStride() {
|
|
1192
|
-
return this.indirect ? 1 : this.primitiveStride;
|
|
1193
|
-
}
|
|
1194
|
-
set primitiveBufferStride(t) {
|
|
1195
|
-
}
|
|
1196
|
-
get primitiveBuffer() {
|
|
1197
|
-
return this.indirect ? this._indirectBuffer : this.geometry.index.array;
|
|
1198
|
-
}
|
|
1199
|
-
set primitiveBuffer(t) {
|
|
1200
|
-
}
|
|
1201
|
-
constructor(t, e = {}) {
|
|
1202
|
-
if (t.isBufferGeometry) {
|
|
1203
|
-
if (t.index && t.index.isInterleavedBufferAttribute)
|
|
1204
|
-
throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.");
|
|
1205
|
-
} else throw new Error("BVH: Only BufferGeometries are supported.");
|
|
1206
|
-
if (e.useSharedArrayBuffer && !gi())
|
|
1207
|
-
throw new Error("BVH: SharedArrayBuffer is not available.");
|
|
1208
|
-
super(), this.geometry = t, this.resolvePrimitiveIndex = e.indirect ? (s) => this._indirectBuffer[s] : (s) => s, this.primitiveBuffer = null, this.primitiveBufferStride = null, this._indirectBuffer = null, e = {
|
|
1209
|
-
...Mn,
|
|
1210
|
-
...e
|
|
1211
|
-
}, e[Ve] || this.init(e);
|
|
1212
|
-
}
|
|
1213
|
-
init(t) {
|
|
1214
|
-
const { geometry: e, primitiveStride: s } = this;
|
|
1215
|
-
if (t.indirect) {
|
|
1216
|
-
const i = Qe(e, t.range, s), o = Ai(i, t.useSharedArrayBuffer);
|
|
1217
|
-
this._indirectBuffer = o;
|
|
1218
|
-
} else
|
|
1219
|
-
xi(e, t);
|
|
1220
|
-
super.init(t), !e.boundingBox && t.setBoundingBox && (e.boundingBox = this.getBoundingBox(new st()));
|
|
1221
|
-
}
|
|
1222
|
-
// Abstract methods to be implemented by subclasses
|
|
1223
|
-
getRootRanges(t) {
|
|
1224
|
-
return this.indirect ? [{ offset: 0, count: this._indirectBuffer.length }] : Qe(this.geometry, t, this.primitiveStride);
|
|
1225
|
-
}
|
|
1226
|
-
raycastObject3D() {
|
|
1227
|
-
throw new Error("BVH: raycastObject3D() not implemented");
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
class at {
|
|
1231
|
-
constructor() {
|
|
1232
|
-
this.min = 1 / 0, this.max = -1 / 0;
|
|
1233
|
-
}
|
|
1234
|
-
setFromPointsField(t, e) {
|
|
1235
|
-
let s = 1 / 0, i = -1 / 0;
|
|
1236
|
-
for (let o = 0, r = t.length; o < r; o++) {
|
|
1237
|
-
const c = t[o][e];
|
|
1238
|
-
s = c < s ? c : s, i = c > i ? c : i;
|
|
1239
|
-
}
|
|
1240
|
-
this.min = s, this.max = i;
|
|
1241
|
-
}
|
|
1242
|
-
setFromPoints(t, e) {
|
|
1243
|
-
let s = 1 / 0, i = -1 / 0;
|
|
1244
|
-
for (let o = 0, r = e.length; o < r; o++) {
|
|
1245
|
-
const a = e[o], c = t.dot(a);
|
|
1246
|
-
s = c < s ? c : s, i = c > i ? c : i;
|
|
1247
|
-
}
|
|
1248
|
-
this.min = s, this.max = i;
|
|
1249
|
-
}
|
|
1250
|
-
isSeparated(t) {
|
|
1251
|
-
return this.min > t.max || t.min > this.max;
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
at.prototype.setFromBox = /* @__PURE__ */ function() {
|
|
1255
|
-
const n = /* @__PURE__ */ new U();
|
|
1256
|
-
return function(e, s) {
|
|
1257
|
-
const i = s.min, o = s.max;
|
|
1258
|
-
let r = 1 / 0, a = -1 / 0;
|
|
1259
|
-
for (let c = 0; c <= 1; c++)
|
|
1260
|
-
for (let d = 0; d <= 1; d++)
|
|
1261
|
-
for (let f = 0; f <= 1; f++) {
|
|
1262
|
-
n.x = i.x * c + o.x * (1 - c), n.y = i.y * d + o.y * (1 - d), n.z = i.z * f + o.z * (1 - f);
|
|
1263
|
-
const u = e.dot(n);
|
|
1264
|
-
r = Math.min(u, r), a = Math.max(u, a);
|
|
1265
|
-
}
|
|
1266
|
-
this.min = r, this.max = a;
|
|
1267
|
-
};
|
|
1268
|
-
}();
|
|
1269
|
-
const Bi = /* @__PURE__ */ function() {
|
|
1270
|
-
const n = /* @__PURE__ */ new U(), t = /* @__PURE__ */ new U(), e = /* @__PURE__ */ new U();
|
|
1271
|
-
return function(i, o, r) {
|
|
1272
|
-
const a = i.start, c = n, d = o.start, f = t;
|
|
1273
|
-
e.subVectors(a, d), n.subVectors(i.end, i.start), t.subVectors(o.end, o.start);
|
|
1274
|
-
const u = e.dot(f), l = f.dot(c), p = f.dot(f), S = e.dot(c), A = c.dot(c) * p - l * l;
|
|
1275
|
-
let I, m;
|
|
1276
|
-
A !== 0 ? I = (u * l - S * p) / A : I = 0, m = (u + I * l) / p, r.x = I, r.y = m;
|
|
1277
|
-
};
|
|
1278
|
-
}(), qe = /* @__PURE__ */ function() {
|
|
1279
|
-
const n = /* @__PURE__ */ new yt(), t = /* @__PURE__ */ new U(), e = /* @__PURE__ */ new U();
|
|
1280
|
-
return function(i, o, r, a) {
|
|
1281
|
-
Bi(i, o, n);
|
|
1282
|
-
let c = n.x, d = n.y;
|
|
1283
|
-
if (c >= 0 && c <= 1 && d >= 0 && d <= 1) {
|
|
1284
|
-
i.at(c, r), o.at(d, a);
|
|
1285
|
-
return;
|
|
1286
|
-
} else if (c >= 0 && c <= 1) {
|
|
1287
|
-
d < 0 ? o.at(0, a) : o.at(1, a), i.closestPointToPoint(a, !0, r);
|
|
1288
|
-
return;
|
|
1289
|
-
} else if (d >= 0 && d <= 1) {
|
|
1290
|
-
c < 0 ? i.at(0, r) : i.at(1, r), o.closestPointToPoint(r, !0, a);
|
|
1291
|
-
return;
|
|
1292
|
-
} else {
|
|
1293
|
-
let f;
|
|
1294
|
-
c < 0 ? f = i.start : f = i.end;
|
|
1295
|
-
let u;
|
|
1296
|
-
d < 0 ? u = o.start : u = o.end;
|
|
1297
|
-
const l = t, p = e;
|
|
1298
|
-
if (i.closestPointToPoint(u, !0, t), o.closestPointToPoint(f, !0, e), l.distanceToSquared(u) <= p.distanceToSquared(f)) {
|
|
1299
|
-
r.copy(l), a.copy(u);
|
|
1300
|
-
return;
|
|
1301
|
-
} else {
|
|
1302
|
-
r.copy(f), a.copy(p);
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
}(), Ti = /* @__PURE__ */ function() {
|
|
1308
|
-
const n = /* @__PURE__ */ new U(), t = /* @__PURE__ */ new U(), e = /* @__PURE__ */ new bn(), s = /* @__PURE__ */ new ct();
|
|
1309
|
-
return function(o, r) {
|
|
1310
|
-
const { radius: a, center: c } = o, { a: d, b: f, c: u } = r;
|
|
1311
|
-
if (s.start = d, s.end = f, s.closestPointToPoint(c, !0, n).distanceTo(c) <= a || (s.start = d, s.end = u, s.closestPointToPoint(c, !0, n).distanceTo(c) <= a) || (s.start = f, s.end = u, s.closestPointToPoint(c, !0, n).distanceTo(c) <= a)) return !0;
|
|
1312
|
-
const P = r.getPlane(e);
|
|
1313
|
-
if (Math.abs(P.distanceToPoint(c)) <= a) {
|
|
1314
|
-
const I = P.projectPoint(c, t);
|
|
1315
|
-
if (r.containsPoint(I)) return !0;
|
|
1316
|
-
}
|
|
1317
|
-
return !1;
|
|
1318
|
-
};
|
|
1319
|
-
}(), Pi = ["x", "y", "z"], ot = 1e-15, tn = ot * ot;
|
|
1320
|
-
function K(n) {
|
|
1321
|
-
return Math.abs(n) < ot;
|
|
1322
|
-
}
|
|
1323
|
-
class nt extends Et {
|
|
1324
|
-
constructor(...t) {
|
|
1325
|
-
super(...t), this.isExtendedTriangle = !0, this.satAxes = new Array(4).fill().map(() => new U()), this.satBounds = new Array(4).fill().map(() => new at()), this.points = [this.a, this.b, this.c], this.plane = new bn(), this.isDegenerateIntoSegment = !1, this.isDegenerateIntoPoint = !1, this.degenerateSegment = new ct(), this.needsUpdate = !0;
|
|
1326
|
-
}
|
|
1327
|
-
intersectsSphere(t) {
|
|
1328
|
-
return Ti(t, this);
|
|
1329
|
-
}
|
|
1330
|
-
update() {
|
|
1331
|
-
const t = this.a, e = this.b, s = this.c, i = this.points, o = this.satAxes, r = this.satBounds, a = o[0], c = r[0];
|
|
1332
|
-
this.getNormal(a), c.setFromPoints(a, i);
|
|
1333
|
-
const d = o[1], f = r[1];
|
|
1334
|
-
d.subVectors(t, e), f.setFromPoints(d, i);
|
|
1335
|
-
const u = o[2], l = r[2];
|
|
1336
|
-
u.subVectors(e, s), l.setFromPoints(u, i);
|
|
1337
|
-
const p = o[3], S = r[3];
|
|
1338
|
-
p.subVectors(s, t), S.setFromPoints(p, i);
|
|
1339
|
-
const P = d.length(), A = u.length(), I = p.length();
|
|
1340
|
-
this.isDegenerateIntoPoint = !1, this.isDegenerateIntoSegment = !1, P < ot ? A < ot || I < ot ? this.isDegenerateIntoPoint = !0 : (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(t), this.degenerateSegment.end.copy(s)) : A < ot ? I < ot ? this.isDegenerateIntoPoint = !0 : (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(e), this.degenerateSegment.end.copy(t)) : I < ot && (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(s), this.degenerateSegment.end.copy(e)), this.plane.setFromNormalAndCoplanarPoint(a, t), this.needsUpdate = !1;
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
nt.prototype.closestPointToSegment = /* @__PURE__ */ function() {
|
|
1344
|
-
const n = /* @__PURE__ */ new U(), t = /* @__PURE__ */ new U(), e = /* @__PURE__ */ new ct();
|
|
1345
|
-
return function(i, o = null, r = null) {
|
|
1346
|
-
const { start: a, end: c } = i, d = this.points;
|
|
1347
|
-
let f, u = 1 / 0;
|
|
1348
|
-
for (let l = 0; l < 3; l++) {
|
|
1349
|
-
const p = (l + 1) % 3;
|
|
1350
|
-
e.start.copy(d[l]), e.end.copy(d[p]), qe(e, i, n, t), f = n.distanceToSquared(t), f < u && (u = f, o && o.copy(n), r && r.copy(t));
|
|
1351
|
-
}
|
|
1352
|
-
return this.closestPointToPoint(a, n), f = a.distanceToSquared(n), f < u && (u = f, o && o.copy(n), r && r.copy(a)), this.closestPointToPoint(c, n), f = c.distanceToSquared(n), f < u && (u = f, o && o.copy(n), r && r.copy(c)), Math.sqrt(u);
|
|
1353
|
-
};
|
|
1354
|
-
}();
|
|
1355
|
-
nt.prototype.intersectsTriangle = /* @__PURE__ */ function() {
|
|
1356
|
-
const n = /* @__PURE__ */ new nt(), t = /* @__PURE__ */ new at(), e = /* @__PURE__ */ new at(), s = /* @__PURE__ */ new U(), i = /* @__PURE__ */ new U(), o = /* @__PURE__ */ new U(), r = /* @__PURE__ */ new U(), a = /* @__PURE__ */ new ct(), c = /* @__PURE__ */ new ct(), d = /* @__PURE__ */ new U(), f = /* @__PURE__ */ new yt(), u = /* @__PURE__ */ new yt();
|
|
1357
|
-
function l(g, h, w, E) {
|
|
1358
|
-
const y = s;
|
|
1359
|
-
!g.isDegenerateIntoPoint && !g.isDegenerateIntoSegment ? y.copy(g.plane.normal) : y.copy(h.plane.normal);
|
|
1360
|
-
const _ = g.satBounds, B = g.satAxes;
|
|
1361
|
-
for (let x = 1; x < 4; x++) {
|
|
1362
|
-
const M = _[x], v = B[x];
|
|
1363
|
-
if (t.setFromPoints(v, h.points), M.isSeparated(t) || (r.copy(y).cross(v), t.setFromPoints(r, g.points), e.setFromPoints(r, h.points), t.isSeparated(e))) return !1;
|
|
1364
|
-
}
|
|
1365
|
-
const b = h.satBounds, T = h.satAxes;
|
|
1366
|
-
for (let x = 1; x < 4; x++) {
|
|
1367
|
-
const M = b[x], v = T[x];
|
|
1368
|
-
if (t.setFromPoints(v, g.points), M.isSeparated(t) || (r.crossVectors(y, v), t.setFromPoints(r, g.points), e.setFromPoints(r, h.points), t.isSeparated(e))) return !1;
|
|
1369
|
-
}
|
|
1370
|
-
return w && (E || console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."), w.start.set(0, 0, 0), w.end.set(0, 0, 0)), !0;
|
|
1371
|
-
}
|
|
1372
|
-
function p(g, h, w, E, y, _, B, b, T, x, M) {
|
|
1373
|
-
let v = B / (B - b);
|
|
1374
|
-
x.x = E + (y - E) * v, M.start.subVectors(h, g).multiplyScalar(v).add(g), v = B / (B - T), x.y = E + (_ - E) * v, M.end.subVectors(w, g).multiplyScalar(v).add(g);
|
|
1375
|
-
}
|
|
1376
|
-
function S(g, h, w, E, y, _, B, b, T, x, M) {
|
|
1377
|
-
if (y > 0)
|
|
1378
|
-
p(g.c, g.a, g.b, E, h, w, T, B, b, x, M);
|
|
1379
|
-
else if (_ > 0)
|
|
1380
|
-
p(g.b, g.a, g.c, w, h, E, b, B, T, x, M);
|
|
1381
|
-
else if (b * T > 0 || B != 0)
|
|
1382
|
-
p(g.a, g.b, g.c, h, w, E, B, b, T, x, M);
|
|
1383
|
-
else if (b != 0)
|
|
1384
|
-
p(g.b, g.a, g.c, w, h, E, b, B, T, x, M);
|
|
1385
|
-
else if (T != 0)
|
|
1386
|
-
p(g.c, g.a, g.b, E, h, w, T, B, b, x, M);
|
|
1387
|
-
else
|
|
1388
|
-
return !0;
|
|
1389
|
-
return !1;
|
|
1390
|
-
}
|
|
1391
|
-
function P(g, h, w, E) {
|
|
1392
|
-
const y = h.degenerateSegment, _ = g.plane.distanceToPoint(y.start), B = g.plane.distanceToPoint(y.end);
|
|
1393
|
-
return K(_) ? K(B) ? l(g, h, w, E) : (w && (w.start.copy(y.start), w.end.copy(y.start)), g.containsPoint(y.start)) : K(B) ? (w && (w.start.copy(y.end), w.end.copy(y.end)), g.containsPoint(y.end)) : g.plane.intersectLine(y, s) != null ? (w && (w.start.copy(s), w.end.copy(s)), g.containsPoint(s)) : !1;
|
|
1394
|
-
}
|
|
1395
|
-
function A(g, h, w) {
|
|
1396
|
-
const E = h.a;
|
|
1397
|
-
return K(g.plane.distanceToPoint(E)) && g.containsPoint(E) ? (w && (w.start.copy(E), w.end.copy(E)), !0) : !1;
|
|
1398
|
-
}
|
|
1399
|
-
function I(g, h, w) {
|
|
1400
|
-
const E = g.degenerateSegment, y = h.a;
|
|
1401
|
-
return E.closestPointToPoint(y, !0, s), y.distanceToSquared(s) < tn ? (w && (w.start.copy(y), w.end.copy(y)), !0) : !1;
|
|
1402
|
-
}
|
|
1403
|
-
function m(g, h, w, E) {
|
|
1404
|
-
if (g.isDegenerateIntoSegment)
|
|
1405
|
-
if (h.isDegenerateIntoSegment) {
|
|
1406
|
-
const y = g.degenerateSegment, _ = h.degenerateSegment, B = i, b = o;
|
|
1407
|
-
y.delta(B), _.delta(b);
|
|
1408
|
-
const T = s.subVectors(_.start, y.start), x = B.x * b.y - B.y * b.x;
|
|
1409
|
-
if (K(x))
|
|
1410
|
-
return !1;
|
|
1411
|
-
const M = (T.x * b.y - T.y * b.x) / x, v = -(B.x * T.y - B.y * T.x) / x;
|
|
1412
|
-
if (M < 0 || M > 1 || v < 0 || v > 1)
|
|
1413
|
-
return !1;
|
|
1414
|
-
const N = y.start.z + B.z * M, L = _.start.z + b.z * v;
|
|
1415
|
-
return K(N - L) ? (w && (w.start.copy(y.start).addScaledVector(B, M), w.end.copy(y.start).addScaledVector(B, M)), !0) : !1;
|
|
1416
|
-
} else return h.isDegenerateIntoPoint ? I(g, h, w) : P(h, g, w, E);
|
|
1417
|
-
else {
|
|
1418
|
-
if (g.isDegenerateIntoPoint)
|
|
1419
|
-
return h.isDegenerateIntoPoint ? h.a.distanceToSquared(g.a) < tn ? (w && (w.start.copy(g.a), w.end.copy(g.a)), !0) : !1 : h.isDegenerateIntoSegment ? I(h, g, w) : A(h, g, w);
|
|
1420
|
-
if (h.isDegenerateIntoPoint)
|
|
1421
|
-
return A(g, h, w);
|
|
1422
|
-
if (h.isDegenerateIntoSegment)
|
|
1423
|
-
return P(g, h, w, E);
|
|
1424
|
-
}
|
|
1425
|
-
}
|
|
1426
|
-
return function(h, w = null, E = !1) {
|
|
1427
|
-
this.needsUpdate && this.update(), h.isExtendedTriangle ? h.needsUpdate && h.update() : (n.copy(h), n.update(), h = n);
|
|
1428
|
-
const y = m(this, h, w, E);
|
|
1429
|
-
if (y !== void 0)
|
|
1430
|
-
return y;
|
|
1431
|
-
const _ = this.plane, B = h.plane;
|
|
1432
|
-
let b = B.distanceToPoint(this.a), T = B.distanceToPoint(this.b), x = B.distanceToPoint(this.c);
|
|
1433
|
-
K(b) && (b = 0), K(T) && (T = 0), K(x) && (x = 0);
|
|
1434
|
-
const M = b * T, v = b * x;
|
|
1435
|
-
if (M > 0 && v > 0)
|
|
1436
|
-
return !1;
|
|
1437
|
-
let N = _.distanceToPoint(h.a), L = _.distanceToPoint(h.b), R = _.distanceToPoint(h.c);
|
|
1438
|
-
K(N) && (N = 0), K(L) && (L = 0), K(R) && (R = 0);
|
|
1439
|
-
const j = N * L, q = N * R;
|
|
1440
|
-
if (j > 0 && q > 0)
|
|
1441
|
-
return !1;
|
|
1442
|
-
i.copy(_.normal), o.copy(B.normal);
|
|
1443
|
-
const tt = i.cross(o);
|
|
1444
|
-
let C = 0, Z = Math.abs(tt.x);
|
|
1445
|
-
const Ut = Math.abs(tt.y);
|
|
1446
|
-
Ut > Z && (Z = Ut, C = 1), Math.abs(tt.z) > Z && (C = 2);
|
|
1447
|
-
const lt = Pi[C], $t = this.a[lt], kt = this.b[lt], qt = this.c[lt], Jt = h.a[lt], Ht = h.b[lt], Rn = h.c[lt];
|
|
1448
|
-
if (S(this, $t, kt, qt, M, v, b, T, x, f, a))
|
|
1449
|
-
return l(this, h, w, E);
|
|
1450
|
-
if (S(h, Jt, Ht, Rn, j, q, N, L, R, u, c))
|
|
1451
|
-
return l(this, h, w, E);
|
|
1452
|
-
if (f.y < f.x) {
|
|
1453
|
-
const he = f.y;
|
|
1454
|
-
f.y = f.x, f.x = he, d.copy(a.start), a.start.copy(a.end), a.end.copy(d);
|
|
1455
|
-
}
|
|
1456
|
-
if (u.y < u.x) {
|
|
1457
|
-
const he = u.y;
|
|
1458
|
-
u.y = u.x, u.x = he, d.copy(c.start), c.start.copy(c.end), c.end.copy(d);
|
|
1459
|
-
}
|
|
1460
|
-
return f.y < u.x || u.y < f.x ? !1 : (w && (u.x > f.x ? w.start.copy(c.start) : w.start.copy(a.start), u.y < f.y ? w.end.copy(c.end) : w.end.copy(a.end)), !0);
|
|
1461
|
-
};
|
|
1462
|
-
}();
|
|
1463
|
-
nt.prototype.distanceToPoint = /* @__PURE__ */ function() {
|
|
1464
|
-
const n = /* @__PURE__ */ new U();
|
|
1465
|
-
return function(e) {
|
|
1466
|
-
return this.closestPointToPoint(e, n), e.distanceTo(n);
|
|
1467
|
-
};
|
|
1468
|
-
}();
|
|
1469
|
-
nt.prototype.distanceToTriangle = /* @__PURE__ */ function() {
|
|
1470
|
-
const n = /* @__PURE__ */ new U(), t = /* @__PURE__ */ new U(), e = ["a", "b", "c"], s = /* @__PURE__ */ new ct(), i = /* @__PURE__ */ new ct();
|
|
1471
|
-
return function(r, a = null, c = null) {
|
|
1472
|
-
const d = a || c ? s : null;
|
|
1473
|
-
if (this.intersectsTriangle(r, d))
|
|
1474
|
-
return (a || c) && (a && d.getCenter(a), c && d.getCenter(c)), 0;
|
|
1475
|
-
let f = 1 / 0;
|
|
1476
|
-
for (let u = 0; u < 3; u++) {
|
|
1477
|
-
let l;
|
|
1478
|
-
const p = e[u], S = r[p];
|
|
1479
|
-
this.closestPointToPoint(S, n), l = S.distanceToSquared(n), l < f && (f = l, a && a.copy(n), c && c.copy(S));
|
|
1480
|
-
const P = this[p];
|
|
1481
|
-
r.closestPointToPoint(P, n), l = P.distanceToSquared(n), l < f && (f = l, a && a.copy(P), c && c.copy(n));
|
|
1482
|
-
}
|
|
1483
|
-
for (let u = 0; u < 3; u++) {
|
|
1484
|
-
const l = e[u], p = e[(u + 1) % 3];
|
|
1485
|
-
s.set(this[l], this[p]);
|
|
1486
|
-
for (let S = 0; S < 3; S++) {
|
|
1487
|
-
const P = e[S], A = e[(S + 1) % 3];
|
|
1488
|
-
i.set(r[P], r[A]), qe(s, i, n, t);
|
|
1489
|
-
const I = n.distanceToSquared(t);
|
|
1490
|
-
I < f && (f = I, a && a.copy(n), c && c.copy(t));
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
return Math.sqrt(f);
|
|
1494
|
-
};
|
|
1495
|
-
}();
|
|
1496
|
-
class G {
|
|
1497
|
-
constructor(t, e, s) {
|
|
1498
|
-
this.isOrientedBox = !0, this.min = new U(), this.max = new U(), this.matrix = new mt(), this.invMatrix = new mt(), this.points = new Array(8).fill().map(() => new U()), this.satAxes = new Array(3).fill().map(() => new U()), this.satBounds = new Array(3).fill().map(() => new at()), this.alignedSatBounds = new Array(3).fill().map(() => new at()), this.needsUpdate = !1, t && this.min.copy(t), e && this.max.copy(e), s && this.matrix.copy(s);
|
|
1499
|
-
}
|
|
1500
|
-
set(t, e, s) {
|
|
1501
|
-
this.min.copy(t), this.max.copy(e), this.matrix.copy(s), this.needsUpdate = !0;
|
|
1502
|
-
}
|
|
1503
|
-
copy(t) {
|
|
1504
|
-
this.min.copy(t.min), this.max.copy(t.max), this.matrix.copy(t.matrix), this.needsUpdate = !0;
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
G.prototype.update = /* @__PURE__ */ function() {
|
|
1508
|
-
return function() {
|
|
1509
|
-
const t = this.matrix, e = this.min, s = this.max, i = this.points;
|
|
1510
|
-
for (let d = 0; d <= 1; d++)
|
|
1511
|
-
for (let f = 0; f <= 1; f++)
|
|
1512
|
-
for (let u = 0; u <= 1; u++) {
|
|
1513
|
-
const l = 1 * d | 2 * f | 4 * u, p = i[l];
|
|
1514
|
-
p.x = d ? s.x : e.x, p.y = f ? s.y : e.y, p.z = u ? s.z : e.z, p.applyMatrix4(t);
|
|
1515
|
-
}
|
|
1516
|
-
const o = this.satBounds, r = this.satAxes, a = i[0];
|
|
1517
|
-
for (let d = 0; d < 3; d++) {
|
|
1518
|
-
const f = r[d], u = o[d], l = 1 << d, p = i[l];
|
|
1519
|
-
f.subVectors(a, p), u.setFromPoints(f, i);
|
|
1520
|
-
}
|
|
1521
|
-
const c = this.alignedSatBounds;
|
|
1522
|
-
c[0].setFromPointsField(i, "x"), c[1].setFromPointsField(i, "y"), c[2].setFromPointsField(i, "z"), this.invMatrix.copy(this.matrix).invert(), this.needsUpdate = !1;
|
|
1523
|
-
};
|
|
1524
|
-
}();
|
|
1525
|
-
G.prototype.intersectsBox = /* @__PURE__ */ function() {
|
|
1526
|
-
const n = /* @__PURE__ */ new at();
|
|
1527
|
-
return function(e) {
|
|
1528
|
-
this.needsUpdate && this.update();
|
|
1529
|
-
const s = e.min, i = e.max, o = this.satBounds, r = this.satAxes, a = this.alignedSatBounds;
|
|
1530
|
-
if (n.min = s.x, n.max = i.x, a[0].isSeparated(n) || (n.min = s.y, n.max = i.y, a[1].isSeparated(n)) || (n.min = s.z, n.max = i.z, a[2].isSeparated(n))) return !1;
|
|
1531
|
-
for (let c = 0; c < 3; c++) {
|
|
1532
|
-
const d = r[c], f = o[c];
|
|
1533
|
-
if (n.setFromBox(d, e), f.isSeparated(n)) return !1;
|
|
1534
|
-
}
|
|
1535
|
-
return !0;
|
|
1536
|
-
};
|
|
1537
|
-
}();
|
|
1538
|
-
G.prototype.intersectsTriangle = /* @__PURE__ */ function() {
|
|
1539
|
-
const n = /* @__PURE__ */ new nt(), t = /* @__PURE__ */ new Array(3), e = /* @__PURE__ */ new at(), s = /* @__PURE__ */ new at(), i = /* @__PURE__ */ new U();
|
|
1540
|
-
return function(r) {
|
|
1541
|
-
this.needsUpdate && this.update(), r.isExtendedTriangle ? r.needsUpdate && r.update() : (n.copy(r), n.update(), r = n);
|
|
1542
|
-
const a = this.satBounds, c = this.satAxes;
|
|
1543
|
-
t[0] = r.a, t[1] = r.b, t[2] = r.c;
|
|
1544
|
-
for (let l = 0; l < 3; l++) {
|
|
1545
|
-
const p = a[l], S = c[l];
|
|
1546
|
-
if (e.setFromPoints(S, t), p.isSeparated(e)) return !1;
|
|
1547
|
-
}
|
|
1548
|
-
const d = r.satBounds, f = r.satAxes, u = this.points;
|
|
1549
|
-
for (let l = 0; l < 3; l++) {
|
|
1550
|
-
const p = d[l], S = f[l];
|
|
1551
|
-
if (e.setFromPoints(S, u), p.isSeparated(e)) return !1;
|
|
1552
|
-
}
|
|
1553
|
-
for (let l = 0; l < 3; l++) {
|
|
1554
|
-
const p = c[l];
|
|
1555
|
-
for (let S = 0; S < 4; S++) {
|
|
1556
|
-
const P = f[S];
|
|
1557
|
-
if (i.crossVectors(p, P), e.setFromPoints(i, t), s.setFromPoints(i, u), e.isSeparated(s)) return !1;
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
return !0;
|
|
1561
|
-
};
|
|
1562
|
-
}();
|
|
1563
|
-
G.prototype.closestPointToPoint = /* @__PURE__ */ function() {
|
|
1564
|
-
return function(t, e) {
|
|
1565
|
-
return this.needsUpdate && this.update(), e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min, this.max).applyMatrix4(this.matrix), e;
|
|
1566
|
-
};
|
|
1567
|
-
}();
|
|
1568
|
-
G.prototype.distanceToPoint = function() {
|
|
1569
|
-
const n = new U();
|
|
1570
|
-
return function(e) {
|
|
1571
|
-
return this.closestPointToPoint(e, n), e.distanceTo(n);
|
|
1572
|
-
};
|
|
1573
|
-
}();
|
|
1574
|
-
G.prototype.distanceToBox = /* @__PURE__ */ function() {
|
|
1575
|
-
const n = ["x", "y", "z"], t = /* @__PURE__ */ new Array(12).fill().map(() => new ct()), e = /* @__PURE__ */ new Array(12).fill().map(() => new ct()), s = /* @__PURE__ */ new U(), i = /* @__PURE__ */ new U();
|
|
1576
|
-
return function(r, a = 0, c = null, d = null) {
|
|
1577
|
-
if (this.needsUpdate && this.update(), this.intersectsBox(r))
|
|
1578
|
-
return (c || d) && (r.getCenter(i), this.closestPointToPoint(i, s), r.closestPointToPoint(s, i), c && c.copy(s), d && d.copy(i)), 0;
|
|
1579
|
-
const f = a * a, u = r.min, l = r.max, p = this.points;
|
|
1580
|
-
let S = 1 / 0;
|
|
1581
|
-
for (let A = 0; A < 8; A++) {
|
|
1582
|
-
const I = p[A];
|
|
1583
|
-
i.copy(I).clamp(u, l);
|
|
1584
|
-
const m = I.distanceToSquared(i);
|
|
1585
|
-
if (m < S && (S = m, c && c.copy(I), d && d.copy(i), m < f))
|
|
1586
|
-
return Math.sqrt(m);
|
|
1587
|
-
}
|
|
1588
|
-
let P = 0;
|
|
1589
|
-
for (let A = 0; A < 3; A++)
|
|
1590
|
-
for (let I = 0; I <= 1; I++)
|
|
1591
|
-
for (let m = 0; m <= 1; m++) {
|
|
1592
|
-
const g = (A + 1) % 3, h = (A + 2) % 3, w = I << g | m << h, E = 1 << A | I << g | m << h, y = p[w], _ = p[E];
|
|
1593
|
-
t[P].set(y, _);
|
|
1594
|
-
const b = n[A], T = n[g], x = n[h], M = e[P], v = M.start, N = M.end;
|
|
1595
|
-
v[b] = u[b], v[T] = I ? u[T] : l[T], v[x] = m ? u[x] : l[T], N[b] = l[b], N[T] = I ? u[T] : l[T], N[x] = m ? u[x] : l[T], P++;
|
|
1596
|
-
}
|
|
1597
|
-
for (let A = 0; A <= 1; A++)
|
|
1598
|
-
for (let I = 0; I <= 1; I++)
|
|
1599
|
-
for (let m = 0; m <= 1; m++) {
|
|
1600
|
-
i.x = A ? l.x : u.x, i.y = I ? l.y : u.y, i.z = m ? l.z : u.z, this.closestPointToPoint(i, s);
|
|
1601
|
-
const g = i.distanceToSquared(s);
|
|
1602
|
-
if (g < S && (S = g, c && c.copy(s), d && d.copy(i), g < f))
|
|
1603
|
-
return Math.sqrt(g);
|
|
1604
|
-
}
|
|
1605
|
-
for (let A = 0; A < 12; A++) {
|
|
1606
|
-
const I = t[A];
|
|
1607
|
-
for (let m = 0; m < 12; m++) {
|
|
1608
|
-
const g = e[m];
|
|
1609
|
-
qe(I, g, s, i);
|
|
1610
|
-
const h = s.distanceToSquared(i);
|
|
1611
|
-
if (h < S && (S = h, c && c.copy(s), d && d.copy(i), h < f))
|
|
1612
|
-
return Math.sqrt(h);
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
return Math.sqrt(S);
|
|
1616
|
-
};
|
|
1617
|
-
}();
|
|
1618
|
-
class Ii extends $e {
|
|
1619
|
-
constructor() {
|
|
1620
|
-
super(() => new nt());
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
const Q = /* @__PURE__ */ new Ii(), Rt = /* @__PURE__ */ new U(), Be = /* @__PURE__ */ new U();
|
|
1624
|
-
function Ei(n, t, e = {}, s = 0, i = 1 / 0) {
|
|
1625
|
-
const o = s * s, r = i * i;
|
|
1626
|
-
let a = 1 / 0, c = null;
|
|
1627
|
-
if (n.shapecast(
|
|
1628
|
-
{
|
|
1629
|
-
boundsTraverseOrder: (f) => (Rt.copy(t).clamp(f.min, f.max), Rt.distanceToSquared(t)),
|
|
1630
|
-
intersectsBounds: (f, u, l) => l < a && l < r,
|
|
1631
|
-
intersectsTriangle: (f, u) => {
|
|
1632
|
-
f.closestPointToPoint(t, Rt);
|
|
1633
|
-
const l = t.distanceToSquared(Rt);
|
|
1634
|
-
return l < a && (Be.copy(Rt), a = l, c = u), l < o;
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
), a === 1 / 0) return null;
|
|
1638
|
-
const d = Math.sqrt(a);
|
|
1639
|
-
return e.point ? e.point.copy(Be) : e.point = Be.clone(), e.distance = d, e.faceIndex = c, e;
|
|
1640
|
-
}
|
|
1641
|
-
const Gt = parseInt(An) >= 169, Mi = parseInt(An) <= 161, gt = /* @__PURE__ */ new U(), wt = /* @__PURE__ */ new U(), xt = /* @__PURE__ */ new U(), Zt = /* @__PURE__ */ new yt(), Kt = /* @__PURE__ */ new yt(), Qt = /* @__PURE__ */ new yt(), en = /* @__PURE__ */ new U(), nn = /* @__PURE__ */ new U(), sn = /* @__PURE__ */ new U(), Dt = /* @__PURE__ */ new U();
|
|
1642
|
-
function vi(n, t, e, s, i, o, r, a) {
|
|
1643
|
-
let c;
|
|
1644
|
-
if (o === On ? c = n.intersectTriangle(s, e, t, !0, i) : c = n.intersectTriangle(t, e, s, o !== _n, i), c === null) return null;
|
|
1645
|
-
const d = n.origin.distanceTo(i);
|
|
1646
|
-
return d < r || d > a ? null : {
|
|
1647
|
-
distance: d,
|
|
1648
|
-
point: i.clone()
|
|
1649
|
-
};
|
|
1650
|
-
}
|
|
1651
|
-
function rn(n, t, e, s, i, o, r, a, c, d, f) {
|
|
1652
|
-
gt.fromBufferAttribute(t, o), wt.fromBufferAttribute(t, r), xt.fromBufferAttribute(t, a);
|
|
1653
|
-
const u = vi(n, gt, wt, xt, Dt, c, d, f);
|
|
1654
|
-
if (u) {
|
|
1655
|
-
if (s) {
|
|
1656
|
-
Zt.fromBufferAttribute(s, o), Kt.fromBufferAttribute(s, r), Qt.fromBufferAttribute(s, a), u.uv = new yt();
|
|
1657
|
-
const p = Et.getInterpolation(Dt, gt, wt, xt, Zt, Kt, Qt, u.uv);
|
|
1658
|
-
Gt || (u.uv = p);
|
|
1659
|
-
}
|
|
1660
|
-
if (i) {
|
|
1661
|
-
Zt.fromBufferAttribute(i, o), Kt.fromBufferAttribute(i, r), Qt.fromBufferAttribute(i, a), u.uv1 = new yt();
|
|
1662
|
-
const p = Et.getInterpolation(Dt, gt, wt, xt, Zt, Kt, Qt, u.uv1);
|
|
1663
|
-
Gt || (u.uv1 = p), Mi && (u.uv2 = u.uv1);
|
|
1664
|
-
}
|
|
1665
|
-
if (e) {
|
|
1666
|
-
en.fromBufferAttribute(e, o), nn.fromBufferAttribute(e, r), sn.fromBufferAttribute(e, a), u.normal = new U();
|
|
1667
|
-
const p = Et.getInterpolation(Dt, gt, wt, xt, en, nn, sn, u.normal);
|
|
1668
|
-
u.normal.dot(n.direction) > 0 && u.normal.multiplyScalar(-1), Gt || (u.normal = p);
|
|
1669
|
-
}
|
|
1670
|
-
const l = {
|
|
1671
|
-
a: o,
|
|
1672
|
-
b: r,
|
|
1673
|
-
c: a,
|
|
1674
|
-
normal: new U(),
|
|
1675
|
-
materialIndex: 0
|
|
1676
|
-
};
|
|
1677
|
-
if (Et.getNormal(gt, wt, xt, l.normal), u.face = l, u.faceIndex = o, Gt) {
|
|
1678
|
-
const p = new U();
|
|
1679
|
-
Et.getBarycoord(Dt, gt, wt, xt, p), u.barycoord = p;
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
return u;
|
|
1683
|
-
}
|
|
1684
|
-
function on(n) {
|
|
1685
|
-
return n && n.isMaterial ? n.side : n;
|
|
1686
|
-
}
|
|
1687
|
-
function ye(n, t, e, s, i, o, r) {
|
|
1688
|
-
const a = s * 3;
|
|
1689
|
-
let c = a + 0, d = a + 1, f = a + 2;
|
|
1690
|
-
const { index: u, groups: l } = n;
|
|
1691
|
-
n.index && (c = u.getX(c), d = u.getX(d), f = u.getX(f));
|
|
1692
|
-
const { position: p, normal: S, uv: P, uv1: A } = n.attributes;
|
|
1693
|
-
if (Array.isArray(t)) {
|
|
1694
|
-
const I = s * 3;
|
|
1695
|
-
for (let m = 0, g = l.length; m < g; m++) {
|
|
1696
|
-
const { start: h, count: w, materialIndex: E } = l[m];
|
|
1697
|
-
if (I >= h && I < h + w) {
|
|
1698
|
-
const y = on(t[E]), _ = rn(e, p, S, P, A, c, d, f, y, o, r);
|
|
1699
|
-
if (_)
|
|
1700
|
-
if (_.faceIndex = s, _.face.materialIndex = E, i)
|
|
1701
|
-
i.push(_);
|
|
1702
|
-
else
|
|
1703
|
-
return _;
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
} else {
|
|
1707
|
-
const I = on(t), m = rn(e, p, S, P, A, c, d, f, I, o, r);
|
|
1708
|
-
if (m)
|
|
1709
|
-
if (m.faceIndex = s, m.face.materialIndex = 0, i)
|
|
1710
|
-
i.push(m);
|
|
1711
|
-
else
|
|
1712
|
-
return m;
|
|
1713
|
-
}
|
|
1714
|
-
return null;
|
|
1715
|
-
}
|
|
1716
|
-
function F(n, t, e, s) {
|
|
1717
|
-
const i = n.a, o = n.b, r = n.c;
|
|
1718
|
-
let a = t, c = t + 1, d = t + 2;
|
|
1719
|
-
e && (a = e.getX(a), c = e.getX(c), d = e.getX(d)), i.x = s.getX(a), i.y = s.getY(a), i.z = s.getZ(a), o.x = s.getX(c), o.y = s.getY(c), o.z = s.getZ(c), r.x = s.getX(d), r.y = s.getY(d), r.z = s.getZ(d);
|
|
1720
|
-
}
|
|
1721
|
-
function Ni(n, t, e, s, i, o, r, a) {
|
|
1722
|
-
const { geometry: c, _indirectBuffer: d } = n;
|
|
1723
|
-
for (let f = s, u = s + i; f < u; f++)
|
|
1724
|
-
ye(c, t, e, f, o, r, a);
|
|
1725
|
-
}
|
|
1726
|
-
function Ui(n, t, e, s, i, o, r) {
|
|
1727
|
-
const { geometry: a, _indirectBuffer: c } = n;
|
|
1728
|
-
let d = 1 / 0, f = null;
|
|
1729
|
-
for (let u = s, l = s + i; u < l; u++) {
|
|
1730
|
-
let p;
|
|
1731
|
-
p = ye(a, t, e, u, null, o, r), p && p.distance < d && (f = p, d = p.distance);
|
|
1732
|
-
}
|
|
1733
|
-
return f;
|
|
1734
|
-
}
|
|
1735
|
-
function Li(n, t, e, s, i, o, r) {
|
|
1736
|
-
const { geometry: a } = e, { index: c } = a, d = a.attributes.position;
|
|
1737
|
-
for (let f = n, u = t + n; f < u; f++) {
|
|
1738
|
-
let l;
|
|
1739
|
-
if (l = f, F(r, l * 3, c, d), r.needsUpdate = !0, s(r, l, i, o))
|
|
1740
|
-
return !0;
|
|
1741
|
-
}
|
|
1742
|
-
return !1;
|
|
1743
|
-
}
|
|
1744
|
-
function Ri(n, t = null) {
|
|
1745
|
-
t && Array.isArray(t) && (t = new Set(t));
|
|
1746
|
-
const e = n.geometry, s = e.index ? e.index.array : null, i = e.attributes.position;
|
|
1747
|
-
let o, r, a, c, d = 0;
|
|
1748
|
-
const f = n._roots;
|
|
1749
|
-
for (let l = 0, p = f.length; l < p; l++)
|
|
1750
|
-
o = f[l], r = new Uint32Array(o), a = new Uint16Array(o), c = new Float32Array(o), u(0, d), d += o.byteLength;
|
|
1751
|
-
function u(l, p, S = !1) {
|
|
1752
|
-
const P = l * 2;
|
|
1753
|
-
if (V(P, a)) {
|
|
1754
|
-
const A = W(l, r), I = X(P, a);
|
|
1755
|
-
let m = 1 / 0, g = 1 / 0, h = 1 / 0, w = -1 / 0, E = -1 / 0, y = -1 / 0;
|
|
1756
|
-
for (let _ = 3 * A, B = 3 * (A + I); _ < B; _++) {
|
|
1757
|
-
let b = s[_];
|
|
1758
|
-
const T = i.getX(b), x = i.getY(b), M = i.getZ(b);
|
|
1759
|
-
T < m && (m = T), T > w && (w = T), x < g && (g = x), x > E && (E = x), M < h && (h = M), M > y && (y = M);
|
|
1760
|
-
}
|
|
1761
|
-
return c[l + 0] !== m || c[l + 1] !== g || c[l + 2] !== h || c[l + 3] !== w || c[l + 4] !== E || c[l + 5] !== y ? (c[l + 0] = m, c[l + 1] = g, c[l + 2] = h, c[l + 3] = w, c[l + 4] = E, c[l + 5] = y, !0) : !1;
|
|
1762
|
-
} else {
|
|
1763
|
-
const A = $(l), I = k(l, r);
|
|
1764
|
-
let m = S, g = !1, h = !1;
|
|
1765
|
-
if (t) {
|
|
1766
|
-
if (!m) {
|
|
1767
|
-
const b = A / z + p / H, T = I / z + p / H;
|
|
1768
|
-
g = t.has(b), h = t.has(T), m = !g && !h;
|
|
1769
|
-
}
|
|
1770
|
-
} else
|
|
1771
|
-
g = !0, h = !0;
|
|
1772
|
-
const w = m || g, E = m || h;
|
|
1773
|
-
let y = !1;
|
|
1774
|
-
w && (y = u(A, p, m));
|
|
1775
|
-
let _ = !1;
|
|
1776
|
-
E && (_ = u(I, p, m));
|
|
1777
|
-
const B = y || _;
|
|
1778
|
-
if (B)
|
|
1779
|
-
for (let b = 0; b < 3; b++) {
|
|
1780
|
-
const T = A + b, x = I + b, M = c[T], v = c[T + 3], N = c[x], L = c[x + 3];
|
|
1781
|
-
c[l + b] = M < N ? M : N, c[l + b + 3] = v > L ? v : L;
|
|
1782
|
-
}
|
|
1783
|
-
return B;
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
function ht(n, t, e, s, i) {
|
|
1788
|
-
let o, r, a, c, d, f;
|
|
1789
|
-
const u = 1 / e.direction.x, l = 1 / e.direction.y, p = 1 / e.direction.z, S = e.origin.x, P = e.origin.y, A = e.origin.z;
|
|
1790
|
-
let I = t[n], m = t[n + 3], g = t[n + 1], h = t[n + 3 + 1], w = t[n + 2], E = t[n + 3 + 2];
|
|
1791
|
-
return u >= 0 ? (o = (I - S) * u, r = (m - S) * u) : (o = (m - S) * u, r = (I - S) * u), l >= 0 ? (a = (g - P) * l, c = (h - P) * l) : (a = (h - P) * l, c = (g - P) * l), o > c || a > r || ((a > o || isNaN(o)) && (o = a), (c < r || isNaN(r)) && (r = c), p >= 0 ? (d = (w - A) * p, f = (E - A) * p) : (d = (E - A) * p, f = (w - A) * p), o > f || d > r) ? !1 : ((d > o || o !== o) && (o = d), (f < r || r !== r) && (r = f), o <= i && r >= s);
|
|
1792
|
-
}
|
|
1793
|
-
function Di(n, t, e, s, i, o, r, a) {
|
|
1794
|
-
const { geometry: c, _indirectBuffer: d } = n;
|
|
1795
|
-
for (let f = s, u = s + i; f < u; f++) {
|
|
1796
|
-
let l = d ? d[f] : f;
|
|
1797
|
-
ye(c, t, e, l, o, r, a);
|
|
1798
|
-
}
|
|
1799
|
-
}
|
|
1800
|
-
function Ci(n, t, e, s, i, o, r) {
|
|
1801
|
-
const { geometry: a, _indirectBuffer: c } = n;
|
|
1802
|
-
let d = 1 / 0, f = null;
|
|
1803
|
-
for (let u = s, l = s + i; u < l; u++) {
|
|
1804
|
-
let p;
|
|
1805
|
-
p = ye(a, t, e, c ? c[u] : u, null, o, r), p && p.distance < d && (f = p, d = p.distance);
|
|
1806
|
-
}
|
|
1807
|
-
return f;
|
|
1808
|
-
}
|
|
1809
|
-
function Oi(n, t, e, s, i, o, r) {
|
|
1810
|
-
const { geometry: a } = e, { index: c } = a, d = a.attributes.position;
|
|
1811
|
-
for (let f = n, u = t + n; f < u; f++) {
|
|
1812
|
-
let l;
|
|
1813
|
-
if (l = e.resolveTriangleIndex(f), F(r, l * 3, c, d), r.needsUpdate = !0, s(r, l, i, o))
|
|
1814
|
-
return !0;
|
|
1815
|
-
}
|
|
1816
|
-
return !1;
|
|
1817
|
-
}
|
|
1818
|
-
function Fi(n, t, e, s, i, o, r) {
|
|
1819
|
-
D.setBuffer(n._roots[t]), Le(0, n, e, s, i, o, r), D.clearBuffer();
|
|
1820
|
-
}
|
|
1821
|
-
function Le(n, t, e, s, i, o, r) {
|
|
1822
|
-
const { float32Array: a, uint16Array: c, uint32Array: d } = D, f = n * 2;
|
|
1823
|
-
if (V(f, c)) {
|
|
1824
|
-
const l = W(n, d), p = X(f, c);
|
|
1825
|
-
Ni(t, e, s, l, p, i, o, r);
|
|
1826
|
-
} else {
|
|
1827
|
-
const l = $(n);
|
|
1828
|
-
ht(l, a, s, o, r) && Le(l, t, e, s, i, o, r);
|
|
1829
|
-
const p = k(n, d);
|
|
1830
|
-
ht(p, a, s, o, r) && Le(p, t, e, s, i, o, r);
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
const zi = ["x", "y", "z"];
|
|
1834
|
-
function Vi(n, t, e, s, i, o) {
|
|
1835
|
-
D.setBuffer(n._roots[t]);
|
|
1836
|
-
const r = Re(0, n, e, s, i, o);
|
|
1837
|
-
return D.clearBuffer(), r;
|
|
1838
|
-
}
|
|
1839
|
-
function Re(n, t, e, s, i, o) {
|
|
1840
|
-
const { float32Array: r, uint16Array: a, uint32Array: c } = D;
|
|
1841
|
-
let d = n * 2;
|
|
1842
|
-
if (V(d, a)) {
|
|
1843
|
-
const u = W(n, c), l = X(d, a);
|
|
1844
|
-
return Ui(t, e, s, u, l, i, o);
|
|
1845
|
-
} else {
|
|
1846
|
-
const u = je(n, c), l = zi[u], S = s.direction[l] >= 0;
|
|
1847
|
-
let P, A;
|
|
1848
|
-
S ? (P = $(n), A = k(n, c)) : (P = k(n, c), A = $(n));
|
|
1849
|
-
const m = ht(P, r, s, i, o) ? Re(P, t, e, s, i, o) : null;
|
|
1850
|
-
if (m) {
|
|
1851
|
-
const w = m.point[l];
|
|
1852
|
-
if (S ? w <= r[A + u] : (
|
|
1853
|
-
// min bounding data
|
|
1854
|
-
w >= r[A + u + 3]
|
|
1855
|
-
))
|
|
1856
|
-
return m;
|
|
1857
|
-
}
|
|
1858
|
-
const h = ht(A, r, s, i, o) ? Re(A, t, e, s, i, o) : null;
|
|
1859
|
-
return m && h ? m.distance <= h.distance ? m : h : m || h || null;
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
const te = /* @__PURE__ */ new st(), Bt = /* @__PURE__ */ new nt(), Tt = /* @__PURE__ */ new nt(), Ct = /* @__PURE__ */ new mt(), cn = /* @__PURE__ */ new G(), ee = /* @__PURE__ */ new G();
|
|
1863
|
-
function ji(n, t, e, s) {
|
|
1864
|
-
D.setBuffer(n._roots[t]);
|
|
1865
|
-
const i = De(0, n, e, s);
|
|
1866
|
-
return D.clearBuffer(), i;
|
|
1867
|
-
}
|
|
1868
|
-
function De(n, t, e, s, i = null) {
|
|
1869
|
-
const { float32Array: o, uint16Array: r, uint32Array: a } = D;
|
|
1870
|
-
let c = n * 2;
|
|
1871
|
-
if (i === null && (e.boundingBox || e.computeBoundingBox(), cn.set(e.boundingBox.min, e.boundingBox.max, s), i = cn), V(c, r)) {
|
|
1872
|
-
const f = t.geometry, u = f.index, l = f.attributes.position, p = e.index, S = e.attributes.position, P = W(n, a), A = X(c, r);
|
|
1873
|
-
if (Ct.copy(s).invert(), e.boundsTree)
|
|
1874
|
-
return O(n, o, ee), ee.matrix.copy(Ct), ee.needsUpdate = !0, e.boundsTree.shapecast({
|
|
1875
|
-
intersectsBounds: (m) => ee.intersectsBox(m),
|
|
1876
|
-
intersectsTriangle: (m) => {
|
|
1877
|
-
m.a.applyMatrix4(s), m.b.applyMatrix4(s), m.c.applyMatrix4(s), m.needsUpdate = !0;
|
|
1878
|
-
for (let g = P * 3, h = (A + P) * 3; g < h; g += 3)
|
|
1879
|
-
if (F(Tt, g, u, l), Tt.needsUpdate = !0, m.intersectsTriangle(Tt))
|
|
1880
|
-
return !0;
|
|
1881
|
-
return !1;
|
|
1882
|
-
}
|
|
1883
|
-
});
|
|
1884
|
-
{
|
|
1885
|
-
const I = me(e);
|
|
1886
|
-
for (let m = P * 3, g = (A + P) * 3; m < g; m += 3) {
|
|
1887
|
-
F(Bt, m, u, l), Bt.a.applyMatrix4(Ct), Bt.b.applyMatrix4(Ct), Bt.c.applyMatrix4(Ct), Bt.needsUpdate = !0;
|
|
1888
|
-
for (let h = 0, w = I * 3; h < w; h += 3)
|
|
1889
|
-
if (F(Tt, h, p, S), Tt.needsUpdate = !0, Bt.intersectsTriangle(Tt))
|
|
1890
|
-
return !0;
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
} else {
|
|
1894
|
-
const f = $(n), u = k(n, a);
|
|
1895
|
-
return O(f, o, te), !!(i.intersectsBox(te) && De(f, t, e, s, i) || (O(u, o, te), i.intersectsBox(te) && De(u, t, e, s, i)));
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
const ne = /* @__PURE__ */ new mt(), Te = /* @__PURE__ */ new G(), Ot = /* @__PURE__ */ new G(), $i = /* @__PURE__ */ new U(), ki = /* @__PURE__ */ new U(), qi = /* @__PURE__ */ new U(), Ji = /* @__PURE__ */ new U();
|
|
1899
|
-
function Hi(n, t, e, s = {}, i = {}, o = 0, r = 1 / 0) {
|
|
1900
|
-
t.boundingBox || t.computeBoundingBox(), Te.set(t.boundingBox.min, t.boundingBox.max, e), Te.needsUpdate = !0;
|
|
1901
|
-
const a = n.geometry, c = a.attributes.position, d = a.index, f = t.attributes.position, u = t.index, l = Q.getPrimitive(), p = Q.getPrimitive();
|
|
1902
|
-
let S = $i, P = ki, A = null, I = null;
|
|
1903
|
-
i && (A = qi, I = Ji);
|
|
1904
|
-
let m = 1 / 0, g = null, h = null;
|
|
1905
|
-
return ne.copy(e).invert(), Ot.matrix.copy(ne), n.shapecast(
|
|
1906
|
-
{
|
|
1907
|
-
boundsTraverseOrder: (w) => Te.distanceToBox(w),
|
|
1908
|
-
intersectsBounds: (w, E, y) => y < m && y < r ? (E && (Ot.min.copy(w.min), Ot.max.copy(w.max), Ot.needsUpdate = !0), !0) : !1,
|
|
1909
|
-
intersectsRange: (w, E) => {
|
|
1910
|
-
if (t.boundsTree)
|
|
1911
|
-
return t.boundsTree.shapecast({
|
|
1912
|
-
boundsTraverseOrder: (_) => Ot.distanceToBox(_),
|
|
1913
|
-
intersectsBounds: (_, B, b) => b < m && b < r,
|
|
1914
|
-
intersectsRange: (_, B) => {
|
|
1915
|
-
for (let b = _, T = _ + B; b < T; b++) {
|
|
1916
|
-
F(p, 3 * b, u, f), p.a.applyMatrix4(e), p.b.applyMatrix4(e), p.c.applyMatrix4(e), p.needsUpdate = !0;
|
|
1917
|
-
for (let x = w, M = w + E; x < M; x++) {
|
|
1918
|
-
F(l, 3 * x, d, c), l.needsUpdate = !0;
|
|
1919
|
-
const v = l.distanceToTriangle(p, S, A);
|
|
1920
|
-
if (v < m && (P.copy(S), I && I.copy(A), m = v, g = x, h = b), v < o)
|
|
1921
|
-
return !0;
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
});
|
|
1926
|
-
{
|
|
1927
|
-
const y = me(t);
|
|
1928
|
-
for (let _ = 0, B = y; _ < B; _++) {
|
|
1929
|
-
F(p, 3 * _, u, f), p.a.applyMatrix4(e), p.b.applyMatrix4(e), p.c.applyMatrix4(e), p.needsUpdate = !0;
|
|
1930
|
-
for (let b = w, T = w + E; b < T; b++) {
|
|
1931
|
-
F(l, 3 * b, d, c), l.needsUpdate = !0;
|
|
1932
|
-
const x = l.distanceToTriangle(p, S, A);
|
|
1933
|
-
if (x < m && (P.copy(S), I && I.copy(A), m = x, g = b, h = _), x < o)
|
|
1934
|
-
return !0;
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
), Q.releasePrimitive(l), Q.releasePrimitive(p), m === 1 / 0 ? null : (s.point ? s.point.copy(P) : s.point = P.clone(), s.distance = m, s.faceIndex = g, i && (i.point ? i.point.copy(I) : i.point = I.clone(), i.point.applyMatrix4(ne), P.applyMatrix4(ne), i.distance = P.sub(i.point).length(), i.faceIndex = h), s);
|
|
1941
|
-
}
|
|
1942
|
-
function Wi(n, t = null) {
|
|
1943
|
-
t && Array.isArray(t) && (t = new Set(t));
|
|
1944
|
-
const e = n.geometry, s = e.index ? e.index.array : null, i = e.attributes.position;
|
|
1945
|
-
let o, r, a, c, d = 0;
|
|
1946
|
-
const f = n._roots;
|
|
1947
|
-
for (let l = 0, p = f.length; l < p; l++)
|
|
1948
|
-
o = f[l], r = new Uint32Array(o), a = new Uint16Array(o), c = new Float32Array(o), u(0, d), d += o.byteLength;
|
|
1949
|
-
function u(l, p, S = !1) {
|
|
1950
|
-
const P = l * 2;
|
|
1951
|
-
if (V(P, a)) {
|
|
1952
|
-
const A = W(l, r), I = X(P, a);
|
|
1953
|
-
let m = 1 / 0, g = 1 / 0, h = 1 / 0, w = -1 / 0, E = -1 / 0, y = -1 / 0;
|
|
1954
|
-
for (let _ = A, B = A + I; _ < B; _++) {
|
|
1955
|
-
const b = 3 * n.resolveTriangleIndex(_);
|
|
1956
|
-
for (let T = 0; T < 3; T++) {
|
|
1957
|
-
let x = b + T;
|
|
1958
|
-
x = s ? s[x] : x;
|
|
1959
|
-
const M = i.getX(x), v = i.getY(x), N = i.getZ(x);
|
|
1960
|
-
M < m && (m = M), M > w && (w = M), v < g && (g = v), v > E && (E = v), N < h && (h = N), N > y && (y = N);
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
|
-
return c[l + 0] !== m || c[l + 1] !== g || c[l + 2] !== h || c[l + 3] !== w || c[l + 4] !== E || c[l + 5] !== y ? (c[l + 0] = m, c[l + 1] = g, c[l + 2] = h, c[l + 3] = w, c[l + 4] = E, c[l + 5] = y, !0) : !1;
|
|
1964
|
-
} else {
|
|
1965
|
-
const A = $(l), I = k(l, r);
|
|
1966
|
-
let m = S, g = !1, h = !1;
|
|
1967
|
-
if (t) {
|
|
1968
|
-
if (!m) {
|
|
1969
|
-
const b = A / z + p / H, T = I / z + p / H;
|
|
1970
|
-
g = t.has(b), h = t.has(T), m = !g && !h;
|
|
1971
|
-
}
|
|
1972
|
-
} else
|
|
1973
|
-
g = !0, h = !0;
|
|
1974
|
-
const w = m || g, E = m || h;
|
|
1975
|
-
let y = !1;
|
|
1976
|
-
w && (y = u(A, p, m));
|
|
1977
|
-
let _ = !1;
|
|
1978
|
-
E && (_ = u(I, p, m));
|
|
1979
|
-
const B = y || _;
|
|
1980
|
-
if (B)
|
|
1981
|
-
for (let b = 0; b < 3; b++) {
|
|
1982
|
-
const T = A + b, x = I + b, M = c[T], v = c[T + 3], N = c[x], L = c[x + 3];
|
|
1983
|
-
c[l + b] = M < N ? M : N, c[l + b + 3] = v > L ? v : L;
|
|
1984
|
-
}
|
|
1985
|
-
return B;
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
function Yi(n, t, e, s, i, o, r) {
|
|
1990
|
-
D.setBuffer(n._roots[t]), Ce(0, n, e, s, i, o, r), D.clearBuffer();
|
|
1991
|
-
}
|
|
1992
|
-
function Ce(n, t, e, s, i, o, r) {
|
|
1993
|
-
const { float32Array: a, uint16Array: c, uint32Array: d } = D, f = n * 2;
|
|
1994
|
-
if (V(f, c)) {
|
|
1995
|
-
const l = W(n, d), p = X(f, c);
|
|
1996
|
-
Di(t, e, s, l, p, i, o, r);
|
|
1997
|
-
} else {
|
|
1998
|
-
const l = $(n);
|
|
1999
|
-
ht(l, a, s, o, r) && Ce(l, t, e, s, i, o, r);
|
|
2000
|
-
const p = k(n, d);
|
|
2001
|
-
ht(p, a, s, o, r) && Ce(p, t, e, s, i, o, r);
|
|
2002
|
-
}
|
|
2003
|
-
}
|
|
2004
|
-
const Xi = ["x", "y", "z"];
|
|
2005
|
-
function Gi(n, t, e, s, i, o) {
|
|
2006
|
-
D.setBuffer(n._roots[t]);
|
|
2007
|
-
const r = Oe(0, n, e, s, i, o);
|
|
2008
|
-
return D.clearBuffer(), r;
|
|
2009
|
-
}
|
|
2010
|
-
function Oe(n, t, e, s, i, o) {
|
|
2011
|
-
const { float32Array: r, uint16Array: a, uint32Array: c } = D;
|
|
2012
|
-
let d = n * 2;
|
|
2013
|
-
if (V(d, a)) {
|
|
2014
|
-
const u = W(n, c), l = X(d, a);
|
|
2015
|
-
return Ci(t, e, s, u, l, i, o);
|
|
2016
|
-
} else {
|
|
2017
|
-
const u = je(n, c), l = Xi[u], S = s.direction[l] >= 0;
|
|
2018
|
-
let P, A;
|
|
2019
|
-
S ? (P = $(n), A = k(n, c)) : (P = k(n, c), A = $(n));
|
|
2020
|
-
const m = ht(P, r, s, i, o) ? Oe(P, t, e, s, i, o) : null;
|
|
2021
|
-
if (m) {
|
|
2022
|
-
const w = m.point[l];
|
|
2023
|
-
if (S ? w <= r[A + u] : (
|
|
2024
|
-
// min bounding data
|
|
2025
|
-
w >= r[A + u + 3]
|
|
2026
|
-
))
|
|
2027
|
-
return m;
|
|
2028
|
-
}
|
|
2029
|
-
const h = ht(A, r, s, i, o) ? Oe(A, t, e, s, i, o) : null;
|
|
2030
|
-
return m && h ? m.distance <= h.distance ? m : h : m || h || null;
|
|
2031
|
-
}
|
|
2032
|
-
}
|
|
2033
|
-
const ie = /* @__PURE__ */ new st(), Pt = /* @__PURE__ */ new nt(), It = /* @__PURE__ */ new nt(), Ft = /* @__PURE__ */ new mt(), an = /* @__PURE__ */ new G(), se = /* @__PURE__ */ new G();
|
|
2034
|
-
function Zi(n, t, e, s) {
|
|
2035
|
-
D.setBuffer(n._roots[t]);
|
|
2036
|
-
const i = Fe(0, n, e, s);
|
|
2037
|
-
return D.clearBuffer(), i;
|
|
2038
|
-
}
|
|
2039
|
-
function Fe(n, t, e, s, i = null) {
|
|
2040
|
-
const { float32Array: o, uint16Array: r, uint32Array: a } = D;
|
|
2041
|
-
let c = n * 2;
|
|
2042
|
-
if (i === null && (e.boundingBox || e.computeBoundingBox(), an.set(e.boundingBox.min, e.boundingBox.max, s), i = an), V(c, r)) {
|
|
2043
|
-
const f = t.geometry, u = f.index, l = f.attributes.position, p = e.index, S = e.attributes.position, P = W(n, a), A = X(c, r);
|
|
2044
|
-
if (Ft.copy(s).invert(), e.boundsTree)
|
|
2045
|
-
return O(n, o, se), se.matrix.copy(Ft), se.needsUpdate = !0, e.boundsTree.shapecast({
|
|
2046
|
-
intersectsBounds: (m) => se.intersectsBox(m),
|
|
2047
|
-
intersectsTriangle: (m) => {
|
|
2048
|
-
m.a.applyMatrix4(s), m.b.applyMatrix4(s), m.c.applyMatrix4(s), m.needsUpdate = !0;
|
|
2049
|
-
for (let g = P, h = A + P; g < h; g++)
|
|
2050
|
-
if (F(It, 3 * t.resolveTriangleIndex(g), u, l), It.needsUpdate = !0, m.intersectsTriangle(It))
|
|
2051
|
-
return !0;
|
|
2052
|
-
return !1;
|
|
2053
|
-
}
|
|
2054
|
-
});
|
|
2055
|
-
{
|
|
2056
|
-
const I = me(e);
|
|
2057
|
-
for (let m = P, g = A + P; m < g; m++) {
|
|
2058
|
-
const h = t.resolveTriangleIndex(m);
|
|
2059
|
-
F(Pt, 3 * h, u, l), Pt.a.applyMatrix4(Ft), Pt.b.applyMatrix4(Ft), Pt.c.applyMatrix4(Ft), Pt.needsUpdate = !0;
|
|
2060
|
-
for (let w = 0, E = I * 3; w < E; w += 3)
|
|
2061
|
-
if (F(It, w, p, S), It.needsUpdate = !0, Pt.intersectsTriangle(It))
|
|
2062
|
-
return !0;
|
|
2063
|
-
}
|
|
2064
|
-
}
|
|
2065
|
-
} else {
|
|
2066
|
-
const f = $(n), u = k(n, a);
|
|
2067
|
-
return O(f, o, ie), !!(i.intersectsBox(ie) && Fe(f, t, e, s, i) || (O(u, o, ie), i.intersectsBox(ie) && Fe(u, t, e, s, i)));
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
const re = /* @__PURE__ */ new mt(), Pe = /* @__PURE__ */ new G(), zt = /* @__PURE__ */ new G(), Ki = /* @__PURE__ */ new U(), Qi = /* @__PURE__ */ new U(), ts = /* @__PURE__ */ new U(), es = /* @__PURE__ */ new U();
|
|
2071
|
-
function ns(n, t, e, s = {}, i = {}, o = 0, r = 1 / 0) {
|
|
2072
|
-
t.boundingBox || t.computeBoundingBox(), Pe.set(t.boundingBox.min, t.boundingBox.max, e), Pe.needsUpdate = !0;
|
|
2073
|
-
const a = n.geometry, c = a.attributes.position, d = a.index, f = t.attributes.position, u = t.index, l = Q.getPrimitive(), p = Q.getPrimitive();
|
|
2074
|
-
let S = Ki, P = Qi, A = null, I = null;
|
|
2075
|
-
i && (A = ts, I = es);
|
|
2076
|
-
let m = 1 / 0, g = null, h = null;
|
|
2077
|
-
return re.copy(e).invert(), zt.matrix.copy(re), n.shapecast(
|
|
2078
|
-
{
|
|
2079
|
-
boundsTraverseOrder: (w) => Pe.distanceToBox(w),
|
|
2080
|
-
intersectsBounds: (w, E, y) => y < m && y < r ? (E && (zt.min.copy(w.min), zt.max.copy(w.max), zt.needsUpdate = !0), !0) : !1,
|
|
2081
|
-
intersectsRange: (w, E) => {
|
|
2082
|
-
if (t.boundsTree) {
|
|
2083
|
-
const y = t.boundsTree;
|
|
2084
|
-
return y.shapecast({
|
|
2085
|
-
boundsTraverseOrder: (_) => zt.distanceToBox(_),
|
|
2086
|
-
intersectsBounds: (_, B, b) => b < m && b < r,
|
|
2087
|
-
intersectsRange: (_, B) => {
|
|
2088
|
-
for (let b = _, T = _ + B; b < T; b++) {
|
|
2089
|
-
const x = y.resolveTriangleIndex(b);
|
|
2090
|
-
F(p, 3 * x, u, f), p.a.applyMatrix4(e), p.b.applyMatrix4(e), p.c.applyMatrix4(e), p.needsUpdate = !0;
|
|
2091
|
-
for (let M = w, v = w + E; M < v; M++) {
|
|
2092
|
-
const N = n.resolveTriangleIndex(M);
|
|
2093
|
-
F(l, 3 * N, d, c), l.needsUpdate = !0;
|
|
2094
|
-
const L = l.distanceToTriangle(p, S, A);
|
|
2095
|
-
if (L < m && (P.copy(S), I && I.copy(A), m = L, g = M, h = b), L < o)
|
|
2096
|
-
return !0;
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
}
|
|
2100
|
-
});
|
|
2101
|
-
} else {
|
|
2102
|
-
const y = me(t);
|
|
2103
|
-
for (let _ = 0, B = y; _ < B; _++) {
|
|
2104
|
-
F(p, 3 * _, u, f), p.a.applyMatrix4(e), p.b.applyMatrix4(e), p.c.applyMatrix4(e), p.needsUpdate = !0;
|
|
2105
|
-
for (let b = w, T = w + E; b < T; b++) {
|
|
2106
|
-
const x = n.resolveTriangleIndex(b);
|
|
2107
|
-
F(l, 3 * x, d, c), l.needsUpdate = !0;
|
|
2108
|
-
const M = l.distanceToTriangle(p, S, A);
|
|
2109
|
-
if (M < m && (P.copy(S), I && I.copy(A), m = M, g = b, h = _), M < o)
|
|
2110
|
-
return !0;
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2116
|
-
), Q.releasePrimitive(l), Q.releasePrimitive(p), m === 1 / 0 ? null : (s.point ? s.point.copy(P) : s.point = P.clone(), s.distance = m, s.faceIndex = g, i && (i.point ? i.point.copy(I) : i.point = I.clone(), i.point.applyMatrix4(re), P.applyMatrix4(re), i.distance = P.sub(i.point).length(), i.faceIndex = h), s);
|
|
2117
|
-
}
|
|
2118
|
-
function ln(n, t, e) {
|
|
2119
|
-
return n === null ? null : (n.point.applyMatrix4(t.matrixWorld), n.distance = n.point.distanceTo(e.ray.origin), n.object = t, n);
|
|
2120
|
-
}
|
|
2121
|
-
const oe = /* @__PURE__ */ new G(), ce = /* @__PURE__ */ new Fn(), un = /* @__PURE__ */ new U(), fn = /* @__PURE__ */ new mt(), dn = /* @__PURE__ */ new U(), Ie = ["getX", "getY", "getZ"];
|
|
2122
|
-
class pe extends Si {
|
|
2123
|
-
static serialize(t, e = {}) {
|
|
2124
|
-
e = {
|
|
2125
|
-
cloneBuffers: !0,
|
|
2126
|
-
...e
|
|
2127
|
-
};
|
|
2128
|
-
const s = t.geometry, i = t._roots, o = t._indirectBuffer, r = s.getIndex(), a = {
|
|
2129
|
-
version: 1,
|
|
2130
|
-
roots: null,
|
|
2131
|
-
index: null,
|
|
2132
|
-
indirectBuffer: null
|
|
2133
|
-
};
|
|
2134
|
-
return e.cloneBuffers ? (a.roots = i.map((c) => c.slice()), a.index = r ? r.array.slice() : null, a.indirectBuffer = o ? o.slice() : null) : (a.roots = i, a.index = r ? r.array : null, a.indirectBuffer = o), a;
|
|
2135
|
-
}
|
|
2136
|
-
static deserialize(t, e, s = {}) {
|
|
2137
|
-
s = {
|
|
2138
|
-
setIndex: !0,
|
|
2139
|
-
indirect: !!t.indirectBuffer,
|
|
2140
|
-
...s
|
|
2141
|
-
};
|
|
2142
|
-
const { index: i, roots: o, indirectBuffer: r } = t;
|
|
2143
|
-
t.version || (console.warn(
|
|
2144
|
-
"MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."
|
|
2145
|
-
), c(o));
|
|
2146
|
-
const a = new pe(e, { ...s, [Ve]: !0 });
|
|
2147
|
-
if (a._roots = o, a._indirectBuffer = r || null, s.setIndex) {
|
|
2148
|
-
const d = e.getIndex();
|
|
2149
|
-
if (d === null) {
|
|
2150
|
-
const f = new xn(t.index, 1, !1);
|
|
2151
|
-
e.setIndex(f);
|
|
2152
|
-
} else d.array !== i && (d.array.set(i), d.needsUpdate = !0);
|
|
2153
|
-
}
|
|
2154
|
-
return a;
|
|
2155
|
-
function c(d) {
|
|
2156
|
-
for (let f = 0; f < d.length; f++) {
|
|
2157
|
-
const u = d[f], l = new Uint32Array(u), p = new Uint16Array(u);
|
|
2158
|
-
for (let S = 0, P = u.byteLength / H; S < P; S++) {
|
|
2159
|
-
const A = z * S, I = 2 * A;
|
|
2160
|
-
V(I, p) || (l[A + 6] = l[A + 6] / z - S);
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
get primitiveStride() {
|
|
2166
|
-
return 3;
|
|
2167
|
-
}
|
|
2168
|
-
get resolveTriangleIndex() {
|
|
2169
|
-
return this.resolvePrimitiveIndex;
|
|
2170
|
-
}
|
|
2171
|
-
constructor(t, e = {}) {
|
|
2172
|
-
e.maxLeafTris && (console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'), e = {
|
|
2173
|
-
...e,
|
|
2174
|
-
maxLeafSize: e.maxLeafTris
|
|
2175
|
-
}), super(t, e);
|
|
2176
|
-
}
|
|
2177
|
-
// implement abstract methods from BVH base class
|
|
2178
|
-
shiftTriangleOffsets(t) {
|
|
2179
|
-
return super.shiftPrimitiveOffsets(t);
|
|
2180
|
-
}
|
|
2181
|
-
// write primitive bounds to the buffer - used only for validateBounds at the moment
|
|
2182
|
-
writePrimitiveBounds(t, e, s) {
|
|
2183
|
-
const i = this.geometry, o = this._indirectBuffer, r = i.attributes.position, a = i.index ? i.index.array : null, d = (o ? o[t] : t) * 3;
|
|
2184
|
-
let f = d + 0, u = d + 1, l = d + 2;
|
|
2185
|
-
a && (f = a[f], u = a[u], l = a[l]);
|
|
2186
|
-
for (let p = 0; p < 3; p++) {
|
|
2187
|
-
const S = r[Ie[p]](f), P = r[Ie[p]](u), A = r[Ie[p]](l);
|
|
2188
|
-
let I = S;
|
|
2189
|
-
P < I && (I = P), A < I && (I = A);
|
|
2190
|
-
let m = S;
|
|
2191
|
-
P > m && (m = P), A > m && (m = A), e[s + p] = I, e[s + p + 3] = m;
|
|
2192
|
-
}
|
|
2193
|
-
return e;
|
|
2194
|
-
}
|
|
2195
|
-
// precomputes the bounding box for each triangle; required for quickly calculating tree splits.
|
|
2196
|
-
// result is an array of size count * 6 where triangle i maps to a
|
|
2197
|
-
// [x_center, x_delta, y_center, y_delta, z_center, z_delta] tuple starting at index (i - offset) * 6,
|
|
2198
|
-
// representing the center and half-extent in each dimension of triangle i
|
|
2199
|
-
computePrimitiveBounds(t, e, s) {
|
|
2200
|
-
const i = this.geometry, o = this._indirectBuffer, r = i.attributes.position, a = i.index ? i.index.array : null, c = r.normalized;
|
|
2201
|
-
if (t < 0 || e + t - s.offset > s.length / 6)
|
|
2202
|
-
throw new Error("MeshBVH: compute triangle bounds range is invalid.");
|
|
2203
|
-
const d = r.array, f = r.offset || 0;
|
|
2204
|
-
let u = 3;
|
|
2205
|
-
r.isInterleavedBufferAttribute && (u = r.data.stride);
|
|
2206
|
-
const l = ["getX", "getY", "getZ"], p = s.offset;
|
|
2207
|
-
for (let S = t, P = t + e; S < P; S++) {
|
|
2208
|
-
const I = (o ? o[S] : S) * 3, m = (S - p) * 6;
|
|
2209
|
-
let g = I + 0, h = I + 1, w = I + 2;
|
|
2210
|
-
a && (g = a[g], h = a[h], w = a[w]), c || (g = g * u + f, h = h * u + f, w = w * u + f);
|
|
2211
|
-
for (let E = 0; E < 3; E++) {
|
|
2212
|
-
let y, _, B;
|
|
2213
|
-
c ? (y = r[l[E]](g), _ = r[l[E]](h), B = r[l[E]](w)) : (y = d[g + E], _ = d[h + E], B = d[w + E]);
|
|
2214
|
-
let b = y;
|
|
2215
|
-
_ < b && (b = _), B < b && (b = B);
|
|
2216
|
-
let T = y;
|
|
2217
|
-
_ > T && (T = _), B > T && (T = B);
|
|
2218
|
-
const x = (T - b) / 2, M = E * 2;
|
|
2219
|
-
s[m + M + 0] = b + x, s[m + M + 1] = x + (Math.abs(b) + x) * ue;
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
return s;
|
|
2223
|
-
}
|
|
2224
|
-
raycastObject3D(t, e, s = []) {
|
|
2225
|
-
const { material: i } = t;
|
|
2226
|
-
if (i === void 0)
|
|
2227
|
-
return;
|
|
2228
|
-
fn.copy(t.matrixWorld).invert(), ce.copy(e.ray).applyMatrix4(fn), dn.setFromMatrixScale(t.matrixWorld), un.copy(ce.direction).multiply(dn);
|
|
2229
|
-
const o = un.length(), r = e.near / o, a = e.far / o;
|
|
2230
|
-
if (e.firstHitOnly === !0) {
|
|
2231
|
-
let c = this.raycastFirst(ce, i, r, a);
|
|
2232
|
-
c = ln(c, t, e), c && s.push(c);
|
|
2233
|
-
} else {
|
|
2234
|
-
const c = this.raycast(ce, i, r, a);
|
|
2235
|
-
for (let d = 0, f = c.length; d < f; d++) {
|
|
2236
|
-
const u = ln(c[d], t, e);
|
|
2237
|
-
u && s.push(u);
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
return s;
|
|
2241
|
-
}
|
|
2242
|
-
refit(t = null) {
|
|
2243
|
-
return (this.indirect ? Wi : Ri)(this, t);
|
|
2244
|
-
}
|
|
2245
|
-
/* Core Cast Functions */
|
|
2246
|
-
raycast(t, e = Je, s = 0, i = 1 / 0) {
|
|
2247
|
-
const o = this._roots, r = [], a = this.indirect ? Yi : Fi;
|
|
2248
|
-
for (let c = 0, d = o.length; c < d; c++)
|
|
2249
|
-
a(this, c, e, t, r, s, i);
|
|
2250
|
-
return r;
|
|
2251
|
-
}
|
|
2252
|
-
raycastFirst(t, e = Je, s = 0, i = 1 / 0) {
|
|
2253
|
-
const o = this._roots;
|
|
2254
|
-
let r = null;
|
|
2255
|
-
const a = this.indirect ? Gi : Vi;
|
|
2256
|
-
for (let c = 0, d = o.length; c < d; c++) {
|
|
2257
|
-
const f = a(this, c, e, t, s, i);
|
|
2258
|
-
f != null && (r == null || f.distance < r.distance) && (r = f);
|
|
2259
|
-
}
|
|
2260
|
-
return r;
|
|
2261
|
-
}
|
|
2262
|
-
intersectsGeometry(t, e) {
|
|
2263
|
-
let s = !1;
|
|
2264
|
-
const i = this._roots, o = this.indirect ? Zi : ji;
|
|
2265
|
-
for (let r = 0, a = i.length; r < a && (s = o(this, r, t, e), !s); r++)
|
|
2266
|
-
;
|
|
2267
|
-
return s;
|
|
2268
|
-
}
|
|
2269
|
-
shapecast(t) {
|
|
2270
|
-
const e = Q.getPrimitive(), s = super.shapecast(
|
|
2271
|
-
{
|
|
2272
|
-
...t,
|
|
2273
|
-
intersectsPrimitive: t.intersectsTriangle,
|
|
2274
|
-
scratchPrimitive: e,
|
|
2275
|
-
// TODO: is the performance significant enough for the added complexity here?
|
|
2276
|
-
// can we just use one function?
|
|
2277
|
-
iterate: this.indirect ? Oi : Li
|
|
2278
|
-
}
|
|
2279
|
-
);
|
|
2280
|
-
return Q.releasePrimitive(e), s;
|
|
2281
|
-
}
|
|
2282
|
-
bvhcast(t, e, s) {
|
|
2283
|
-
let {
|
|
2284
|
-
intersectsRanges: i,
|
|
2285
|
-
intersectsTriangles: o
|
|
2286
|
-
} = s;
|
|
2287
|
-
const r = Q.getPrimitive(), a = this.geometry.index, c = this.geometry.attributes.position, d = this.indirect ? (S) => {
|
|
2288
|
-
const P = this.resolveTriangleIndex(S);
|
|
2289
|
-
F(r, P * 3, a, c);
|
|
2290
|
-
} : (S) => {
|
|
2291
|
-
F(r, S * 3, a, c);
|
|
2292
|
-
}, f = Q.getPrimitive(), u = t.geometry.index, l = t.geometry.attributes.position, p = t.indirect ? (S) => {
|
|
2293
|
-
const P = t.resolveTriangleIndex(S);
|
|
2294
|
-
F(f, P * 3, u, l);
|
|
2295
|
-
} : (S) => {
|
|
2296
|
-
F(f, S * 3, u, l);
|
|
2297
|
-
};
|
|
2298
|
-
if (o) {
|
|
2299
|
-
if (!(t instanceof pe))
|
|
2300
|
-
throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');
|
|
2301
|
-
const S = (P, A, I, m, g, h, w, E) => {
|
|
2302
|
-
for (let y = I, _ = I + m; y < _; y++) {
|
|
2303
|
-
p(y), f.a.applyMatrix4(e), f.b.applyMatrix4(e), f.c.applyMatrix4(e), f.needsUpdate = !0;
|
|
2304
|
-
for (let B = P, b = P + A; B < b; B++)
|
|
2305
|
-
if (d(B), r.needsUpdate = !0, o(r, f, B, y, g, h, w, E))
|
|
2306
|
-
return !0;
|
|
2307
|
-
}
|
|
2308
|
-
return !1;
|
|
2309
|
-
};
|
|
2310
|
-
if (i) {
|
|
2311
|
-
const P = i;
|
|
2312
|
-
i = function(A, I, m, g, h, w, E, y) {
|
|
2313
|
-
return P(A, I, m, g, h, w, E, y) ? !0 : S(A, I, m, g, h, w, E, y);
|
|
2314
|
-
};
|
|
2315
|
-
} else
|
|
2316
|
-
i = S;
|
|
2317
|
-
}
|
|
2318
|
-
return super.bvhcast(t, e, { intersectsRanges: i });
|
|
2319
|
-
}
|
|
2320
|
-
/* Derived Cast Functions */
|
|
2321
|
-
intersectsBox(t, e) {
|
|
2322
|
-
return oe.set(t.min, t.max, e), oe.needsUpdate = !0, this.shapecast(
|
|
2323
|
-
{
|
|
2324
|
-
intersectsBounds: (s) => oe.intersectsBox(s),
|
|
2325
|
-
intersectsTriangle: (s) => oe.intersectsTriangle(s)
|
|
2326
|
-
}
|
|
2327
|
-
);
|
|
2328
|
-
}
|
|
2329
|
-
intersectsSphere(t) {
|
|
2330
|
-
return this.shapecast(
|
|
2331
|
-
{
|
|
2332
|
-
intersectsBounds: (e) => t.intersectsBox(e),
|
|
2333
|
-
intersectsTriangle: (e) => e.intersectsSphere(t)
|
|
2334
|
-
}
|
|
2335
|
-
);
|
|
2336
|
-
}
|
|
2337
|
-
closestPointToGeometry(t, e, s = {}, i = {}, o = 0, r = 1 / 0) {
|
|
2338
|
-
return (this.indirect ? ns : Hi)(
|
|
2339
|
-
this,
|
|
2340
|
-
t,
|
|
2341
|
-
e,
|
|
2342
|
-
s,
|
|
2343
|
-
i,
|
|
2344
|
-
o,
|
|
2345
|
-
r
|
|
2346
|
-
);
|
|
2347
|
-
}
|
|
2348
|
-
closestPointToPoint(t, e = {}, s = 0, i = 1 / 0) {
|
|
2349
|
-
return Ei(
|
|
2350
|
-
this,
|
|
2351
|
-
t,
|
|
2352
|
-
e,
|
|
2353
|
-
s,
|
|
2354
|
-
i
|
|
2355
|
-
);
|
|
2356
|
-
}
|
|
2357
|
-
}
|
|
2358
|
-
const Mt = {
|
|
2359
|
-
Mesh: jt.prototype.raycast,
|
|
2360
|
-
Line: Bn.prototype.raycast,
|
|
2361
|
-
LineSegments: ze.prototype.raycast,
|
|
2362
|
-
LineLoop: Sn.prototype.raycast,
|
|
2363
|
-
Points: Tn.prototype.raycast,
|
|
2364
|
-
BatchedMesh: Vn.prototype.raycast
|
|
2365
|
-
}, J = /* @__PURE__ */ new jt(), ae = [];
|
|
2366
|
-
function pn(n, t) {
|
|
2367
|
-
if (this.isBatchedMesh)
|
|
2368
|
-
is.call(this, n, t);
|
|
2369
|
-
else {
|
|
2370
|
-
const { geometry: e } = this;
|
|
2371
|
-
if (e.boundsTree)
|
|
2372
|
-
e.boundsTree.raycastObject3D(this, n, t);
|
|
2373
|
-
else {
|
|
2374
|
-
let s;
|
|
2375
|
-
if (this instanceof jt)
|
|
2376
|
-
s = Mt.Mesh;
|
|
2377
|
-
else if (this instanceof ze)
|
|
2378
|
-
s = Mt.LineSegments;
|
|
2379
|
-
else if (this instanceof Sn)
|
|
2380
|
-
s = Mt.LineLoop;
|
|
2381
|
-
else if (this instanceof Bn)
|
|
2382
|
-
s = Mt.Line;
|
|
2383
|
-
else if (this instanceof Tn)
|
|
2384
|
-
s = Mt.Points;
|
|
2385
|
-
else
|
|
2386
|
-
throw new Error("BVH: Fallback raycast function not found.");
|
|
2387
|
-
s.call(this, n, t);
|
|
2388
|
-
}
|
|
2389
|
-
}
|
|
2390
|
-
}
|
|
2391
|
-
function is(n, t) {
|
|
2392
|
-
if (this.boundsTrees) {
|
|
2393
|
-
const e = this.boundsTrees, s = this._drawInfo || this._instanceInfo, i = this._drawRanges || this._geometryInfo, o = this.matrixWorld;
|
|
2394
|
-
J.material = this.material, J.geometry = this.geometry;
|
|
2395
|
-
const r = J.geometry.boundsTree, a = J.geometry.drawRange;
|
|
2396
|
-
J.geometry.boundingSphere === null && (J.geometry.boundingSphere = new zn());
|
|
2397
|
-
for (let c = 0, d = s.length; c < d; c++) {
|
|
2398
|
-
if (!this.getVisibleAt(c))
|
|
2399
|
-
continue;
|
|
2400
|
-
const f = s[c].geometryIndex;
|
|
2401
|
-
if (J.geometry.boundsTree = e[f], this.getMatrixAt(c, J.matrixWorld).premultiply(o), !J.geometry.boundsTree) {
|
|
2402
|
-
this.getBoundingBoxAt(f, J.geometry.boundingBox), this.getBoundingSphereAt(f, J.geometry.boundingSphere);
|
|
2403
|
-
const u = i[f];
|
|
2404
|
-
J.geometry.setDrawRange(u.start, u.count);
|
|
2405
|
-
}
|
|
2406
|
-
J.raycast(n, ae);
|
|
2407
|
-
for (let u = 0, l = ae.length; u < l; u++) {
|
|
2408
|
-
const p = ae[u];
|
|
2409
|
-
p.object = this, p.batchId = c, t.push(p);
|
|
2410
|
-
}
|
|
2411
|
-
ae.length = 0;
|
|
2412
|
-
}
|
|
2413
|
-
J.geometry.boundsTree = r, J.geometry.drawRange = a, J.material = null, J.geometry = null;
|
|
2414
|
-
} else
|
|
2415
|
-
Mt.BatchedMesh.call(this, n, t);
|
|
2416
|
-
}
|
|
2417
|
-
const ss = { dispose() {
|
|
2418
|
-
} };
|
|
2419
|
-
function rs(n) {
|
|
2420
|
-
const t = [], e = /* @__PURE__ */ new Set();
|
|
2421
|
-
for (const i of n)
|
|
2422
|
-
i.traverse((o) => {
|
|
2423
|
-
if (!(o instanceof jt) || e.has(o) || (e.add(o), !os(o))) return;
|
|
2424
|
-
const r = o.geometry;
|
|
2425
|
-
let a = r.boundsTree, c = !1;
|
|
2426
|
-
if (!a) {
|
|
2427
|
-
try {
|
|
2428
|
-
a = new pe(r, { maxLeafSize: 20, indirect: !0, verbose: !1 });
|
|
2429
|
-
} catch {
|
|
2430
|
-
return;
|
|
2431
|
-
}
|
|
2432
|
-
r.boundsTree = a, c = !0;
|
|
2433
|
-
}
|
|
2434
|
-
o.raycast !== pn && (t.push({
|
|
2435
|
-
mesh: o,
|
|
2436
|
-
originalRaycast: o.raycast,
|
|
2437
|
-
tree: a,
|
|
2438
|
-
ownsTree: c
|
|
2439
|
-
}), o.raycast = pn);
|
|
2440
|
-
});
|
|
2441
|
-
if (t.length === 0) return ss;
|
|
2442
|
-
let s = !1;
|
|
2443
|
-
return {
|
|
2444
|
-
dispose() {
|
|
2445
|
-
if (!s) {
|
|
2446
|
-
s = !0;
|
|
2447
|
-
for (const i of t) {
|
|
2448
|
-
i.mesh.raycast = i.originalRaycast;
|
|
2449
|
-
const o = i.mesh.geometry;
|
|
2450
|
-
i.ownsTree && o.boundsTree === i.tree && delete o.boundsTree;
|
|
2451
|
-
}
|
|
2452
|
-
t.length = 0;
|
|
2453
|
-
}
|
|
2454
|
-
}
|
|
2455
|
-
};
|
|
2456
|
-
}
|
|
2457
|
-
function os(n) {
|
|
2458
|
-
return n.isSkinnedMesh || n.isInstancedMesh || n.isBatchedMesh ? !1 : !Object.values(n.geometry.morphAttributes).some((t) => t.length > 0);
|
|
2459
|
-
}
|
|
2460
|
-
class Ns {
|
|
2461
|
-
constructor(t, e, s = {}) {
|
|
2462
|
-
it(this, "root");
|
|
2463
|
-
it(this, "bodies", /* @__PURE__ */ new Map());
|
|
2464
|
-
it(this, "links", /* @__PURE__ */ new Map());
|
|
2465
|
-
it(this, "raycastAcceleration");
|
|
2466
|
-
it(this, "disposed", !1);
|
|
2467
|
-
this.runtime = t, this.root = e.root, this.raycastAcceleration = s.accelerateRaycast === !1 ? null : rs([this.root]);
|
|
2468
|
-
const i = t.mujoco, o = t.model;
|
|
2469
|
-
for (const [r, a] of e.bindings) {
|
|
2470
|
-
const c = i.mj_name2id(o, i.mjtObj.mjOBJ_BODY.value, r);
|
|
2471
|
-
if (c < 0) throw mn(`Physics body missing for visual link: ${r}`, "E_SIMULATION_BIND");
|
|
2472
|
-
this.links.set(r, a), a.userData.bodyId = c, this.bodies.set(c, a);
|
|
2473
|
-
}
|
|
2474
|
-
if (this.bodies.size !== e.expectedLinkCount) throw mn("Visual body binding count mismatch.", "E_SIMULATION_BIND");
|
|
2475
|
-
this.sync();
|
|
2476
|
-
}
|
|
2477
|
-
objectForLink(t) {
|
|
2478
|
-
return this.links.get(t) ?? null;
|
|
2479
|
-
}
|
|
2480
|
-
bodyPoses() {
|
|
2481
|
-
return new Map([...this.bodies.values()].map((t) => [t.name, { position: t.position.clone(), quaternion: t.quaternion.clone() }]));
|
|
2482
|
-
}
|
|
2483
|
-
sync() {
|
|
2484
|
-
if (this.disposed || !this.runtime.data) return;
|
|
2485
|
-
const { xpos: t, xquat: e } = this.runtime.data;
|
|
2486
|
-
for (const [s, i] of this.bodies) {
|
|
2487
|
-
const o = s * 3, r = s * 4;
|
|
2488
|
-
i.position.set(t[o], t[o + 1], t[o + 2]), i.quaternion.set(e[r + 1], e[r + 2], e[r + 3], e[r]);
|
|
2489
|
-
}
|
|
2490
|
-
this.root.updateMatrixWorld(!0);
|
|
2491
|
-
}
|
|
2492
|
-
dispose() {
|
|
2493
|
-
var t;
|
|
2494
|
-
this.disposed || (this.disposed = !0, this.bodies.clear(), this.links.clear(), (t = this.raycastAcceleration) == null || t.dispose(), qn(this.root));
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
function mn(n, t) {
|
|
2498
|
-
return Object.assign(new Error(n), { code: t });
|
|
2499
|
-
}
|
|
2500
|
-
const cs = /<UDIM>/i;
|
|
2501
|
-
function as(n, t) {
|
|
2502
|
-
const e = yn(n).replaceAll("\\", "/");
|
|
2503
|
-
if (!cs.test(e)) return null;
|
|
2504
|
-
const s = hn(e), i = s.split("/").at(-1);
|
|
2505
|
-
if (!i) return { paths: [], tiles: [] };
|
|
2506
|
-
const o = us(i);
|
|
2507
|
-
if (!o) return { paths: [], tiles: [] };
|
|
2508
|
-
const r = [];
|
|
2509
|
-
for (const d of new Set(t)) {
|
|
2510
|
-
const f = yn(d).replaceAll("\\", "/"), u = hn(f), l = u.split("/").at(-1);
|
|
2511
|
-
if (!l) continue;
|
|
2512
|
-
const p = o.exec(l);
|
|
2513
|
-
if (!p) continue;
|
|
2514
|
-
const S = Number(p[1]);
|
|
2515
|
-
!Number.isInteger(S) || S < 1001 || S > 9999 || r.push({
|
|
2516
|
-
path: d,
|
|
2517
|
-
tile: S,
|
|
2518
|
-
score: fs(s, u)
|
|
2519
|
-
});
|
|
2520
|
-
}
|
|
2521
|
-
if (!r.length) return { paths: [], tiles: [] };
|
|
2522
|
-
const a = Math.max(...r.map((d) => d.score)), c = r.filter((d) => d.score === a).sort((d, f) => d.tile - f.tile || d.path.localeCompare(f.path));
|
|
2523
|
-
return {
|
|
2524
|
-
paths: c.map((d) => d.path),
|
|
2525
|
-
tiles: c.map((d) => d.tile)
|
|
2526
|
-
};
|
|
2527
|
-
}
|
|
2528
|
-
function Us(n) {
|
|
2529
|
-
if (!n.tiles.length) return null;
|
|
2530
|
-
const t = n.tiles.map(ls), e = Math.min(...t.map(({ column: r }) => r)), s = Math.max(...t.map(({ column: r }) => r)), i = Math.min(...t.map(({ row: r }) => r)), o = Math.max(...t.map(({ row: r }) => r));
|
|
2531
|
-
return {
|
|
2532
|
-
minColumn: e,
|
|
2533
|
-
maxColumn: s,
|
|
2534
|
-
minRow: i,
|
|
2535
|
-
maxRow: o,
|
|
2536
|
-
columns: s - e + 1,
|
|
2537
|
-
rows: o - i + 1
|
|
2538
|
-
};
|
|
2539
|
-
}
|
|
2540
|
-
function ls(n) {
|
|
2541
|
-
const t = n - 1001;
|
|
2542
|
-
return {
|
|
2543
|
-
column: (t % 10 + 10) % 10,
|
|
2544
|
-
row: Math.floor(t / 10)
|
|
2545
|
-
};
|
|
2546
|
-
}
|
|
2547
|
-
function us(n) {
|
|
2548
|
-
const t = n.split(/<UDIM>/i);
|
|
2549
|
-
return t.length !== 2 ? null : new RegExp(`^${gn(t[0])}(\\d{4})${gn(t[1])}$`, "i");
|
|
2550
|
-
}
|
|
2551
|
-
function fs(n, t) {
|
|
2552
|
-
const e = n.split("/").slice(0, -1).filter(Boolean), s = t.split("/").slice(0, -1).filter(Boolean);
|
|
2553
|
-
let i = 0;
|
|
2554
|
-
for (; i < e.length && i < s.length; ) {
|
|
2555
|
-
const o = e.at(-1 - i), r = s.at(-1 - i);
|
|
2556
|
-
if ((o == null ? void 0 : o.toLowerCase()) !== (r == null ? void 0 : r.toLowerCase())) break;
|
|
2557
|
-
i += 1;
|
|
2558
|
-
}
|
|
2559
|
-
return i;
|
|
2560
|
-
}
|
|
2561
|
-
function yn(n) {
|
|
2562
|
-
const t = n.replace(/%3CUDIM%3E/gi, "<UDIM>");
|
|
2563
|
-
try {
|
|
2564
|
-
return decodeURIComponent(t);
|
|
2565
|
-
} catch {
|
|
2566
|
-
return t;
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
|
-
function hn(n) {
|
|
2570
|
-
const t = n.search(/[?#]/);
|
|
2571
|
-
return t < 0 ? n : n.slice(0, t);
|
|
2572
|
-
}
|
|
2573
|
-
function gn(n) {
|
|
2574
|
-
return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2575
|
-
}
|
|
2576
|
-
class Ls {
|
|
2577
|
-
constructor(t) {
|
|
2578
|
-
it(this, "entries", /* @__PURE__ */ new Map());
|
|
2579
|
-
it(this, "objectUrls", /* @__PURE__ */ new Map());
|
|
2580
|
-
it(this, "objectUrlPaths", /* @__PURE__ */ new Map());
|
|
2581
|
-
/**
|
|
2582
|
-
* Reads that already failed, so a missing resource is not requested again by
|
|
2583
|
-
* the visual adapter after the reference prefetch has recorded it.
|
|
2584
|
-
*/
|
|
2585
|
-
it(this, "failures", /* @__PURE__ */ new Map());
|
|
2586
|
-
this.source = t;
|
|
2587
|
-
const e = t.original;
|
|
2588
|
-
if (ys(e))
|
|
2589
|
-
for (const s of e.files) this.entries.set(Y(s.path), s.file);
|
|
2590
|
-
else typeof Blob < "u" && e instanceof Blob ? this.entries.set(t.entryPath ?? t.filename ?? "asset", e) : e instanceof ArrayBuffer ? this.entries.set(t.entryPath ?? t.filename ?? "asset", new Blob([e])) : typeof e == "object" && e !== null && "kind" in e && e.kind === "buffer" && this.entries.set(t.entryPath ?? t.filename ?? "asset", new Blob([e.buffer]));
|
|
2591
|
-
}
|
|
2592
|
-
paths() {
|
|
2593
|
-
return [...this.entries.keys()];
|
|
2594
|
-
}
|
|
2595
|
-
hasLocalFiles() {
|
|
2596
|
-
return this.entries.size > 0;
|
|
2597
|
-
}
|
|
2598
|
-
put(t, e) {
|
|
2599
|
-
this.entries.set(Y(t), e);
|
|
2600
|
-
}
|
|
2601
|
-
relativePaths(t = "", e = !1) {
|
|
2602
|
-
return [...this.relativeEntries(t, e)].map(([s]) => s);
|
|
2603
|
-
}
|
|
2604
|
-
asSourceRecord(t = "", e = !1) {
|
|
2605
|
-
return Object.fromEntries(this.relativeEntries(t, e));
|
|
2606
|
-
}
|
|
2607
|
-
*relativeEntries(t = "", e = !1) {
|
|
2608
|
-
const s = Y(t), i = s ? `${s}/` : "";
|
|
2609
|
-
for (const [o, r] of this.entries)
|
|
2610
|
-
if (!i || o.startsWith(i)) yield [i ? o.slice(i.length) : o, r];
|
|
2611
|
-
else if (e) {
|
|
2612
|
-
const a = s.split("/"), c = o.split("/");
|
|
2613
|
-
let d = 0;
|
|
2614
|
-
for (; d < a.length && a[d] === c[d]; ) d++;
|
|
2615
|
-
yield [[...a.slice(d).map(() => ".."), ...c.slice(d)].join("/"), r];
|
|
2616
|
-
}
|
|
2617
|
-
}
|
|
2618
|
-
resolve(t, e = "") {
|
|
2619
|
-
const s = this.find(t, e);
|
|
2620
|
-
if (s) return s;
|
|
2621
|
-
const i = Y(e).split("/").slice(0, -1).join("/");
|
|
2622
|
-
if (this.source.url) return Y(`${i}/${t.replace(/^package:\/\//, "")}`);
|
|
2623
|
-
throw ft(`Simulation resource not found: ${t}`, "E_ASSET_RESOURCE_NOT_FOUND");
|
|
2624
|
-
}
|
|
2625
|
-
find(t, e = "") {
|
|
2626
|
-
const s = Y(t.replace(/^package:\/\//, ""));
|
|
2627
|
-
if (Nt(s)) return this.entries.has(s) ? s : null;
|
|
2628
|
-
const i = Y(e).split("/").slice(0, -1).join("/");
|
|
2629
|
-
for (const r of [Y(`${i}/${t.replace(/^package:\/\//, "")}`), s])
|
|
2630
|
-
if (this.entries.has(r)) return r;
|
|
2631
|
-
const o = this.paths().filter(
|
|
2632
|
-
(r) => !Nt(r) && (r === s || r.endsWith(`/${s}`) || s.endsWith(`/${r}`))
|
|
2633
|
-
);
|
|
2634
|
-
return o.length === 1 ? o[0] : null;
|
|
2635
|
-
}
|
|
2636
|
-
async text(t) {
|
|
2637
|
-
await this.ensure(t);
|
|
2638
|
-
const e = this.entries.get(this.resolve(t));
|
|
2639
|
-
if (!e) throw ft(`Simulation resource not found: ${t}`, "E_ASSET_RESOURCE_NOT_FOUND");
|
|
2640
|
-
return e.text();
|
|
2641
|
-
}
|
|
2642
|
-
async bytes(t) {
|
|
2643
|
-
await this.ensure(t);
|
|
2644
|
-
const e = this.entries.get(this.resolve(t));
|
|
2645
|
-
if (!e) throw ft(`Simulation resource not found: ${t}`, "E_ASSET_RESOURCE_NOT_FOUND");
|
|
2646
|
-
return new Uint8Array(await e.arrayBuffer());
|
|
2647
|
-
}
|
|
2648
|
-
getBlob(t) {
|
|
2649
|
-
const e = this.resolve(t), s = this.entries.get(e);
|
|
2650
|
-
if (!s) throw ft(`Simulation resource not found: ${t}`, "E_ASSET_RESOURCE_NOT_FOUND");
|
|
2651
|
-
return s;
|
|
2652
|
-
}
|
|
2653
|
-
async ensure(t) {
|
|
2654
|
-
const e = Y(t);
|
|
2655
|
-
if (this.entries.has(e)) return;
|
|
2656
|
-
const s = this.failures.get(e);
|
|
2657
|
-
if (s) throw s;
|
|
2658
|
-
try {
|
|
2659
|
-
const i = await this.source.resolve(e);
|
|
2660
|
-
if (!/^https?:\/\//i.test(i) && !/^blob:/i.test(i))
|
|
2661
|
-
throw ft(`Simulation resource not found: ${t}. Upload the complete asset folder or provide a resourceResolver/baseUrl.`, He);
|
|
2662
|
-
const o = await fetch(i, { signal: this.source.signal });
|
|
2663
|
-
if (!o.ok) {
|
|
2664
|
-
const c = o.status === 401 || o.status === 403 ? Jn : o.status === 404 || o.status === 410 ? He : Hn;
|
|
2665
|
-
throw ft(`Simulation resource request failed (${o.status}): ${i}`, c);
|
|
2666
|
-
}
|
|
2667
|
-
const r = await o.blob();
|
|
2668
|
-
this.source.signal.throwIfAborted();
|
|
2669
|
-
const a = await Wn(r);
|
|
2670
|
-
if (a) throw ft(`Simulation resource is not usable (${a}): ${i}`, Yn);
|
|
2671
|
-
this.entries.set(e, r);
|
|
2672
|
-
} catch (i) {
|
|
2673
|
-
throw Xn(i) === "aborted" || this.failures.set(e, i instanceof Error ? i : new Error(String(i))), i;
|
|
2674
|
-
}
|
|
2675
|
-
}
|
|
2676
|
-
/** The recorded failure for a resource, if a previous read already failed. */
|
|
2677
|
-
failureOf(t) {
|
|
2678
|
-
return this.failures.get(Y(t));
|
|
2679
|
-
}
|
|
2680
|
-
objectUrl(t) {
|
|
2681
|
-
const e = this.resolve(t);
|
|
2682
|
-
let s = this.objectUrls.get(e);
|
|
2683
|
-
return s || (s = URL.createObjectURL(this.getBlob(e)), this.objectUrls.set(e, s), this.objectUrlPaths.set(s, e)), s;
|
|
2684
|
-
}
|
|
2685
|
-
pathForObjectUrl(t) {
|
|
2686
|
-
return this.objectUrlPaths.get(t) ?? null;
|
|
2687
|
-
}
|
|
2688
|
-
/**
|
|
2689
|
-
* Resolve a texture relative to the directory containing the entry layer.
|
|
2690
|
-
* Pass the entry directory, not the entry file path.
|
|
2691
|
-
*/
|
|
2692
|
-
findTexture(t, e = "") {
|
|
2693
|
-
const s = this.findPresent(t, e);
|
|
2694
|
-
if (s) return s;
|
|
2695
|
-
const i = this.udimTextureSet(t, e);
|
|
2696
|
-
return (i == null ? void 0 : i.paths.length) === 1 ? i.paths[0] : null;
|
|
2697
|
-
}
|
|
2698
|
-
udimTextureSet(t, e = "") {
|
|
2699
|
-
const s = this.bindPackageReference(t, e), i = this.texturesUnderEntryDirectory(e);
|
|
2700
|
-
return as(s, i.length ? i : this.paths());
|
|
2701
|
-
}
|
|
2702
|
-
/**
|
|
2703
|
-
* Package files below the entry directory named like UDIM tiles. A set the
|
|
2704
|
-
* entry directory does not contain falls back to the whole package.
|
|
2705
|
-
*/
|
|
2706
|
-
texturesUnderEntryDirectory(t) {
|
|
2707
|
-
const e = Y(t);
|
|
2708
|
-
return e ? this.paths().filter((s) => s.startsWith(`${e}/`) && /\d{4}\.[^/]*$/i.test(s)) : [];
|
|
2709
|
-
}
|
|
2710
|
-
objectUrlIfPresent(t, e = "") {
|
|
2711
|
-
const s = this.findTexture(t, e);
|
|
2712
|
-
return s ? this.objectUrl(s) : null;
|
|
2713
|
-
}
|
|
2714
|
-
findPresent(t, e = "") {
|
|
2715
|
-
if (Nt(t)) {
|
|
2716
|
-
if (this.entries.has(t)) return t;
|
|
2717
|
-
const a = this.bindPackageReference(t, e);
|
|
2718
|
-
return a === t ? null : this.findPresent(a, e);
|
|
2719
|
-
}
|
|
2720
|
-
const s = Y(e), i = s ? `${s}/` : "", o = Y(t), r = i ? this.paths().filter((a) => {
|
|
2721
|
-
if (!a.startsWith(i)) return !1;
|
|
2722
|
-
const c = a.slice(i.length);
|
|
2723
|
-
return c === o || o.endsWith(`/${c}`);
|
|
2724
|
-
}) : [];
|
|
2725
|
-
return r.length === 1 ? r[0] : this.find(t);
|
|
2726
|
-
}
|
|
2727
|
-
/**
|
|
2728
|
-
* Rewrites a protocol reference (`https://bucket/asset/textures/a.png`,
|
|
2729
|
-
* `file:///asset/textures/a.png`) into the package path it names, relative to
|
|
2730
|
-
* the entry directory, preferring the longest tail of the URL path that
|
|
2731
|
-
* repeats inside the package. The file name alone is never enough to bind,
|
|
2732
|
-
* so an unrelated same-name file elsewhere in the package is not guessed.
|
|
2733
|
-
* References that are not URLs, or that bind to nothing, are returned as-is.
|
|
2734
|
-
*/
|
|
2735
|
-
bindPackageReference(t, e = "") {
|
|
2736
|
-
const s = Y(e), i = s ? `${s}/` : "", o = ms(t).flatMap((a) => a.split("/")).filter(Boolean);
|
|
2737
|
-
if (!o.length) return t;
|
|
2738
|
-
let r = null;
|
|
2739
|
-
for (const a of this.paths()) {
|
|
2740
|
-
if (Nt(a) || i && !a.startsWith(i)) continue;
|
|
2741
|
-
const c = a.split("/");
|
|
2742
|
-
let d = 0;
|
|
2743
|
-
for (; d < o.length && d < c.length && ds(o.at(-1 - d), c.at(-1 - d)); ) d += 1;
|
|
2744
|
-
d < 2 || (!r || d > r.depth) && (r = { path: a, depth: d });
|
|
2745
|
-
}
|
|
2746
|
-
return r ? i && r.path.startsWith(i) ? r.path.slice(i.length) : r.path : t;
|
|
2747
|
-
}
|
|
2748
|
-
dispose() {
|
|
2749
|
-
for (const t of this.objectUrls.values()) URL.revokeObjectURL(t);
|
|
2750
|
-
this.objectUrls.clear(), this.objectUrlPaths.clear(), this.entries.clear(), this.failures.clear();
|
|
2751
|
-
}
|
|
2752
|
-
}
|
|
2753
|
-
async function Rs(n, t) {
|
|
2754
|
-
if (t.hasLocalFiles()) return t.text(n.entryPath ?? n.filename ?? t.paths()[0]);
|
|
2755
|
-
const e = await fetch(n.url ?? await n.resolve(n.entryPath ?? ""), { signal: n.signal });
|
|
2756
|
-
if (!e.ok) throw ft(`Simulation asset request failed: ${e.status}`, "E_ASSET_FETCH");
|
|
2757
|
-
return e.text();
|
|
2758
|
-
}
|
|
2759
|
-
function Ds(n) {
|
|
2760
|
-
return Y(n);
|
|
2761
|
-
}
|
|
2762
|
-
function Y(n) {
|
|
2763
|
-
if (Nt(n)) return n;
|
|
2764
|
-
const t = [];
|
|
2765
|
-
for (const e of n.replaceAll("\\", "/").split("/"))
|
|
2766
|
-
!e || e === "." || (e === ".." && t.length && t.at(-1) !== ".." ? t.pop() : t.push(e));
|
|
2767
|
-
return t.join("/");
|
|
2768
|
-
}
|
|
2769
|
-
function Nt(n) {
|
|
2770
|
-
return /^[a-z][a-z\d+.-]*:/i.test(n) && !/^package:\/\//i.test(n);
|
|
2771
|
-
}
|
|
2772
|
-
function ds(n, t) {
|
|
2773
|
-
const e = n.search(/[?#]/);
|
|
2774
|
-
return t === (e < 0 ? n : n.slice(0, e));
|
|
2775
|
-
}
|
|
2776
|
-
function ps(n) {
|
|
2777
|
-
try {
|
|
2778
|
-
return decodeURIComponent(n);
|
|
2779
|
-
} catch {
|
|
2780
|
-
return n;
|
|
2781
|
-
}
|
|
2782
|
-
}
|
|
2783
|
-
function ms(n) {
|
|
2784
|
-
if (!Nt(n) || /^(?:data|blob):/i.test(n)) return [];
|
|
2785
|
-
let t;
|
|
2786
|
-
try {
|
|
2787
|
-
t = new URL(n, "file:///").pathname;
|
|
2788
|
-
} catch {
|
|
2789
|
-
t = n.replace(/^[a-z][a-z\d+.-]*:\/\/[^/]*/i, "").replace(/[?#].*$/, "");
|
|
2790
|
-
}
|
|
2791
|
-
return t.split("/").filter(Boolean).map(ps);
|
|
2792
|
-
}
|
|
2793
|
-
function ys(n) {
|
|
2794
|
-
return typeof n == "object" && n !== null && "kind" in n && n.kind === "files";
|
|
2795
|
-
}
|
|
2796
|
-
function ft(n, t) {
|
|
2797
|
-
return Object.assign(new Error(n), { code: t });
|
|
2798
|
-
}
|
|
2799
|
-
function Cs() {
|
|
2800
|
-
return { errors: [], warnings: [], approximations: [], droppedFeatures: [] };
|
|
2801
|
-
}
|
|
2802
|
-
function Os(n, t = {}) {
|
|
2803
|
-
const e = Object.freeze({ schemaVersion: 1, ...n });
|
|
2804
|
-
return hs(e, t), e;
|
|
2805
|
-
}
|
|
2806
|
-
function hs(n, t = {}) {
|
|
2807
|
-
if (!n.id.trim() || !n.name.trim()) throw le("Asset IR id and name are required.", "E_ASSET_IR_INVALID");
|
|
2808
|
-
if (n.source.format !== "usd" && n.links.length === 0) throw le("Asset IR requires at least one link.", "E_ASSET_IR_INVALID");
|
|
2809
|
-
const e = /* @__PURE__ */ new Set();
|
|
2810
|
-
for (const i of n.links) {
|
|
2811
|
-
if (!i.id || e.has(i.id)) throw le(`Invalid or duplicate link: ${i.id}`, "E_ASSET_IR_INVALID");
|
|
2812
|
-
e.add(i.id);
|
|
2813
|
-
}
|
|
2814
|
-
const s = /* @__PURE__ */ new Set();
|
|
2815
|
-
for (const i of n.joints) {
|
|
2816
|
-
if (!i.id || s.has(i.id) || !t.allowInvalidGraph && (!e.has(i.parent) || !e.has(i.child)))
|
|
2817
|
-
throw le(`Invalid joint: ${i.id}`, "E_ASSET_IR_INVALID");
|
|
2818
|
-
s.add(i.id);
|
|
2819
|
-
}
|
|
2820
|
-
}
|
|
2821
|
-
function le(n, t) {
|
|
2822
|
-
return Object.assign(new Error(n), { code: t });
|
|
2823
|
-
}
|
|
2824
|
-
const Un = 3073715, Fs = 16758861, gs = 0.96, ws = 0.1, xs = 20, bs = 1;
|
|
2825
|
-
function zs(n = Un) {
|
|
2826
|
-
return new jn({
|
|
2827
|
-
color: n,
|
|
2828
|
-
transparent: !0,
|
|
2829
|
-
opacity: gs,
|
|
2830
|
-
depthTest: !1,
|
|
2831
|
-
depthWrite: !1,
|
|
2832
|
-
linewidth: 2,
|
|
2833
|
-
toneMapped: !1,
|
|
2834
|
-
fog: !1
|
|
2835
|
-
});
|
|
2836
|
-
}
|
|
2837
|
-
function Vs(n = Un) {
|
|
2838
|
-
return new $n({
|
|
2839
|
-
color: n,
|
|
2840
|
-
transparent: !0,
|
|
2841
|
-
opacity: ws,
|
|
2842
|
-
depthTest: !0,
|
|
2843
|
-
depthWrite: !1,
|
|
2844
|
-
side: _n,
|
|
2845
|
-
polygonOffset: !0,
|
|
2846
|
-
polygonOffsetFactor: -1,
|
|
2847
|
-
polygonOffsetUnits: -1,
|
|
2848
|
-
toneMapped: !1,
|
|
2849
|
-
fog: !1
|
|
2850
|
-
});
|
|
2851
|
-
}
|
|
2852
|
-
function js(n, t, e = "feature", s) {
|
|
2853
|
-
const i = e === "mesh" ? new kn(n) : _s(n), o = new ze(i, t);
|
|
2854
|
-
if (o.renderOrder = 9, s) {
|
|
2855
|
-
const r = new jt(n.clone(), s);
|
|
2856
|
-
r.name = "collision-volume", r.renderOrder = 8, r.userData.collisionDebugRole = "volume", o.add(r), o.userData.collisionDebugRole = "outline";
|
|
2857
|
-
}
|
|
2858
|
-
return o;
|
|
2859
|
-
}
|
|
2860
|
-
function _s(n) {
|
|
2861
|
-
let t = new ge(n, xs);
|
|
2862
|
-
return wn(n, t) || (t.dispose(), t = new ge(n, bs)), wn(n, t) || (t.dispose(), t = new ge(n, 0)), t;
|
|
2863
|
-
}
|
|
2864
|
-
const As = 256, Ss = 0.5;
|
|
2865
|
-
function wn(n, t) {
|
|
2866
|
-
var a, c;
|
|
2867
|
-
const e = t.getAttribute("position");
|
|
2868
|
-
if (!e || e.count === 0) return !1;
|
|
2869
|
-
const s = n.getAttribute("position");
|
|
2870
|
-
if (!s || s.count < As) return !0;
|
|
2871
|
-
n.computeBoundingBox(), t.computeBoundingBox();
|
|
2872
|
-
const i = (a = n.boundingBox) == null ? void 0 : a.getSize(new U()), o = (c = t.boundingBox) == null ? void 0 : c.getSize(new U());
|
|
2873
|
-
if (!i || !o) return !1;
|
|
2874
|
-
const r = i.length();
|
|
2875
|
-
return !Number.isFinite(r) || r <= 0 ? !0 : o.length() / r >= Ss;
|
|
2876
|
-
}
|
|
2877
|
-
export {
|
|
2878
|
-
Fs as C,
|
|
2879
|
-
pe as M,
|
|
2880
|
-
Ns as S,
|
|
2881
|
-
Vs as a,
|
|
2882
|
-
js as b,
|
|
2883
|
-
zs as c,
|
|
2884
|
-
Os as d,
|
|
2885
|
-
vs as e,
|
|
2886
|
-
Cs as f,
|
|
2887
|
-
Ls as g,
|
|
2888
|
-
Rs as h,
|
|
2889
|
-
pn as i,
|
|
2890
|
-
Ee as j,
|
|
2891
|
-
Ds as n,
|
|
2892
|
-
Ms as p,
|
|
2893
|
-
as as r,
|
|
2894
|
-
Us as u,
|
|
2895
|
-
Es as w
|
|
2896
|
-
};
|