@nebula-spatial/viewer 0.4.5 → 0.5.0
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 +62 -5
- package/README.md +98 -51
- package/dist/assets/types.d.ts +40 -11
- package/dist/cad/types.d.ts +4 -8
- package/dist/{index-CxbZ--5C.js → index-D2vtjYht.js} +2648 -2287
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -2
- package/dist/{mjcf-visual-6_RqDf4z.js → mjcf-visual-NkIASi_6.js} +2 -2
- package/dist/mujoco-runtime-7xiBQNJm.js +324 -0
- package/dist/session-DHPMjyl3.js +809 -0
- package/dist/{session-CnlODeFp.js → session-di9BueA_.js} +152 -163
- package/dist/{stage-BPiGudYP.js → stage-D-BewE6x.js} +198 -150
- package/dist/types.d.ts +11 -0
- package/dist/{urdf-session-CuIZOiCF.js → urdf-session-DsE5uC-u.js} +433 -424
- package/dist/usd-session-yEFMGOIp.js +2240 -0
- package/dist/version.d.ts +5 -0
- package/dist/{xacro-DrBtv-gK.js → xacro-D8OfZ2xw.js} +1 -1
- package/openusd/openusd_probe.js +14 -0
- package/openusd/openusd_probe.wasm +0 -0
- package/package.json +5 -4
- package/dist/mujoco-runtime-C29PXDOl.js +0 -258
- package/dist/session-DNyPmQOW.js +0 -795
- package/dist/usd-session-JDfuDgWv.js +0 -1907
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var $ = (n, t, i) =>
|
|
4
|
-
import { d as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { OBJLoader as
|
|
10
|
-
import { STLLoader as
|
|
11
|
-
function
|
|
1
|
+
var un = Object.defineProperty;
|
|
2
|
+
var fn = (n, t, i) => t in n ? un(n, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[t] = i;
|
|
3
|
+
var $ = (n, t, i) => fn(n, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
import { d as dn, b as pn, e as oi, c as mn, a as ri, r as hn, S as ai, p as yn } from "./session-DHPMjyl3.js";
|
|
5
|
+
import { b as ft, S as gn, m as ci } from "./stage-D-BewE6x.js";
|
|
6
|
+
import { Quaternion as K, Euler as Zt, LoadingManager as Ci, Group as ut, Mesh as C, MeshLambertMaterial as wn, MeshPhongMaterial as li, MeshStandardMaterial as Je, Matrix4 as H, TextureLoader as bn, SRGBColorSpace as xn, RepeatWrapping as An, BoxGeometry as He, SphereGeometry as Ze, CylinderGeometry as Ni, CapsuleGeometry as qi, Vector3 as z, MathUtils as Mn, Matrix3 as ui, Box3 as it, BufferAttribute as Oi, Line3 as dt, Plane as Vi, Vector2 as gt, Triangle as $t, BackSide as vn, DoubleSide as Pn, REVISION as Wi, Ray as Sn, FrontSide as fi, LineSegments as Qe, LineLoop as Gi, Line as Ye, Points as Xi, Sphere as Tn, BatchedMesh as Rn, AxesHelper as Bn, ArrowHelper as di, BufferGeometry as _n, LineBasicMaterial as pi, Float32BufferAttribute as En, MeshBasicMaterial as mi, EdgesGeometry as zn } from "three";
|
|
7
|
+
import { GLTFLoader as Un } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
8
|
+
import { ColladaLoader as Fn } from "three/examples/jsm/loaders/ColladaLoader.js";
|
|
9
|
+
import { OBJLoader as $n } from "three/examples/jsm/loaders/OBJLoader.js";
|
|
10
|
+
import { STLLoader as In } from "three/examples/jsm/loaders/STLLoader.js";
|
|
11
|
+
function Ji(n) {
|
|
12
12
|
const t = new Map(n.map((o) => [o.id, o])), i = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Set(), s = (o) => {
|
|
13
13
|
throw Object.assign(new Error(`Invalid URDF mimic relationship: ${o}`), { code: "E_URDF_MIMIC" });
|
|
14
14
|
}, r = (o) => {
|
|
@@ -31,7 +31,7 @@ function Xi(n) {
|
|
|
31
31
|
return i;
|
|
32
32
|
}
|
|
33
33
|
function xe(n) {
|
|
34
|
-
const t =
|
|
34
|
+
const t = Ji(n), i = /* @__PURE__ */ new Map();
|
|
35
35
|
for (const e of n) {
|
|
36
36
|
const s = t.get(e.id);
|
|
37
37
|
if (i.has(s.root) || i.set(s.root, { lower: -1 / 0, upper: 1 / 0 }), e.type === "continuous" || !e.limits || e.limits.lower > e.limits.upper) continue;
|
|
@@ -46,7 +46,7 @@ function xe(n) {
|
|
|
46
46
|
return i;
|
|
47
47
|
}
|
|
48
48
|
function Ke(n, t = {}) {
|
|
49
|
-
const i =
|
|
49
|
+
const i = Ji(n), e = xe(n);
|
|
50
50
|
return Object.fromEntries(n.map((s) => {
|
|
51
51
|
const r = i.get(s.id), o = e.get(r.root), f = Math.max(o.lower, Math.min(o.upper, t[r.root] ?? 0));
|
|
52
52
|
return [s.id, f * r.multiplier + r.offset];
|
|
@@ -55,9 +55,9 @@ function Ke(n, t = {}) {
|
|
|
55
55
|
function Qt(n) {
|
|
56
56
|
return n.rotationQuaternion ? new K().fromArray(n.rotationQuaternion).normalize() : new K().setFromEuler(new Zt(n.rotationRpy[0], n.rotationRpy[1], n.rotationRpy[2], "ZYX"));
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function Dn(n) {
|
|
59
59
|
const t = /* @__PURE__ */ new Map(), i = (e) => {
|
|
60
|
-
if (!(e instanceof
|
|
60
|
+
if (!(e instanceof wn || e instanceof li)) return e;
|
|
61
61
|
const s = t.get(e);
|
|
62
62
|
if (s) return s;
|
|
63
63
|
const r = new Je({
|
|
@@ -82,7 +82,7 @@ function In(n) {
|
|
|
82
82
|
depthWrite: e.depthWrite,
|
|
83
83
|
vertexColors: e.vertexColors,
|
|
84
84
|
flatShading: e.flatShading,
|
|
85
|
-
roughness: e instanceof
|
|
85
|
+
roughness: e instanceof li ? Math.sqrt(2 / (Math.max(0, e.shininess) + 2)) : 0.5,
|
|
86
86
|
metalness: 0
|
|
87
87
|
});
|
|
88
88
|
return r.normalScale.copy(e.normalScale), r.normalMapType = e.normalMapType, r.userData = { ...e.userData, colladaSourceMaterial: e.type }, t.set(e, r), r;
|
|
@@ -92,7 +92,7 @@ function In(n) {
|
|
|
92
92
|
});
|
|
93
93
|
for (const e of t.keys()) e.dispose();
|
|
94
94
|
}
|
|
95
|
-
async function
|
|
95
|
+
async function Ln(n, t) {
|
|
96
96
|
var p, c, d;
|
|
97
97
|
const i = await t.text(n), e = new DOMParser().parseFromString(i, "application/xml");
|
|
98
98
|
if (e.querySelector("parsererror") || e.documentElement.localName !== "COLLADA")
|
|
@@ -106,7 +106,7 @@ async function Dn(n, t) {
|
|
|
106
106
|
const x = t.resolve(g, n);
|
|
107
107
|
await t.ensure(x), r.set(g, t.objectUrl(x));
|
|
108
108
|
}
|
|
109
|
-
const o = new
|
|
109
|
+
const o = new Ci();
|
|
110
110
|
o.setURLModifier((y) => {
|
|
111
111
|
if (y.startsWith("data:")) return y;
|
|
112
112
|
const g = r.get(y);
|
|
@@ -123,25 +123,25 @@ async function Dn(n, t) {
|
|
|
123
123
|
}, o.itemStart("urdf-collada-parse");
|
|
124
124
|
const l = new ut();
|
|
125
125
|
try {
|
|
126
|
-
const y = new
|
|
126
|
+
const y = new Fn(o).parse(i, "");
|
|
127
127
|
if (!(y != null && y.scene)) throw new Error(`COLLADA has no scene: ${n}`);
|
|
128
128
|
if (l.add(y.scene), s === "X_UP" ? y.scene.rotateY(-Math.PI / 2) : y.scene.rotateX(Math.PI / 2), o.itemEnd("urdf-collada-parse"), await a, u) throw new Error(`COLLADA texture failed to load: ${u}`);
|
|
129
129
|
let g = 0;
|
|
130
130
|
if (l.traverse((x) => {
|
|
131
131
|
x instanceof C && g++;
|
|
132
132
|
}), !g) throw new Error(`COLLADA has no visual meshes: ${n}`);
|
|
133
|
-
return
|
|
133
|
+
return Dn(l), l.updateMatrixWorld(!0), l;
|
|
134
134
|
} catch (y) {
|
|
135
|
-
throw
|
|
135
|
+
throw ft(l), y;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function Hi(n) {
|
|
139
139
|
const [t, i, e, s, r, o] = n;
|
|
140
140
|
if (![t, i, e, s, r, o].every(Number.isFinite)) return !1;
|
|
141
141
|
const f = t * i - s * s, a = t * (i * e - o * o) - s * (s * e - o * r) + r * (s * o - i * r);
|
|
142
142
|
return t > 0 && f > 0 && a > 0 ? t <= i + e + 1e-12 && i <= t + e + 1e-12 && e <= t + i + 1e-12 : !1;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function kn(n, t) {
|
|
145
145
|
if (!(t > 0) || !Number.isFinite(t) || n.length !== 6 || !n.every(Number.isFinite)) return null;
|
|
146
146
|
const i = [[n[0], n[3], n[4]], [n[3], n[1], n[5]], [n[4], n[5], n[2]]], e = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], s = Math.max(...n.map(Math.abs));
|
|
147
147
|
for (let a = 0; a < 40; a++) {
|
|
@@ -164,8 +164,8 @@ function Ln(n, t) {
|
|
|
164
164
|
const f = new H().set(e[0][0], e[0][1], e[0][2], 0, e[1][0], e[1][1], e[1][2], 0, e[2][0], e[2][1], e[2][2], 0, 0, 0, 0, 1);
|
|
165
165
|
return { radii: o.map((a) => Math.sqrt(Math.max(0, a))), rotation: new K().setFromRotationMatrix(f) };
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
const i =
|
|
167
|
+
function jn(n, t) {
|
|
168
|
+
const i = kn(n, t);
|
|
169
169
|
return i ? { size: i.radii.map((e) => e * Math.sqrt(12 / 5)), rotation: i.rotation } : null;
|
|
170
170
|
}
|
|
171
171
|
function Lt(n, t) {
|
|
@@ -184,9 +184,9 @@ function he(n) {
|
|
|
184
184
|
...i.length ? { rotationQuaternion: i } : {}
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function hi(n, t, i) {
|
|
188
188
|
const e = n.querySelector("geometry"), s = e == null ? void 0 : e.querySelector("box");
|
|
189
|
-
if (s) return { type: "box", size:
|
|
189
|
+
if (s) return { type: "box", size: Jn(s.getAttribute("size"), 3, "box size") };
|
|
190
190
|
const r = e == null ? void 0 : e.querySelector("sphere");
|
|
191
191
|
if (r) return { type: "sphere", radius: jt(r.getAttribute("radius"), "sphere radius") };
|
|
192
192
|
const o = e == null ? void 0 : e.querySelector("cylinder");
|
|
@@ -196,10 +196,10 @@ function mi(n, t, i) {
|
|
|
196
196
|
const a = e == null ? void 0 : e.querySelector("mesh"), u = a == null ? void 0 : a.getAttribute("filename");
|
|
197
197
|
return u ? { type: "mesh", resourcePath: i.resolve(u, t), scale: Lt(a.getAttribute("scale"), [1, 1, 1]) } : null;
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
const s =
|
|
199
|
+
function Cn(n, t, i) {
|
|
200
|
+
const s = Xn(n, "URDF").querySelector("robot");
|
|
201
201
|
if (!s) throw O("URDF requires a robot root element.", "E_URDF_PARSE");
|
|
202
|
-
const r =
|
|
202
|
+
const r = pn(), o = /* @__PURE__ */ new Map();
|
|
203
203
|
for (const u of s.children) if (u.tagName === "material" && u.getAttribute("name")) {
|
|
204
204
|
const l = u.getAttribute("name");
|
|
205
205
|
if (o.has(l)) throw O(`Duplicate URDF material: ${l}`, "E_URDF_MATERIAL");
|
|
@@ -209,11 +209,11 @@ function jn(n, t, i) {
|
|
|
209
209
|
id: ot(u, "name"),
|
|
210
210
|
name: ot(u, "name"),
|
|
211
211
|
inertial: (() => {
|
|
212
|
-
const l =
|
|
213
|
-
return l && (!(l.mass > 0) || !Number.isFinite(l.mass) || !
|
|
212
|
+
const l = Hn(u);
|
|
213
|
+
return l && (!(l.mass > 0) || !Number.isFinite(l.mass) || !Hi(l.tensor)) && r.errors.push({ code: "E_URDF_INERTIA", message: `连杆 ${u.getAttribute("name")} 的质量或惯性张量无效。`, source: u.getAttribute("name") ?? void 0 }), l;
|
|
214
214
|
})(),
|
|
215
215
|
visuals: [...u.querySelectorAll("visual")].map((l) => {
|
|
216
|
-
const p =
|
|
216
|
+
const p = hi(l, t, i), c = l.querySelector("material"), d = c == null ? void 0 : c.getAttribute("name"), y = d ? o.get(d) : void 0, g = (c == null ? void 0 : c.querySelector("color")) ?? (y == null ? void 0 : y.querySelector("color")), x = (c == null ? void 0 : c.querySelector("texture")) ?? (y == null ? void 0 : y.querySelector("texture"));
|
|
217
217
|
d && !y && !g && !x && r.warnings.push({ code: "URDF_MATERIAL_UNRESOLVED", message: `Undefined material: ${d}`, source: u.getAttribute("name") ?? void 0 });
|
|
218
218
|
const w = g ? (g.getAttribute("rgba") ?? "").trim().split(/\s+/).map(Number) : x ? [1, 1, 1, 1] : void 0;
|
|
219
219
|
if (w && (w.length !== 4 || w.some((b) => !Number.isFinite(b) || b < 0 || b > 1))) throw O(`Invalid URDF material RGBA: ${d ?? ""}`, "E_URDF_MATERIAL");
|
|
@@ -223,12 +223,12 @@ function jn(n, t, i) {
|
|
|
223
223
|
return p ? { origin: he(l), geometry: p, color: w, texturePath: h } : null;
|
|
224
224
|
}).filter((l) => !!l),
|
|
225
225
|
collisions: [...u.querySelectorAll("collision")].map((l) => {
|
|
226
|
-
const p =
|
|
226
|
+
const p = hi(l, t, i);
|
|
227
227
|
return p ? { origin: he(l), geometry: p } : null;
|
|
228
228
|
}).filter((l) => !!l)
|
|
229
229
|
})), a = [...s.querySelectorAll("joint")].map((u) => {
|
|
230
230
|
var w;
|
|
231
|
-
const l = u.querySelector("limit"), p = u.querySelector("mimic"), c = p ? { joint: ot(p, "joint"), multiplier: Yt(p.getAttribute("multiplier"), "mimic multiplier") ?? 1, offset: Yt(p.getAttribute("offset"), "mimic offset") ?? 0 } : void 0, d = u.querySelector("dynamics"), y = d ?
|
|
231
|
+
const l = u.querySelector("limit"), p = u.querySelector("mimic"), c = p ? { joint: ot(p, "joint"), multiplier: Yt(p.getAttribute("multiplier"), "mimic multiplier") ?? 1, offset: Yt(p.getAttribute("offset"), "mimic offset") ?? 0 } : void 0, d = u.querySelector("dynamics"), y = d ? wi(d.getAttribute("damping"), 0) : 0, g = d ? wi(d.getAttribute("friction"), 0) : 0, x = d && (y > 0 || g > 0) ? { damping: y, friction: g } : void 0;
|
|
232
232
|
return {
|
|
233
233
|
id: ot(u, "name"),
|
|
234
234
|
type: u.getAttribute("type") ?? "fixed",
|
|
@@ -245,9 +245,9 @@ function jn(n, t, i) {
|
|
|
245
245
|
...c ? { mimic: c } : {}
|
|
246
246
|
};
|
|
247
247
|
});
|
|
248
|
-
return xe(a), s.querySelector("transmission, gazebo") && r.droppedFeatures.push({ code: "UNSUPPORTED_URDF_EXTENSION", message: "URDF transmission/gazebo extensions are not compiled." }),
|
|
248
|
+
return xe(a), s.querySelector("transmission, gazebo") && r.droppedFeatures.push({ code: "UNSUPPORTED_URDF_EXTENSION", message: "URDF transmission/gazebo extensions are not compiled." }), dn({ id: s.getAttribute("name") || t, name: s.getAttribute("name") || t, source: { format: "urdf", uri: t }, links: f, joints: a, diagnostics: r, extension: { files: i } }, { allowInvalidGraph: !0 });
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function yi(n) {
|
|
251
251
|
const t = Qt(n);
|
|
252
252
|
return `quat="${t.w} ${t.x} ${t.y} ${t.z}"`;
|
|
253
253
|
}
|
|
@@ -255,12 +255,12 @@ function Ie(n) {
|
|
|
255
255
|
const t = new H(), i = Qt(n);
|
|
256
256
|
return t.compose(new z().fromArray(n.position), i, new z(1, 1, 1));
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function Nn(n) {
|
|
259
259
|
if (n.type === "continuous" || !n.limits) return 0;
|
|
260
260
|
const { lower: t, upper: i } = n.limits;
|
|
261
|
-
return !Number.isFinite(t) || !Number.isFinite(i) ? 0 :
|
|
261
|
+
return !Number.isFinite(t) || !Number.isFinite(i) ? 0 : Mn.clamp(0, t, i);
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function qn(n) {
|
|
264
264
|
let t;
|
|
265
265
|
if (n.type === "box")
|
|
266
266
|
t = [n.size[0] / 2, n.size[1] / 2, n.size[2] / 2];
|
|
@@ -277,7 +277,7 @@ function Nn(n) {
|
|
|
277
277
|
i.push(new z(e, s, r));
|
|
278
278
|
return i;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function Zi(n, t, i) {
|
|
281
281
|
let e = 0;
|
|
282
282
|
const s = new Map(n.links.map((l) => [l.id, l])), r = Ke(n.joints), o = (l) => {
|
|
283
283
|
let p = 1 / 0;
|
|
@@ -285,7 +285,7 @@ function Hi(n, t, i) {
|
|
|
285
285
|
const g = s.get(d);
|
|
286
286
|
if (g) {
|
|
287
287
|
for (const x of g.collisions) {
|
|
288
|
-
const w =
|
|
288
|
+
const w = qn(x.geometry);
|
|
289
289
|
if (!w) {
|
|
290
290
|
l && (e += 1);
|
|
291
291
|
continue;
|
|
@@ -307,17 +307,17 @@ function Hi(n, t, i) {
|
|
|
307
307
|
message: `自动落地忽略了 ${e} 个网格碰撞体`
|
|
308
308
|
}), Number.isFinite(u) ? Math.max(0, 0.015 - u) : 0;
|
|
309
309
|
}
|
|
310
|
-
async function
|
|
310
|
+
async function On(n) {
|
|
311
311
|
const t = n.extension.files, i = /* @__PURE__ */ new Map(), e = new Set(n.joints.map((w) => w.child));
|
|
312
312
|
for (const w of n.joints) i.set(w.parent, [...i.get(w.parent) ?? [], w]);
|
|
313
313
|
const s = n.links.filter((w) => !e.has(w.id));
|
|
314
314
|
if (s.length !== 1) throw O(`URDF requires exactly one root link; found ${s.length}.`, "E_URDF_COMPILE");
|
|
315
|
-
const r =
|
|
315
|
+
const r = Zi(n, s[0].id, i);
|
|
316
316
|
r > 0 && n.diagnostics.approximations.push({
|
|
317
317
|
code: "AUTO_GROUNDED_FREE_ROOT",
|
|
318
318
|
message: `自由根初始高度自动抬升 ${r.toFixed(4)} m`
|
|
319
319
|
});
|
|
320
|
-
const o = n.joints.filter((w) =>
|
|
320
|
+
const o = n.joints.filter((w) => Nn(w) !== 0);
|
|
321
321
|
o.length && n.diagnostics.approximations.push({
|
|
322
322
|
code: "JOINT_REFERENCE_CLAMPED",
|
|
323
323
|
message: `${o.length} 个关节的默认参考值已夹到合法限位`
|
|
@@ -343,27 +343,27 @@ async function qn(n) {
|
|
|
343
343
|
var M, T;
|
|
344
344
|
const h = n.links.find((R) => R.id === w), b = [...(m == null ? void 0 : m.origin.position) ?? [0, 0, 0]];
|
|
345
345
|
m || (b[2] += r);
|
|
346
|
-
const A = (m == null ? void 0 : m.origin) ?? { rotationRpy: [0, 0, 0] }, P = [`<body name="${St(w)}" pos="${b.join(" ")}" ${
|
|
346
|
+
const A = (m == null ? void 0 : m.origin) ?? { rotationRpy: [0, 0, 0] }, P = [`<body name="${St(w)}" pos="${b.join(" ")}" ${yi(A)}>`];
|
|
347
347
|
if (h.inertial) {
|
|
348
|
-
const { origin: R, mass: v, tensor:
|
|
349
|
-
|
|
350
|
-
const E =
|
|
348
|
+
const { origin: R, mass: v, tensor: B } = h.inertial, S = new ui().setFromMatrix4(new H().makeRotationFromQuaternion(Qt(R))), _ = new ui().set(B[0], B[3], B[4], B[3], B[1], B[5], B[4], B[5], B[2]);
|
|
349
|
+
_.premultiply(S).multiply(S.clone().transpose());
|
|
350
|
+
const E = _.elements;
|
|
351
351
|
P.push(`<inertial pos="${R.position.join(" ")}" mass="${v}" fullinertia="${[E[0], E[4], E[8], E[3], E[6], E[7]].join(" ")}"/>`);
|
|
352
352
|
}
|
|
353
353
|
if (!m) P.push("<freejoint/>");
|
|
354
354
|
else if (["fixed", "planar", "floating"].includes(m.type))
|
|
355
355
|
(m == null ? void 0 : m.type) === "floating" && (P.push("<freejoint/>"), u.push(0, 0, 0, 1, 0, 0, 0));
|
|
356
356
|
else {
|
|
357
|
-
const R = m.type === "prismatic" ? "slide" : "hinge", v = m.type !== "continuous" && !!m.limits && Number.isFinite(m.limits.lower) && Number.isFinite(m.limits.upper),
|
|
358
|
-
u.push(
|
|
359
|
-
const S = ((M = m.dynamics) == null ? void 0 : M.damping) ?? 0,
|
|
360
|
-
P.push(`<joint name="${St(m.id)}" type="${R}" axis="${m.axis.join(" ")}"${v ? ` limited="true" range="${m.limits.lower} ${m.limits.upper}" ref="0"` : ""} damping="${S}" frictionloss="${
|
|
357
|
+
const R = m.type === "prismatic" ? "slide" : "hinge", v = m.type !== "continuous" && !!m.limits && Number.isFinite(m.limits.lower) && Number.isFinite(m.limits.upper), B = l[m.id];
|
|
358
|
+
u.push(B);
|
|
359
|
+
const S = ((M = m.dynamics) == null ? void 0 : M.damping) ?? 0, _ = ((T = m.dynamics) == null ? void 0 : T.friction) ?? 0;
|
|
360
|
+
P.push(`<joint name="${St(m.id)}" type="${R}" axis="${m.axis.join(" ")}"${v ? ` limited="true" range="${m.limits.lower} ${m.limits.upper}" ref="0"` : ""} damping="${S}" frictionloss="${_}"/>`);
|
|
361
361
|
}
|
|
362
362
|
for (const R of h.collisions) {
|
|
363
363
|
const v = await p(R.geometry);
|
|
364
364
|
if (v) {
|
|
365
|
-
const
|
|
366
|
-
P.push(`<geom ${v} pos="${R.origin.position.join(" ")}"${
|
|
365
|
+
const B = ` ${yi(R.origin)}`;
|
|
366
|
+
P.push(`<geom ${v} pos="${R.origin.position.join(" ")}"${B} rgba="0.55 0.62 0.59 1"/>`);
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
for (const R of i.get(w) ?? []) P.push(await c(R.child, R));
|
|
@@ -381,10 +381,10 @@ async function qn(n) {
|
|
|
381
381
|
xml: `<mujoco model="${St(n.name)}"><compiler angle="radian" autolimits="true"/><option gravity="0 0 -9.81"/><asset>${y}</asset><worldbody><geom name="__viewer_default_ground__" type="plane" size="5 5 0.1" contype="1" conaffinity="1" friction="0.8 0.01 0.0002"/>${d}</worldbody>${x ? `<equality>${x}</equality>` : ""}${g}</mujoco>`
|
|
382
382
|
};
|
|
383
383
|
}
|
|
384
|
-
async function
|
|
384
|
+
async function Qi(n) {
|
|
385
385
|
const t = n.extension.files, i = new ut();
|
|
386
386
|
i.name = "URDF authored collisions";
|
|
387
|
-
const e = /* @__PURE__ */ new Map(), s =
|
|
387
|
+
const e = /* @__PURE__ */ new Map(), s = mn();
|
|
388
388
|
let r = 0;
|
|
389
389
|
for (const o of n.links) {
|
|
390
390
|
const f = new ut();
|
|
@@ -397,9 +397,9 @@ async function Zi(n) {
|
|
|
397
397
|
if (!(p instanceof C)) return;
|
|
398
398
|
const c = ri(p.geometry, s, "mesh");
|
|
399
399
|
c.matrixAutoUpdate = !1, c.matrix.copy(p.matrixWorld), c.name = `Collision:${o.id}`, c.userData.urdfLink = o.id, u.add(c), r += 1;
|
|
400
|
-
}),
|
|
400
|
+
}), ft(l);
|
|
401
401
|
} else {
|
|
402
|
-
const l =
|
|
402
|
+
const l = Wn(a.geometry);
|
|
403
403
|
if (!l) continue;
|
|
404
404
|
const p = ri(l, s, "feature");
|
|
405
405
|
l.dispose(), p.name = `Collision:${o.id}`, p.userData.urdfLink = o.id, u.add(p), r += 1;
|
|
@@ -407,13 +407,13 @@ async function Zi(n) {
|
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
if (r === 0) {
|
|
410
|
-
s.dispose(),
|
|
410
|
+
s.dispose(), ft(i);
|
|
411
411
|
return;
|
|
412
412
|
}
|
|
413
413
|
return { root: i, bindings: e, expectedLinkCount: e.size };
|
|
414
414
|
}
|
|
415
|
-
async function
|
|
416
|
-
const i = await
|
|
415
|
+
async function Vn(n, t) {
|
|
416
|
+
const i = await Qi(n);
|
|
417
417
|
if (!i) return;
|
|
418
418
|
const e = () => {
|
|
419
419
|
t.root.updateMatrixWorld(!0);
|
|
@@ -424,23 +424,23 @@ async function On(n, t) {
|
|
|
424
424
|
i.root.updateMatrixWorld(!0);
|
|
425
425
|
};
|
|
426
426
|
return e(), i.root.visible = !1, { root: i.root, sync: e, dispose() {
|
|
427
|
-
|
|
427
|
+
ft(i.root);
|
|
428
428
|
} };
|
|
429
429
|
}
|
|
430
|
-
function
|
|
430
|
+
function Wn(n) {
|
|
431
431
|
if (n.type === "box") return new He(...n.size);
|
|
432
432
|
if (n.type === "sphere") return new Ze(n.radius, 24, 16);
|
|
433
433
|
if (n.type === "cylinder") {
|
|
434
|
-
const t = new
|
|
434
|
+
const t = new Ni(n.radius, n.radius, n.length, 24);
|
|
435
435
|
return t.rotateX(Math.PI / 2), t;
|
|
436
436
|
}
|
|
437
437
|
if (n.type === "capsule") {
|
|
438
|
-
const t = new
|
|
438
|
+
const t = new qi(n.radius, n.length, 8, 24);
|
|
439
439
|
return t.rotateX(Math.PI / 2), t;
|
|
440
440
|
}
|
|
441
441
|
return null;
|
|
442
442
|
}
|
|
443
|
-
async function
|
|
443
|
+
async function gi(n) {
|
|
444
444
|
const t = n.extension.files, i = new ut();
|
|
445
445
|
i.name = n.name;
|
|
446
446
|
const e = /* @__PURE__ */ new Map();
|
|
@@ -449,16 +449,16 @@ async function yi(n) {
|
|
|
449
449
|
const r = new ut();
|
|
450
450
|
r.name = s.id, r.userData.urdfEntityId = `link:${s.id}`, e.set(s.id, r), i.add(r);
|
|
451
451
|
for (const o of s.visuals) {
|
|
452
|
-
const f = await
|
|
452
|
+
const f = await Gn(o, t, n.diagnostics), a = new ut();
|
|
453
453
|
a.position.fromArray(o.origin.position), a.quaternion.copy(Qt(o.origin)), a.add(f), r.add(a);
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
return { root: i, bindings: e, expectedLinkCount: n.links.length };
|
|
457
457
|
} catch (s) {
|
|
458
|
-
throw
|
|
458
|
+
throw ft(i), s;
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
async function
|
|
461
|
+
async function Gn(n, t, i) {
|
|
462
462
|
var r;
|
|
463
463
|
if (n.geometry.type === "mesh" && /\.gl(?:tf|b)$/i.test(n.geometry.resourcePath)) {
|
|
464
464
|
(n.color || n.texturePath) && i.warnings.push({ code: "URDF_EMBEDDED_MATERIAL_PRESERVED", message: "Embedded glTF materials take precedence over the URDF visual material.", source: n.geometry.resourcePath });
|
|
@@ -472,7 +472,7 @@ async function Wn(n, t, i) {
|
|
|
472
472
|
const e = oi({ color: n.color });
|
|
473
473
|
let s;
|
|
474
474
|
try {
|
|
475
|
-
if (n.texturePath && (await t.ensure(n.texturePath), e.map = await new
|
|
475
|
+
if (n.texturePath && (await t.ensure(n.texturePath), e.map = await new bn().loadAsync(t.objectUrl(n.texturePath)), e.transparent = !0, e.map.colorSpace = xn, e.map.wrapS = e.map.wrapT = An), s = await De(n.geometry, t, e), n.geometry.type === "mesh" && /\.dae$/i.test(n.geometry.resourcePath))
|
|
476
476
|
if (n.color || n.texturePath) {
|
|
477
477
|
const o = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
|
|
478
478
|
s.traverse((a) => {
|
|
@@ -491,7 +491,7 @@ async function Wn(n, t, i) {
|
|
|
491
491
|
if (o instanceof C && !o.geometry.getAttribute("uv")) throw O(`URDF texture requires authored UVs: ${n.texturePath}`, "E_URDF_TEXTURE_UV");
|
|
492
492
|
}), s;
|
|
493
493
|
} catch (o) {
|
|
494
|
-
throw s ?
|
|
494
|
+
throw s ? ft(s) : ((r = e.map) == null || r.dispose(), e.dispose()), o;
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
async function De(n, t, i) {
|
|
@@ -499,38 +499,38 @@ async function De(n, t, i) {
|
|
|
499
499
|
if (n.type === "box") return new C(new He(...n.size), i);
|
|
500
500
|
if (n.type === "sphere") return new C(new Ze(n.radius, 24, 16), i);
|
|
501
501
|
if (n.type === "cylinder") {
|
|
502
|
-
const o = new C(new
|
|
502
|
+
const o = new C(new Ni(n.radius, n.radius, n.length, 24), i);
|
|
503
503
|
return o.quaternion.copy(new K().setFromEuler(new Zt(Math.PI / 2, 0, 0))), o;
|
|
504
504
|
}
|
|
505
505
|
if (n.type === "capsule") {
|
|
506
|
-
const o = new C(new
|
|
506
|
+
const o = new C(new qi(n.radius, n.length, 8, 24), i);
|
|
507
507
|
return o.quaternion.copy(new K().setFromEuler(new Zt(Math.PI / 2, 0, 0))), o;
|
|
508
508
|
}
|
|
509
509
|
const e = (r = n.resourcePath.split(".").pop()) == null ? void 0 : r.toLowerCase();
|
|
510
510
|
await t.ensure(n.resourcePath);
|
|
511
511
|
let s;
|
|
512
|
-
if (e === "stl") s = new C(new
|
|
512
|
+
if (e === "stl") s = new C(new In().parse(await t.getBlob(n.resourcePath).arrayBuffer()), i);
|
|
513
513
|
else if (e === "obj")
|
|
514
|
-
s = new
|
|
514
|
+
s = new $n().parse(await t.getBlob(n.resourcePath).text()), s.traverse((o) => {
|
|
515
515
|
if (o instanceof C) {
|
|
516
516
|
for (const f of Array.isArray(o.material) ? o.material : [o.material]) f.dispose();
|
|
517
517
|
o.material = i;
|
|
518
518
|
}
|
|
519
519
|
});
|
|
520
520
|
else if (e === "gltf" || e === "glb") {
|
|
521
|
-
const o = new
|
|
521
|
+
const o = new Ci();
|
|
522
522
|
o.setURLModifier((f) => {
|
|
523
523
|
try {
|
|
524
524
|
return t.objectUrl(t.resolve(f, n.resourcePath));
|
|
525
525
|
} catch {
|
|
526
526
|
return f;
|
|
527
527
|
}
|
|
528
|
-
}), s = (await new
|
|
529
|
-
} else if (e === "dae") s = await
|
|
528
|
+
}), s = (await new Un(o).parseAsync(await t.getBlob(n.resourcePath).arrayBuffer(), "")).scene;
|
|
529
|
+
} else if (e === "dae") s = await Ln(n.resourcePath, t);
|
|
530
530
|
else throw O(`Unsupported URDF visual mesh: .${e ?? ""}`, "E_URDF_VISUAL");
|
|
531
531
|
return s.scale.fromArray(n.scale), s;
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function Xn(n, t) {
|
|
534
534
|
const i = new DOMParser().parseFromString(n, "application/xml"), e = i.querySelector("parsererror");
|
|
535
535
|
if (e) throw O(`${t} XML parse failed: ${e.textContent ?? ""}`, `E_${t}_PARSE`);
|
|
536
536
|
return i;
|
|
@@ -540,7 +540,7 @@ function ot(n, t) {
|
|
|
540
540
|
if (!i) throw O(`Missing ${t}.`, "E_URDF_PARSE");
|
|
541
541
|
return i;
|
|
542
542
|
}
|
|
543
|
-
function
|
|
543
|
+
function wi(n, t) {
|
|
544
544
|
const i = Number(n);
|
|
545
545
|
return Number.isFinite(i) ? i : t;
|
|
546
546
|
}
|
|
@@ -555,7 +555,7 @@ function jt(n, t) {
|
|
|
555
555
|
if (!(i > 0)) throw O(`${t} must be greater than zero.`, "E_URDF_PARSE");
|
|
556
556
|
return i;
|
|
557
557
|
}
|
|
558
|
-
function
|
|
558
|
+
function Jn(n, t, i) {
|
|
559
559
|
if (n === null || n.trim() === "") throw O(`${i} is required.`, "E_URDF_PARSE");
|
|
560
560
|
const e = Lt(n, []);
|
|
561
561
|
if (e.length !== t || e.some((s) => !(s > 0))) throw O(`${i} requires ${t} values greater than zero.`, "E_URDF_PARSE");
|
|
@@ -573,7 +573,7 @@ function St(n) {
|
|
|
573
573
|
function O(n, t) {
|
|
574
574
|
return Object.assign(new Error(n), { code: t });
|
|
575
575
|
}
|
|
576
|
-
function
|
|
576
|
+
function Hn(n) {
|
|
577
577
|
var o;
|
|
578
578
|
const t = n.querySelector("inertial");
|
|
579
579
|
if (!t) return;
|
|
@@ -583,8 +583,8 @@ function Jn(n) {
|
|
|
583
583
|
});
|
|
584
584
|
return { origin: he(t), mass: s, tensor: r };
|
|
585
585
|
}
|
|
586
|
-
const
|
|
587
|
-
strategy:
|
|
586
|
+
const Yi = 0, Zn = 1, Qn = 2, bi = 2, Pe = 1.25, xi = 1, X = 6 * 4 + 4 + 4, N = X / 4, Ki = 65535, ye = Math.pow(2, -24), ti = Symbol("SKIP_GENERATION"), tn = {
|
|
587
|
+
strategy: Yi,
|
|
588
588
|
maxDepth: 40,
|
|
589
589
|
maxLeafSize: 10,
|
|
590
590
|
useSharedArrayBuffer: !1,
|
|
@@ -598,7 +598,7 @@ const Qi = 0, Hn = 1, Zn = 2, wi = 2, Pe = 1.25, bi = 1, X = 6 * 4 + 4 + 4, N =
|
|
|
598
598
|
function k(n, t, i) {
|
|
599
599
|
return i.min.x = t[n], i.min.y = t[n + 1], i.min.z = t[n + 2], i.max.x = t[n + 3], i.max.y = t[n + 4], i.max.z = t[n + 5], i;
|
|
600
600
|
}
|
|
601
|
-
function
|
|
601
|
+
function Ai(n) {
|
|
602
602
|
let t = -1, i = -1 / 0;
|
|
603
603
|
for (let e = 0; e < 3; e++) {
|
|
604
604
|
const s = n[e + 3] - n[e];
|
|
@@ -606,10 +606,10 @@ function xi(n) {
|
|
|
606
606
|
}
|
|
607
607
|
return t;
|
|
608
608
|
}
|
|
609
|
-
function
|
|
609
|
+
function Mi(n, t) {
|
|
610
610
|
t.set(n);
|
|
611
611
|
}
|
|
612
|
-
function
|
|
612
|
+
function vi(n, t, i) {
|
|
613
613
|
let e, s;
|
|
614
614
|
for (let r = 0; r < 3; r++) {
|
|
615
615
|
const o = r + 3;
|
|
@@ -627,7 +627,7 @@ function Ct(n) {
|
|
|
627
627
|
return 2 * (t * i + i * e + e * t);
|
|
628
628
|
}
|
|
629
629
|
function q(n, t) {
|
|
630
|
-
return t[n + 15] ===
|
|
630
|
+
return t[n + 15] === Ki;
|
|
631
631
|
}
|
|
632
632
|
function J(n, t) {
|
|
633
633
|
return t[n + 6];
|
|
@@ -651,27 +651,27 @@ function Se(n, t, i, e, s) {
|
|
|
651
651
|
for (let m = (t - w) * 6, h = (t + i - w) * 6; m < h; m += 6) {
|
|
652
652
|
const b = n[m + 0], A = n[m + 1], P = b - A, M = b + A;
|
|
653
653
|
P < r && (r = P), M > a && (a = M), b < p && (p = b), b > y && (y = b);
|
|
654
|
-
const T = n[m + 2], R = n[m + 3], v = T - R,
|
|
655
|
-
v < o && (o = v),
|
|
656
|
-
const S = n[m + 4],
|
|
657
|
-
E < f && (f = E),
|
|
654
|
+
const T = n[m + 2], R = n[m + 3], v = T - R, B = T + R;
|
|
655
|
+
v < o && (o = v), B > u && (u = B), T < c && (c = T), T > g && (g = T);
|
|
656
|
+
const S = n[m + 4], _ = n[m + 5], E = S - _, F = S + _;
|
|
657
|
+
E < f && (f = E), F > l && (l = F), S < d && (d = S), S > x && (x = S);
|
|
658
658
|
}
|
|
659
659
|
e[0] = r, e[1] = o, e[2] = f, e[3] = a, e[4] = u, e[5] = l, s[0] = p, s[1] = c, s[2] = d, s[3] = y, s[4] = g, s[5] = x;
|
|
660
660
|
}
|
|
661
|
-
const ct = 32,
|
|
661
|
+
const ct = 32, Yn = (n, t) => n.candidate - t.candidate, mt = /* @__PURE__ */ new Array(ct).fill().map(() => ({
|
|
662
662
|
count: 0,
|
|
663
663
|
bounds: new Float32Array(6),
|
|
664
664
|
rightCacheBounds: new Float32Array(6),
|
|
665
665
|
leftCacheBounds: new Float32Array(6),
|
|
666
666
|
candidate: 0
|
|
667
667
|
})), te = /* @__PURE__ */ new Float32Array(6);
|
|
668
|
-
function
|
|
668
|
+
function Kn(n, t, i, e, s, r) {
|
|
669
669
|
let o = -1, f = 0;
|
|
670
|
-
if (r ===
|
|
671
|
-
o =
|
|
672
|
-
else if (r ===
|
|
673
|
-
o =
|
|
674
|
-
else if (r ===
|
|
670
|
+
if (r === Yi)
|
|
671
|
+
o = Ai(t), o !== -1 && (f = (t[o] + t[o + 3]) / 2);
|
|
672
|
+
else if (r === Zn)
|
|
673
|
+
o = Ai(n), o !== -1 && (f = ts(i, e, s, o));
|
|
674
|
+
else if (r === Qn) {
|
|
675
675
|
const a = Ct(n);
|
|
676
676
|
let u = Pe * s;
|
|
677
677
|
const l = i.offset || 0, p = (e - l) * 6, c = (e + s - l) * 6;
|
|
@@ -693,7 +693,7 @@ function Yn(n, t, i, e, s, r) {
|
|
|
693
693
|
R[v] = 1 / 0, R[v + 3] = -1 / 0, T[v] = 1 / 0, T[v + 3] = -1 / 0, M[v] = 1 / 0, M[v + 3] = -1 / 0;
|
|
694
694
|
Kt(A, i, M);
|
|
695
695
|
}
|
|
696
|
-
m.sort(
|
|
696
|
+
m.sort(Yn);
|
|
697
697
|
let b = s;
|
|
698
698
|
for (let A = 0; A < b; A++) {
|
|
699
699
|
const P = m[A];
|
|
@@ -709,12 +709,12 @@ function Yn(n, t, i, e, s, r) {
|
|
|
709
709
|
}
|
|
710
710
|
for (let A = 0; A < b; A++) {
|
|
711
711
|
const P = m[A], M = P.count, T = s - P.count, R = P.leftCacheBounds, v = P.rightCacheBounds;
|
|
712
|
-
let
|
|
713
|
-
M !== 0 && (
|
|
712
|
+
let B = 0;
|
|
713
|
+
M !== 0 && (B = Ct(R) / a);
|
|
714
714
|
let S = 0;
|
|
715
715
|
T !== 0 && (S = Ct(v) / a);
|
|
716
|
-
const
|
|
717
|
-
|
|
716
|
+
const _ = xi + Pe * (B * M + S * T);
|
|
717
|
+
_ < u && (o = d, u = _, f = P.candidate);
|
|
718
718
|
}
|
|
719
719
|
} else {
|
|
720
720
|
for (let b = 0; b < ct; b++) {
|
|
@@ -731,21 +731,21 @@ function Yn(n, t, i, e, s, r) {
|
|
|
731
731
|
T.count++, Kt(b, i, T.bounds);
|
|
732
732
|
}
|
|
733
733
|
const m = mt[ct - 1];
|
|
734
|
-
|
|
734
|
+
Mi(m.bounds, m.rightCacheBounds);
|
|
735
735
|
for (let b = ct - 2; b >= 0; b--) {
|
|
736
736
|
const A = mt[b], P = mt[b + 1];
|
|
737
|
-
|
|
737
|
+
vi(A.bounds, P.rightCacheBounds, A.rightCacheBounds);
|
|
738
738
|
}
|
|
739
739
|
let h = 0;
|
|
740
740
|
for (let b = 0; b < ct - 1; b++) {
|
|
741
741
|
const A = mt[b], P = A.count, M = A.bounds, R = mt[b + 1].rightCacheBounds;
|
|
742
|
-
P !== 0 && (h === 0 ?
|
|
743
|
-
let v = 0,
|
|
742
|
+
P !== 0 && (h === 0 ? Mi(M, te) : vi(M, te, te)), h += P;
|
|
743
|
+
let v = 0, B = 0;
|
|
744
744
|
h !== 0 && (v = Ct(te) / a);
|
|
745
745
|
const S = s - h;
|
|
746
|
-
S !== 0 && (
|
|
747
|
-
const
|
|
748
|
-
|
|
746
|
+
S !== 0 && (B = Ct(R) / a);
|
|
747
|
+
const _ = xi + Pe * (v * h + B * S);
|
|
748
|
+
_ < u && (o = d, u = _, f = A.candidate);
|
|
749
749
|
}
|
|
750
750
|
}
|
|
751
751
|
}
|
|
@@ -753,7 +753,7 @@ function Yn(n, t, i, e, s, r) {
|
|
|
753
753
|
console.warn(`BVH: Invalid build strategy value ${r} used.`);
|
|
754
754
|
return { axis: o, pos: f };
|
|
755
755
|
}
|
|
756
|
-
function
|
|
756
|
+
function ts(n, t, i, e) {
|
|
757
757
|
let s = 0;
|
|
758
758
|
const r = n.offset;
|
|
759
759
|
for (let o = t, f = t + i; o < f; o++)
|
|
@@ -765,7 +765,7 @@ class Te {
|
|
|
765
765
|
this.boundingData = new Float32Array(6);
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
|
-
function
|
|
768
|
+
function es(n, t, i, e, s, r) {
|
|
769
769
|
let o = e, f = e + s - 1;
|
|
770
770
|
const a = r.pos, u = r.axis * 2, l = i.offset || 0;
|
|
771
771
|
for (; ; ) {
|
|
@@ -787,30 +787,30 @@ function ts(n, t, i, e, s, r) {
|
|
|
787
787
|
return o;
|
|
788
788
|
}
|
|
789
789
|
}
|
|
790
|
-
let
|
|
791
|
-
const
|
|
790
|
+
let en, ge, ke, nn;
|
|
791
|
+
const is = Math.pow(2, 32);
|
|
792
792
|
function je(n) {
|
|
793
793
|
return "count" in n ? 1 : 1 + je(n.left) + je(n.right);
|
|
794
794
|
}
|
|
795
|
-
function
|
|
796
|
-
return
|
|
795
|
+
function ns(n, t, i) {
|
|
796
|
+
return en = new Float32Array(i), ge = new Uint32Array(i), ke = new Uint16Array(i), nn = new Uint8Array(i), Ce(n, t);
|
|
797
797
|
}
|
|
798
798
|
function Ce(n, t) {
|
|
799
799
|
const i = n / 4, e = n / 2, s = "count" in t, r = t.boundingData;
|
|
800
800
|
for (let o = 0; o < 6; o++)
|
|
801
|
-
|
|
801
|
+
en[i + o] = r[o];
|
|
802
802
|
if (s)
|
|
803
|
-
return t.buffer ? (
|
|
803
|
+
return t.buffer ? (nn.set(new Uint8Array(t.buffer), n), n + t.buffer.byteLength) : (ge[i + 6] = t.offset, ke[e + 14] = t.count, ke[e + 15] = Ki, n + X);
|
|
804
804
|
{
|
|
805
805
|
const { left: o, right: f, splitAxis: a } = t, u = n + X;
|
|
806
806
|
let l = Ce(u, o);
|
|
807
807
|
const p = n / X, d = l / X - p;
|
|
808
|
-
if (d >
|
|
808
|
+
if (d > is)
|
|
809
809
|
throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");
|
|
810
810
|
return ge[i + 6] = d, ge[i + 7] = a, Ce(l, f);
|
|
811
811
|
}
|
|
812
812
|
}
|
|
813
|
-
function
|
|
813
|
+
function ss(n, t, i, e, s, r) {
|
|
814
814
|
const {
|
|
815
815
|
maxDepth: o,
|
|
816
816
|
verbose: f,
|
|
@@ -827,30 +827,30 @@ function ns(n, t, i, e, s, r) {
|
|
|
827
827
|
function w(m, h, b, A = null, P = 0) {
|
|
828
828
|
if (!y && P >= o && (y = !0, f && console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`)), b <= a || P >= o)
|
|
829
829
|
return x(h + b), m.offset = h, m.count = b, m;
|
|
830
|
-
const M =
|
|
830
|
+
const M = Kn(m.boundingData, A, t, h, b, u);
|
|
831
831
|
if (M.axis === -1)
|
|
832
832
|
return x(h + b), m.offset = h, m.count = b, m;
|
|
833
|
-
const T =
|
|
833
|
+
const T = es(p, c, t, h, b, M);
|
|
834
834
|
if (T === h || T === h + b)
|
|
835
835
|
x(h + b), m.offset = h, m.count = b;
|
|
836
836
|
else {
|
|
837
837
|
m.splitAxis = M.axis;
|
|
838
|
-
const R = new Te(), v = h,
|
|
839
|
-
m.left = R, Se(t, v,
|
|
840
|
-
const S = new Te(),
|
|
841
|
-
m.right = S, Se(t,
|
|
838
|
+
const R = new Te(), v = h, B = T - h;
|
|
839
|
+
m.left = R, Se(t, v, B, R.boundingData, d), w(R, v, B, d, P + 1);
|
|
840
|
+
const S = new Te(), _ = T, E = b - B;
|
|
841
|
+
m.right = S, Se(t, _, E, S.boundingData, d), w(S, _, E, d, P + 1);
|
|
842
842
|
}
|
|
843
843
|
return m;
|
|
844
844
|
}
|
|
845
845
|
}
|
|
846
|
-
function
|
|
846
|
+
function os(n, t) {
|
|
847
847
|
const i = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, e = n.getRootRanges(t.range), s = e[0], r = e[e.length - 1], o = {
|
|
848
848
|
offset: s.offset,
|
|
849
849
|
count: r.offset + r.count - s.offset
|
|
850
850
|
}, f = new Float32Array(6 * o.count);
|
|
851
851
|
f.offset = o.offset, n.computePrimitiveBounds(o.offset, o.count, f), n._roots = e.map((a) => {
|
|
852
|
-
const u =
|
|
853
|
-
return
|
|
852
|
+
const u = ss(n, f, a.offset, a.count, t, o), l = je(u), p = new i(X * l);
|
|
853
|
+
return ns(0, u, p), p;
|
|
854
854
|
});
|
|
855
855
|
}
|
|
856
856
|
class ii {
|
|
@@ -865,7 +865,7 @@ class ii {
|
|
|
865
865
|
this._primitives.push(t);
|
|
866
866
|
}
|
|
867
867
|
}
|
|
868
|
-
class
|
|
868
|
+
class rs {
|
|
869
869
|
constructor() {
|
|
870
870
|
this.float32Array = null, this.uint16Array = null, this.uint32Array = null;
|
|
871
871
|
const t = [];
|
|
@@ -877,10 +877,10 @@ class os {
|
|
|
877
877
|
};
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
|
-
const I = /* @__PURE__ */ new
|
|
880
|
+
const I = /* @__PURE__ */ new rs();
|
|
881
881
|
let yt, Dt;
|
|
882
882
|
const Tt = [], ee = /* @__PURE__ */ new ii(() => new it());
|
|
883
|
-
function
|
|
883
|
+
function as(n, t, i, e, s, r) {
|
|
884
884
|
yt = ee.getPrimitive(), Dt = ee.getPrimitive(), Tt.push(yt, Dt), I.setBuffer(n._roots[t]);
|
|
885
885
|
const o = Ne(0, n.geometry, i, e, s, r);
|
|
886
886
|
I.clearBuffer(), ee.releasePrimitive(yt), ee.releasePrimitive(Dt), Tt.pop(), Tt.pop();
|
|
@@ -895,17 +895,17 @@ function Ne(n, t, i, e, s = null, r = 0, o = 0) {
|
|
|
895
895
|
return k(n, f, yt), e(c, d, !1, o, r + n / N, yt);
|
|
896
896
|
} else {
|
|
897
897
|
let v = function(S) {
|
|
898
|
-
const { uint16Array:
|
|
899
|
-
let
|
|
900
|
-
for (; !q(
|
|
901
|
-
S = V(S),
|
|
898
|
+
const { uint16Array: _, uint32Array: E } = I;
|
|
899
|
+
let F = S * 2;
|
|
900
|
+
for (; !q(F, _); )
|
|
901
|
+
S = V(S), F = S * 2;
|
|
902
902
|
return J(S, E);
|
|
903
|
-
},
|
|
904
|
-
const { uint16Array:
|
|
905
|
-
let
|
|
906
|
-
for (; !q(
|
|
907
|
-
S = W(S, E),
|
|
908
|
-
return J(S, E) + Z(
|
|
903
|
+
}, B = function(S) {
|
|
904
|
+
const { uint16Array: _, uint32Array: E } = I;
|
|
905
|
+
let F = S * 2;
|
|
906
|
+
for (; !q(F, _); )
|
|
907
|
+
S = W(S, E), F = S * 2;
|
|
908
|
+
return J(S, E) + Z(F, _);
|
|
909
909
|
};
|
|
910
910
|
const c = V(n), d = W(n, u);
|
|
911
911
|
let y = c, g = d, x, w, m, h;
|
|
@@ -917,8 +917,8 @@ function Ne(n, t, i, e, s = null, r = 0, o = 0) {
|
|
|
917
917
|
m || (m = yt, k(y, f, m));
|
|
918
918
|
const b = q(y * 2, a), A = i(m, b, x, o + 1, r + y / N);
|
|
919
919
|
let P;
|
|
920
|
-
if (A ===
|
|
921
|
-
const S = v(y), E =
|
|
920
|
+
if (A === bi) {
|
|
921
|
+
const S = v(y), E = B(y) - S;
|
|
922
922
|
P = e(S, E, !0, o + 1, r + y / N, m);
|
|
923
923
|
} else
|
|
924
924
|
P = A && Ne(
|
|
@@ -934,8 +934,8 @@ function Ne(n, t, i, e, s = null, r = 0, o = 0) {
|
|
|
934
934
|
h = Dt, k(g, f, h);
|
|
935
935
|
const M = q(g * 2, a), T = i(h, M, w, o + 1, r + g / N);
|
|
936
936
|
let R;
|
|
937
|
-
if (T ===
|
|
938
|
-
const S = v(g), E =
|
|
937
|
+
if (T === bi) {
|
|
938
|
+
const S = v(g), E = B(g) - S;
|
|
939
939
|
R = e(S, E, !0, o + 1, r + g / N, h);
|
|
940
940
|
} else
|
|
941
941
|
R = T && Ne(
|
|
@@ -950,12 +950,12 @@ function Ne(n, t, i, e, s = null, r = 0, o = 0) {
|
|
|
950
950
|
return !!R;
|
|
951
951
|
}
|
|
952
952
|
}
|
|
953
|
-
const Ht = /* @__PURE__ */ new I.constructor(), we = /* @__PURE__ */ new I.constructor(), ht = /* @__PURE__ */ new ii(() => new it()), Rt = /* @__PURE__ */ new it(),
|
|
954
|
-
let
|
|
955
|
-
function
|
|
956
|
-
if (
|
|
953
|
+
const Ht = /* @__PURE__ */ new I.constructor(), we = /* @__PURE__ */ new I.constructor(), ht = /* @__PURE__ */ new ii(() => new it()), Rt = /* @__PURE__ */ new it(), Bt = /* @__PURE__ */ new it(), Re = /* @__PURE__ */ new it(), Be = /* @__PURE__ */ new it();
|
|
954
|
+
let _e = !1;
|
|
955
|
+
function cs(n, t, i, e) {
|
|
956
|
+
if (_e)
|
|
957
957
|
throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");
|
|
958
|
-
|
|
958
|
+
_e = !0;
|
|
959
959
|
const s = n._roots, r = t._roots;
|
|
960
960
|
let o, f = 0, a = 0;
|
|
961
961
|
const u = new H().copy(i).invert();
|
|
@@ -979,7 +979,7 @@ function as(n, t, i, e) {
|
|
|
979
979
|
if (ht.releasePrimitive(c), Ht.clearBuffer(), f += s[l].byteLength / X, o)
|
|
980
980
|
break;
|
|
981
981
|
}
|
|
982
|
-
return
|
|
982
|
+
return _e = !1, o;
|
|
983
983
|
}
|
|
984
984
|
function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
|
|
985
985
|
let p, c;
|
|
@@ -1010,9 +1010,9 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
|
|
|
1010
1010
|
const T = ht.getPrimitive();
|
|
1011
1011
|
k(t, x, T), T.applyMatrix4(i);
|
|
1012
1012
|
const R = V(n), v = W(n, y);
|
|
1013
|
-
k(R, d, Rt), k(v, d,
|
|
1014
|
-
const
|
|
1015
|
-
M =
|
|
1013
|
+
k(R, d, Rt), k(v, d, Bt);
|
|
1014
|
+
const B = T.intersectsBox(Rt), S = T.intersectsBox(Bt);
|
|
1015
|
+
M = B && nt(
|
|
1016
1016
|
t,
|
|
1017
1017
|
R,
|
|
1018
1018
|
e,
|
|
@@ -1039,9 +1039,9 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
|
|
|
1039
1039
|
), ht.releasePrimitive(T);
|
|
1040
1040
|
} else {
|
|
1041
1041
|
const T = V(t), R = W(t, w);
|
|
1042
|
-
k(T, x, Re), k(R, x,
|
|
1043
|
-
const v = u.intersectsBox(Re),
|
|
1044
|
-
if (v &&
|
|
1042
|
+
k(T, x, Re), k(R, x, Be);
|
|
1043
|
+
const v = u.intersectsBox(Re), B = u.intersectsBox(Be);
|
|
1044
|
+
if (v && B)
|
|
1045
1045
|
M = nt(
|
|
1046
1046
|
n,
|
|
1047
1047
|
T,
|
|
@@ -1085,12 +1085,12 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
|
|
|
1085
1085
|
else {
|
|
1086
1086
|
const S = ht.getPrimitive();
|
|
1087
1087
|
S.copy(Re).applyMatrix4(i);
|
|
1088
|
-
const
|
|
1089
|
-
k(
|
|
1090
|
-
const
|
|
1091
|
-
M =
|
|
1088
|
+
const _ = V(n), E = W(n, y);
|
|
1089
|
+
k(_, d, Rt), k(E, d, Bt);
|
|
1090
|
+
const F = S.intersectsBox(Rt), D = S.intersectsBox(Bt);
|
|
1091
|
+
M = F && nt(
|
|
1092
1092
|
T,
|
|
1093
|
-
|
|
1093
|
+
_,
|
|
1094
1094
|
e,
|
|
1095
1095
|
i,
|
|
1096
1096
|
s,
|
|
@@ -1114,7 +1114,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
|
|
|
1114
1114
|
!l
|
|
1115
1115
|
), ht.releasePrimitive(S);
|
|
1116
1116
|
}
|
|
1117
|
-
else if (
|
|
1117
|
+
else if (B)
|
|
1118
1118
|
if (A)
|
|
1119
1119
|
M = nt(
|
|
1120
1120
|
n,
|
|
@@ -1131,13 +1131,13 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
|
|
|
1131
1131
|
);
|
|
1132
1132
|
else {
|
|
1133
1133
|
const S = ht.getPrimitive();
|
|
1134
|
-
S.copy(
|
|
1135
|
-
const
|
|
1136
|
-
k(
|
|
1137
|
-
const
|
|
1138
|
-
M =
|
|
1134
|
+
S.copy(Be).applyMatrix4(i);
|
|
1135
|
+
const _ = V(n), E = W(n, y);
|
|
1136
|
+
k(_, d, Rt), k(E, d, Bt);
|
|
1137
|
+
const F = S.intersectsBox(Rt), D = S.intersectsBox(Bt);
|
|
1138
|
+
M = F && nt(
|
|
1139
1139
|
R,
|
|
1140
|
-
|
|
1140
|
+
_,
|
|
1141
1141
|
e,
|
|
1142
1142
|
i,
|
|
1143
1143
|
s,
|
|
@@ -1164,16 +1164,16 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
|
|
|
1164
1164
|
}
|
|
1165
1165
|
return M;
|
|
1166
1166
|
}
|
|
1167
|
-
const
|
|
1168
|
-
class
|
|
1167
|
+
const Pi = /* @__PURE__ */ new it(), _t = /* @__PURE__ */ new Float32Array(6);
|
|
1168
|
+
class ls {
|
|
1169
1169
|
constructor() {
|
|
1170
1170
|
this._roots = null, this.primitiveBuffer = null, this.primitiveBufferStride = null;
|
|
1171
1171
|
}
|
|
1172
1172
|
init(t) {
|
|
1173
1173
|
t = {
|
|
1174
|
-
...
|
|
1174
|
+
...tn,
|
|
1175
1175
|
...t
|
|
1176
|
-
},
|
|
1176
|
+
}, os(this, t);
|
|
1177
1177
|
}
|
|
1178
1178
|
getRootRanges() {
|
|
1179
1179
|
throw new Error("BVH: getRootRanges() not implemented");
|
|
@@ -1188,8 +1188,8 @@ class cs {
|
|
|
1188
1188
|
writePrimitiveRangeBounds(t, i, e, s) {
|
|
1189
1189
|
let r = 1 / 0, o = 1 / 0, f = 1 / 0, a = -1 / 0, u = -1 / 0, l = -1 / 0;
|
|
1190
1190
|
for (let p = t, c = t + i; p < c; p++) {
|
|
1191
|
-
this.writePrimitiveBounds(p,
|
|
1192
|
-
const [d, y, g, x, w, m] =
|
|
1191
|
+
this.writePrimitiveBounds(p, _t, 0);
|
|
1192
|
+
const [d, y, g, x, w, m] = _t;
|
|
1193
1193
|
d < r && (r = d), x > a && (a = x), y < o && (o = y), w > u && (u = w), g < f && (f = g), m > l && (l = m);
|
|
1194
1194
|
}
|
|
1195
1195
|
return e[s + 0] = r, e[s + 1] = o, e[s + 2] = f, e[s + 3] = a, e[s + 4] = u, e[s + 5] = l, e;
|
|
@@ -1197,8 +1197,8 @@ class cs {
|
|
|
1197
1197
|
computePrimitiveBounds(t, i, e) {
|
|
1198
1198
|
const s = e.offset || 0;
|
|
1199
1199
|
for (let r = t, o = t + i; r < o; r++) {
|
|
1200
|
-
this.writePrimitiveBounds(r,
|
|
1201
|
-
const [f, a, u, l, p, c] =
|
|
1200
|
+
this.writePrimitiveBounds(r, _t, 0);
|
|
1201
|
+
const [f, a, u, l, p, c] = _t, d = (f + l) / 2, y = (a + p) / 2, g = (u + c) / 2, x = (l - f) / 2, w = (p - a) / 2, m = (c - u) / 2, h = (r - s) * 6;
|
|
1202
1202
|
e[h + 0] = d, e[h + 1] = x + (Math.abs(d) + x) * ye, e[h + 2] = y, e[h + 3] = w + (Math.abs(y) + w) * ye, e[h + 4] = g, e[h + 5] = m + (Math.abs(g) + m) * ye;
|
|
1203
1203
|
}
|
|
1204
1204
|
return e;
|
|
@@ -1241,7 +1241,7 @@ class cs {
|
|
|
1241
1241
|
const l = u * N, p = l * 2;
|
|
1242
1242
|
if (q(p, o)) {
|
|
1243
1243
|
const d = J(l, r), y = Z(p, o);
|
|
1244
|
-
this.writePrimitiveRangeBounds(d, y,
|
|
1244
|
+
this.writePrimitiveRangeBounds(d, y, _t, 0), f.set(_t, l);
|
|
1245
1245
|
} else {
|
|
1246
1246
|
const d = V(l), y = W(l, r);
|
|
1247
1247
|
for (let g = 0; g < 3; g++) {
|
|
@@ -1254,7 +1254,7 @@ class cs {
|
|
|
1254
1254
|
}
|
|
1255
1255
|
getBoundingBox(t) {
|
|
1256
1256
|
return t.makeEmpty(), this._roots.forEach((e) => {
|
|
1257
|
-
k(0, new Float32Array(e),
|
|
1257
|
+
k(0, new Float32Array(e), Pi), t.union(Pi);
|
|
1258
1258
|
}), t;
|
|
1259
1259
|
}
|
|
1260
1260
|
// Base shapecast implementation that can be used by subclasses
|
|
@@ -1277,7 +1277,7 @@ class cs {
|
|
|
1277
1277
|
const l = this._roots;
|
|
1278
1278
|
for (let p = 0, c = l.length; p < c; p++) {
|
|
1279
1279
|
const d = l[p];
|
|
1280
|
-
if (a =
|
|
1280
|
+
if (a = as(this, p, e, s, i, u), a)
|
|
1281
1281
|
break;
|
|
1282
1282
|
u += d.byteLength / X;
|
|
1283
1283
|
}
|
|
@@ -1285,10 +1285,10 @@ class cs {
|
|
|
1285
1285
|
}
|
|
1286
1286
|
bvhcast(t, i, e) {
|
|
1287
1287
|
let { intersectsRanges: s } = e;
|
|
1288
|
-
return
|
|
1288
|
+
return cs(this, t, i, s);
|
|
1289
1289
|
}
|
|
1290
1290
|
}
|
|
1291
|
-
function
|
|
1291
|
+
function us() {
|
|
1292
1292
|
return typeof SharedArrayBuffer < "u";
|
|
1293
1293
|
}
|
|
1294
1294
|
function ni(n) {
|
|
@@ -1297,32 +1297,32 @@ function ni(n) {
|
|
|
1297
1297
|
function Ae(n) {
|
|
1298
1298
|
return ni(n) / 3;
|
|
1299
1299
|
}
|
|
1300
|
-
function
|
|
1300
|
+
function fs(n, t = ArrayBuffer) {
|
|
1301
1301
|
return n > 65535 ? new Uint32Array(new t(4 * n)) : new Uint16Array(new t(2 * n));
|
|
1302
1302
|
}
|
|
1303
|
-
function
|
|
1303
|
+
function ds(n, t) {
|
|
1304
1304
|
if (!n.index) {
|
|
1305
|
-
const i = n.attributes.position.count, e = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, s =
|
|
1306
|
-
n.setIndex(new
|
|
1305
|
+
const i = n.attributes.position.count, e = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, s = fs(i, e);
|
|
1306
|
+
n.setIndex(new Oi(s, 1));
|
|
1307
1307
|
for (let r = 0; r < i; r++)
|
|
1308
1308
|
s[r] = r;
|
|
1309
1309
|
}
|
|
1310
1310
|
}
|
|
1311
|
-
function
|
|
1311
|
+
function ps(n, t, i) {
|
|
1312
1312
|
const e = ni(n) / i, s = t || n.drawRange, r = s.start / i, o = (s.start + s.count) / i, f = Math.max(0, r), a = Math.min(e, o) - f;
|
|
1313
1313
|
return {
|
|
1314
1314
|
offset: Math.floor(f),
|
|
1315
1315
|
count: Math.floor(a)
|
|
1316
1316
|
};
|
|
1317
1317
|
}
|
|
1318
|
-
function
|
|
1318
|
+
function ms(n, t) {
|
|
1319
1319
|
return n.groups.map((i) => ({
|
|
1320
1320
|
offset: i.start / t,
|
|
1321
1321
|
count: i.count / t
|
|
1322
1322
|
}));
|
|
1323
1323
|
}
|
|
1324
|
-
function
|
|
1325
|
-
const e =
|
|
1324
|
+
function Si(n, t, i) {
|
|
1325
|
+
const e = ps(n, t, i), s = ms(n, i);
|
|
1326
1326
|
if (!s.length)
|
|
1327
1327
|
return [e];
|
|
1328
1328
|
const r = [], o = e.offset, f = e.offset + e.count, a = ni(n) / i, u = [];
|
|
@@ -1341,7 +1341,7 @@ function Pi(n, t, i) {
|
|
|
1341
1341
|
}
|
|
1342
1342
|
return r;
|
|
1343
1343
|
}
|
|
1344
|
-
function
|
|
1344
|
+
function hs(n, t) {
|
|
1345
1345
|
const i = n[n.length - 1], e = i.offset + i.count > 2 ** 16, s = n.reduce((u, l) => u + l.count, 0), r = e ? 4 : 2, o = t ? new SharedArrayBuffer(s * r) : new ArrayBuffer(s * r), f = e ? new Uint32Array(o) : new Uint16Array(o);
|
|
1346
1346
|
let a = 0;
|
|
1347
1347
|
for (let u = 0; u < n.length; u++) {
|
|
@@ -1352,7 +1352,7 @@ function ms(n, t) {
|
|
|
1352
1352
|
}
|
|
1353
1353
|
return f;
|
|
1354
1354
|
}
|
|
1355
|
-
class
|
|
1355
|
+
class ys extends ls {
|
|
1356
1356
|
get indirect() {
|
|
1357
1357
|
return !!this._indirectBuffer;
|
|
1358
1358
|
}
|
|
@@ -1374,25 +1374,25 @@ class hs extends cs {
|
|
|
1374
1374
|
if (t.index && t.index.isInterleavedBufferAttribute)
|
|
1375
1375
|
throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.");
|
|
1376
1376
|
} else throw new Error("BVH: Only BufferGeometries are supported.");
|
|
1377
|
-
if (i.useSharedArrayBuffer && !
|
|
1377
|
+
if (i.useSharedArrayBuffer && !us())
|
|
1378
1378
|
throw new Error("BVH: SharedArrayBuffer is not available.");
|
|
1379
1379
|
super(), this.geometry = t, this.resolvePrimitiveIndex = i.indirect ? (e) => this._indirectBuffer[e] : (e) => e, this.primitiveBuffer = null, this.primitiveBufferStride = null, this._indirectBuffer = null, i = {
|
|
1380
|
-
...
|
|
1380
|
+
...tn,
|
|
1381
1381
|
...i
|
|
1382
1382
|
}, i[ti] || this.init(i);
|
|
1383
1383
|
}
|
|
1384
1384
|
init(t) {
|
|
1385
1385
|
const { geometry: i, primitiveStride: e } = this;
|
|
1386
1386
|
if (t.indirect) {
|
|
1387
|
-
const s =
|
|
1387
|
+
const s = Si(i, t.range, e), r = hs(s, t.useSharedArrayBuffer);
|
|
1388
1388
|
this._indirectBuffer = r;
|
|
1389
1389
|
} else
|
|
1390
|
-
|
|
1390
|
+
ds(i, t);
|
|
1391
1391
|
super.init(t), !i.boundingBox && t.setBoundingBox && (i.boundingBox = this.getBoundingBox(new it()));
|
|
1392
1392
|
}
|
|
1393
1393
|
// Abstract methods to be implemented by subclasses
|
|
1394
1394
|
getRootRanges(t) {
|
|
1395
|
-
return this.indirect ? [{ offset: 0, count: this._indirectBuffer.length }] :
|
|
1395
|
+
return this.indirect ? [{ offset: 0, count: this._indirectBuffer.length }] : Si(this.geometry, t, this.primitiveStride);
|
|
1396
1396
|
}
|
|
1397
1397
|
raycastObject3D() {
|
|
1398
1398
|
throw new Error("BVH: raycastObject3D() not implemented");
|
|
@@ -1437,7 +1437,7 @@ pt.prototype.setFromBox = /* @__PURE__ */ function() {
|
|
|
1437
1437
|
this.min = o, this.max = f;
|
|
1438
1438
|
};
|
|
1439
1439
|
}();
|
|
1440
|
-
const
|
|
1440
|
+
const gs = /* @__PURE__ */ function() {
|
|
1441
1441
|
const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new z();
|
|
1442
1442
|
return function(s, r, o) {
|
|
1443
1443
|
const f = s.start, a = n, u = r.start, l = t;
|
|
@@ -1449,7 +1449,7 @@ const ys = /* @__PURE__ */ function() {
|
|
|
1449
1449
|
}(), si = /* @__PURE__ */ function() {
|
|
1450
1450
|
const n = /* @__PURE__ */ new gt(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new z();
|
|
1451
1451
|
return function(s, r, o, f) {
|
|
1452
|
-
|
|
1452
|
+
gs(s, r, n);
|
|
1453
1453
|
let a = n.x, u = n.y;
|
|
1454
1454
|
if (a >= 0 && a <= 1 && u >= 0 && u <= 1) {
|
|
1455
1455
|
s.at(a, o), r.at(u, f);
|
|
@@ -1475,8 +1475,8 @@ const ys = /* @__PURE__ */ function() {
|
|
|
1475
1475
|
}
|
|
1476
1476
|
}
|
|
1477
1477
|
};
|
|
1478
|
-
}(),
|
|
1479
|
-
const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new
|
|
1478
|
+
}(), ws = /* @__PURE__ */ function() {
|
|
1479
|
+
const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new Vi(), e = /* @__PURE__ */ new dt();
|
|
1480
1480
|
return function(r, o) {
|
|
1481
1481
|
const { radius: f, center: a } = r, { a: u, b: l, c: p } = o;
|
|
1482
1482
|
if (e.start = u, e.end = l, e.closestPointToPoint(a, !0, n).distanceTo(a) <= f || (e.start = u, e.end = p, e.closestPointToPoint(a, !0, n).distanceTo(a) <= f) || (e.start = l, e.end = p, e.closestPointToPoint(a, !0, n).distanceTo(a) <= f)) return !0;
|
|
@@ -1487,16 +1487,16 @@ const ys = /* @__PURE__ */ function() {
|
|
|
1487
1487
|
}
|
|
1488
1488
|
return !1;
|
|
1489
1489
|
};
|
|
1490
|
-
}(),
|
|
1490
|
+
}(), bs = ["x", "y", "z"], lt = 1e-15, Ti = lt * lt;
|
|
1491
1491
|
function tt(n) {
|
|
1492
1492
|
return Math.abs(n) < lt;
|
|
1493
1493
|
}
|
|
1494
1494
|
class st extends $t {
|
|
1495
1495
|
constructor(...t) {
|
|
1496
|
-
super(...t), this.isExtendedTriangle = !0, this.satAxes = new Array(4).fill().map(() => new z()), this.satBounds = new Array(4).fill().map(() => new pt()), this.points = [this.a, this.b, this.c], this.plane = new
|
|
1496
|
+
super(...t), this.isExtendedTriangle = !0, this.satAxes = new Array(4).fill().map(() => new z()), this.satBounds = new Array(4).fill().map(() => new pt()), this.points = [this.a, this.b, this.c], this.plane = new Vi(), this.isDegenerateIntoSegment = !1, this.isDegenerateIntoPoint = !1, this.degenerateSegment = new dt(), this.needsUpdate = !0;
|
|
1497
1497
|
}
|
|
1498
1498
|
intersectsSphere(t) {
|
|
1499
|
-
return
|
|
1499
|
+
return ws(t, this);
|
|
1500
1500
|
}
|
|
1501
1501
|
update() {
|
|
1502
1502
|
const t = this.a, i = this.b, e = this.c, s = this.points, r = this.satAxes, o = this.satBounds, f = r[0], a = o[0];
|
|
@@ -1512,7 +1512,7 @@ class st extends $t {
|
|
|
1512
1512
|
}
|
|
1513
1513
|
}
|
|
1514
1514
|
st.prototype.closestPointToSegment = /* @__PURE__ */ function() {
|
|
1515
|
-
const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new
|
|
1515
|
+
const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new dt();
|
|
1516
1516
|
return function(s, r = null, o = null) {
|
|
1517
1517
|
const { start: f, end: a } = s, u = this.points;
|
|
1518
1518
|
let l, p = 1 / 0;
|
|
@@ -1524,37 +1524,37 @@ st.prototype.closestPointToSegment = /* @__PURE__ */ function() {
|
|
|
1524
1524
|
};
|
|
1525
1525
|
}();
|
|
1526
1526
|
st.prototype.intersectsTriangle = /* @__PURE__ */ function() {
|
|
1527
|
-
const n = /* @__PURE__ */ new st(), t = /* @__PURE__ */ new pt(), i = /* @__PURE__ */ new pt(), e = /* @__PURE__ */ new z(), s = /* @__PURE__ */ new z(), r = /* @__PURE__ */ new z(), o = /* @__PURE__ */ new z(), f = /* @__PURE__ */ new
|
|
1527
|
+
const n = /* @__PURE__ */ new st(), t = /* @__PURE__ */ new pt(), i = /* @__PURE__ */ new pt(), e = /* @__PURE__ */ new z(), s = /* @__PURE__ */ new z(), r = /* @__PURE__ */ new z(), o = /* @__PURE__ */ new z(), f = /* @__PURE__ */ new dt(), a = /* @__PURE__ */ new dt(), u = /* @__PURE__ */ new z(), l = /* @__PURE__ */ new gt(), p = /* @__PURE__ */ new gt();
|
|
1528
1528
|
function c(h, b, A, P) {
|
|
1529
1529
|
const M = e;
|
|
1530
1530
|
!h.isDegenerateIntoPoint && !h.isDegenerateIntoSegment ? M.copy(h.plane.normal) : M.copy(b.plane.normal);
|
|
1531
1531
|
const T = h.satBounds, R = h.satAxes;
|
|
1532
1532
|
for (let S = 1; S < 4; S++) {
|
|
1533
|
-
const
|
|
1534
|
-
if (t.setFromPoints(E, b.points),
|
|
1533
|
+
const _ = T[S], E = R[S];
|
|
1534
|
+
if (t.setFromPoints(E, b.points), _.isSeparated(t) || (o.copy(M).cross(E), t.setFromPoints(o, h.points), i.setFromPoints(o, b.points), t.isSeparated(i))) return !1;
|
|
1535
1535
|
}
|
|
1536
|
-
const v = b.satBounds,
|
|
1536
|
+
const v = b.satBounds, B = b.satAxes;
|
|
1537
1537
|
for (let S = 1; S < 4; S++) {
|
|
1538
|
-
const
|
|
1539
|
-
if (t.setFromPoints(E, h.points),
|
|
1538
|
+
const _ = v[S], E = B[S];
|
|
1539
|
+
if (t.setFromPoints(E, h.points), _.isSeparated(t) || (o.crossVectors(M, E), t.setFromPoints(o, h.points), i.setFromPoints(o, b.points), t.isSeparated(i))) return !1;
|
|
1540
1540
|
}
|
|
1541
1541
|
return A && (P || console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."), A.start.set(0, 0, 0), A.end.set(0, 0, 0)), !0;
|
|
1542
1542
|
}
|
|
1543
|
-
function d(h, b, A, P, M, T, R, v,
|
|
1543
|
+
function d(h, b, A, P, M, T, R, v, B, S, _) {
|
|
1544
1544
|
let E = R / (R - v);
|
|
1545
|
-
S.x = P + (M - P) * E,
|
|
1545
|
+
S.x = P + (M - P) * E, _.start.subVectors(b, h).multiplyScalar(E).add(h), E = R / (R - B), S.y = P + (T - P) * E, _.end.subVectors(A, h).multiplyScalar(E).add(h);
|
|
1546
1546
|
}
|
|
1547
|
-
function y(h, b, A, P, M, T, R, v,
|
|
1547
|
+
function y(h, b, A, P, M, T, R, v, B, S, _) {
|
|
1548
1548
|
if (M > 0)
|
|
1549
|
-
d(h.c, h.a, h.b, P, b, A,
|
|
1549
|
+
d(h.c, h.a, h.b, P, b, A, B, R, v, S, _);
|
|
1550
1550
|
else if (T > 0)
|
|
1551
|
-
d(h.b, h.a, h.c, A, b, P, v, R,
|
|
1552
|
-
else if (v *
|
|
1553
|
-
d(h.a, h.b, h.c, b, A, P, R, v,
|
|
1551
|
+
d(h.b, h.a, h.c, A, b, P, v, R, B, S, _);
|
|
1552
|
+
else if (v * B > 0 || R != 0)
|
|
1553
|
+
d(h.a, h.b, h.c, b, A, P, R, v, B, S, _);
|
|
1554
1554
|
else if (v != 0)
|
|
1555
|
-
d(h.b, h.a, h.c, A, b, P, v, R,
|
|
1556
|
-
else if (
|
|
1557
|
-
d(h.c, h.a, h.b, P, b, A,
|
|
1555
|
+
d(h.b, h.a, h.c, A, b, P, v, R, B, S, _);
|
|
1556
|
+
else if (B != 0)
|
|
1557
|
+
d(h.c, h.a, h.b, P, b, A, B, R, v, S, _);
|
|
1558
1558
|
else
|
|
1559
1559
|
return !0;
|
|
1560
1560
|
return !1;
|
|
@@ -1569,25 +1569,25 @@ st.prototype.intersectsTriangle = /* @__PURE__ */ function() {
|
|
|
1569
1569
|
}
|
|
1570
1570
|
function w(h, b, A) {
|
|
1571
1571
|
const P = h.degenerateSegment, M = b.a;
|
|
1572
|
-
return P.closestPointToPoint(M, !0, e), M.distanceToSquared(e) <
|
|
1572
|
+
return P.closestPointToPoint(M, !0, e), M.distanceToSquared(e) < Ti ? (A && (A.start.copy(M), A.end.copy(M)), !0) : !1;
|
|
1573
1573
|
}
|
|
1574
1574
|
function m(h, b, A, P) {
|
|
1575
1575
|
if (h.isDegenerateIntoSegment)
|
|
1576
1576
|
if (b.isDegenerateIntoSegment) {
|
|
1577
1577
|
const M = h.degenerateSegment, T = b.degenerateSegment, R = s, v = r;
|
|
1578
1578
|
M.delta(R), T.delta(v);
|
|
1579
|
-
const
|
|
1579
|
+
const B = e.subVectors(T.start, M.start), S = R.x * v.y - R.y * v.x;
|
|
1580
1580
|
if (tt(S))
|
|
1581
1581
|
return !1;
|
|
1582
|
-
const
|
|
1583
|
-
if (
|
|
1582
|
+
const _ = (B.x * v.y - B.y * v.x) / S, E = -(R.x * B.y - R.y * B.x) / S;
|
|
1583
|
+
if (_ < 0 || _ > 1 || E < 0 || E > 1)
|
|
1584
1584
|
return !1;
|
|
1585
|
-
const
|
|
1586
|
-
return tt(
|
|
1585
|
+
const F = M.start.z + R.z * _, D = T.start.z + v.z * E;
|
|
1586
|
+
return tt(F - D) ? (A && (A.start.copy(M.start).addScaledVector(R, _), A.end.copy(M.start).addScaledVector(R, _)), !0) : !1;
|
|
1587
1587
|
} else return b.isDegenerateIntoPoint ? w(h, b, A) : g(b, h, A, P);
|
|
1588
1588
|
else {
|
|
1589
1589
|
if (h.isDegenerateIntoPoint)
|
|
1590
|
-
return b.isDegenerateIntoPoint ? b.a.distanceToSquared(h.a) <
|
|
1590
|
+
return b.isDegenerateIntoPoint ? b.a.distanceToSquared(h.a) < Ti ? (A && (A.start.copy(h.a), A.end.copy(h.a)), !0) : !1 : b.isDegenerateIntoSegment ? w(b, h, A) : x(b, h, A);
|
|
1591
1591
|
if (b.isDegenerateIntoPoint)
|
|
1592
1592
|
return x(h, b, A);
|
|
1593
1593
|
if (b.isDegenerateIntoSegment)
|
|
@@ -1600,14 +1600,14 @@ st.prototype.intersectsTriangle = /* @__PURE__ */ function() {
|
|
|
1600
1600
|
if (M !== void 0)
|
|
1601
1601
|
return M;
|
|
1602
1602
|
const T = this.plane, R = b.plane;
|
|
1603
|
-
let v = R.distanceToPoint(this.a),
|
|
1604
|
-
tt(v) && (v = 0), tt(
|
|
1605
|
-
const
|
|
1606
|
-
if (
|
|
1603
|
+
let v = R.distanceToPoint(this.a), B = R.distanceToPoint(this.b), S = R.distanceToPoint(this.c);
|
|
1604
|
+
tt(v) && (v = 0), tt(B) && (B = 0), tt(S) && (S = 0);
|
|
1605
|
+
const _ = v * B, E = v * S;
|
|
1606
|
+
if (_ > 0 && E > 0)
|
|
1607
1607
|
return !1;
|
|
1608
|
-
let
|
|
1609
|
-
tt(
|
|
1610
|
-
const L =
|
|
1608
|
+
let F = T.distanceToPoint(b.a), D = T.distanceToPoint(b.b), U = T.distanceToPoint(b.c);
|
|
1609
|
+
tt(F) && (F = 0), tt(D) && (D = 0), tt(U) && (U = 0);
|
|
1610
|
+
const L = F * D, Y = F * U;
|
|
1611
1611
|
if (L > 0 && Y > 0)
|
|
1612
1612
|
return !1;
|
|
1613
1613
|
s.copy(T.normal), r.copy(R.normal);
|
|
@@ -1615,10 +1615,10 @@ st.prototype.intersectsTriangle = /* @__PURE__ */ function() {
|
|
|
1615
1615
|
let vt = 0, Pt = Math.abs(Mt.x);
|
|
1616
1616
|
const rt = Math.abs(Mt.y);
|
|
1617
1617
|
rt > Pt && (Pt = rt, vt = 1), Math.abs(Mt.z) > Pt && (vt = 2);
|
|
1618
|
-
const at =
|
|
1619
|
-
if (y(this,
|
|
1618
|
+
const at = bs[vt], sn = this.a[at], on = this.b[at], rn = this.c[at], an = b.a[at], cn = b.b[at], ln = b.c[at];
|
|
1619
|
+
if (y(this, sn, on, rn, _, E, v, B, S, l, f))
|
|
1620
1620
|
return c(this, b, A, P);
|
|
1621
|
-
if (y(b,
|
|
1621
|
+
if (y(b, an, cn, ln, L, Y, F, D, U, p, a))
|
|
1622
1622
|
return c(this, b, A, P);
|
|
1623
1623
|
if (l.y < l.x) {
|
|
1624
1624
|
const ve = l.y;
|
|
@@ -1638,7 +1638,7 @@ st.prototype.distanceToPoint = /* @__PURE__ */ function() {
|
|
|
1638
1638
|
};
|
|
1639
1639
|
}();
|
|
1640
1640
|
st.prototype.distanceToTriangle = /* @__PURE__ */ function() {
|
|
1641
|
-
const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = ["a", "b", "c"], e = /* @__PURE__ */ new
|
|
1641
|
+
const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = ["a", "b", "c"], e = /* @__PURE__ */ new dt(), s = /* @__PURE__ */ new dt();
|
|
1642
1642
|
return function(o, f = null, a = null) {
|
|
1643
1643
|
const u = f || a ? e : null;
|
|
1644
1644
|
if (this.intersectsTriangle(o, u))
|
|
@@ -1743,7 +1743,7 @@ Q.prototype.distanceToPoint = function() {
|
|
|
1743
1743
|
};
|
|
1744
1744
|
}();
|
|
1745
1745
|
Q.prototype.distanceToBox = /* @__PURE__ */ function() {
|
|
1746
|
-
const n = ["x", "y", "z"], t = /* @__PURE__ */ new Array(12).fill().map(() => new
|
|
1746
|
+
const n = ["x", "y", "z"], t = /* @__PURE__ */ new Array(12).fill().map(() => new dt()), i = /* @__PURE__ */ new Array(12).fill().map(() => new dt()), e = /* @__PURE__ */ new z(), s = /* @__PURE__ */ new z();
|
|
1747
1747
|
return function(o, f = 0, a = null, u = null) {
|
|
1748
1748
|
if (this.needsUpdate && this.update(), this.intersectsBox(o))
|
|
1749
1749
|
return (a || u) && (o.getCenter(s), this.closestPointToPoint(s, e), o.closestPointToPoint(e, s), a && a.copy(e), u && u.copy(s)), 0;
|
|
@@ -1762,8 +1762,8 @@ Q.prototype.distanceToBox = /* @__PURE__ */ function() {
|
|
|
1762
1762
|
for (let m = 0; m <= 1; m++) {
|
|
1763
1763
|
const h = (x + 1) % 3, b = (x + 2) % 3, A = w << h | m << b, P = 1 << x | w << h | m << b, M = d[A], T = d[P];
|
|
1764
1764
|
t[g].set(M, T);
|
|
1765
|
-
const v = n[x],
|
|
1766
|
-
E[v] = p[v], E[
|
|
1765
|
+
const v = n[x], B = n[h], S = n[b], _ = i[g], E = _.start, F = _.end;
|
|
1766
|
+
E[v] = p[v], E[B] = w ? p[B] : c[B], E[S] = m ? p[S] : c[B], F[v] = c[v], F[B] = w ? p[B] : c[B], F[S] = m ? p[S] : c[B], g++;
|
|
1767
1767
|
}
|
|
1768
1768
|
for (let x = 0; x <= 1; x++)
|
|
1769
1769
|
for (let w = 0; w <= 1; w++)
|
|
@@ -1786,13 +1786,13 @@ Q.prototype.distanceToBox = /* @__PURE__ */ function() {
|
|
|
1786
1786
|
return Math.sqrt(y);
|
|
1787
1787
|
};
|
|
1788
1788
|
}();
|
|
1789
|
-
class
|
|
1789
|
+
class xs extends ii {
|
|
1790
1790
|
constructor() {
|
|
1791
1791
|
super(() => new st());
|
|
1792
1792
|
}
|
|
1793
1793
|
}
|
|
1794
|
-
const et = /* @__PURE__ */ new
|
|
1795
|
-
function
|
|
1794
|
+
const et = /* @__PURE__ */ new xs(), Nt = /* @__PURE__ */ new z(), Ee = /* @__PURE__ */ new z();
|
|
1795
|
+
function As(n, t, i = {}, e = 0, s = 1 / 0) {
|
|
1796
1796
|
const r = e * e, o = s * s;
|
|
1797
1797
|
let f = 1 / 0, a = null;
|
|
1798
1798
|
if (n.shapecast(
|
|
@@ -1809,19 +1809,19 @@ function xs(n, t, i = {}, e = 0, s = 1 / 0) {
|
|
|
1809
1809
|
const u = Math.sqrt(f);
|
|
1810
1810
|
return i.point ? i.point.copy(Ee) : i.point = Ee.clone(), i.distance = u, i.faceIndex = a, i;
|
|
1811
1811
|
}
|
|
1812
|
-
const ie = parseInt(
|
|
1813
|
-
function
|
|
1812
|
+
const ie = parseInt(Wi) >= 169, Ms = parseInt(Wi) <= 161, bt = /* @__PURE__ */ new z(), xt = /* @__PURE__ */ new z(), At = /* @__PURE__ */ new z(), ne = /* @__PURE__ */ new gt(), se = /* @__PURE__ */ new gt(), oe = /* @__PURE__ */ new gt(), Ri = /* @__PURE__ */ new z(), Bi = /* @__PURE__ */ new z(), _i = /* @__PURE__ */ new z(), qt = /* @__PURE__ */ new z();
|
|
1813
|
+
function vs(n, t, i, e, s, r, o, f) {
|
|
1814
1814
|
let a;
|
|
1815
|
-
if (r ===
|
|
1815
|
+
if (r === vn ? a = n.intersectTriangle(e, i, t, !0, s) : a = n.intersectTriangle(t, i, e, r !== Pn, s), a === null) return null;
|
|
1816
1816
|
const u = n.origin.distanceTo(s);
|
|
1817
1817
|
return u < o || u > f ? null : {
|
|
1818
1818
|
distance: u,
|
|
1819
1819
|
point: s.clone()
|
|
1820
1820
|
};
|
|
1821
1821
|
}
|
|
1822
|
-
function
|
|
1822
|
+
function Ei(n, t, i, e, s, r, o, f, a, u, l) {
|
|
1823
1823
|
bt.fromBufferAttribute(t, r), xt.fromBufferAttribute(t, o), At.fromBufferAttribute(t, f);
|
|
1824
|
-
const p =
|
|
1824
|
+
const p = vs(n, bt, xt, At, qt, a, u, l);
|
|
1825
1825
|
if (p) {
|
|
1826
1826
|
if (e) {
|
|
1827
1827
|
ne.fromBufferAttribute(e, r), se.fromBufferAttribute(e, o), oe.fromBufferAttribute(e, f), p.uv = new gt();
|
|
@@ -1831,11 +1831,11 @@ function Bi(n, t, i, e, s, r, o, f, a, u, l) {
|
|
|
1831
1831
|
if (s) {
|
|
1832
1832
|
ne.fromBufferAttribute(s, r), se.fromBufferAttribute(s, o), oe.fromBufferAttribute(s, f), p.uv1 = new gt();
|
|
1833
1833
|
const d = $t.getInterpolation(qt, bt, xt, At, ne, se, oe, p.uv1);
|
|
1834
|
-
ie || (p.uv1 = d),
|
|
1834
|
+
ie || (p.uv1 = d), Ms && (p.uv2 = p.uv1);
|
|
1835
1835
|
}
|
|
1836
1836
|
if (i) {
|
|
1837
|
-
|
|
1838
|
-
const d = $t.getInterpolation(qt, bt, xt, At,
|
|
1837
|
+
Ri.fromBufferAttribute(i, r), Bi.fromBufferAttribute(i, o), _i.fromBufferAttribute(i, f), p.normal = new z();
|
|
1838
|
+
const d = $t.getInterpolation(qt, bt, xt, At, Ri, Bi, _i, p.normal);
|
|
1839
1839
|
p.normal.dot(n.direction) > 0 && p.normal.multiplyScalar(-1), ie || (p.normal = d);
|
|
1840
1840
|
}
|
|
1841
1841
|
const c = {
|
|
@@ -1852,7 +1852,7 @@ function Bi(n, t, i, e, s, r, o, f, a, u, l) {
|
|
|
1852
1852
|
}
|
|
1853
1853
|
return p;
|
|
1854
1854
|
}
|
|
1855
|
-
function
|
|
1855
|
+
function zi(n) {
|
|
1856
1856
|
return n && n.isMaterial ? n.side : n;
|
|
1857
1857
|
}
|
|
1858
1858
|
function Me(n, t, i, e, s, r, o) {
|
|
@@ -1866,7 +1866,7 @@ function Me(n, t, i, e, s, r, o) {
|
|
|
1866
1866
|
for (let m = 0, h = c.length; m < h; m++) {
|
|
1867
1867
|
const { start: b, count: A, materialIndex: P } = c[m];
|
|
1868
1868
|
if (w >= b && w < b + A) {
|
|
1869
|
-
const M =
|
|
1869
|
+
const M = zi(t[P]), T = Ei(i, d, y, g, x, a, u, l, M, r, o);
|
|
1870
1870
|
if (T)
|
|
1871
1871
|
if (T.faceIndex = e, T.face.materialIndex = P, s)
|
|
1872
1872
|
s.push(T);
|
|
@@ -1875,7 +1875,7 @@ function Me(n, t, i, e, s, r, o) {
|
|
|
1875
1875
|
}
|
|
1876
1876
|
}
|
|
1877
1877
|
} else {
|
|
1878
|
-
const w =
|
|
1878
|
+
const w = zi(t), m = Ei(i, d, y, g, x, a, u, l, w, r, o);
|
|
1879
1879
|
if (m)
|
|
1880
1880
|
if (m.faceIndex = e, m.face.materialIndex = 0, s)
|
|
1881
1881
|
s.push(m);
|
|
@@ -1889,12 +1889,12 @@ function j(n, t, i, e) {
|
|
|
1889
1889
|
let f = t, a = t + 1, u = t + 2;
|
|
1890
1890
|
i && (f = i.getX(f), a = i.getX(a), u = i.getX(u)), s.x = e.getX(f), s.y = e.getY(f), s.z = e.getZ(f), r.x = e.getX(a), r.y = e.getY(a), r.z = e.getZ(a), o.x = e.getX(u), o.y = e.getY(u), o.z = e.getZ(u);
|
|
1891
1891
|
}
|
|
1892
|
-
function
|
|
1892
|
+
function Ps(n, t, i, e, s, r, o, f) {
|
|
1893
1893
|
const { geometry: a, _indirectBuffer: u } = n;
|
|
1894
1894
|
for (let l = e, p = e + s; l < p; l++)
|
|
1895
1895
|
Me(a, t, i, l, r, o, f);
|
|
1896
1896
|
}
|
|
1897
|
-
function
|
|
1897
|
+
function Ss(n, t, i, e, s, r, o) {
|
|
1898
1898
|
const { geometry: f, _indirectBuffer: a } = n;
|
|
1899
1899
|
let u = 1 / 0, l = null;
|
|
1900
1900
|
for (let p = e, c = e + s; p < c; p++) {
|
|
@@ -1903,7 +1903,7 @@ function Ps(n, t, i, e, s, r, o) {
|
|
|
1903
1903
|
}
|
|
1904
1904
|
return l;
|
|
1905
1905
|
}
|
|
1906
|
-
function
|
|
1906
|
+
function Ts(n, t, i, e, s, r, o) {
|
|
1907
1907
|
const { geometry: f } = i, { index: a } = f, u = f.attributes.position;
|
|
1908
1908
|
for (let l = n, p = t + n; l < p; l++) {
|
|
1909
1909
|
let c;
|
|
@@ -1912,7 +1912,7 @@ function Ss(n, t, i, e, s, r, o) {
|
|
|
1912
1912
|
}
|
|
1913
1913
|
return !1;
|
|
1914
1914
|
}
|
|
1915
|
-
function
|
|
1915
|
+
function Rs(n, t = null) {
|
|
1916
1916
|
t && Array.isArray(t) && (t = new Set(t));
|
|
1917
1917
|
const i = n.geometry, e = i.index ? i.index.array : null, s = i.attributes.position;
|
|
1918
1918
|
let r, o, f, a, u = 0;
|
|
@@ -1926,8 +1926,8 @@ function Ts(n, t = null) {
|
|
|
1926
1926
|
let m = 1 / 0, h = 1 / 0, b = 1 / 0, A = -1 / 0, P = -1 / 0, M = -1 / 0;
|
|
1927
1927
|
for (let T = 3 * x, R = 3 * (x + w); T < R; T++) {
|
|
1928
1928
|
let v = e[T];
|
|
1929
|
-
const
|
|
1930
|
-
|
|
1929
|
+
const B = s.getX(v), S = s.getY(v), _ = s.getZ(v);
|
|
1930
|
+
B < m && (m = B), B > A && (A = B), S < h && (h = S), S > P && (P = S), _ < b && (b = _), _ > M && (M = _);
|
|
1931
1931
|
}
|
|
1932
1932
|
return a[c + 0] !== m || a[c + 1] !== h || a[c + 2] !== b || a[c + 3] !== A || a[c + 4] !== P || a[c + 5] !== M ? (a[c + 0] = m, a[c + 1] = h, a[c + 2] = b, a[c + 3] = A, a[c + 4] = P, a[c + 5] = M, !0) : !1;
|
|
1933
1933
|
} else {
|
|
@@ -1935,8 +1935,8 @@ function Ts(n, t = null) {
|
|
|
1935
1935
|
let m = y, h = !1, b = !1;
|
|
1936
1936
|
if (t) {
|
|
1937
1937
|
if (!m) {
|
|
1938
|
-
const v = x / N + d / X,
|
|
1939
|
-
h = t.has(v), b = t.has(
|
|
1938
|
+
const v = x / N + d / X, B = w / N + d / X;
|
|
1939
|
+
h = t.has(v), b = t.has(B), m = !h && !b;
|
|
1940
1940
|
}
|
|
1941
1941
|
} else
|
|
1942
1942
|
h = !0, b = !0;
|
|
@@ -1948,8 +1948,8 @@ function Ts(n, t = null) {
|
|
|
1948
1948
|
const R = M || T;
|
|
1949
1949
|
if (R)
|
|
1950
1950
|
for (let v = 0; v < 3; v++) {
|
|
1951
|
-
const
|
|
1952
|
-
a[c + v] =
|
|
1951
|
+
const B = x + v, S = w + v, _ = a[B], E = a[B + 3], F = a[S], D = a[S + 3];
|
|
1952
|
+
a[c + v] = _ < F ? _ : F, a[c + v + 3] = E > D ? E : D;
|
|
1953
1953
|
}
|
|
1954
1954
|
return R;
|
|
1955
1955
|
}
|
|
@@ -1961,7 +1961,7 @@ function wt(n, t, i, e, s) {
|
|
|
1961
1961
|
let w = t[n], m = t[n + 3], h = t[n + 1], b = t[n + 3 + 1], A = t[n + 2], P = t[n + 3 + 2];
|
|
1962
1962
|
return p >= 0 ? (r = (w - y) * p, o = (m - y) * p) : (r = (m - y) * p, o = (w - y) * p), c >= 0 ? (f = (h - g) * c, a = (b - g) * c) : (f = (b - g) * c, a = (h - g) * c), r > a || f > o || ((f > r || isNaN(r)) && (r = f), (a < o || isNaN(o)) && (o = a), d >= 0 ? (u = (A - x) * d, l = (P - x) * d) : (u = (P - x) * d, l = (A - x) * d), r > l || u > o) ? !1 : ((u > r || r !== r) && (r = u), (l < o || o !== o) && (o = l), r <= s && o >= e);
|
|
1963
1963
|
}
|
|
1964
|
-
function
|
|
1964
|
+
function Bs(n, t, i, e, s, r, o, f) {
|
|
1965
1965
|
const { geometry: a, _indirectBuffer: u } = n;
|
|
1966
1966
|
for (let l = e, p = e + s; l < p; l++) {
|
|
1967
1967
|
let c = u ? u[l] : l;
|
|
@@ -1977,7 +1977,7 @@ function _s(n, t, i, e, s, r, o) {
|
|
|
1977
1977
|
}
|
|
1978
1978
|
return l;
|
|
1979
1979
|
}
|
|
1980
|
-
function
|
|
1980
|
+
function Es(n, t, i, e, s, r, o) {
|
|
1981
1981
|
const { geometry: f } = i, { index: a } = f, u = f.attributes.position;
|
|
1982
1982
|
for (let l = n, p = t + n; l < p; l++) {
|
|
1983
1983
|
let c;
|
|
@@ -1986,14 +1986,14 @@ function Bs(n, t, i, e, s, r, o) {
|
|
|
1986
1986
|
}
|
|
1987
1987
|
return !1;
|
|
1988
1988
|
}
|
|
1989
|
-
function
|
|
1989
|
+
function zs(n, t, i, e, s, r, o) {
|
|
1990
1990
|
I.setBuffer(n._roots[t]), qe(0, n, i, e, s, r, o), I.clearBuffer();
|
|
1991
1991
|
}
|
|
1992
1992
|
function qe(n, t, i, e, s, r, o) {
|
|
1993
1993
|
const { float32Array: f, uint16Array: a, uint32Array: u } = I, l = n * 2;
|
|
1994
1994
|
if (q(l, a)) {
|
|
1995
1995
|
const c = J(n, u), d = Z(l, a);
|
|
1996
|
-
|
|
1996
|
+
Ps(t, i, e, c, d, s, r, o);
|
|
1997
1997
|
} else {
|
|
1998
1998
|
const c = V(n);
|
|
1999
1999
|
wt(c, f, e, r, o) && qe(c, t, i, e, s, r, o);
|
|
@@ -2001,7 +2001,7 @@ function qe(n, t, i, e, s, r, o) {
|
|
|
2001
2001
|
wt(d, f, e, r, o) && qe(d, t, i, e, s, r, o);
|
|
2002
2002
|
}
|
|
2003
2003
|
}
|
|
2004
|
-
const
|
|
2004
|
+
const Us = ["x", "y", "z"];
|
|
2005
2005
|
function Fs(n, t, i, e, s, r) {
|
|
2006
2006
|
I.setBuffer(n._roots[t]);
|
|
2007
2007
|
const o = Oe(0, n, i, e, s, r);
|
|
@@ -2012,9 +2012,9 @@ function Oe(n, t, i, e, s, r) {
|
|
|
2012
2012
|
let u = n * 2;
|
|
2013
2013
|
if (q(u, f)) {
|
|
2014
2014
|
const p = J(n, a), c = Z(u, f);
|
|
2015
|
-
return
|
|
2015
|
+
return Ss(t, i, e, p, c, s, r);
|
|
2016
2016
|
} else {
|
|
2017
|
-
const p = ei(n, a), c =
|
|
2017
|
+
const p = ei(n, a), c = Us[p], y = e.direction[c] >= 0;
|
|
2018
2018
|
let g, x;
|
|
2019
2019
|
y ? (g = V(n), x = W(n, a)) : (g = W(n, a), x = V(n));
|
|
2020
2020
|
const m = wt(g, o, e, s, r) ? Oe(g, t, i, e, s, r) : null;
|
|
@@ -2030,8 +2030,8 @@ function Oe(n, t, i, e, s, r) {
|
|
|
2030
2030
|
return m && b ? m.distance <= b.distance ? m : b : m || b || null;
|
|
2031
2031
|
}
|
|
2032
2032
|
}
|
|
2033
|
-
const re = /* @__PURE__ */ new it(), Et = /* @__PURE__ */ new st(), zt = /* @__PURE__ */ new st(), Ot = /* @__PURE__ */ new H(),
|
|
2034
|
-
function
|
|
2033
|
+
const re = /* @__PURE__ */ new it(), Et = /* @__PURE__ */ new st(), zt = /* @__PURE__ */ new st(), Ot = /* @__PURE__ */ new H(), Ui = /* @__PURE__ */ new Q(), ae = /* @__PURE__ */ new Q();
|
|
2034
|
+
function $s(n, t, i, e) {
|
|
2035
2035
|
I.setBuffer(n._roots[t]);
|
|
2036
2036
|
const s = Ve(0, n, i, e);
|
|
2037
2037
|
return I.clearBuffer(), s;
|
|
@@ -2039,7 +2039,7 @@ function Us(n, t, i, e) {
|
|
|
2039
2039
|
function Ve(n, t, i, e, s = null) {
|
|
2040
2040
|
const { float32Array: r, uint16Array: o, uint32Array: f } = I;
|
|
2041
2041
|
let a = n * 2;
|
|
2042
|
-
if (s === null && (i.boundingBox || i.computeBoundingBox(),
|
|
2042
|
+
if (s === null && (i.boundingBox || i.computeBoundingBox(), Ui.set(i.boundingBox.min, i.boundingBox.max, e), s = Ui), q(a, o)) {
|
|
2043
2043
|
const l = t.geometry, p = l.index, c = l.attributes.position, d = i.index, y = i.attributes.position, g = J(n, f), x = Z(a, o);
|
|
2044
2044
|
if (Ot.copy(e).invert(), i.boundsTree)
|
|
2045
2045
|
return k(n, r, ae), ae.matrix.copy(Ot), ae.needsUpdate = !0, i.boundsTree.shapecast({
|
|
@@ -2066,12 +2066,12 @@ function Ve(n, t, i, e, s = null) {
|
|
|
2066
2066
|
return k(l, r, re), !!(s.intersectsBox(re) && Ve(l, t, i, e, s) || (k(p, r, re), s.intersectsBox(re) && Ve(p, t, i, e, s)));
|
|
2067
2067
|
}
|
|
2068
2068
|
}
|
|
2069
|
-
const ce = /* @__PURE__ */ new H(), ze = /* @__PURE__ */ new Q(), Vt = /* @__PURE__ */ new Q(),
|
|
2070
|
-
function
|
|
2069
|
+
const ce = /* @__PURE__ */ new H(), ze = /* @__PURE__ */ new Q(), Vt = /* @__PURE__ */ new Q(), Is = /* @__PURE__ */ new z(), Ds = /* @__PURE__ */ new z(), Ls = /* @__PURE__ */ new z(), ks = /* @__PURE__ */ new z();
|
|
2070
|
+
function js(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
|
|
2071
2071
|
t.boundingBox || t.computeBoundingBox(), ze.set(t.boundingBox.min, t.boundingBox.max, i), ze.needsUpdate = !0;
|
|
2072
2072
|
const f = n.geometry, a = f.attributes.position, u = f.index, l = t.attributes.position, p = t.index, c = et.getPrimitive(), d = et.getPrimitive();
|
|
2073
|
-
let y =
|
|
2074
|
-
s && (x =
|
|
2073
|
+
let y = Is, g = Ds, x = null, w = null;
|
|
2074
|
+
s && (x = Ls, w = ks);
|
|
2075
2075
|
let m = 1 / 0, h = null, b = null;
|
|
2076
2076
|
return ce.copy(i).invert(), Vt.matrix.copy(ce), n.shapecast(
|
|
2077
2077
|
{
|
|
@@ -2083,9 +2083,9 @@ function ks(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
|
|
|
2083
2083
|
boundsTraverseOrder: (T) => Vt.distanceToBox(T),
|
|
2084
2084
|
intersectsBounds: (T, R, v) => v < m && v < o,
|
|
2085
2085
|
intersectsRange: (T, R) => {
|
|
2086
|
-
for (let v = T,
|
|
2086
|
+
for (let v = T, B = T + R; v < B; v++) {
|
|
2087
2087
|
j(d, 3 * v, p, l), d.a.applyMatrix4(i), d.b.applyMatrix4(i), d.c.applyMatrix4(i), d.needsUpdate = !0;
|
|
2088
|
-
for (let S = A,
|
|
2088
|
+
for (let S = A, _ = A + P; S < _; S++) {
|
|
2089
2089
|
j(c, 3 * S, u, a), c.needsUpdate = !0;
|
|
2090
2090
|
const E = c.distanceToTriangle(d, y, x);
|
|
2091
2091
|
if (E < m && (g.copy(y), w && w.copy(x), m = E, h = S, b = v), E < r)
|
|
@@ -2098,7 +2098,7 @@ function ks(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
|
|
|
2098
2098
|
const M = Ae(t);
|
|
2099
2099
|
for (let T = 0, R = M; T < R; T++) {
|
|
2100
2100
|
j(d, 3 * T, p, l), d.a.applyMatrix4(i), d.b.applyMatrix4(i), d.c.applyMatrix4(i), d.needsUpdate = !0;
|
|
2101
|
-
for (let v = A,
|
|
2101
|
+
for (let v = A, B = A + P; v < B; v++) {
|
|
2102
2102
|
j(c, 3 * v, u, a), c.needsUpdate = !0;
|
|
2103
2103
|
const S = c.distanceToTriangle(d, y, x);
|
|
2104
2104
|
if (S < m && (g.copy(y), w && w.copy(x), m = S, h = v, b = T), S < r)
|
|
@@ -2110,7 +2110,7 @@ function ks(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
|
|
|
2110
2110
|
}
|
|
2111
2111
|
), et.releasePrimitive(c), et.releasePrimitive(d), m === 1 / 0 ? null : (e.point ? e.point.copy(g) : e.point = g.clone(), e.distance = m, e.faceIndex = h, s && (s.point ? s.point.copy(w) : s.point = w.clone(), s.point.applyMatrix4(ce), g.applyMatrix4(ce), s.distance = g.sub(s.point).length(), s.faceIndex = b), e);
|
|
2112
2112
|
}
|
|
2113
|
-
function
|
|
2113
|
+
function Cs(n, t = null) {
|
|
2114
2114
|
t && Array.isArray(t) && (t = new Set(t));
|
|
2115
2115
|
const i = n.geometry, e = i.index ? i.index.array : null, s = i.attributes.position;
|
|
2116
2116
|
let r, o, f, a, u = 0;
|
|
@@ -2124,11 +2124,11 @@ function js(n, t = null) {
|
|
|
2124
2124
|
let m = 1 / 0, h = 1 / 0, b = 1 / 0, A = -1 / 0, P = -1 / 0, M = -1 / 0;
|
|
2125
2125
|
for (let T = x, R = x + w; T < R; T++) {
|
|
2126
2126
|
const v = 3 * n.resolveTriangleIndex(T);
|
|
2127
|
-
for (let
|
|
2128
|
-
let S = v +
|
|
2127
|
+
for (let B = 0; B < 3; B++) {
|
|
2128
|
+
let S = v + B;
|
|
2129
2129
|
S = e ? e[S] : S;
|
|
2130
|
-
const
|
|
2131
|
-
|
|
2130
|
+
const _ = s.getX(S), E = s.getY(S), F = s.getZ(S);
|
|
2131
|
+
_ < m && (m = _), _ > A && (A = _), E < h && (h = E), E > P && (P = E), F < b && (b = F), F > M && (M = F);
|
|
2132
2132
|
}
|
|
2133
2133
|
}
|
|
2134
2134
|
return a[c + 0] !== m || a[c + 1] !== h || a[c + 2] !== b || a[c + 3] !== A || a[c + 4] !== P || a[c + 5] !== M ? (a[c + 0] = m, a[c + 1] = h, a[c + 2] = b, a[c + 3] = A, a[c + 4] = P, a[c + 5] = M, !0) : !1;
|
|
@@ -2137,8 +2137,8 @@ function js(n, t = null) {
|
|
|
2137
2137
|
let m = y, h = !1, b = !1;
|
|
2138
2138
|
if (t) {
|
|
2139
2139
|
if (!m) {
|
|
2140
|
-
const v = x / N + d / X,
|
|
2141
|
-
h = t.has(v), b = t.has(
|
|
2140
|
+
const v = x / N + d / X, B = w / N + d / X;
|
|
2141
|
+
h = t.has(v), b = t.has(B), m = !h && !b;
|
|
2142
2142
|
}
|
|
2143
2143
|
} else
|
|
2144
2144
|
h = !0, b = !0;
|
|
@@ -2150,21 +2150,21 @@ function js(n, t = null) {
|
|
|
2150
2150
|
const R = M || T;
|
|
2151
2151
|
if (R)
|
|
2152
2152
|
for (let v = 0; v < 3; v++) {
|
|
2153
|
-
const
|
|
2154
|
-
a[c + v] =
|
|
2153
|
+
const B = x + v, S = w + v, _ = a[B], E = a[B + 3], F = a[S], D = a[S + 3];
|
|
2154
|
+
a[c + v] = _ < F ? _ : F, a[c + v + 3] = E > D ? E : D;
|
|
2155
2155
|
}
|
|
2156
2156
|
return R;
|
|
2157
2157
|
}
|
|
2158
2158
|
}
|
|
2159
2159
|
}
|
|
2160
|
-
function
|
|
2160
|
+
function Ns(n, t, i, e, s, r, o) {
|
|
2161
2161
|
I.setBuffer(n._roots[t]), We(0, n, i, e, s, r, o), I.clearBuffer();
|
|
2162
2162
|
}
|
|
2163
2163
|
function We(n, t, i, e, s, r, o) {
|
|
2164
2164
|
const { float32Array: f, uint16Array: a, uint32Array: u } = I, l = n * 2;
|
|
2165
2165
|
if (q(l, a)) {
|
|
2166
2166
|
const c = J(n, u), d = Z(l, a);
|
|
2167
|
-
|
|
2167
|
+
Bs(t, i, e, c, d, s, r, o);
|
|
2168
2168
|
} else {
|
|
2169
2169
|
const c = V(n);
|
|
2170
2170
|
wt(c, f, e, r, o) && We(c, t, i, e, s, r, o);
|
|
@@ -2172,8 +2172,8 @@ function We(n, t, i, e, s, r, o) {
|
|
|
2172
2172
|
wt(d, f, e, r, o) && We(d, t, i, e, s, r, o);
|
|
2173
2173
|
}
|
|
2174
2174
|
}
|
|
2175
|
-
const
|
|
2176
|
-
function
|
|
2175
|
+
const qs = ["x", "y", "z"];
|
|
2176
|
+
function Os(n, t, i, e, s, r) {
|
|
2177
2177
|
I.setBuffer(n._roots[t]);
|
|
2178
2178
|
const o = Ge(0, n, i, e, s, r);
|
|
2179
2179
|
return I.clearBuffer(), o;
|
|
@@ -2185,7 +2185,7 @@ function Ge(n, t, i, e, s, r) {
|
|
|
2185
2185
|
const p = J(n, a), c = Z(u, f);
|
|
2186
2186
|
return _s(t, i, e, p, c, s, r);
|
|
2187
2187
|
} else {
|
|
2188
|
-
const p = ei(n, a), c =
|
|
2188
|
+
const p = ei(n, a), c = qs[p], y = e.direction[c] >= 0;
|
|
2189
2189
|
let g, x;
|
|
2190
2190
|
y ? (g = V(n), x = W(n, a)) : (g = W(n, a), x = V(n));
|
|
2191
2191
|
const m = wt(g, o, e, s, r) ? Ge(g, t, i, e, s, r) : null;
|
|
@@ -2201,8 +2201,8 @@ function Ge(n, t, i, e, s, r) {
|
|
|
2201
2201
|
return m && b ? m.distance <= b.distance ? m : b : m || b || null;
|
|
2202
2202
|
}
|
|
2203
2203
|
}
|
|
2204
|
-
const le = /* @__PURE__ */ new it(),
|
|
2205
|
-
function
|
|
2204
|
+
const le = /* @__PURE__ */ new it(), Ut = /* @__PURE__ */ new st(), Ft = /* @__PURE__ */ new st(), Wt = /* @__PURE__ */ new H(), Fi = /* @__PURE__ */ new Q(), ue = /* @__PURE__ */ new Q();
|
|
2205
|
+
function Vs(n, t, i, e) {
|
|
2206
2206
|
I.setBuffer(n._roots[t]);
|
|
2207
2207
|
const s = Xe(0, n, i, e);
|
|
2208
2208
|
return I.clearBuffer(), s;
|
|
@@ -2218,7 +2218,7 @@ function Xe(n, t, i, e, s = null) {
|
|
|
2218
2218
|
intersectsTriangle: (m) => {
|
|
2219
2219
|
m.a.applyMatrix4(e), m.b.applyMatrix4(e), m.c.applyMatrix4(e), m.needsUpdate = !0;
|
|
2220
2220
|
for (let h = g, b = x + g; h < b; h++)
|
|
2221
|
-
if (j(
|
|
2221
|
+
if (j(Ft, 3 * t.resolveTriangleIndex(h), p, c), Ft.needsUpdate = !0, m.intersectsTriangle(Ft))
|
|
2222
2222
|
return !0;
|
|
2223
2223
|
return !1;
|
|
2224
2224
|
}
|
|
@@ -2227,9 +2227,9 @@ function Xe(n, t, i, e, s = null) {
|
|
|
2227
2227
|
const w = Ae(i);
|
|
2228
2228
|
for (let m = g, h = x + g; m < h; m++) {
|
|
2229
2229
|
const b = t.resolveTriangleIndex(m);
|
|
2230
|
-
j(
|
|
2230
|
+
j(Ut, 3 * b, p, c), Ut.a.applyMatrix4(Wt), Ut.b.applyMatrix4(Wt), Ut.c.applyMatrix4(Wt), Ut.needsUpdate = !0;
|
|
2231
2231
|
for (let A = 0, P = w * 3; A < P; A += 3)
|
|
2232
|
-
if (j(
|
|
2232
|
+
if (j(Ft, A, d, y), Ft.needsUpdate = !0, Ut.intersectsTriangle(Ft))
|
|
2233
2233
|
return !0;
|
|
2234
2234
|
}
|
|
2235
2235
|
}
|
|
@@ -2238,16 +2238,16 @@ function Xe(n, t, i, e, s = null) {
|
|
|
2238
2238
|
return k(l, r, le), !!(s.intersectsBox(le) && Xe(l, t, i, e, s) || (k(p, r, le), s.intersectsBox(le) && Xe(p, t, i, e, s)));
|
|
2239
2239
|
}
|
|
2240
2240
|
}
|
|
2241
|
-
const fe = /* @__PURE__ */ new H(),
|
|
2242
|
-
function
|
|
2243
|
-
t.boundingBox || t.computeBoundingBox(),
|
|
2241
|
+
const fe = /* @__PURE__ */ new H(), Ue = /* @__PURE__ */ new Q(), Gt = /* @__PURE__ */ new Q(), Ws = /* @__PURE__ */ new z(), Gs = /* @__PURE__ */ new z(), Xs = /* @__PURE__ */ new z(), Js = /* @__PURE__ */ new z();
|
|
2242
|
+
function Hs(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
|
|
2243
|
+
t.boundingBox || t.computeBoundingBox(), Ue.set(t.boundingBox.min, t.boundingBox.max, i), Ue.needsUpdate = !0;
|
|
2244
2244
|
const f = n.geometry, a = f.attributes.position, u = f.index, l = t.attributes.position, p = t.index, c = et.getPrimitive(), d = et.getPrimitive();
|
|
2245
|
-
let y =
|
|
2246
|
-
s && (x =
|
|
2245
|
+
let y = Ws, g = Gs, x = null, w = null;
|
|
2246
|
+
s && (x = Xs, w = Js);
|
|
2247
2247
|
let m = 1 / 0, h = null, b = null;
|
|
2248
2248
|
return fe.copy(i).invert(), Gt.matrix.copy(fe), n.shapecast(
|
|
2249
2249
|
{
|
|
2250
|
-
boundsTraverseOrder: (A) =>
|
|
2250
|
+
boundsTraverseOrder: (A) => Ue.distanceToBox(A),
|
|
2251
2251
|
intersectsBounds: (A, P, M) => M < m && M < o ? (P && (Gt.min.copy(A.min), Gt.max.copy(A.max), Gt.needsUpdate = !0), !0) : !1,
|
|
2252
2252
|
intersectsRange: (A, P) => {
|
|
2253
2253
|
if (t.boundsTree) {
|
|
@@ -2256,14 +2256,14 @@ function Js(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
|
|
|
2256
2256
|
boundsTraverseOrder: (T) => Gt.distanceToBox(T),
|
|
2257
2257
|
intersectsBounds: (T, R, v) => v < m && v < o,
|
|
2258
2258
|
intersectsRange: (T, R) => {
|
|
2259
|
-
for (let v = T,
|
|
2259
|
+
for (let v = T, B = T + R; v < B; v++) {
|
|
2260
2260
|
const S = M.resolveTriangleIndex(v);
|
|
2261
2261
|
j(d, 3 * S, p, l), d.a.applyMatrix4(i), d.b.applyMatrix4(i), d.c.applyMatrix4(i), d.needsUpdate = !0;
|
|
2262
|
-
for (let
|
|
2263
|
-
const
|
|
2264
|
-
j(c, 3 *
|
|
2262
|
+
for (let _ = A, E = A + P; _ < E; _++) {
|
|
2263
|
+
const F = n.resolveTriangleIndex(_);
|
|
2264
|
+
j(c, 3 * F, u, a), c.needsUpdate = !0;
|
|
2265
2265
|
const D = c.distanceToTriangle(d, y, x);
|
|
2266
|
-
if (D < m && (g.copy(y), w && w.copy(x), m = D, h =
|
|
2266
|
+
if (D < m && (g.copy(y), w && w.copy(x), m = D, h = _, b = v), D < r)
|
|
2267
2267
|
return !0;
|
|
2268
2268
|
}
|
|
2269
2269
|
}
|
|
@@ -2273,11 +2273,11 @@ function Js(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
|
|
|
2273
2273
|
const M = Ae(t);
|
|
2274
2274
|
for (let T = 0, R = M; T < R; T++) {
|
|
2275
2275
|
j(d, 3 * T, p, l), d.a.applyMatrix4(i), d.b.applyMatrix4(i), d.c.applyMatrix4(i), d.needsUpdate = !0;
|
|
2276
|
-
for (let v = A,
|
|
2276
|
+
for (let v = A, B = A + P; v < B; v++) {
|
|
2277
2277
|
const S = n.resolveTriangleIndex(v);
|
|
2278
2278
|
j(c, 3 * S, u, a), c.needsUpdate = !0;
|
|
2279
|
-
const
|
|
2280
|
-
if (
|
|
2279
|
+
const _ = c.distanceToTriangle(d, y, x);
|
|
2280
|
+
if (_ < m && (g.copy(y), w && w.copy(x), m = _, h = v, b = T), _ < r)
|
|
2281
2281
|
return !0;
|
|
2282
2282
|
}
|
|
2283
2283
|
}
|
|
@@ -2286,11 +2286,11 @@ function Js(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
|
|
|
2286
2286
|
}
|
|
2287
2287
|
), et.releasePrimitive(c), et.releasePrimitive(d), m === 1 / 0 ? null : (e.point ? e.point.copy(g) : e.point = g.clone(), e.distance = m, e.faceIndex = h, s && (s.point ? s.point.copy(w) : s.point = w.clone(), s.point.applyMatrix4(fe), g.applyMatrix4(fe), s.distance = g.sub(s.point).length(), s.faceIndex = b), e);
|
|
2288
2288
|
}
|
|
2289
|
-
function
|
|
2289
|
+
function $i(n, t, i) {
|
|
2290
2290
|
return n === null ? null : (n.point.applyMatrix4(t.matrixWorld), n.distance = n.point.distanceTo(i.ray.origin), n.object = t, n);
|
|
2291
2291
|
}
|
|
2292
|
-
const de = /* @__PURE__ */ new Q(), pe = /* @__PURE__ */ new
|
|
2293
|
-
class be extends
|
|
2292
|
+
const de = /* @__PURE__ */ new Q(), pe = /* @__PURE__ */ new Sn(), Ii = /* @__PURE__ */ new z(), Di = /* @__PURE__ */ new H(), Li = /* @__PURE__ */ new z(), Fe = ["getX", "getY", "getZ"];
|
|
2293
|
+
class be extends ys {
|
|
2294
2294
|
static serialize(t, i = {}) {
|
|
2295
2295
|
i = {
|
|
2296
2296
|
cloneBuffers: !0,
|
|
@@ -2318,7 +2318,7 @@ class be extends hs {
|
|
|
2318
2318
|
if (f._roots = r, f._indirectBuffer = o || null, e.setIndex) {
|
|
2319
2319
|
const u = i.getIndex();
|
|
2320
2320
|
if (u === null) {
|
|
2321
|
-
const l = new
|
|
2321
|
+
const l = new Oi(t.index, 1, !1);
|
|
2322
2322
|
i.setIndex(l);
|
|
2323
2323
|
} else u.array !== s && (u.array.set(s), u.needsUpdate = !0);
|
|
2324
2324
|
}
|
|
@@ -2355,7 +2355,7 @@ class be extends hs {
|
|
|
2355
2355
|
let l = u + 0, p = u + 1, c = u + 2;
|
|
2356
2356
|
f && (l = f[l], p = f[p], c = f[c]);
|
|
2357
2357
|
for (let d = 0; d < 3; d++) {
|
|
2358
|
-
const y = o[
|
|
2358
|
+
const y = o[Fe[d]](l), g = o[Fe[d]](p), x = o[Fe[d]](c);
|
|
2359
2359
|
let w = y;
|
|
2360
2360
|
g < w && (w = g), x < w && (w = x);
|
|
2361
2361
|
let m = y;
|
|
@@ -2384,10 +2384,10 @@ class be extends hs {
|
|
|
2384
2384
|
a ? (M = o[c[P]](h), T = o[c[P]](b), R = o[c[P]](A)) : (M = u[h + P], T = u[b + P], R = u[A + P]);
|
|
2385
2385
|
let v = M;
|
|
2386
2386
|
T < v && (v = T), R < v && (v = R);
|
|
2387
|
-
let
|
|
2388
|
-
T >
|
|
2389
|
-
const S = (
|
|
2390
|
-
e[m +
|
|
2387
|
+
let B = M;
|
|
2388
|
+
T > B && (B = T), R > B && (B = R);
|
|
2389
|
+
const S = (B - v) / 2, _ = P * 2;
|
|
2390
|
+
e[m + _ + 0] = v + S, e[m + _ + 1] = S + (Math.abs(v) + S) * ye;
|
|
2391
2391
|
}
|
|
2392
2392
|
}
|
|
2393
2393
|
return e;
|
|
@@ -2396,34 +2396,34 @@ class be extends hs {
|
|
|
2396
2396
|
const { material: s } = t;
|
|
2397
2397
|
if (s === void 0)
|
|
2398
2398
|
return;
|
|
2399
|
-
|
|
2400
|
-
const r =
|
|
2399
|
+
Di.copy(t.matrixWorld).invert(), pe.copy(i.ray).applyMatrix4(Di), Li.setFromMatrixScale(t.matrixWorld), Ii.copy(pe.direction).multiply(Li);
|
|
2400
|
+
const r = Ii.length(), o = i.near / r, f = i.far / r;
|
|
2401
2401
|
if (i.firstHitOnly === !0) {
|
|
2402
2402
|
let a = this.raycastFirst(pe, s, o, f);
|
|
2403
|
-
a =
|
|
2403
|
+
a = $i(a, t, i), a && e.push(a);
|
|
2404
2404
|
} else {
|
|
2405
2405
|
const a = this.raycast(pe, s, o, f);
|
|
2406
2406
|
for (let u = 0, l = a.length; u < l; u++) {
|
|
2407
|
-
const p =
|
|
2407
|
+
const p = $i(a[u], t, i);
|
|
2408
2408
|
p && e.push(p);
|
|
2409
2409
|
}
|
|
2410
2410
|
}
|
|
2411
2411
|
return e;
|
|
2412
2412
|
}
|
|
2413
2413
|
refit(t = null) {
|
|
2414
|
-
return (this.indirect ?
|
|
2414
|
+
return (this.indirect ? Cs : Rs)(this, t);
|
|
2415
2415
|
}
|
|
2416
2416
|
/* Core Cast Functions */
|
|
2417
|
-
raycast(t, i =
|
|
2418
|
-
const r = this._roots, o = [], f = this.indirect ?
|
|
2417
|
+
raycast(t, i = fi, e = 0, s = 1 / 0) {
|
|
2418
|
+
const r = this._roots, o = [], f = this.indirect ? Ns : zs;
|
|
2419
2419
|
for (let a = 0, u = r.length; a < u; a++)
|
|
2420
2420
|
f(this, a, i, t, o, e, s);
|
|
2421
2421
|
return o;
|
|
2422
2422
|
}
|
|
2423
|
-
raycastFirst(t, i =
|
|
2423
|
+
raycastFirst(t, i = fi, e = 0, s = 1 / 0) {
|
|
2424
2424
|
const r = this._roots;
|
|
2425
2425
|
let o = null;
|
|
2426
|
-
const f = this.indirect ?
|
|
2426
|
+
const f = this.indirect ? Os : Fs;
|
|
2427
2427
|
for (let a = 0, u = r.length; a < u; a++) {
|
|
2428
2428
|
const l = f(this, a, i, t, e, s);
|
|
2429
2429
|
l != null && (o == null || l.distance < o.distance) && (o = l);
|
|
@@ -2432,7 +2432,7 @@ class be extends hs {
|
|
|
2432
2432
|
}
|
|
2433
2433
|
intersectsGeometry(t, i) {
|
|
2434
2434
|
let e = !1;
|
|
2435
|
-
const s = this._roots, r = this.indirect ?
|
|
2435
|
+
const s = this._roots, r = this.indirect ? Vs : $s;
|
|
2436
2436
|
for (let o = 0, f = s.length; o < f && (e = r(this, o, t, i), !e); o++)
|
|
2437
2437
|
;
|
|
2438
2438
|
return e;
|
|
@@ -2445,7 +2445,7 @@ class be extends hs {
|
|
|
2445
2445
|
scratchPrimitive: i,
|
|
2446
2446
|
// TODO: is the performance significant enough for the added complexity here?
|
|
2447
2447
|
// can we just use one function?
|
|
2448
|
-
iterate: this.indirect ?
|
|
2448
|
+
iterate: this.indirect ? Es : Ts
|
|
2449
2449
|
}
|
|
2450
2450
|
);
|
|
2451
2451
|
return et.releasePrimitive(i), e;
|
|
@@ -2506,7 +2506,7 @@ class be extends hs {
|
|
|
2506
2506
|
);
|
|
2507
2507
|
}
|
|
2508
2508
|
closestPointToGeometry(t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
|
|
2509
|
-
return (this.indirect ?
|
|
2509
|
+
return (this.indirect ? Hs : js)(
|
|
2510
2510
|
this,
|
|
2511
2511
|
t,
|
|
2512
2512
|
i,
|
|
@@ -2517,7 +2517,7 @@ class be extends hs {
|
|
|
2517
2517
|
);
|
|
2518
2518
|
}
|
|
2519
2519
|
closestPointToPoint(t, i = {}, e = 0, s = 1 / 0) {
|
|
2520
|
-
return
|
|
2520
|
+
return As(
|
|
2521
2521
|
this,
|
|
2522
2522
|
t,
|
|
2523
2523
|
i,
|
|
@@ -2530,13 +2530,13 @@ const It = {
|
|
|
2530
2530
|
Mesh: C.prototype.raycast,
|
|
2531
2531
|
Line: Ye.prototype.raycast,
|
|
2532
2532
|
LineSegments: Qe.prototype.raycast,
|
|
2533
|
-
LineLoop:
|
|
2534
|
-
Points:
|
|
2535
|
-
BatchedMesh:
|
|
2533
|
+
LineLoop: Gi.prototype.raycast,
|
|
2534
|
+
Points: Xi.prototype.raycast,
|
|
2535
|
+
BatchedMesh: Rn.prototype.raycast
|
|
2536
2536
|
}, G = /* @__PURE__ */ new C(), me = [];
|
|
2537
|
-
function
|
|
2537
|
+
function Zs(n, t) {
|
|
2538
2538
|
if (this.isBatchedMesh)
|
|
2539
|
-
|
|
2539
|
+
Qs.call(this, n, t);
|
|
2540
2540
|
else {
|
|
2541
2541
|
const { geometry: i } = this;
|
|
2542
2542
|
if (i.boundsTree)
|
|
@@ -2547,11 +2547,11 @@ function Hs(n, t) {
|
|
|
2547
2547
|
e = It.Mesh;
|
|
2548
2548
|
else if (this instanceof Qe)
|
|
2549
2549
|
e = It.LineSegments;
|
|
2550
|
-
else if (this instanceof
|
|
2550
|
+
else if (this instanceof Gi)
|
|
2551
2551
|
e = It.LineLoop;
|
|
2552
2552
|
else if (this instanceof Ye)
|
|
2553
2553
|
e = It.Line;
|
|
2554
|
-
else if (this instanceof
|
|
2554
|
+
else if (this instanceof Xi)
|
|
2555
2555
|
e = It.Points;
|
|
2556
2556
|
else
|
|
2557
2557
|
throw new Error("BVH: Fallback raycast function not found.");
|
|
@@ -2559,12 +2559,12 @@ function Hs(n, t) {
|
|
|
2559
2559
|
}
|
|
2560
2560
|
}
|
|
2561
2561
|
}
|
|
2562
|
-
function
|
|
2562
|
+
function Qs(n, t) {
|
|
2563
2563
|
if (this.boundsTrees) {
|
|
2564
2564
|
const i = this.boundsTrees, e = this._drawInfo || this._instanceInfo, s = this._drawRanges || this._geometryInfo, r = this.matrixWorld;
|
|
2565
2565
|
G.material = this.material, G.geometry = this.geometry;
|
|
2566
2566
|
const o = G.geometry.boundsTree, f = G.geometry.drawRange;
|
|
2567
|
-
G.geometry.boundingSphere === null && (G.geometry.boundingSphere = new
|
|
2567
|
+
G.geometry.boundingSphere === null && (G.geometry.boundingSphere = new Tn());
|
|
2568
2568
|
for (let a = 0, u = e.length; a < u; a++) {
|
|
2569
2569
|
if (!this.getVisibleAt(a))
|
|
2570
2570
|
continue;
|
|
@@ -2588,7 +2588,7 @@ function Zs(n, t) {
|
|
|
2588
2588
|
function $e(n) {
|
|
2589
2589
|
return n.type === "continuous" || !n.limits ? 0 : Math.max(n.limits.lower, Math.min(n.limits.upper, 0));
|
|
2590
2590
|
}
|
|
2591
|
-
class
|
|
2591
|
+
class Ys {
|
|
2592
2592
|
constructor(t, i) {
|
|
2593
2593
|
$(this, "root");
|
|
2594
2594
|
$(this, "visual");
|
|
@@ -2637,7 +2637,7 @@ class Qs {
|
|
|
2637
2637
|
y && (this.root.add(y), p(d.id));
|
|
2638
2638
|
}
|
|
2639
2639
|
if (o.length === 1) {
|
|
2640
|
-
const d =
|
|
2640
|
+
const d = Zi(t, o[0].id, f), y = i.bindings.get(o[0].id);
|
|
2641
2641
|
y && d > 0 && (y.position.z += d);
|
|
2642
2642
|
}
|
|
2643
2643
|
for (const d of i.bindings.values()) d.parent === this.root && this.initialRoots.set(d, { position: d.position.clone(), quaternion: d.quaternion.clone() });
|
|
@@ -2707,7 +2707,7 @@ class Qs {
|
|
|
2707
2707
|
const i = t.geometry;
|
|
2708
2708
|
delete i.boundsTree;
|
|
2709
2709
|
}
|
|
2710
|
-
this.pickMeshes.length = 0,
|
|
2710
|
+
this.pickMeshes.length = 0, ft(this.root);
|
|
2711
2711
|
}
|
|
2712
2712
|
}
|
|
2713
2713
|
applyAll() {
|
|
@@ -2720,7 +2720,7 @@ class Qs {
|
|
|
2720
2720
|
this.root.traverse((i) => {
|
|
2721
2721
|
if (!(i instanceof C) || !i.geometry) return;
|
|
2722
2722
|
const e = i.geometry;
|
|
2723
|
-
!e.boundsTree && !t.has(e) && (e.boundsTree = new be(e, { maxLeafSize: 20, indirect: !0, verbose: !1 }), t.add(e)), i.raycast =
|
|
2723
|
+
!e.boundsTree && !t.has(e) && (e.boundsTree = new be(e, { maxLeafSize: 20, indirect: !0, verbose: !1 }), t.add(e)), i.raycast = Zs, this.pickMeshes.push(i);
|
|
2724
2724
|
});
|
|
2725
2725
|
}
|
|
2726
2726
|
apply(t, i) {
|
|
@@ -2730,9 +2730,9 @@ class Qs {
|
|
|
2730
2730
|
function Xt(n, t) {
|
|
2731
2731
|
return Object.assign(new Error(n), { code: t });
|
|
2732
2732
|
}
|
|
2733
|
-
function
|
|
2733
|
+
function Ks(n, t, i = n.source.uri) {
|
|
2734
2734
|
var m;
|
|
2735
|
-
const e =
|
|
2735
|
+
const e = no(t, i), s = new Set(n.links.map((h) => h.id)), r = n.joints.filter((h) => s.has(h.parent) && s.has(h.child) && h.parent !== h.child), o = /* @__PURE__ */ new Map();
|
|
2736
2736
|
for (const h of r) o.has(h.child) || o.set(h.child, h);
|
|
2737
2737
|
const f = n.links.filter((h) => !o.has(h.id)), a = /* @__PURE__ */ new Map();
|
|
2738
2738
|
for (const h of o.values()) a.set(h.parent, [...a.get(h.parent) ?? [], h]);
|
|
@@ -2756,19 +2756,19 @@ function Ys(n, t, i = n.source.uri) {
|
|
|
2756
2756
|
source: e.robot
|
|
2757
2757
|
});
|
|
2758
2758
|
g.push(x);
|
|
2759
|
-
for (const h of n.links) g.push(
|
|
2759
|
+
for (const h of n.links) g.push(to(h, n, e.links.get(h.id), y, c, o));
|
|
2760
2760
|
const w = xe(n.joints);
|
|
2761
|
-
for (const h of n.joints) g.push(
|
|
2761
|
+
for (const h of n.joints) g.push(eo({ ...h, controlLimits: w.get(h.id) }, e.joints.get(h.id), ((m = o.get(h.child)) == null ? void 0 : m.id) === h.id));
|
|
2762
2762
|
return Object.freeze({
|
|
2763
2763
|
robotName: n.name,
|
|
2764
2764
|
sourcePath: i,
|
|
2765
2765
|
sourceText: t,
|
|
2766
2766
|
nodes: Object.freeze(g),
|
|
2767
2767
|
rootEntityId: d,
|
|
2768
|
-
issues: Object.freeze(
|
|
2768
|
+
issues: Object.freeze(io(n, e))
|
|
2769
2769
|
});
|
|
2770
2770
|
}
|
|
2771
|
-
function
|
|
2771
|
+
function to(n, t, i, e, s, r) {
|
|
2772
2772
|
var f, a, u, l;
|
|
2773
2773
|
const o = r.get(n.id);
|
|
2774
2774
|
return Object.freeze({
|
|
@@ -2787,7 +2787,7 @@ function Ks(n, t, i, e, s, r) {
|
|
|
2787
2787
|
collisionCount: n.collisions.length
|
|
2788
2788
|
});
|
|
2789
2789
|
}
|
|
2790
|
-
function
|
|
2790
|
+
function eo(n, t, i) {
|
|
2791
2791
|
return Object.freeze({
|
|
2792
2792
|
id: `joint:${n.id}`,
|
|
2793
2793
|
kind: "joint",
|
|
@@ -2809,7 +2809,7 @@ function to(n, t, i) {
|
|
|
2809
2809
|
...n.mimic ? { mimic: Object.freeze({ ...n.mimic }) } : {}
|
|
2810
2810
|
});
|
|
2811
2811
|
}
|
|
2812
|
-
function
|
|
2812
|
+
function io(n, t) {
|
|
2813
2813
|
const i = [], e = (c, d, y, g, x, w) => {
|
|
2814
2814
|
i.push(Object.freeze({ id: `${c}:${g}`, ruleId: c, severity: "error", title: d, message: y, entityId: g, source: x, values: w ? Object.freeze(w) : void 0 }));
|
|
2815
2815
|
}, s = new Set(n.links.map((c) => c.id));
|
|
@@ -2848,35 +2848,35 @@ function eo(n, t) {
|
|
|
2848
2848
|
for (const [c, d] of p) d.length > 1 && e("link.multiple-parents", "连杆存在多个父关节", `${c} 同时被 ${d.join("、")} 作为 child。`, `link:${c}`, t.links.get(c), { joints: d });
|
|
2849
2849
|
for (const c of n.links) {
|
|
2850
2850
|
const d = c.inertial;
|
|
2851
|
-
d && ((!(d.mass > 0) || !Number.isFinite(d.mass)) && e("inertial.mass.invalid", "质量无效", `${c.id} 的质量必须是大于零的有限数。`, `link:${c.id}`, t.links.get(c.id), { mass: d.mass }),
|
|
2851
|
+
d && ((!(d.mass > 0) || !Number.isFinite(d.mass)) && e("inertial.mass.invalid", "质量无效", `${c.id} 的质量必须是大于零的有限数。`, `link:${c.id}`, t.links.get(c.id), { mass: d.mass }), Hi(d.tensor) || e("inertial.tensor.invalid", "惯性张量无效", `${c.id} 的惯性张量不是正定的物理惯性张量。`, `link:${c.id}`, t.links.get(c.id), { tensor: d.tensor }));
|
|
2852
2852
|
}
|
|
2853
2853
|
return i;
|
|
2854
2854
|
}
|
|
2855
|
-
function
|
|
2855
|
+
function no(n, t) {
|
|
2856
2856
|
const i = { robot: void 0, links: /* @__PURE__ */ new Map(), joints: /* @__PURE__ */ new Map() };
|
|
2857
|
-
i.robot =
|
|
2857
|
+
i.robot = ki(n, "robot", void 0, t);
|
|
2858
2858
|
for (const e of ["link", "joint"]) {
|
|
2859
2859
|
const s = new RegExp(`<${e}\\b[^>]*\\bname\\s*=\\s*(["'])(.*?)\\1[^>]*>`, "gi");
|
|
2860
2860
|
for (const r of n.matchAll(s)) {
|
|
2861
|
-
const o = r[2], f =
|
|
2861
|
+
const o = r[2], f = ki(n, e, o, t, r.index);
|
|
2862
2862
|
f && i[e === "link" ? "links" : "joints"].set(o, f);
|
|
2863
2863
|
}
|
|
2864
2864
|
}
|
|
2865
2865
|
return i;
|
|
2866
2866
|
}
|
|
2867
|
-
function
|
|
2867
|
+
function ki(n, t, i, e, s) {
|
|
2868
2868
|
const r = s ?? n.search(new RegExp(`<${t}\\b`, "i"));
|
|
2869
2869
|
if (r < 0) return;
|
|
2870
2870
|
const o = n.indexOf(">", r);
|
|
2871
2871
|
if (o < 0) return;
|
|
2872
|
-
const a = n.slice(r, o + 1).trimEnd().endsWith("/>") ? o + 1 : n.indexOf(`</${t}>`, o + 1), u = a < 0 ? o + 1 : a + t.length + 3, l =
|
|
2872
|
+
const a = n.slice(r, o + 1).trimEnd().endsWith("/>") ? o + 1 : n.indexOf(`</${t}>`, o + 1), u = a < 0 ? o + 1 : a + t.length + 3, l = ji(n, r), p = ji(n, u);
|
|
2873
2873
|
return Object.freeze({ file: e, startOffset: r, endOffset: u, startLine: l.line, startColumn: l.column, endLine: p.line, endColumn: p.column });
|
|
2874
2874
|
}
|
|
2875
|
-
function
|
|
2875
|
+
function ji(n, t) {
|
|
2876
2876
|
const e = n.slice(0, t).split(/\r?\n/);
|
|
2877
2877
|
return { line: e.length, column: e.at(-1).length + 1 };
|
|
2878
2878
|
}
|
|
2879
|
-
class
|
|
2879
|
+
class so {
|
|
2880
2880
|
constructor(t, i, e, s, r) {
|
|
2881
2881
|
$(this, "kind", "urdf");
|
|
2882
2882
|
$(this, "overlayRoot", new ut());
|
|
@@ -2922,7 +2922,7 @@ class no {
|
|
|
2922
2922
|
}
|
|
2923
2923
|
select(t) {
|
|
2924
2924
|
if (!(this.mode === "dynamics-running" || this.mode === "dynamics-initializing")) {
|
|
2925
|
-
if (t !== null && !this.document.nodes.some((i) => i.id === t)) throw
|
|
2925
|
+
if (t !== null && !this.document.nodes.some((i) => i.id === t)) throw oo(`Unknown URDF entity: ${t}`, "E_URDF_ENTITY_UNKNOWN");
|
|
2926
2926
|
this.selectedEntityId !== t && (this.selectedEntityId = t, this.rebuildOverlay(), this.publish());
|
|
2927
2927
|
}
|
|
2928
2928
|
}
|
|
@@ -2958,7 +2958,7 @@ class no {
|
|
|
2958
2958
|
if (!this.disposed) {
|
|
2959
2959
|
this.disposed = !0, this.listeners.clear(), this.restoreSelectionMaterials();
|
|
2960
2960
|
for (const t of this.selectionMaterials.values()) t.dispose();
|
|
2961
|
-
this.selectionMaterials.clear(),
|
|
2961
|
+
this.selectionMaterials.clear(), ft(this.overlayRoot), this.overlayRoot.removeFromParent();
|
|
2962
2962
|
}
|
|
2963
2963
|
}
|
|
2964
2964
|
publish() {
|
|
@@ -2996,7 +2996,7 @@ class no {
|
|
|
2996
2996
|
this.guideBindings.push({ guide: t, source: i, local: e });
|
|
2997
2997
|
}
|
|
2998
2998
|
clearGuides() {
|
|
2999
|
-
this.guideBindings.length = 0,
|
|
2999
|
+
this.guideBindings.length = 0, ft(this.overlayRoot), this.overlayRoot.clear();
|
|
3000
3000
|
}
|
|
3001
3001
|
/** Cache own-link bounds once; exclude child links and never traverse meshes per physics tick. */
|
|
3002
3002
|
measureGuideSizes() {
|
|
@@ -3040,16 +3040,16 @@ class no {
|
|
|
3040
3040
|
if (!r) continue;
|
|
3041
3041
|
const o = new ut();
|
|
3042
3042
|
o.name = `Joint guide:${e.name}`;
|
|
3043
|
-
const f = this.guideSize(e.childLink), a = new
|
|
3043
|
+
const f = this.guideSize(e.childLink), a = new Bn(0.18 * f);
|
|
3044
3044
|
if (a.name = `Joint frame:${e.name}`, a.position.copy(r.position), a.quaternion.copy(r.quaternion), o.add(a), ["revolute", "continuous", "prismatic"].includes(e.jointType)) {
|
|
3045
|
-
const u = r.axis.clone().normalize(), l = new
|
|
3045
|
+
const u = r.axis.clone().normalize(), l = new di(u, r.position, 0.28 * f, 5625523, 0.045 * f, 0.022 * f);
|
|
3046
3046
|
if (l.name = `Joint axis:${e.name}`, o.add(l), e.jointType !== "prismatic") {
|
|
3047
3047
|
const c = (Math.abs(u.z) < 0.9 ? new z(0, 0, 1) : new z(0, 1, 0)).cross(u).normalize(), d = u.clone().cross(c).normalize(), y = 0.09 * f, g = Math.PI * 1.65, x = r.position.clone().addScaledVector(u, 0.085 * f), w = Array.from({ length: 33 }, (A, P) => {
|
|
3048
3048
|
const M = g * P / 32;
|
|
3049
3049
|
return x.clone().addScaledVector(c, y * Math.cos(M)).addScaledVector(d, y * Math.sin(M));
|
|
3050
|
-
}), m = new Ye(new
|
|
3050
|
+
}), m = new Ye(new _n().setFromPoints(w), new pi({ color: 16761963 }));
|
|
3051
3051
|
m.name = `Positive rotation:${e.name}`;
|
|
3052
|
-
const h = c.clone().multiplyScalar(-Math.sin(g)).addScaledVector(d, Math.cos(g)), b = new
|
|
3052
|
+
const h = c.clone().multiplyScalar(-Math.sin(g)).addScaledVector(d, Math.cos(g)), b = new di(h, w[32], 0.03 * f, 16761963, 0.03 * f, 0.022 * f);
|
|
3053
3053
|
b.name = `Positive rotation arrow:${e.name}`, o.add(m, b);
|
|
3054
3054
|
}
|
|
3055
3055
|
}
|
|
@@ -3080,13 +3080,13 @@ class no {
|
|
|
3080
3080
|
const P = h * b * A >= 0 ? 1 : 0.015;
|
|
3081
3081
|
for (let M = 0; M < 9; M++) x[m * 3 + M] = P;
|
|
3082
3082
|
}
|
|
3083
|
-
y.setAttribute("color", new
|
|
3084
|
-
const w = new C(y, new
|
|
3083
|
+
y.setAttribute("color", new En(x, 3));
|
|
3084
|
+
const w = new C(y, new mi({ color: f ? 16739210 : 16777215, vertexColors: !0, depthTest: !1, depthWrite: !1 }));
|
|
3085
3085
|
w.quaternion.copy(r.getWorldQuaternion(new K())), w.position.copy(o), w.renderOrder = 1002, w.name = `Center of mass:${e.id}`, this.overlayRoot.add(w), this.trackGuide(w, r);
|
|
3086
3086
|
}
|
|
3087
|
-
const a = this.overlays.inertia ?
|
|
3087
|
+
const a = this.overlays.inertia ? jn(s.tensor, s.mass) : null;
|
|
3088
3088
|
if (!a) continue;
|
|
3089
|
-
const u = new He(1, 1, 1), l = new Qe(new
|
|
3089
|
+
const u = new He(1, 1, 1), l = new Qe(new zn(u), new pi({ color: f ? 16736135 : 2211300, transparent: !0, opacity: f ? 0.98 : 0.82, depthTest: !0, depthWrite: !1 })), p = new C(u, new mi({ color: f ? 16739210 : 3262699, transparent: !0, opacity: f ? 0.28 : 0.16, depthTest: !0, depthWrite: !1 }));
|
|
3090
3090
|
p.name = `Inertia fill:${e.id}`;
|
|
3091
3091
|
const c = s.origin.rotationQuaternion ? new K().fromArray(s.origin.rotationQuaternion) : new K().setFromEuler(new Zt(...s.origin.rotationRpy, "ZYX"));
|
|
3092
3092
|
l.position.copy(o), l.scale.fromArray(a.size), l.quaternion.copy(r.getWorldQuaternion(new K())).multiply(c).multiply(a.rotation), l.renderOrder = 1001, l.name = `Inertia:${e.id}`, p.position.copy(l.position), p.quaternion.copy(l.quaternion), p.scale.copy(l.scale), p.renderOrder = 1e3, this.overlayRoot.add(p, l), this.trackGuide(p, r), this.trackGuide(l, r);
|
|
@@ -3113,61 +3113,61 @@ class no {
|
|
|
3113
3113
|
this.highlightedMaterials.clear();
|
|
3114
3114
|
}
|
|
3115
3115
|
}
|
|
3116
|
-
function
|
|
3116
|
+
function oo(n, t) {
|
|
3117
3117
|
return Object.assign(new Error(n), { code: t });
|
|
3118
3118
|
}
|
|
3119
|
-
async function
|
|
3120
|
-
var
|
|
3119
|
+
async function yo(n, t, i) {
|
|
3120
|
+
var _, E, F, D;
|
|
3121
3121
|
const e = n.entryPath ?? n.filename ?? "asset.urdf";
|
|
3122
|
-
(
|
|
3123
|
-
let s = await
|
|
3122
|
+
(_ = t.reportProgress) == null || _.call(t, "fetch", "正在读取模型描述与依赖资源...");
|
|
3123
|
+
let s = await hn(n, i);
|
|
3124
3124
|
const r = t.format === "xacro";
|
|
3125
3125
|
if (r) {
|
|
3126
3126
|
(E = t.reportProgress) == null || E.call(t, "xacro", "正在展开 Xacro 宏与依赖文件...");
|
|
3127
|
-
const { expandXacro:
|
|
3128
|
-
s = await
|
|
3127
|
+
const { expandXacro: U } = await import("./xacro-D8OfZ2xw.js");
|
|
3128
|
+
s = await U(s, e, i, t.options.xacro, t.signal);
|
|
3129
3129
|
}
|
|
3130
3130
|
if (t.signal.aborted) throw Jt();
|
|
3131
|
-
(
|
|
3132
|
-
const o =
|
|
3131
|
+
(F = t.reportProgress) == null || F.call(t, "parse", "正在解析 URDF 结构与连杆...");
|
|
3132
|
+
const o = Cn(s, e, i);
|
|
3133
3133
|
(D = t.reportProgress) == null || D.call(t, "visual", "正在构建运动学预览...");
|
|
3134
|
-
const f = await
|
|
3134
|
+
const f = await gi(o), a = new Ys(o, f), u = await Vn(o, f), l = o.diagnostics.errors.find((U) => U.code === "E_URDF_INERTIA"), p = o.links.some((U) => U.inertial), c = p && !l, d = new gn(a.root, t.options.simulationTheme, void 0);
|
|
3135
3135
|
u && (u.root.visible = !1, d.attachAuxiliary(u.root));
|
|
3136
3136
|
let y = null, g = null, x = null;
|
|
3137
3137
|
const w = o.diagnostics.warnings[0], m = w ? { ...w, stage: "visual-material" } : null;
|
|
3138
3138
|
let h = l ? { code: l.code, message: l.message, stage: "physics-validation" } : m, b = l ? { status: "unavailable", issue: h } : p ? { status: "available" } : { status: "not-authored" }, A = !1, P = null, M = !1, T = !1;
|
|
3139
3139
|
const R = () => {
|
|
3140
3140
|
var L;
|
|
3141
|
-
const
|
|
3142
|
-
A = !1, d.setRuntime(void 0), g && (g.root.visible = !1), d.replaceModel(a.root, !1), a.root.visible = !0, u && u.sync(), u != null && u.root && (u.root.visible = v.getSnapshot().overlays.collision), x && (x.root.visible = !1),
|
|
3143
|
-
}, v = new
|
|
3141
|
+
const U = A || !a.root.visible;
|
|
3142
|
+
A = !1, d.setRuntime(void 0), g && (g.root.visible = !1), d.replaceModel(a.root, !1), a.root.visible = !0, u && u.sync(), u != null && u.root && (u.root.visible = v.getSnapshot().overlays.collision), x && (x.root.visible = !1), U && ((L = t.reportSessionState) == null || L.call(t)), t.requestRender();
|
|
3143
|
+
}, v = new so(o, Ks(o, s, r ? `${e} (expanded URDF)` : e), a, {
|
|
3144
3144
|
requestRender() {
|
|
3145
3145
|
a.root.visible && (u == null || u.sync()), t.requestRender();
|
|
3146
3146
|
},
|
|
3147
|
-
setCollisionVisible(
|
|
3148
|
-
u && (u.root.visible =
|
|
3147
|
+
setCollisionVisible(U) {
|
|
3148
|
+
u && (u.root.visible = U && a.root.visible), x && (x.root.visible = U && (g == null ? void 0 : g.root.visible) === !0);
|
|
3149
3149
|
},
|
|
3150
3150
|
enterKinematicPreview: R,
|
|
3151
|
-
linkObject: (
|
|
3151
|
+
linkObject: (U) => g != null && g.root.visible ? g.objectForLink(U) : a.objectForEntity(`link:${U}`),
|
|
3152
3152
|
pickRoots: () => A || b.status === "initializing" ? [] : a.pickRoots()
|
|
3153
3153
|
}, c);
|
|
3154
3154
|
l && v.setMode("dynamics-unavailable", l.message), d.attachAuxiliary(v.overlayRoot);
|
|
3155
|
-
const
|
|
3155
|
+
const B = () => !y || !g ? !1 : (y.setJointValues(v.getSnapshot().jointValues), d.replaceModel(g.root, !1), d.setRuntime(y), g.sync(), x == null || x.sync(), a.root.visible = !1, g.root.visible = !0, u && (u.root.visible = !1), x && (x.root.visible = v.getSnapshot().overlays.collision), !0), S = async () => {
|
|
3156
3156
|
var Mt, vt, Pt;
|
|
3157
3157
|
if (y || M || !c) return;
|
|
3158
3158
|
v.setMode("dynamics-initializing"), b = { status: "initializing" }, (Mt = t.reportSessionState) == null || Mt.call(t);
|
|
3159
|
-
let
|
|
3159
|
+
let U = null, L = null, Y = null;
|
|
3160
3160
|
try {
|
|
3161
|
-
const rt = await
|
|
3161
|
+
const rt = await On(o);
|
|
3162
3162
|
if (t.signal.aborted || M) throw Jt();
|
|
3163
|
-
const kt = await import("./mujoco-runtime-
|
|
3164
|
-
if (
|
|
3165
|
-
const at = await
|
|
3166
|
-
if (Y = at ? new ai(
|
|
3167
|
-
y =
|
|
3163
|
+
const kt = await import("./mujoco-runtime-7xiBQNJm.js");
|
|
3164
|
+
if (U = new kt.MujocoRuntime(), await U.initialize(rt, t.options.mujocoBaseUrl), U.setWorldRotation(ci(d.getUpAxis())), t.signal.aborted || M || (L = new ai(U, await gi(o)), t.signal.aborted || M)) throw Jt();
|
|
3165
|
+
const at = await Qi(o);
|
|
3166
|
+
if (Y = at ? new ai(U, at) : null, t.signal.aborted || M) throw Jt();
|
|
3167
|
+
y = U, U = null, g = L, L = null, g.root.visible = !1, x = Y, Y = null, x && (x.root.visible = !1, d.attachAuxiliary(x.root)), b = { status: "ready" }, h = m, T && (B(), A = !0, v.setMode("dynamics-running")), (vt = t.reportSessionState) == null || vt.call(t), t.requestRender();
|
|
3168
3168
|
} catch (rt) {
|
|
3169
|
-
if (Y == null || Y.dispose(), L == null || L.dispose(),
|
|
3170
|
-
const kt =
|
|
3169
|
+
if (Y == null || Y.dispose(), L == null || L.dispose(), U == null || U.dispose(), M || t.signal.aborted || rt instanceof Error && rt.name === "AbortError") return;
|
|
3170
|
+
const kt = yn(rt, t.signal, "urdf-physics");
|
|
3171
3171
|
d.setRuntime(void 0), y == null || y.dispose(), y = null, g == null || g.dispose(), g = null, x && (d.detachAuxiliary(x.root), x.dispose(), x = null), R(), h = { ...kt, stage: "physics-fallback" }, b = { status: "unavailable", issue: h }, v.setMode("dynamics-unavailable", h.message), (Pt = t.reportSessionState) == null || Pt.call(t), t.reportError(rt, { fatal: !1, stage: "physics-start", code: kt.code });
|
|
3172
3172
|
}
|
|
3173
3173
|
};
|
|
@@ -3178,8 +3178,8 @@ async function mo(n, t, i) {
|
|
|
3178
3178
|
autoPlay: !1,
|
|
3179
3179
|
root: d.root,
|
|
3180
3180
|
get capabilities() {
|
|
3181
|
-
const
|
|
3182
|
-
return { canPlay: !
|
|
3181
|
+
const U = b.status === "initializing", L = b.status === "unavailable" || b.status === "not-authored";
|
|
3182
|
+
return { canPlay: !U && !L, canPause: y !== null, canReset: !0, hasPhysics: y !== null, canToggleGround: !0, canToggleCollision: u !== void 0 || x !== null, canReorientUpAxis: !0 };
|
|
3183
3183
|
},
|
|
3184
3184
|
get physics() {
|
|
3185
3185
|
return b;
|
|
@@ -3189,7 +3189,7 @@ async function mo(n, t, i) {
|
|
|
3189
3189
|
},
|
|
3190
3190
|
isPlaying: () => A,
|
|
3191
3191
|
play() {
|
|
3192
|
-
var
|
|
3192
|
+
var U;
|
|
3193
3193
|
if (!(M || b.status === "unavailable" || b.status === "not-authored")) {
|
|
3194
3194
|
if (T = !0, v.select(null), !y) {
|
|
3195
3195
|
P ?? (P = S().finally(() => {
|
|
@@ -3197,33 +3197,33 @@ async function mo(n, t, i) {
|
|
|
3197
3197
|
}));
|
|
3198
3198
|
return;
|
|
3199
3199
|
}
|
|
3200
|
-
|
|
3200
|
+
B() && (A = !0, v.setMode("dynamics-running"), (U = t.reportSessionState) == null || U.call(t));
|
|
3201
3201
|
}
|
|
3202
3202
|
},
|
|
3203
3203
|
pause() {
|
|
3204
|
-
var
|
|
3205
|
-
T = !1, A = !1, d.endGrab(), y && (a.syncPhysicsPose(y.getJointValues(o.joints.map((L) => L.id)), g.bodyPoses()), R(), v.setMode("dynamics-paused")), (
|
|
3204
|
+
var U;
|
|
3205
|
+
T = !1, A = !1, d.endGrab(), y && (a.syncPhysicsPose(y.getJointValues(o.joints.map((L) => L.id)), ro(g.bodyPoses(), ci(d.getUpAxis()))), R(), v.setMode("dynamics-paused")), (U = t.reportSessionState) == null || U.call(t), t.requestRender();
|
|
3206
3206
|
},
|
|
3207
3207
|
reset() {
|
|
3208
|
-
var
|
|
3209
|
-
T = !1, d.endGrab(), y && (y.reset(), g == null || g.sync(), x == null || x.sync()), v.resetPose(), d.resetGround(), (
|
|
3208
|
+
var U;
|
|
3209
|
+
T = !1, d.endGrab(), y && (y.reset(), g == null || g.sync(), x == null || x.sync()), v.resetPose(), d.resetGround(), (U = t.reportSessionState) == null || U.call(t), t.requestRender();
|
|
3210
3210
|
},
|
|
3211
|
-
step(
|
|
3211
|
+
step(U) {
|
|
3212
3212
|
if (!y || !A) return !1;
|
|
3213
|
-
const L = y.step(
|
|
3213
|
+
const L = y.step(U);
|
|
3214
3214
|
return L && (g == null || g.sync(), x == null || x.sync(), v.syncGuides(), d.updateForceLine()), L;
|
|
3215
3215
|
},
|
|
3216
|
-
beginGrab(
|
|
3217
|
-
return !!(y && d.beginGrab(
|
|
3216
|
+
beginGrab(U, L, Y) {
|
|
3217
|
+
return !!(y && d.beginGrab(U, L, Y));
|
|
3218
3218
|
},
|
|
3219
|
-
moveGrab(
|
|
3220
|
-
y && d.moveGrab(
|
|
3219
|
+
moveGrab(U, L, Y) {
|
|
3220
|
+
y && d.moveGrab(U, L, Y);
|
|
3221
3221
|
},
|
|
3222
3222
|
endGrab() {
|
|
3223
3223
|
d.endGrab();
|
|
3224
3224
|
},
|
|
3225
|
-
setCollisionVisible(
|
|
3226
|
-
u && (u.root.visible =
|
|
3225
|
+
setCollisionVisible(U) {
|
|
3226
|
+
u && (u.root.visible = U && a.root.visible), x && (x.root.visible = U && (g == null ? void 0 : g.root.visible) === !0);
|
|
3227
3227
|
},
|
|
3228
3228
|
dispose() {
|
|
3229
3229
|
M || (M = !0, A = !1, v.dispose(), u && (d.detachAuxiliary(u.root), u.dispose()), x && (d.detachAuxiliary(x.root), x.dispose()), d.setRuntime(void 0), g == null || g.dispose(), a.dispose(), y == null || y.dispose(), d.dispose());
|
|
@@ -3233,6 +3233,15 @@ async function mo(n, t, i) {
|
|
|
3233
3233
|
function Jt() {
|
|
3234
3234
|
return Object.assign(new Error("Simulation load aborted."), { name: "AbortError", code: "E_ABORTED" });
|
|
3235
3235
|
}
|
|
3236
|
+
function ro(n, t) {
|
|
3237
|
+
const i = t.clone().invert(), e = /* @__PURE__ */ new Map();
|
|
3238
|
+
for (const [s, r] of n)
|
|
3239
|
+
e.set(s, {
|
|
3240
|
+
position: r.position.clone().applyQuaternion(i),
|
|
3241
|
+
quaternion: i.clone().multiply(r.quaternion)
|
|
3242
|
+
});
|
|
3243
|
+
return e;
|
|
3244
|
+
}
|
|
3236
3245
|
export {
|
|
3237
|
-
|
|
3246
|
+
yo as loadUrdfSimulation
|
|
3238
3247
|
};
|