@nebula-spatial/viewer 0.5.5 → 0.5.6

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.
@@ -1,14 +1,16 @@
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, e as pn, f as oi, c as mn, a as hn, b as ri, r as yn, S as ai, p as gn } from "./session-CZghJvw6.js";
5
- import { b as ft, S as wn, m as ci } from "./stage-DGMYxyAS.js";
6
- import { Quaternion as K, Euler as Zt, LoadingManager as Ci, Group as ut, Mesh as C, MeshLambertMaterial as bn, MeshPhongMaterial as li, MeshStandardMaterial as Je, Matrix4 as H, TextureLoader as xn, SRGBColorSpace as An, RepeatWrapping as Mn, BoxGeometry as He, SphereGeometry as Ze, CylinderGeometry as Ni, CapsuleGeometry as qi, Vector3 as z, MathUtils as vn, Matrix3 as ui, Box3 as it, BufferAttribute as Oi, Line3 as dt, Plane as Vi, Vector2 as gt, Triangle as $t, BackSide as Pn, DoubleSide as Sn, REVISION as Wi, Ray as Tn, FrontSide as fi, LineSegments as Qe, LineLoop as Gi, Line as Ye, Points as Xi, Sphere as Rn, BatchedMesh as Bn, AxesHelper as _n, ArrowHelper as di, BufferGeometry as En, LineBasicMaterial as pi, Float32BufferAttribute as zn, MeshBasicMaterial as mi, EdgesGeometry as Un } from "three";
7
- import { GLTFLoader as Fn } from "three/examples/jsm/loaders/GLTFLoader.js";
8
- import { ColladaLoader as $n } from "three/examples/jsm/loaders/ColladaLoader.js";
9
- import { OBJLoader as In } from "three/examples/jsm/loaders/OBJLoader.js";
10
- import { STLLoader as Dn } from "three/examples/jsm/loaders/STLLoader.js";
11
- function Ji(n) {
1
+ var dn = Object.defineProperty;
2
+ var pn = (n, t, i) => t in n ? dn(n, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[t] = i;
3
+ var $ = (n, t, i) => pn(n, typeof t != "symbol" ? t + "" : t, i);
4
+ import { d as mn, e as hn, c as yn, a as gn, b as ri, g as wn, w as ai, h as ci, S as li, p as bn } from "./collision-debug-CqRm6cC8.js";
5
+ import { S as xn, m as ui } from "./stage-CSRMl8kx.js";
6
+ import { Quaternion as K, Euler as Zt, LoadingManager as Oi, Group as lt, Mesh as N, MeshLambertMaterial as An, MeshPhongMaterial as fi, MeshStandardMaterial as He, Matrix4 as H, TextureLoader as Mn, SRGBColorSpace as vn, RepeatWrapping as Pn, BoxGeometry as Ze, SphereGeometry as Qe, CylinderGeometry as Vi, CapsuleGeometry as Wi, Vector3 as z, MathUtils as Sn, Matrix3 as di, Box3 as it, BufferAttribute as Gi, Line3 as ut, Plane as Xi, Vector2 as yt, Triangle as $t, BackSide as Tn, DoubleSide as Rn, REVISION as Ji, Ray as Bn, FrontSide as pi, LineSegments as Ye, LineLoop as Hi, Line as Ke, Points as Zi, Sphere as _n, BatchedMesh as En, AxesHelper as zn, ArrowHelper as mi, BufferGeometry as Un, LineBasicMaterial as hi, Float32BufferAttribute as Fn, MeshBasicMaterial as yi, EdgesGeometry as $n } from "three";
7
+ import { c as gi } from "./session-DgvOdcLe.js";
8
+ import { GLTFLoader as In } from "three/examples/jsm/loaders/GLTFLoader.js";
9
+ import { ColladaLoader as Dn } from "three/examples/jsm/loaders/ColladaLoader.js";
10
+ import { disposeModelResources as ft } from "./resources-CHhCm2f7.js";
11
+ import { OBJLoader as Ln } from "three/examples/jsm/loaders/OBJLoader.js";
12
+ import { STLLoader as kn } from "three/examples/jsm/loaders/STLLoader.js";
13
+ function Qi(n) {
12
14
  const t = new Map(n.map((o) => [o.id, o])), i = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Set(), s = (o) => {
13
15
  throw Object.assign(new Error(`Invalid URDF mimic relationship: ${o}`), { code: "E_URDF_MIMIC" });
14
16
  }, r = (o) => {
@@ -30,8 +32,8 @@ function Ji(n) {
30
32
  for (const o of n) r(o.id);
31
33
  return i;
32
34
  }
33
- function xe(n) {
34
- const t = Ji(n), i = /* @__PURE__ */ new Map();
35
+ function Ae(n) {
36
+ const t = Qi(n), i = /* @__PURE__ */ new Map();
35
37
  for (const e of n) {
36
38
  const s = t.get(e.id);
37
39
  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;
@@ -45,8 +47,8 @@ function xe(n) {
45
47
  }
46
48
  return i;
47
49
  }
48
- function Ke(n, t = {}) {
49
- const i = Ji(n), e = xe(n);
50
+ function ti(n, t = {}) {
51
+ const i = Qi(n), e = Ae(n);
50
52
  return Object.fromEntries(n.map((s) => {
51
53
  const r = i.get(s.id), o = e.get(r.root), d = Math.max(o.lower, Math.min(o.upper, t[r.root] ?? 0));
52
54
  return [s.id, d * r.multiplier + r.offset];
@@ -55,12 +57,12 @@ function Ke(n, t = {}) {
55
57
  function Qt(n) {
56
58
  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
59
  }
58
- function Ln(n) {
60
+ function jn(n) {
59
61
  const t = /* @__PURE__ */ new Map(), i = (e) => {
60
- if (!(e instanceof bn || e instanceof li)) return e;
62
+ if (!(e instanceof An || e instanceof fi)) return e;
61
63
  const s = t.get(e);
62
64
  if (s) return s;
63
- const r = new Je({
65
+ const r = new He({
64
66
  name: e.name,
65
67
  color: e.color.clone(),
66
68
  emissive: e.emissive.clone(),
@@ -82,17 +84,17 @@ function Ln(n) {
82
84
  depthWrite: e.depthWrite,
83
85
  vertexColors: e.vertexColors,
84
86
  flatShading: e.flatShading,
85
- roughness: e instanceof li ? Math.sqrt(2 / (Math.max(0, e.shininess) + 2)) : 0.5,
87
+ roughness: e instanceof fi ? Math.sqrt(2 / (Math.max(0, e.shininess) + 2)) : 0.5,
86
88
  metalness: 0
87
89
  });
88
90
  return r.normalScale.copy(e.normalScale), r.normalMapType = e.normalMapType, r.userData = { ...e.userData, colladaSourceMaterial: e.type }, t.set(e, r), r;
89
91
  };
90
92
  n.traverse((e) => {
91
- e instanceof C && (e.material = Array.isArray(e.material) ? e.material.map(i) : i(e.material));
93
+ e instanceof N && (e.material = Array.isArray(e.material) ? e.material.map(i) : i(e.material));
92
94
  });
93
95
  for (const e of t.keys()) e.dispose();
94
96
  }
95
- async function kn(n, t) {
97
+ async function Nn(n, t) {
96
98
  var p, c, u;
97
99
  const i = await t.text(n), e = new DOMParser().parseFromString(i, "application/xml");
98
100
  if (e.querySelector("parsererror") || e.documentElement.localName !== "COLLADA")
@@ -106,7 +108,7 @@ async function kn(n, t) {
106
108
  const x = t.resolve(g, n);
107
109
  await t.ensure(x), r.set(g, t.objectUrl(x));
108
110
  }
109
- const o = new Ci();
111
+ const o = new Oi();
110
112
  o.setURLModifier((y) => {
111
113
  if (y.startsWith("data:")) return y;
112
114
  const g = r.get(y);
@@ -121,27 +123,27 @@ async function kn(n, t) {
121
123
  o.onLoad = d, o.onError = (y) => {
122
124
  f = y;
123
125
  }, o.itemStart("urdf-collada-parse");
124
- const l = new ut();
126
+ const l = new lt();
125
127
  try {
126
- const y = new $n(o).parse(i, "");
128
+ const y = new Dn(o).parse(i, "");
127
129
  if (!(y != null && y.scene)) throw new Error(`COLLADA has no scene: ${n}`);
128
130
  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, f) throw new Error(`COLLADA texture failed to load: ${f}`);
129
131
  let g = 0;
130
132
  if (l.traverse((x) => {
131
- x instanceof C && g++;
133
+ x instanceof N && g++;
132
134
  }), !g) throw new Error(`COLLADA has no visual meshes: ${n}`);
133
- return Ln(l), l.updateMatrixWorld(!0), l;
135
+ return jn(l), l.updateMatrixWorld(!0), l;
134
136
  } catch (y) {
135
137
  throw ft(l), y;
136
138
  }
137
139
  }
138
- function Hi(n) {
140
+ function Yi(n) {
139
141
  const [t, i, e, s, r, o] = n;
140
142
  if (![t, i, e, s, r, o].every(Number.isFinite)) return !1;
141
143
  const d = t * i - s * s, a = t * (i * e - o * o) - s * (s * e - o * r) + r * (s * o - i * r);
142
144
  return t > 0 && d > 0 && a > 0 ? t <= i + e + 1e-12 && i <= t + e + 1e-12 && e <= t + i + 1e-12 : !1;
143
145
  }
144
- function jn(n, t) {
146
+ function Cn(n, t) {
145
147
  if (!(t > 0) || !Number.isFinite(t) || n.length !== 6 || !n.every(Number.isFinite)) return null;
146
148
  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
149
  for (let a = 0; a < 40; a++) {
@@ -164,8 +166,8 @@ function jn(n, t) {
164
166
  const d = 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
167
  return { radii: o.map((a) => Math.sqrt(Math.max(0, a))), rotation: new K().setFromRotationMatrix(d) };
166
168
  }
167
- function Cn(n, t) {
168
- const i = jn(n, t);
169
+ function qn(n, t) {
170
+ const i = Cn(n, t);
169
171
  return i ? { size: i.radii.map((e) => e * Math.sqrt(12 / 5)), rotation: i.rotation } : null;
170
172
  }
171
173
  function Lt(n, t) {
@@ -174,7 +176,7 @@ function Lt(n, t) {
174
176
  if (i.some((e) => !Number.isFinite(e))) throw O(`Invalid numeric value: ${n}`, "E_URDF_PARSE");
175
177
  return i;
176
178
  }
177
- function he(n) {
179
+ function ye(n) {
178
180
  const t = (n == null ? void 0 : n.querySelector("origin")) ?? null, i = Lt((t == null ? void 0 : t.getAttribute("quat_xyzw")) ?? null, []);
179
181
  if (i.length !== 0 && i.length !== 4) throw O("URDF origin quat_xyzw requires four values.", "E_URDF_PARSE");
180
182
  if (i.length && (t != null && t.hasAttribute("rpy"))) throw O("URDF origin cannot declare both rpy and quat_xyzw.", "E_URDF_PARSE");
@@ -184,9 +186,9 @@ function he(n) {
184
186
  ...i.length ? { rotationQuaternion: i } : {}
185
187
  };
186
188
  }
187
- function hi(n, t, i) {
189
+ function wi(n, t, i) {
188
190
  const e = n.querySelector("geometry"), s = e == null ? void 0 : e.querySelector("box");
189
- if (s) return { type: "box", size: Hn(s.getAttribute("size"), 3, "box size") };
191
+ if (s) return { type: "box", size: Qn(s.getAttribute("size"), 3, "box size") };
190
192
  const r = e == null ? void 0 : e.querySelector("sphere");
191
193
  if (r) return { type: "sphere", radius: jt(r.getAttribute("radius"), "sphere radius") };
192
194
  const o = e == null ? void 0 : e.querySelector("cylinder");
@@ -196,71 +198,71 @@ function hi(n, t, i) {
196
198
  const a = e == null ? void 0 : e.querySelector("mesh"), f = a == null ? void 0 : a.getAttribute("filename");
197
199
  return f ? { type: "mesh", resourcePath: i.resolve(f, t), scale: Lt(a.getAttribute("scale"), [1, 1, 1]) } : null;
198
200
  }
199
- function Nn(n, t, i) {
200
- const s = Jn(n, "URDF").querySelector("robot");
201
+ function On(n, t, i) {
202
+ const s = Zn(n, "URDF").querySelector("robot");
201
203
  if (!s) throw O("URDF requires a robot root element.", "E_URDF_PARSE");
202
- const r = pn(), o = /* @__PURE__ */ new Map();
204
+ const r = hn(), o = /* @__PURE__ */ new Map();
203
205
  for (const f of s.children) if (f.tagName === "material" && f.getAttribute("name")) {
204
206
  const l = f.getAttribute("name");
205
207
  if (o.has(l)) throw O(`Duplicate URDF material: ${l}`, "E_URDF_MATERIAL");
206
208
  o.set(l, f);
207
209
  }
208
210
  const d = [...s.querySelectorAll("link")].map((f) => ({
209
- id: ot(f, "name"),
210
- name: ot(f, "name"),
211
+ id: rt(f, "name"),
212
+ name: rt(f, "name"),
211
213
  inertial: (() => {
212
- const l = Zn(f);
213
- return l && (!(l.mass > 0) || !Number.isFinite(l.mass) || !Hi(l.tensor)) && r.errors.push({ code: "E_URDF_INERTIA", message: `连杆 ${f.getAttribute("name")} 的质量或惯性张量无效。`, source: f.getAttribute("name") ?? void 0 }), l;
214
+ const l = Yn(f);
215
+ return l && (!(l.mass > 0) || !Number.isFinite(l.mass) || !Yi(l.tensor)) && r.errors.push({ code: "E_URDF_INERTIA", message: `连杆 ${f.getAttribute("name")} 的质量或惯性张量无效。`, source: f.getAttribute("name") ?? void 0 }), l;
214
216
  })(),
215
217
  visuals: [...f.querySelectorAll("visual")].map((l) => {
216
- const p = hi(l, t, i), c = l.querySelector("material"), u = c == null ? void 0 : c.getAttribute("name"), y = u ? o.get(u) : 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"));
218
+ const p = wi(l, t, i), c = l.querySelector("material"), u = c == null ? void 0 : c.getAttribute("name"), y = u ? o.get(u) : 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
219
  u && !y && !g && !x && r.warnings.push({ code: "URDF_MATERIAL_UNRESOLVED", message: `Undefined material: ${u}`, source: f.getAttribute("name") ?? void 0 });
218
220
  const w = g ? (g.getAttribute("rgba") ?? "").trim().split(/\s+/).map(Number) : x ? [1, 1, 1, 1] : void 0;
219
221
  if (w && (w.length !== 4 || w.some((b) => !Number.isFinite(b) || b < 0 || b > 1))) throw O(`Invalid URDF material RGBA: ${u ?? ""}`, "E_URDF_MATERIAL");
220
222
  const m = x == null ? void 0 : x.getAttribute("filename");
221
223
  if (x && !m) throw O("URDF texture requires a filename", "E_URDF_MATERIAL");
222
224
  const h = m ? i.resolve(m, t) : void 0;
223
- return p ? { origin: he(l), geometry: p, color: w, texturePath: h } : null;
225
+ return p ? { origin: ye(l), geometry: p, color: w, texturePath: h } : null;
224
226
  }).filter((l) => !!l),
225
227
  collisions: [...f.querySelectorAll("collision")].map((l) => {
226
- const p = hi(l, t, i);
227
- return p ? { origin: he(l), geometry: p } : null;
228
+ const p = wi(l, t, i);
229
+ return p ? { origin: ye(l), geometry: p } : null;
228
230
  }).filter((l) => !!l)
229
231
  })), a = [...s.querySelectorAll("joint")].map((f) => {
230
232
  var w;
231
- const l = f.querySelector("limit"), p = f.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, u = f.querySelector("dynamics"), y = u ? wi(u.getAttribute("damping"), 0) : 0, g = u ? wi(u.getAttribute("friction"), 0) : 0, x = u && (y > 0 || g > 0) ? { damping: y, friction: g } : void 0;
233
+ const l = f.querySelector("limit"), p = f.querySelector("mimic"), c = p ? { joint: rt(p, "joint"), multiplier: Kt(p.getAttribute("multiplier"), "mimic multiplier") ?? 1, offset: Kt(p.getAttribute("offset"), "mimic offset") ?? 0 } : void 0, u = f.querySelector("dynamics"), y = u ? Ai(u.getAttribute("damping"), 0) : 0, g = u ? Ai(u.getAttribute("friction"), 0) : 0, x = u && (y > 0 || g > 0) ? { damping: y, friction: g } : void 0;
232
234
  return {
233
- id: ot(f, "name"),
235
+ id: rt(f, "name"),
234
236
  type: f.getAttribute("type") ?? "fixed",
235
- parent: ot(f.querySelector("parent"), "link"),
236
- child: ot(f.querySelector("child"), "link"),
237
- origin: he(f),
237
+ parent: rt(f.querySelector("parent"), "link"),
238
+ child: rt(f.querySelector("child"), "link"),
239
+ origin: ye(f),
238
240
  axis: Lt(((w = f.querySelector("axis")) == null ? void 0 : w.getAttribute("xyz")) ?? null, [1, 0, 0]),
239
241
  ...l ? {
240
- limits: { lower: Le(l.getAttribute("lower"), `Joint ${ot(f, "name")} limit lower`), upper: Le(l.getAttribute("upper"), `Joint ${ot(f, "name")} limit upper`) },
241
- effort: Yt(l.getAttribute("effort"), `Joint ${ot(f, "name")} limit effort`),
242
- velocity: Yt(l.getAttribute("velocity"), `Joint ${ot(f, "name")} limit velocity`)
242
+ limits: { lower: ke(l.getAttribute("lower"), `Joint ${rt(f, "name")} limit lower`), upper: ke(l.getAttribute("upper"), `Joint ${rt(f, "name")} limit upper`) },
243
+ effort: Kt(l.getAttribute("effort"), `Joint ${rt(f, "name")} limit effort`),
244
+ velocity: Kt(l.getAttribute("velocity"), `Joint ${rt(f, "name")} limit velocity`)
243
245
  } : {},
244
246
  ...x ? { dynamics: x } : {},
245
247
  ...c ? { mimic: c } : {}
246
248
  };
247
249
  });
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: d, joints: a, diagnostics: r, extension: { files: i } }, { allowInvalidGraph: !0 });
250
+ return Ae(a), s.querySelector("transmission, gazebo") && r.droppedFeatures.push({ code: "UNSUPPORTED_URDF_EXTENSION", message: "URDF transmission/gazebo extensions are not compiled." }), mn({ id: s.getAttribute("name") || t, name: s.getAttribute("name") || t, source: { format: "urdf", uri: t }, links: d, joints: a, diagnostics: r, extension: { files: i } }, { allowInvalidGraph: !0 });
249
251
  }
250
- function yi(n) {
252
+ function bi(n) {
251
253
  const t = Qt(n);
252
254
  return `quat="${t.w} ${t.x} ${t.y} ${t.z}"`;
253
255
  }
254
- function Ie(n) {
256
+ function De(n) {
255
257
  const t = new H(), i = Qt(n);
256
258
  return t.compose(new z().fromArray(n.position), i, new z(1, 1, 1));
257
259
  }
258
- function qn(n) {
260
+ function Vn(n) {
259
261
  if (n.type === "continuous" || !n.limits) return 0;
260
262
  const { lower: t, upper: i } = n.limits;
261
- return !Number.isFinite(t) || !Number.isFinite(i) ? 0 : vn.clamp(0, t, i);
263
+ return !Number.isFinite(t) || !Number.isFinite(i) ? 0 : Sn.clamp(0, t, i);
262
264
  }
263
- function On(n) {
265
+ function Wn(n) {
264
266
  let t;
265
267
  if (n.type === "box")
266
268
  t = [n.size[0] / 2, n.size[1] / 2, n.size[2] / 2];
@@ -277,25 +279,25 @@ function On(n) {
277
279
  i.push(new z(e, s, r));
278
280
  return i;
279
281
  }
280
- function Zi(n, t, i) {
282
+ function Ki(n, t, i) {
281
283
  let e = 0;
282
- const s = new Map(n.links.map((l) => [l.id, l])), r = Ke(n.joints), o = (l) => {
284
+ const s = new Map(n.links.map((l) => [l.id, l])), r = ti(n.joints), o = (l) => {
283
285
  let p = 1 / 0;
284
286
  const c = (u, y) => {
285
287
  const g = s.get(u);
286
288
  if (g) {
287
289
  for (const x of g.collisions) {
288
- const w = On(x.geometry);
290
+ const w = Wn(x.geometry);
289
291
  if (!w) {
290
292
  l && (e += 1);
291
293
  continue;
292
294
  }
293
- const m = y.clone().multiply(Ie(x.origin));
295
+ const m = y.clone().multiply(De(x.origin));
294
296
  for (const h of w)
295
297
  p = Math.min(p, h.applyMatrix4(m).z);
296
298
  }
297
299
  for (const x of i.get(u) ?? []) {
298
- const w = y.clone().multiply(Ie(x.origin)), m = l ? r[x.id] : 0;
300
+ const w = y.clone().multiply(De(x.origin)), m = l ? r[x.id] : 0;
299
301
  m && x.type === "revolute" ? w.multiply(new H().makeRotationAxis(new z().fromArray(x.axis).normalize(), m)) : m && x.type === "prismatic" && w.multiply(new H().makeTranslation(x.axis[0] * m, x.axis[1] * m, x.axis[2] * m)), c(x.child, w);
300
302
  }
301
303
  }
@@ -307,22 +309,22 @@ function Zi(n, t, i) {
307
309
  message: `自动落地忽略了 ${e} 个网格碰撞体`
308
310
  }), Number.isFinite(f) ? Math.max(0, 0.015 - f) : 0;
309
311
  }
310
- async function Vn(n) {
312
+ async function Gn(n) {
311
313
  const t = n.extension.files, i = /* @__PURE__ */ new Map(), e = new Set(n.joints.map((w) => w.child));
312
314
  for (const w of n.joints) i.set(w.parent, [...i.get(w.parent) ?? [], w]);
313
315
  const s = n.links.filter((w) => !e.has(w.id));
314
316
  if (s.length !== 1) throw O(`URDF requires exactly one root link; found ${s.length}.`, "E_URDF_COMPILE");
315
- const r = Zi(n, s[0].id, i);
317
+ const r = Ki(n, s[0].id, i);
316
318
  r > 0 && n.diagnostics.approximations.push({
317
319
  code: "AUTO_GROUNDED_FREE_ROOT",
318
320
  message: `自由根初始高度自动抬升 ${r.toFixed(4)} m`
319
321
  });
320
- const o = n.joints.filter((w) => qn(w) !== 0);
322
+ const o = n.joints.filter((w) => Vn(w) !== 0);
321
323
  o.length && n.diagnostics.approximations.push({
322
324
  code: "JOINT_REFERENCE_CLAMPED",
323
325
  message: `${o.length} 个关节的默认参考值已夹到合法限位`
324
326
  });
325
- const d = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), f = [], l = Ke(n.joints), p = async (w) => {
327
+ const d = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), f = [], l = ti(n.joints), p = async (w) => {
326
328
  var A;
327
329
  if (w.type === "box") return `type="box" size="${w.size.map((P) => P / 2).join(" ")}"`;
328
330
  if (w.type === "sphere") return `type="sphere" size="${w.radius}"`;
@@ -343,9 +345,9 @@ async function Vn(n) {
343
345
  var M, T;
344
346
  const h = n.links.find((R) => R.id === w), b = [...(m == null ? void 0 : m.origin.position) ?? [0, 0, 0]];
345
347
  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(" ")}" ${yi(A)}>`];
348
+ const A = (m == null ? void 0 : m.origin) ?? { rotationRpy: [0, 0, 0] }, P = [`<body name="${St(w)}" pos="${b.join(" ")}" ${bi(A)}>`];
347
349
  if (h.inertial) {
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]);
350
+ const { origin: R, mass: v, tensor: B } = h.inertial, S = new di().setFromMatrix4(new H().makeRotationFromQuaternion(Qt(R))), _ = new di().set(B[0], B[3], B[4], B[3], B[1], B[5], B[4], B[5], B[2]);
349
351
  _.premultiply(S).multiply(S.clone().transpose());
350
352
  const E = _.elements;
351
353
  P.push(`<inertial pos="${R.position.join(" ")}" mass="${v}" fullinertia="${[E[0], E[4], E[8], E[3], E[6], E[7]].join(" ")}"/>`);
@@ -362,7 +364,7 @@ async function Vn(n) {
362
364
  for (const R of h.collisions) {
363
365
  const v = await p(R.geometry);
364
366
  if (v) {
365
- const B = ` ${yi(R.origin)}`;
367
+ const B = ` ${bi(R.origin)}`;
366
368
  P.push(`<geom ${v} pos="${R.origin.position.join(" ")}"${B} rgba="0.55 0.62 0.59 1"/>`);
367
369
  }
368
370
  }
@@ -381,25 +383,25 @@ async function Vn(n) {
381
383
  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"/>${u}</worldbody>${x ? `<equality>${x}</equality>` : ""}${g}</mujoco>`
382
384
  };
383
385
  }
384
- async function Qi(n) {
385
- const t = n.extension.files, i = new ut();
386
+ async function tn(n) {
387
+ const t = n.extension.files, i = new lt();
386
388
  i.name = "URDF authored collisions";
387
- const e = /* @__PURE__ */ new Map(), s = mn(), r = hn();
389
+ const e = /* @__PURE__ */ new Map(), s = yn(), r = gn();
388
390
  let o = 0;
389
391
  for (const d of n.links) {
390
- const a = new ut();
392
+ const a = new lt();
391
393
  a.name = d.id, a.userData.urdfEntityId = `link:${d.id}`, e.set(d.id, a), i.add(a);
392
394
  for (const f of d.collisions) {
393
- const l = new ut();
394
- if (l.matrixAutoUpdate = !1, l.matrix.copy(Ie(f.origin)), a.add(l), f.geometry.type === "mesh") {
395
- const p = await De(f.geometry, t, new Je());
395
+ const l = new lt();
396
+ if (l.matrixAutoUpdate = !1, l.matrix.copy(De(f.origin)), a.add(l), f.geometry.type === "mesh") {
397
+ const p = await Le(f.geometry, t, new He());
396
398
  p.updateMatrixWorld(!0), p.traverse((c) => {
397
- if (!(c instanceof C)) return;
399
+ if (!(c instanceof N)) return;
398
400
  const u = ri(c.geometry, s, "mesh", r);
399
401
  u.matrixAutoUpdate = !1, u.matrix.copy(c.matrixWorld), u.name = `Collision:${d.id}`, u.userData.urdfLink = d.id, l.add(u), o += 1;
400
402
  }), ft(p);
401
403
  } else {
402
- const p = Gn(f.geometry);
404
+ const p = Jn(f.geometry);
403
405
  if (!p) continue;
404
406
  const c = ri(p, s, "feature", r);
405
407
  p.dispose(), c.name = `Collision:${d.id}`, c.userData.urdfLink = d.id, l.add(c), o += 1;
@@ -412,8 +414,8 @@ async function Qi(n) {
412
414
  }
413
415
  return { root: i, bindings: e, expectedLinkCount: e.size };
414
416
  }
415
- async function Wn(n, t) {
416
- const i = await Qi(n);
417
+ async function Xn(n, t) {
418
+ const i = await tn(n);
417
419
  if (!i) return;
418
420
  const e = () => {
419
421
  t.root.updateMatrixWorld(!0);
@@ -427,29 +429,29 @@ async function Wn(n, t) {
427
429
  ft(i.root);
428
430
  } };
429
431
  }
430
- function Gn(n) {
431
- if (n.type === "box") return new He(...n.size);
432
- if (n.type === "sphere") return new Ze(n.radius, 24, 16);
432
+ function Jn(n) {
433
+ if (n.type === "box") return new Ze(...n.size);
434
+ if (n.type === "sphere") return new Qe(n.radius, 24, 16);
433
435
  if (n.type === "cylinder") {
434
- const t = new Ni(n.radius, n.radius, n.length, 24);
436
+ const t = new Vi(n.radius, n.radius, n.length, 24);
435
437
  return t.rotateX(Math.PI / 2), t;
436
438
  }
437
439
  if (n.type === "capsule") {
438
- const t = new qi(n.radius, n.length, 8, 24);
440
+ const t = new Wi(n.radius, n.length, 8, 24);
439
441
  return t.rotateX(Math.PI / 2), t;
440
442
  }
441
443
  return null;
442
444
  }
443
- async function gi(n) {
444
- const t = n.extension.files, i = new ut();
445
+ async function xi(n) {
446
+ const t = n.extension.files, i = new lt();
445
447
  i.name = n.name;
446
448
  const e = /* @__PURE__ */ new Map();
447
449
  try {
448
450
  for (const s of n.links) {
449
- const r = new ut();
451
+ const r = new lt();
450
452
  r.name = s.id, r.userData.urdfEntityId = `link:${s.id}`, e.set(s.id, r), i.add(r);
451
453
  for (const o of s.visuals) {
452
- const d = await Xn(o, t, n.diagnostics), a = new ut();
454
+ const d = await Hn(o, t, n.diagnostics), a = new lt();
453
455
  a.position.fromArray(o.origin.position), a.quaternion.copy(Qt(o.origin)), a.add(d), r.add(a);
454
456
  }
455
457
  }
@@ -458,25 +460,25 @@ async function gi(n) {
458
460
  throw ft(i), s;
459
461
  }
460
462
  }
461
- async function Xn(n, t, i) {
463
+ async function Hn(n, t, i) {
462
464
  var r;
463
465
  if (n.geometry.type === "mesh" && /\.gl(?:tf|b)$/i.test(n.geometry.resourcePath)) {
464
466
  (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 });
465
- const o = oi();
467
+ const o = gi();
466
468
  try {
467
- return await De(n.geometry, t, o);
469
+ return await Le(n.geometry, t, o);
468
470
  } finally {
469
471
  o.dispose();
470
472
  }
471
473
  }
472
- const e = oi({ color: n.color });
474
+ const e = gi({ color: n.color });
473
475
  let s;
474
476
  try {
475
- if (n.texturePath && (await t.ensure(n.texturePath), e.map = await new xn().loadAsync(t.objectUrl(n.texturePath)), e.transparent = !0, e.map.colorSpace = An, e.map.wrapS = e.map.wrapT = Mn), s = await De(n.geometry, t, e), n.geometry.type === "mesh" && /\.dae$/i.test(n.geometry.resourcePath))
477
+ if (n.texturePath && (await t.ensure(n.texturePath), e.map = await new Mn().loadAsync(t.objectUrl(n.texturePath)), e.transparent = !0, e.map.colorSpace = vn, e.map.wrapS = e.map.wrapT = Pn), s = await Le(n.geometry, t, e), n.geometry.type === "mesh" && /\.dae$/i.test(n.geometry.resourcePath))
476
478
  if (n.color || n.texturePath) {
477
479
  const o = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
478
480
  s.traverse((a) => {
479
- if (a instanceof C) {
481
+ if (a instanceof N) {
480
482
  for (const f of Array.isArray(a.material) ? a.material : [a.material]) o.add(f);
481
483
  a.material = e;
482
484
  }
@@ -488,80 +490,80 @@ async function Xn(n, t, i) {
488
490
  for (const a of d) a.dispose();
489
491
  } else e.dispose();
490
492
  return e.map && s.traverse((o) => {
491
- if (o instanceof C && !o.geometry.getAttribute("uv")) throw O(`URDF texture requires authored UVs: ${n.texturePath}`, "E_URDF_TEXTURE_UV");
493
+ if (o instanceof N && !o.geometry.getAttribute("uv")) throw O(`URDF texture requires authored UVs: ${n.texturePath}`, "E_URDF_TEXTURE_UV");
492
494
  }), s;
493
495
  } catch (o) {
494
496
  throw s ? ft(s) : ((r = e.map) == null || r.dispose(), e.dispose()), o;
495
497
  }
496
498
  }
497
- async function De(n, t, i) {
499
+ async function Le(n, t, i) {
498
500
  var r;
499
- if (n.type === "box") return new C(new He(...n.size), i);
500
- if (n.type === "sphere") return new C(new Ze(n.radius, 24, 16), i);
501
+ if (n.type === "box") return new N(new Ze(...n.size), i);
502
+ if (n.type === "sphere") return new N(new Qe(n.radius, 24, 16), i);
501
503
  if (n.type === "cylinder") {
502
- const o = new C(new Ni(n.radius, n.radius, n.length, 24), i);
504
+ const o = new N(new Vi(n.radius, n.radius, n.length, 24), i);
503
505
  return o.quaternion.copy(new K().setFromEuler(new Zt(Math.PI / 2, 0, 0))), o;
504
506
  }
505
507
  if (n.type === "capsule") {
506
- const o = new C(new qi(n.radius, n.length, 8, 24), i);
508
+ const o = new N(new Wi(n.radius, n.length, 8, 24), i);
507
509
  return o.quaternion.copy(new K().setFromEuler(new Zt(Math.PI / 2, 0, 0))), o;
508
510
  }
509
511
  const e = (r = n.resourcePath.split(".").pop()) == null ? void 0 : r.toLowerCase();
510
512
  await t.ensure(n.resourcePath);
511
513
  let s;
512
- if (e === "stl") s = new C(new Dn().parse(await t.getBlob(n.resourcePath).arrayBuffer()), i);
514
+ if (e === "stl") s = new N(new kn().parse(await t.getBlob(n.resourcePath).arrayBuffer()), i);
513
515
  else if (e === "obj")
514
- s = new In().parse(await t.getBlob(n.resourcePath).text()), s.traverse((o) => {
515
- if (o instanceof C) {
516
+ s = new Ln().parse(await t.getBlob(n.resourcePath).text()), s.traverse((o) => {
517
+ if (o instanceof N) {
516
518
  for (const d of Array.isArray(o.material) ? o.material : [o.material]) d.dispose();
517
519
  o.material = i;
518
520
  }
519
521
  });
520
522
  else if (e === "gltf" || e === "glb") {
521
- const o = new Ci();
523
+ const o = new Oi();
522
524
  o.setURLModifier((d) => {
523
525
  try {
524
526
  return t.objectUrl(t.resolve(d, n.resourcePath));
525
527
  } catch {
526
528
  return d;
527
529
  }
528
- }), s = (await new Fn(o).parseAsync(await t.getBlob(n.resourcePath).arrayBuffer(), "")).scene;
529
- } else if (e === "dae") s = await kn(n.resourcePath, t);
530
+ }), s = (await new In(o).parseAsync(await t.getBlob(n.resourcePath).arrayBuffer(), "")).scene;
531
+ } else if (e === "dae") s = await Nn(n.resourcePath, t);
530
532
  else throw O(`Unsupported URDF visual mesh: .${e ?? ""}`, "E_URDF_VISUAL");
531
533
  return s.scale.fromArray(n.scale), s;
532
534
  }
533
- function Jn(n, t) {
535
+ function Zn(n, t) {
534
536
  const i = new DOMParser().parseFromString(n, "application/xml"), e = i.querySelector("parsererror");
535
537
  if (e) throw O(`${t} XML parse failed: ${e.textContent ?? ""}`, `E_${t}_PARSE`);
536
538
  return i;
537
539
  }
538
- function ot(n, t) {
540
+ function rt(n, t) {
539
541
  const i = n == null ? void 0 : n.getAttribute(t);
540
542
  if (!i) throw O(`Missing ${t}.`, "E_URDF_PARSE");
541
543
  return i;
542
544
  }
543
- function wi(n, t) {
545
+ function Ai(n, t) {
544
546
  const i = Number(n);
545
547
  return Number.isFinite(i) ? i : t;
546
548
  }
547
- function Le(n, t) {
549
+ function ke(n, t) {
548
550
  if (n === null || n.trim() === "") throw O(`${t} is required.`, "E_URDF_PARSE");
549
551
  const i = Number(n);
550
552
  if (!Number.isFinite(i)) throw O(`${t} must be finite.`, "E_URDF_PARSE");
551
553
  return i;
552
554
  }
553
555
  function jt(n, t) {
554
- const i = Le(n, t);
556
+ const i = ke(n, t);
555
557
  if (!(i > 0)) throw O(`${t} must be greater than zero.`, "E_URDF_PARSE");
556
558
  return i;
557
559
  }
558
- function Hn(n, t, i) {
560
+ function Qn(n, t, i) {
559
561
  if (n === null || n.trim() === "") throw O(`${i} is required.`, "E_URDF_PARSE");
560
562
  const e = Lt(n, []);
561
563
  if (e.length !== t || e.some((s) => !(s > 0))) throw O(`${i} requires ${t} values greater than zero.`, "E_URDF_PARSE");
562
564
  return e;
563
565
  }
564
- function Yt(n, t) {
566
+ function Kt(n, t) {
565
567
  if (n === null || n.trim() === "") return;
566
568
  const i = Number(n);
567
569
  if (!Number.isFinite(i)) throw O(`${t} must be finite.`, "E_URDF_PARSE");
@@ -573,7 +575,7 @@ function St(n) {
573
575
  function O(n, t) {
574
576
  return Object.assign(new Error(n), { code: t });
575
577
  }
576
- function Zn(n) {
578
+ function Yn(n) {
577
579
  var o;
578
580
  const t = n.querySelector("inertial");
579
581
  if (!t) return;
@@ -581,10 +583,10 @@ function Zn(n) {
581
583
  const a = i == null ? void 0 : i.getAttribute(d);
582
584
  return a == null || a.trim() === "" ? Number.NaN : Number(a);
583
585
  });
584
- return { origin: he(t), mass: s, tensor: r };
586
+ return { origin: ye(t), mass: s, tensor: r };
585
587
  }
586
- const Yi = 0, Qn = 1, Yn = 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
+ const en = 0, Kn = 1, ts = 2, Mi = 2, Se = 1.25, vi = 1, X = 6 * 4 + 4 + 4, C = X / 4, nn = 65535, ge = Math.pow(2, -24), ei = Symbol("SKIP_GENERATION"), sn = {
589
+ strategy: en,
588
590
  maxDepth: 40,
589
591
  maxLeafSize: 10,
590
592
  useSharedArrayBuffer: !1,
@@ -593,12 +595,12 @@ const Yi = 0, Qn = 1, Yn = 2, bi = 2, Pe = 1.25, xi = 1, X = 6 * 4 + 4 + 4, N =
593
595
  indirect: !1,
594
596
  verbose: !0,
595
597
  range: null,
596
- [ti]: !1
598
+ [ei]: !1
597
599
  };
598
600
  function k(n, t, i) {
599
601
  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
602
  }
601
- function Ai(n) {
603
+ function Pi(n) {
602
604
  let t = -1, i = -1 / 0;
603
605
  for (let e = 0; e < 3; e++) {
604
606
  const s = n[e + 3] - n[e];
@@ -606,28 +608,28 @@ function Ai(n) {
606
608
  }
607
609
  return t;
608
610
  }
609
- function Mi(n, t) {
611
+ function Si(n, t) {
610
612
  t.set(n);
611
613
  }
612
- function vi(n, t, i) {
614
+ function Ti(n, t, i) {
613
615
  let e, s;
614
616
  for (let r = 0; r < 3; r++) {
615
617
  const o = r + 3;
616
618
  e = n[r], s = t[r], i[r] = e < s ? e : s, e = n[o], s = t[o], i[o] = e > s ? e : s;
617
619
  }
618
620
  }
619
- function Kt(n, t, i) {
621
+ function te(n, t, i) {
620
622
  for (let e = 0; e < 3; e++) {
621
623
  const s = t[n + 2 * e], r = t[n + 2 * e + 1], o = s - r, d = s + r;
622
624
  o < i[e] && (i[e] = o), d > i[e + 3] && (i[e + 3] = d);
623
625
  }
624
626
  }
625
- function Ct(n) {
627
+ function Nt(n) {
626
628
  const t = n[3] - n[0], i = n[4] - n[1], e = n[5] - n[2];
627
629
  return 2 * (t * i + i * e + e * t);
628
630
  }
629
631
  function q(n, t) {
630
- return t[n + 15] === Ki;
632
+ return t[n + 15] === nn;
631
633
  }
632
634
  function J(n, t) {
633
635
  return t[n + 6];
@@ -636,16 +638,16 @@ function Z(n, t) {
636
638
  return t[n + 14];
637
639
  }
638
640
  function V(n) {
639
- return n + N;
641
+ return n + C;
640
642
  }
641
643
  function W(n, t) {
642
644
  const i = t[n + 6];
643
- return n + i * N;
645
+ return n + i * C;
644
646
  }
645
- function ei(n, t) {
647
+ function ii(n, t) {
646
648
  return t[n + 7];
647
649
  }
648
- function Se(n, t, i, e, s) {
650
+ function Te(n, t, i, e, s) {
649
651
  let r = 1 / 0, o = 1 / 0, d = 1 / 0, a = -1 / 0, f = -1 / 0, l = -1 / 0, p = 1 / 0, c = 1 / 0, u = 1 / 0, y = -1 / 0, g = -1 / 0, x = -1 / 0;
650
652
  const w = n.offset || 0;
651
653
  for (let m = (t - w) * 6, h = (t + i - w) * 6; m < h; m += 6) {
@@ -658,27 +660,27 @@ function Se(n, t, i, e, s) {
658
660
  }
659
661
  e[0] = r, e[1] = o, e[2] = d, e[3] = a, e[4] = f, e[5] = l, s[0] = p, s[1] = c, s[2] = u, s[3] = y, s[4] = g, s[5] = x;
660
662
  }
661
- const ct = 32, Kn = (n, t) => n.candidate - t.candidate, mt = /* @__PURE__ */ new Array(ct).fill().map(() => ({
663
+ const at = 32, es = (n, t) => n.candidate - t.candidate, pt = /* @__PURE__ */ new Array(at).fill().map(() => ({
662
664
  count: 0,
663
665
  bounds: new Float32Array(6),
664
666
  rightCacheBounds: new Float32Array(6),
665
667
  leftCacheBounds: new Float32Array(6),
666
668
  candidate: 0
667
- })), te = /* @__PURE__ */ new Float32Array(6);
668
- function ts(n, t, i, e, s, r) {
669
+ })), ee = /* @__PURE__ */ new Float32Array(6);
670
+ function is(n, t, i, e, s, r) {
669
671
  let o = -1, d = 0;
670
- if (r === Yi)
671
- o = Ai(t), o !== -1 && (d = (t[o] + t[o + 3]) / 2);
672
- else if (r === Qn)
673
- o = Ai(n), o !== -1 && (d = es(i, e, s, o));
674
- else if (r === Yn) {
675
- const a = Ct(n);
676
- let f = Pe * s;
672
+ if (r === en)
673
+ o = Pi(t), o !== -1 && (d = (t[o] + t[o + 3]) / 2);
674
+ else if (r === Kn)
675
+ o = Pi(n), o !== -1 && (d = ns(i, e, s, o));
676
+ else if (r === ts) {
677
+ const a = Nt(n);
678
+ let f = Se * s;
677
679
  const l = i.offset || 0, p = (e - l) * 6, c = (e + s - l) * 6;
678
680
  for (let u = 0; u < 3; u++) {
679
- const y = t[u], w = (t[u + 3] - y) / ct;
680
- if (s < ct / 4) {
681
- const m = [...mt];
681
+ const y = t[u], w = (t[u + 3] - y) / at;
682
+ if (s < at / 4) {
683
+ const m = [...pt];
682
684
  m.length = s;
683
685
  let h = 0;
684
686
  for (let A = p; A < c; A += 6, h++) {
@@ -691,9 +693,9 @@ function ts(n, t, i, e, s, r) {
691
693
  } = P;
692
694
  for (let v = 0; v < 3; v++)
693
695
  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
- Kt(A, i, M);
696
+ te(A, i, M);
695
697
  }
696
- m.sort(Kn);
698
+ m.sort(es);
697
699
  let b = s;
698
700
  for (let A = 0; A < b; A++) {
699
701
  const P = m[A];
@@ -704,21 +706,21 @@ function ts(n, t, i, e, s, r) {
704
706
  const P = i[A + 2 * u];
705
707
  for (let M = 0; M < b; M++) {
706
708
  const T = m[M];
707
- P >= T.candidate ? Kt(A, i, T.rightCacheBounds) : (Kt(A, i, T.leftCacheBounds), T.count++);
709
+ P >= T.candidate ? te(A, i, T.rightCacheBounds) : (te(A, i, T.leftCacheBounds), T.count++);
708
710
  }
709
711
  }
710
712
  for (let A = 0; A < b; A++) {
711
713
  const P = m[A], M = P.count, T = s - P.count, R = P.leftCacheBounds, v = P.rightCacheBounds;
712
714
  let B = 0;
713
- M !== 0 && (B = Ct(R) / a);
715
+ M !== 0 && (B = Nt(R) / a);
714
716
  let S = 0;
715
- T !== 0 && (S = Ct(v) / a);
716
- const _ = xi + Pe * (B * M + S * T);
717
+ T !== 0 && (S = Nt(v) / a);
718
+ const _ = vi + Se * (B * M + S * T);
717
719
  _ < f && (o = u, f = _, d = P.candidate);
718
720
  }
719
721
  } else {
720
- for (let b = 0; b < ct; b++) {
721
- const A = mt[b];
722
+ for (let b = 0; b < at; b++) {
723
+ const A = pt[b];
722
724
  A.count = 0, A.candidate = y + w + b * w;
723
725
  const P = A.bounds;
724
726
  for (let M = 0; M < 3; M++)
@@ -726,25 +728,25 @@ function ts(n, t, i, e, s, r) {
726
728
  }
727
729
  for (let b = p; b < c; b += 6) {
728
730
  let M = ~~((i[b + 2 * u] - y) / w);
729
- M >= ct && (M = ct - 1);
730
- const T = mt[M];
731
- T.count++, Kt(b, i, T.bounds);
731
+ M >= at && (M = at - 1);
732
+ const T = pt[M];
733
+ T.count++, te(b, i, T.bounds);
732
734
  }
733
- const m = mt[ct - 1];
734
- Mi(m.bounds, m.rightCacheBounds);
735
- for (let b = ct - 2; b >= 0; b--) {
736
- const A = mt[b], P = mt[b + 1];
737
- vi(A.bounds, P.rightCacheBounds, A.rightCacheBounds);
735
+ const m = pt[at - 1];
736
+ Si(m.bounds, m.rightCacheBounds);
737
+ for (let b = at - 2; b >= 0; b--) {
738
+ const A = pt[b], P = pt[b + 1];
739
+ Ti(A.bounds, P.rightCacheBounds, A.rightCacheBounds);
738
740
  }
739
741
  let h = 0;
740
- for (let b = 0; b < ct - 1; b++) {
741
- const A = mt[b], P = A.count, M = A.bounds, R = mt[b + 1].rightCacheBounds;
742
- P !== 0 && (h === 0 ? Mi(M, te) : vi(M, te, te)), h += P;
742
+ for (let b = 0; b < at - 1; b++) {
743
+ const A = pt[b], P = A.count, M = A.bounds, R = pt[b + 1].rightCacheBounds;
744
+ P !== 0 && (h === 0 ? Si(M, ee) : Ti(M, ee, ee)), h += P;
743
745
  let v = 0, B = 0;
744
- h !== 0 && (v = Ct(te) / a);
746
+ h !== 0 && (v = Nt(ee) / a);
745
747
  const S = s - h;
746
- S !== 0 && (B = Ct(R) / a);
747
- const _ = xi + Pe * (v * h + B * S);
748
+ S !== 0 && (B = Nt(R) / a);
749
+ const _ = vi + Se * (v * h + B * S);
748
750
  _ < f && (o = u, f = _, d = A.candidate);
749
751
  }
750
752
  }
@@ -753,19 +755,19 @@ function ts(n, t, i, e, s, r) {
753
755
  console.warn(`BVH: Invalid build strategy value ${r} used.`);
754
756
  return { axis: o, pos: d };
755
757
  }
756
- function es(n, t, i, e) {
758
+ function ns(n, t, i, e) {
757
759
  let s = 0;
758
760
  const r = n.offset;
759
761
  for (let o = t, d = t + i; o < d; o++)
760
762
  s += n[(o - r) * 6 + e * 2];
761
763
  return s / i;
762
764
  }
763
- class Te {
765
+ class Re {
764
766
  constructor() {
765
767
  this.boundingData = new Float32Array(6);
766
768
  }
767
769
  }
768
- function is(n, t, i, e, s, r) {
770
+ function ss(n, t, i, e, s, r) {
769
771
  let o = e, d = e + s - 1;
770
772
  const a = r.pos, f = r.axis * 2, l = i.offset || 0;
771
773
  for (; ; ) {
@@ -787,30 +789,30 @@ function is(n, t, i, e, s, r) {
787
789
  return o;
788
790
  }
789
791
  }
790
- let en, ge, ke, nn;
791
- const ns = Math.pow(2, 32);
792
- function je(n) {
793
- return "count" in n ? 1 : 1 + je(n.left) + je(n.right);
792
+ let on, we, je, rn;
793
+ const os = Math.pow(2, 32);
794
+ function Ne(n) {
795
+ return "count" in n ? 1 : 1 + Ne(n.left) + Ne(n.right);
794
796
  }
795
- function ss(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
+ function rs(n, t, i) {
798
+ return on = new Float32Array(i), we = new Uint32Array(i), je = new Uint16Array(i), rn = new Uint8Array(i), Ce(n, t);
797
799
  }
798
800
  function Ce(n, t) {
799
801
  const i = n / 4, e = n / 2, s = "count" in t, r = t.boundingData;
800
802
  for (let o = 0; o < 6; o++)
801
- en[i + o] = r[o];
803
+ on[i + o] = r[o];
802
804
  if (s)
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);
805
+ return t.buffer ? (rn.set(new Uint8Array(t.buffer), n), n + t.buffer.byteLength) : (we[i + 6] = t.offset, je[e + 14] = t.count, je[e + 15] = nn, n + X);
804
806
  {
805
807
  const { left: o, right: d, splitAxis: a } = t, f = n + X;
806
808
  let l = Ce(f, o);
807
809
  const p = n / X, u = l / X - p;
808
- if (u > ns)
810
+ if (u > os)
809
811
  throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");
810
- return ge[i + 6] = u, ge[i + 7] = a, Ce(l, d);
812
+ return we[i + 6] = u, we[i + 7] = a, Ce(l, d);
811
813
  }
812
814
  }
813
- function os(n, t, i, e, s, r) {
815
+ function as(n, t, i, e, s, r) {
814
816
  const {
815
817
  maxDepth: o,
816
818
  verbose: d,
@@ -819,41 +821,41 @@ function os(n, t, i, e, s, r) {
819
821
  onProgress: l
820
822
  } = s, p = n.primitiveBuffer, c = n.primitiveBufferStride, u = new Float32Array(6);
821
823
  let y = !1;
822
- const g = new Te();
823
- return Se(t, i, e, g.boundingData, u), w(g, i, e, u), g;
824
+ const g = new Re();
825
+ return Te(t, i, e, g.boundingData, u), w(g, i, e, u), g;
824
826
  function x(m) {
825
827
  l && l((m - r.offset) / r.count);
826
828
  }
827
829
  function w(m, h, b, A = null, P = 0) {
828
830
  if (!y && P >= o && (y = !0, d && console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`)), b <= a || P >= o)
829
831
  return x(h + b), m.offset = h, m.count = b, m;
830
- const M = ts(m.boundingData, A, t, h, b, f);
832
+ const M = is(m.boundingData, A, t, h, b, f);
831
833
  if (M.axis === -1)
832
834
  return x(h + b), m.offset = h, m.count = b, m;
833
- const T = is(p, c, t, h, b, M);
835
+ const T = ss(p, c, t, h, b, M);
834
836
  if (T === h || T === h + b)
835
837
  x(h + b), m.offset = h, m.count = b;
836
838
  else {
837
839
  m.splitAxis = M.axis;
838
- const R = new Te(), v = h, B = T - h;
839
- m.left = R, Se(t, v, B, R.boundingData, u), w(R, v, B, u, P + 1);
840
- const S = new Te(), _ = T, E = b - B;
841
- m.right = S, Se(t, _, E, S.boundingData, u), w(S, _, E, u, P + 1);
840
+ const R = new Re(), v = h, B = T - h;
841
+ m.left = R, Te(t, v, B, R.boundingData, u), w(R, v, B, u, P + 1);
842
+ const S = new Re(), _ = T, E = b - B;
843
+ m.right = S, Te(t, _, E, S.boundingData, u), w(S, _, E, u, P + 1);
842
844
  }
843
845
  return m;
844
846
  }
845
847
  }
846
- function rs(n, t) {
848
+ function cs(n, t) {
847
849
  const i = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, e = n.getRootRanges(t.range), s = e[0], r = e[e.length - 1], o = {
848
850
  offset: s.offset,
849
851
  count: r.offset + r.count - s.offset
850
852
  }, d = new Float32Array(6 * o.count);
851
853
  d.offset = o.offset, n.computePrimitiveBounds(o.offset, o.count, d), n._roots = e.map((a) => {
852
- const f = os(n, d, a.offset, a.count, t, o), l = je(f), p = new i(X * l);
853
- return ss(0, f, p), p;
854
+ const f = as(n, d, a.offset, a.count, t, o), l = Ne(f), p = new i(X * l);
855
+ return rs(0, f, p), p;
854
856
  });
855
857
  }
856
- class ii {
858
+ class ni {
857
859
  constructor(t) {
858
860
  this._getNewPrimitive = t, this._primitives = [];
859
861
  }
@@ -865,7 +867,7 @@ class ii {
865
867
  this._primitives.push(t);
866
868
  }
867
869
  }
868
- class as {
870
+ class ls {
869
871
  constructor() {
870
872
  this.float32Array = null, this.uint16Array = null, this.uint32Array = null;
871
873
  const t = [];
@@ -877,22 +879,22 @@ class as {
877
879
  };
878
880
  }
879
881
  }
880
- const I = /* @__PURE__ */ new as();
881
- let yt, Dt;
882
- const Tt = [], ee = /* @__PURE__ */ new ii(() => new it());
883
- function cs(n, t, i, e, s, r) {
884
- yt = ee.getPrimitive(), Dt = ee.getPrimitive(), Tt.push(yt, Dt), I.setBuffer(n._roots[t]);
885
- const o = Ne(0, n.geometry, i, e, s, r);
886
- I.clearBuffer(), ee.releasePrimitive(yt), ee.releasePrimitive(Dt), Tt.pop(), Tt.pop();
882
+ const I = /* @__PURE__ */ new ls();
883
+ let ht, Dt;
884
+ const Tt = [], ie = /* @__PURE__ */ new ni(() => new it());
885
+ function us(n, t, i, e, s, r) {
886
+ ht = ie.getPrimitive(), Dt = ie.getPrimitive(), Tt.push(ht, Dt), I.setBuffer(n._roots[t]);
887
+ const o = qe(0, n.geometry, i, e, s, r);
888
+ I.clearBuffer(), ie.releasePrimitive(ht), ie.releasePrimitive(Dt), Tt.pop(), Tt.pop();
887
889
  const d = Tt.length;
888
- return d > 0 && (Dt = Tt[d - 1], yt = Tt[d - 2]), o;
890
+ return d > 0 && (Dt = Tt[d - 1], ht = Tt[d - 2]), o;
889
891
  }
890
- function Ne(n, t, i, e, s = null, r = 0, o = 0) {
892
+ function qe(n, t, i, e, s = null, r = 0, o = 0) {
891
893
  const { float32Array: d, uint16Array: a, uint32Array: f } = I;
892
894
  let l = n * 2;
893
895
  if (q(l, a)) {
894
896
  const c = J(n, f), u = Z(l, a);
895
- return k(n, d, yt), e(c, u, !1, o, r + n / N, yt);
897
+ return k(n, d, ht), e(c, u, !1, o, r + n / C, ht);
896
898
  } else {
897
899
  let v = function(S) {
898
900
  const { uint16Array: _, uint32Array: E } = I;
@@ -909,19 +911,19 @@ function Ne(n, t, i, e, s = null, r = 0, o = 0) {
909
911
  };
910
912
  const c = V(n), u = W(n, f);
911
913
  let y = c, g = u, x, w, m, h;
912
- if (s && (m = yt, h = Dt, k(y, d, m), k(g, d, h), x = s(m), w = s(h), w < x)) {
914
+ if (s && (m = ht, h = Dt, k(y, d, m), k(g, d, h), x = s(m), w = s(h), w < x)) {
913
915
  y = u, g = c;
914
916
  const S = x;
915
917
  x = w, w = S, m = h;
916
918
  }
917
- m || (m = yt, k(y, d, m));
918
- const b = q(y * 2, a), A = i(m, b, x, o + 1, r + y / N);
919
+ m || (m = ht, k(y, d, m));
920
+ const b = q(y * 2, a), A = i(m, b, x, o + 1, r + y / C);
919
921
  let P;
920
- if (A === bi) {
922
+ if (A === Mi) {
921
923
  const S = v(y), E = B(y) - S;
922
- P = e(S, E, !0, o + 1, r + y / N, m);
924
+ P = e(S, E, !0, o + 1, r + y / C, m);
923
925
  } else
924
- P = A && Ne(
926
+ P = A && qe(
925
927
  y,
926
928
  t,
927
929
  i,
@@ -932,13 +934,13 @@ function Ne(n, t, i, e, s = null, r = 0, o = 0) {
932
934
  );
933
935
  if (P) return !0;
934
936
  h = Dt, k(g, d, h);
935
- const M = q(g * 2, a), T = i(h, M, w, o + 1, r + g / N);
937
+ const M = q(g * 2, a), T = i(h, M, w, o + 1, r + g / C);
936
938
  let R;
937
- if (T === bi) {
939
+ if (T === Mi) {
938
940
  const S = v(g), E = B(g) - S;
939
- R = e(S, E, !0, o + 1, r + g / N, h);
941
+ R = e(S, E, !0, o + 1, r + g / C, h);
940
942
  } else
941
- R = T && Ne(
943
+ R = T && qe(
942
944
  g,
943
945
  t,
944
946
  i,
@@ -950,20 +952,20 @@ function Ne(n, t, i, e, s = null, r = 0, o = 0) {
950
952
  return !!R;
951
953
  }
952
954
  }
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 ls(n, t, i, e) {
956
- if (_e)
955
+ const Ht = /* @__PURE__ */ new I.constructor(), be = /* @__PURE__ */ new I.constructor(), mt = /* @__PURE__ */ new ni(() => new it()), Rt = /* @__PURE__ */ new it(), Bt = /* @__PURE__ */ new it(), Be = /* @__PURE__ */ new it(), _e = /* @__PURE__ */ new it();
956
+ let Ee = !1;
957
+ function fs(n, t, i, e) {
958
+ if (Ee)
957
959
  throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");
958
- _e = !0;
960
+ Ee = !0;
959
961
  const s = n._roots, r = t._roots;
960
962
  let o, d = 0, a = 0;
961
963
  const f = new H().copy(i).invert();
962
964
  for (let l = 0, p = s.length; l < p; l++) {
963
965
  Ht.setBuffer(s[l]), a = 0;
964
- const c = ht.getPrimitive();
966
+ const c = mt.getPrimitive();
965
967
  k(0, Ht.float32Array, c), c.applyMatrix4(f);
966
- for (let u = 0, y = r.length; u < y && (we.setBuffer(r[u]), o = nt(
968
+ for (let u = 0, y = r.length; u < y && (be.setBuffer(r[u]), o = st(
967
969
  0,
968
970
  0,
969
971
  i,
@@ -974,16 +976,16 @@ function ls(n, t, i, e) {
974
976
  0,
975
977
  0,
976
978
  c
977
- ), we.clearBuffer(), a += r[u].byteLength / X, !o); u++)
979
+ ), be.clearBuffer(), a += r[u].byteLength / X, !o); u++)
978
980
  ;
979
- if (ht.releasePrimitive(c), Ht.clearBuffer(), d += s[l].byteLength / X, o)
981
+ if (mt.releasePrimitive(c), Ht.clearBuffer(), d += s[l].byteLength / X, o)
980
982
  break;
981
983
  }
982
- return _e = !1, o;
984
+ return Ee = !1, o;
983
985
  }
984
- function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
986
+ function st(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
985
987
  let p, c;
986
- l ? (p = we, c = Ht) : (p = Ht, c = we);
988
+ l ? (p = be, c = Ht) : (p = Ht, c = be);
987
989
  const u = p.float32Array, y = p.uint32Array, g = p.uint16Array, x = c.float32Array, w = c.uint32Array, m = c.uint16Array, h = n * 2, b = t * 2, A = q(h, g), P = q(b, m);
988
990
  let M = !1;
989
991
  if (P && A)
@@ -993,26 +995,26 @@ function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
993
995
  J(n, y),
994
996
  Z(n * 2, g),
995
997
  a,
996
- o + t / N,
998
+ o + t / C,
997
999
  d,
998
- r + n / N
1000
+ r + n / C
999
1001
  ) : M = s(
1000
1002
  J(n, y),
1001
1003
  Z(n * 2, g),
1002
1004
  J(t, w),
1003
1005
  Z(t * 2, m),
1004
1006
  d,
1005
- r + n / N,
1007
+ r + n / C,
1006
1008
  a,
1007
- o + t / N
1009
+ o + t / C
1008
1010
  );
1009
1011
  else if (P) {
1010
- const T = ht.getPrimitive();
1012
+ const T = mt.getPrimitive();
1011
1013
  k(t, x, T), T.applyMatrix4(i);
1012
1014
  const R = V(n), v = W(n, y);
1013
1015
  k(R, u, Rt), k(v, u, Bt);
1014
1016
  const B = T.intersectsBox(Rt), S = T.intersectsBox(Bt);
1015
- M = B && nt(
1017
+ M = B && st(
1016
1018
  t,
1017
1019
  R,
1018
1020
  e,
@@ -1024,7 +1026,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
1024
1026
  d + 1,
1025
1027
  T,
1026
1028
  !l
1027
- ) || S && nt(
1029
+ ) || S && st(
1028
1030
  t,
1029
1031
  v,
1030
1032
  e,
@@ -1036,13 +1038,13 @@ function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
1036
1038
  d + 1,
1037
1039
  T,
1038
1040
  !l
1039
- ), ht.releasePrimitive(T);
1041
+ ), mt.releasePrimitive(T);
1040
1042
  } else {
1041
1043
  const T = V(t), R = W(t, w);
1042
- k(T, x, Re), k(R, x, Be);
1043
- const v = f.intersectsBox(Re), B = f.intersectsBox(Be);
1044
+ k(T, x, Be), k(R, x, _e);
1045
+ const v = f.intersectsBox(Be), B = f.intersectsBox(_e);
1044
1046
  if (v && B)
1045
- M = nt(
1047
+ M = st(
1046
1048
  n,
1047
1049
  T,
1048
1050
  i,
@@ -1054,7 +1056,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
1054
1056
  a + 1,
1055
1057
  f,
1056
1058
  l
1057
- ) || nt(
1059
+ ) || st(
1058
1060
  n,
1059
1061
  R,
1060
1062
  i,
@@ -1069,7 +1071,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
1069
1071
  );
1070
1072
  else if (v)
1071
1073
  if (A)
1072
- M = nt(
1074
+ M = st(
1073
1075
  n,
1074
1076
  T,
1075
1077
  i,
@@ -1083,12 +1085,12 @@ function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
1083
1085
  l
1084
1086
  );
1085
1087
  else {
1086
- const S = ht.getPrimitive();
1087
- S.copy(Re).applyMatrix4(i);
1088
+ const S = mt.getPrimitive();
1089
+ S.copy(Be).applyMatrix4(i);
1088
1090
  const _ = V(n), E = W(n, y);
1089
1091
  k(_, u, Rt), k(E, u, Bt);
1090
1092
  const F = S.intersectsBox(Rt), D = S.intersectsBox(Bt);
1091
- M = F && nt(
1093
+ M = F && st(
1092
1094
  T,
1093
1095
  _,
1094
1096
  e,
@@ -1100,7 +1102,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
1100
1102
  d + 1,
1101
1103
  S,
1102
1104
  !l
1103
- ) || D && nt(
1105
+ ) || D && st(
1104
1106
  T,
1105
1107
  E,
1106
1108
  e,
@@ -1112,11 +1114,11 @@ function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
1112
1114
  d + 1,
1113
1115
  S,
1114
1116
  !l
1115
- ), ht.releasePrimitive(S);
1117
+ ), mt.releasePrimitive(S);
1116
1118
  }
1117
1119
  else if (B)
1118
1120
  if (A)
1119
- M = nt(
1121
+ M = st(
1120
1122
  n,
1121
1123
  R,
1122
1124
  i,
@@ -1130,12 +1132,12 @@ function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
1130
1132
  l
1131
1133
  );
1132
1134
  else {
1133
- const S = ht.getPrimitive();
1134
- S.copy(Be).applyMatrix4(i);
1135
+ const S = mt.getPrimitive();
1136
+ S.copy(_e).applyMatrix4(i);
1135
1137
  const _ = V(n), E = W(n, y);
1136
1138
  k(_, u, Rt), k(E, u, Bt);
1137
1139
  const F = S.intersectsBox(Rt), D = S.intersectsBox(Bt);
1138
- M = F && nt(
1140
+ M = F && st(
1139
1141
  R,
1140
1142
  _,
1141
1143
  e,
@@ -1147,7 +1149,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
1147
1149
  d + 1,
1148
1150
  S,
1149
1151
  !l
1150
- ) || D && nt(
1152
+ ) || D && st(
1151
1153
  R,
1152
1154
  E,
1153
1155
  e,
@@ -1159,21 +1161,21 @@ function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
1159
1161
  d + 1,
1160
1162
  S,
1161
1163
  !l
1162
- ), ht.releasePrimitive(S);
1164
+ ), mt.releasePrimitive(S);
1163
1165
  }
1164
1166
  }
1165
1167
  return M;
1166
1168
  }
1167
- const Pi = /* @__PURE__ */ new it(), _t = /* @__PURE__ */ new Float32Array(6);
1168
- class us {
1169
+ const Ri = /* @__PURE__ */ new it(), _t = /* @__PURE__ */ new Float32Array(6);
1170
+ class ds {
1169
1171
  constructor() {
1170
1172
  this._roots = null, this.primitiveBuffer = null, this.primitiveBufferStride = null;
1171
1173
  }
1172
1174
  init(t) {
1173
1175
  t = {
1174
- ...tn,
1176
+ ...sn,
1175
1177
  ...t
1176
- }, rs(this, t);
1178
+ }, cs(this, t);
1177
1179
  }
1178
1180
  getRootRanges() {
1179
1181
  throw new Error("BVH: getRootRanges() not implemented");
@@ -1199,7 +1201,7 @@ class us {
1199
1201
  for (let r = t, o = t + i; r < o; r++) {
1200
1202
  this.writePrimitiveBounds(r, _t, 0);
1201
1203
  const [d, a, f, l, p, c] = _t, u = (d + l) / 2, y = (a + p) / 2, g = (f + c) / 2, x = (l - d) / 2, w = (p - a) / 2, m = (c - f) / 2, h = (r - s) * 6;
1202
- e[h + 0] = u, e[h + 1] = x + (Math.abs(u) + 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;
1204
+ e[h + 0] = u, e[h + 1] = x + (Math.abs(u) + x) * ge, e[h + 2] = y, e[h + 3] = w + (Math.abs(y) + w) * ge, e[h + 4] = g, e[h + 5] = m + (Math.abs(g) + m) * ge;
1203
1205
  }
1204
1206
  return e;
1205
1207
  }
@@ -1213,7 +1215,7 @@ class us {
1213
1215
  for (let s = 0; s < e.length; s++) {
1214
1216
  const r = e[s], o = new Uint32Array(r), d = new Uint16Array(r), a = r.byteLength / X;
1215
1217
  for (let f = 0; f < a; f++) {
1216
- const l = N * f, p = 2 * l;
1218
+ const l = C * f, p = 2 * l;
1217
1219
  q(p, d) && (o[l + 6] += t);
1218
1220
  }
1219
1221
  }
@@ -1228,7 +1230,7 @@ class us {
1228
1230
  const p = s[d + 6], c = r[f + 14];
1229
1231
  t(a, l, new Float32Array(e, d * 4, 6), p, c);
1230
1232
  } else {
1231
- const p = V(d), c = W(d, s), u = ei(d, s);
1233
+ const p = V(d), c = W(d, s), u = ii(d, s);
1232
1234
  t(a, l, new Float32Array(e, d * 4, 6), u) || (o(p, a + 1), o(c, a + 1));
1233
1235
  }
1234
1236
  }
@@ -1238,7 +1240,7 @@ class us {
1238
1240
  for (let i = 0, e = t.length; i < e; i++) {
1239
1241
  const s = t[i], r = new Uint32Array(s), o = new Uint16Array(s), d = new Float32Array(s), a = s.byteLength / X;
1240
1242
  for (let f = a - 1; f >= 0; f--) {
1241
- const l = f * N, p = l * 2;
1243
+ const l = f * C, p = l * 2;
1242
1244
  if (q(p, o)) {
1243
1245
  const u = J(l, r), y = Z(p, o);
1244
1246
  this.writePrimitiveRangeBounds(u, y, _t, 0), d.set(_t, l);
@@ -1254,7 +1256,7 @@ class us {
1254
1256
  }
1255
1257
  getBoundingBox(t) {
1256
1258
  return t.makeEmpty(), this._roots.forEach((e) => {
1257
- k(0, new Float32Array(e), Pi), t.union(Pi);
1259
+ k(0, new Float32Array(e), Ri), t.union(Ri);
1258
1260
  }), t;
1259
1261
  }
1260
1262
  // Base shapecast implementation that can be used by subclasses
@@ -1277,7 +1279,7 @@ class us {
1277
1279
  const l = this._roots;
1278
1280
  for (let p = 0, c = l.length; p < c; p++) {
1279
1281
  const u = l[p];
1280
- if (a = cs(this, p, e, s, i, f), a)
1282
+ if (a = us(this, p, e, s, i, f), a)
1281
1283
  break;
1282
1284
  f += u.byteLength / X;
1283
1285
  }
@@ -1285,47 +1287,47 @@ class us {
1285
1287
  }
1286
1288
  bvhcast(t, i, e) {
1287
1289
  let { intersectsRanges: s } = e;
1288
- return ls(this, t, i, s);
1290
+ return fs(this, t, i, s);
1289
1291
  }
1290
1292
  }
1291
- function fs() {
1293
+ function ps() {
1292
1294
  return typeof SharedArrayBuffer < "u";
1293
1295
  }
1294
- function ni(n) {
1296
+ function si(n) {
1295
1297
  return n.index ? n.index.count : n.attributes.position.count;
1296
1298
  }
1297
- function Ae(n) {
1298
- return ni(n) / 3;
1299
+ function Me(n) {
1300
+ return si(n) / 3;
1299
1301
  }
1300
- function ds(n, t = ArrayBuffer) {
1302
+ function ms(n, t = ArrayBuffer) {
1301
1303
  return n > 65535 ? new Uint32Array(new t(4 * n)) : new Uint16Array(new t(2 * n));
1302
1304
  }
1303
- function ps(n, t) {
1305
+ function hs(n, t) {
1304
1306
  if (!n.index) {
1305
- const i = n.attributes.position.count, e = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, s = ds(i, e);
1306
- n.setIndex(new Oi(s, 1));
1307
+ const i = n.attributes.position.count, e = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, s = ms(i, e);
1308
+ n.setIndex(new Gi(s, 1));
1307
1309
  for (let r = 0; r < i; r++)
1308
1310
  s[r] = r;
1309
1311
  }
1310
1312
  }
1311
- function ms(n, t, i) {
1312
- const e = ni(n) / i, s = t || n.drawRange, r = s.start / i, o = (s.start + s.count) / i, d = Math.max(0, r), a = Math.min(e, o) - d;
1313
+ function ys(n, t, i) {
1314
+ const e = si(n) / i, s = t || n.drawRange, r = s.start / i, o = (s.start + s.count) / i, d = Math.max(0, r), a = Math.min(e, o) - d;
1313
1315
  return {
1314
1316
  offset: Math.floor(d),
1315
1317
  count: Math.floor(a)
1316
1318
  };
1317
1319
  }
1318
- function hs(n, t) {
1320
+ function gs(n, t) {
1319
1321
  return n.groups.map((i) => ({
1320
1322
  offset: i.start / t,
1321
1323
  count: i.count / t
1322
1324
  }));
1323
1325
  }
1324
- function Si(n, t, i) {
1325
- const e = ms(n, t, i), s = hs(n, i);
1326
+ function Bi(n, t, i) {
1327
+ const e = ys(n, t, i), s = gs(n, i);
1326
1328
  if (!s.length)
1327
1329
  return [e];
1328
- const r = [], o = e.offset, d = e.offset + e.count, a = ni(n) / i, f = [];
1330
+ const r = [], o = e.offset, d = e.offset + e.count, a = si(n) / i, f = [];
1329
1331
  for (const c of s) {
1330
1332
  const { offset: u, count: y } = c, g = u, x = isFinite(y) ? y : a - u, w = u + x;
1331
1333
  g < d && w > o && (f.push({ pos: Math.max(o, g), isStart: !0 }), f.push({ pos: Math.min(d, w), isStart: !1 }));
@@ -1341,7 +1343,7 @@ function Si(n, t, i) {
1341
1343
  }
1342
1344
  return r;
1343
1345
  }
1344
- function ys(n, t) {
1346
+ function ws(n, t) {
1345
1347
  const i = n[n.length - 1], e = i.offset + i.count > 2 ** 16, s = n.reduce((f, l) => f + l.count, 0), r = e ? 4 : 2, o = t ? new SharedArrayBuffer(s * r) : new ArrayBuffer(s * r), d = e ? new Uint32Array(o) : new Uint16Array(o);
1346
1348
  let a = 0;
1347
1349
  for (let f = 0; f < n.length; f++) {
@@ -1352,7 +1354,7 @@ function ys(n, t) {
1352
1354
  }
1353
1355
  return d;
1354
1356
  }
1355
- class gs extends us {
1357
+ class bs extends ds {
1356
1358
  get indirect() {
1357
1359
  return !!this._indirectBuffer;
1358
1360
  }
@@ -1374,31 +1376,31 @@ class gs extends us {
1374
1376
  if (t.index && t.index.isInterleavedBufferAttribute)
1375
1377
  throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.");
1376
1378
  } else throw new Error("BVH: Only BufferGeometries are supported.");
1377
- if (i.useSharedArrayBuffer && !fs())
1379
+ if (i.useSharedArrayBuffer && !ps())
1378
1380
  throw new Error("BVH: SharedArrayBuffer is not available.");
1379
1381
  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
- ...tn,
1382
+ ...sn,
1381
1383
  ...i
1382
- }, i[ti] || this.init(i);
1384
+ }, i[ei] || this.init(i);
1383
1385
  }
1384
1386
  init(t) {
1385
1387
  const { geometry: i, primitiveStride: e } = this;
1386
1388
  if (t.indirect) {
1387
- const s = Si(i, t.range, e), r = ys(s, t.useSharedArrayBuffer);
1389
+ const s = Bi(i, t.range, e), r = ws(s, t.useSharedArrayBuffer);
1388
1390
  this._indirectBuffer = r;
1389
1391
  } else
1390
- ps(i, t);
1392
+ hs(i, t);
1391
1393
  super.init(t), !i.boundingBox && t.setBoundingBox && (i.boundingBox = this.getBoundingBox(new it()));
1392
1394
  }
1393
1395
  // Abstract methods to be implemented by subclasses
1394
1396
  getRootRanges(t) {
1395
- return this.indirect ? [{ offset: 0, count: this._indirectBuffer.length }] : Si(this.geometry, t, this.primitiveStride);
1397
+ return this.indirect ? [{ offset: 0, count: this._indirectBuffer.length }] : Bi(this.geometry, t, this.primitiveStride);
1396
1398
  }
1397
1399
  raycastObject3D() {
1398
1400
  throw new Error("BVH: raycastObject3D() not implemented");
1399
1401
  }
1400
1402
  }
1401
- class pt {
1403
+ class dt {
1402
1404
  constructor() {
1403
1405
  this.min = 1 / 0, this.max = -1 / 0;
1404
1406
  }
@@ -1422,7 +1424,7 @@ class pt {
1422
1424
  return this.min > t.max || t.min > this.max;
1423
1425
  }
1424
1426
  }
1425
- pt.prototype.setFromBox = /* @__PURE__ */ function() {
1427
+ dt.prototype.setFromBox = /* @__PURE__ */ function() {
1426
1428
  const n = /* @__PURE__ */ new z();
1427
1429
  return function(i, e) {
1428
1430
  const s = e.min, r = e.max;
@@ -1437,7 +1439,7 @@ pt.prototype.setFromBox = /* @__PURE__ */ function() {
1437
1439
  this.min = o, this.max = d;
1438
1440
  };
1439
1441
  }();
1440
- const ws = /* @__PURE__ */ function() {
1442
+ const xs = /* @__PURE__ */ function() {
1441
1443
  const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new z();
1442
1444
  return function(s, r, o) {
1443
1445
  const d = s.start, a = n, f = r.start, l = t;
@@ -1446,10 +1448,10 @@ const ws = /* @__PURE__ */ function() {
1446
1448
  let w, m;
1447
1449
  x !== 0 ? w = (p * c - y * u) / x : w = 0, m = (p + w * c) / u, o.x = w, o.y = m;
1448
1450
  };
1449
- }(), si = /* @__PURE__ */ function() {
1450
- const n = /* @__PURE__ */ new gt(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new z();
1451
+ }(), oi = /* @__PURE__ */ function() {
1452
+ const n = /* @__PURE__ */ new yt(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new z();
1451
1453
  return function(s, r, o, d) {
1452
- ws(s, r, n);
1454
+ xs(s, r, n);
1453
1455
  let a = n.x, f = n.y;
1454
1456
  if (a >= 0 && a <= 1 && f >= 0 && f <= 1) {
1455
1457
  s.at(a, o), r.at(f, d);
@@ -1475,8 +1477,8 @@ const ws = /* @__PURE__ */ function() {
1475
1477
  }
1476
1478
  }
1477
1479
  };
1478
- }(), bs = /* @__PURE__ */ function() {
1479
- const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new Vi(), e = /* @__PURE__ */ new dt();
1480
+ }(), As = /* @__PURE__ */ function() {
1481
+ const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new Xi(), e = /* @__PURE__ */ new ut();
1480
1482
  return function(r, o) {
1481
1483
  const { radius: d, center: a } = r, { a: f, b: l, c: p } = o;
1482
1484
  if (e.start = f, e.end = l, e.closestPointToPoint(a, !0, n).distanceTo(a) <= d || (e.start = f, e.end = p, e.closestPointToPoint(a, !0, n).distanceTo(a) <= d) || (e.start = l, e.end = p, e.closestPointToPoint(a, !0, n).distanceTo(a) <= d)) return !0;
@@ -1487,16 +1489,16 @@ const ws = /* @__PURE__ */ function() {
1487
1489
  }
1488
1490
  return !1;
1489
1491
  };
1490
- }(), xs = ["x", "y", "z"], lt = 1e-15, Ti = lt * lt;
1492
+ }(), Ms = ["x", "y", "z"], ct = 1e-15, _i = ct * ct;
1491
1493
  function tt(n) {
1492
- return Math.abs(n) < lt;
1494
+ return Math.abs(n) < ct;
1493
1495
  }
1494
- class st extends $t {
1496
+ class ot extends $t {
1495
1497
  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 Vi(), this.isDegenerateIntoSegment = !1, this.isDegenerateIntoPoint = !1, this.degenerateSegment = new dt(), this.needsUpdate = !0;
1498
+ super(...t), this.isExtendedTriangle = !0, this.satAxes = new Array(4).fill().map(() => new z()), this.satBounds = new Array(4).fill().map(() => new dt()), this.points = [this.a, this.b, this.c], this.plane = new Xi(), this.isDegenerateIntoSegment = !1, this.isDegenerateIntoPoint = !1, this.degenerateSegment = new ut(), this.needsUpdate = !0;
1497
1499
  }
1498
1500
  intersectsSphere(t) {
1499
- return bs(t, this);
1501
+ return As(t, this);
1500
1502
  }
1501
1503
  update() {
1502
1504
  const t = this.a, i = this.b, e = this.c, s = this.points, r = this.satAxes, o = this.satBounds, d = r[0], a = o[0];
@@ -1508,23 +1510,23 @@ class st extends $t {
1508
1510
  const u = r[3], y = o[3];
1509
1511
  u.subVectors(e, t), y.setFromPoints(u, s);
1510
1512
  const g = f.length(), x = p.length(), w = u.length();
1511
- this.isDegenerateIntoPoint = !1, this.isDegenerateIntoSegment = !1, g < lt ? x < lt || w < lt ? this.isDegenerateIntoPoint = !0 : (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(t), this.degenerateSegment.end.copy(e)) : x < lt ? w < lt ? this.isDegenerateIntoPoint = !0 : (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(i), this.degenerateSegment.end.copy(t)) : w < lt && (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(e), this.degenerateSegment.end.copy(i)), this.plane.setFromNormalAndCoplanarPoint(d, t), this.needsUpdate = !1;
1513
+ this.isDegenerateIntoPoint = !1, this.isDegenerateIntoSegment = !1, g < ct ? x < ct || w < ct ? this.isDegenerateIntoPoint = !0 : (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(t), this.degenerateSegment.end.copy(e)) : x < ct ? w < ct ? this.isDegenerateIntoPoint = !0 : (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(i), this.degenerateSegment.end.copy(t)) : w < ct && (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(e), this.degenerateSegment.end.copy(i)), this.plane.setFromNormalAndCoplanarPoint(d, t), this.needsUpdate = !1;
1512
1514
  }
1513
1515
  }
1514
- st.prototype.closestPointToSegment = /* @__PURE__ */ function() {
1515
- const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new dt();
1516
+ ot.prototype.closestPointToSegment = /* @__PURE__ */ function() {
1517
+ const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new ut();
1516
1518
  return function(s, r = null, o = null) {
1517
1519
  const { start: d, end: a } = s, f = this.points;
1518
1520
  let l, p = 1 / 0;
1519
1521
  for (let c = 0; c < 3; c++) {
1520
1522
  const u = (c + 1) % 3;
1521
- i.start.copy(f[c]), i.end.copy(f[u]), si(i, s, n, t), l = n.distanceToSquared(t), l < p && (p = l, r && r.copy(n), o && o.copy(t));
1523
+ i.start.copy(f[c]), i.end.copy(f[u]), oi(i, s, n, t), l = n.distanceToSquared(t), l < p && (p = l, r && r.copy(n), o && o.copy(t));
1522
1524
  }
1523
1525
  return this.closestPointToPoint(d, n), l = d.distanceToSquared(n), l < p && (p = l, r && r.copy(n), o && o.copy(d)), this.closestPointToPoint(a, n), l = a.distanceToSquared(n), l < p && (p = l, r && r.copy(n), o && o.copy(a)), Math.sqrt(p);
1524
1526
  };
1525
1527
  }();
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(), d = /* @__PURE__ */ new dt(), a = /* @__PURE__ */ new dt(), f = /* @__PURE__ */ new z(), l = /* @__PURE__ */ new gt(), p = /* @__PURE__ */ new gt();
1528
+ ot.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1529
+ const n = /* @__PURE__ */ new ot(), t = /* @__PURE__ */ new dt(), i = /* @__PURE__ */ new dt(), e = /* @__PURE__ */ new z(), s = /* @__PURE__ */ new z(), r = /* @__PURE__ */ new z(), o = /* @__PURE__ */ new z(), d = /* @__PURE__ */ new ut(), a = /* @__PURE__ */ new ut(), f = /* @__PURE__ */ new z(), l = /* @__PURE__ */ new yt(), p = /* @__PURE__ */ new yt();
1528
1530
  function c(h, b, A, P) {
1529
1531
  const M = e;
1530
1532
  !h.isDegenerateIntoPoint && !h.isDegenerateIntoSegment ? M.copy(h.plane.normal) : M.copy(b.plane.normal);
@@ -1569,7 +1571,7 @@ st.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1569
1571
  }
1570
1572
  function w(h, b, A) {
1571
1573
  const P = h.degenerateSegment, M = b.a;
1572
- return P.closestPointToPoint(M, !0, e), M.distanceToSquared(e) < Ti ? (A && (A.start.copy(M), A.end.copy(M)), !0) : !1;
1574
+ return P.closestPointToPoint(M, !0, e), M.distanceToSquared(e) < _i ? (A && (A.start.copy(M), A.end.copy(M)), !0) : !1;
1573
1575
  }
1574
1576
  function m(h, b, A, P) {
1575
1577
  if (h.isDegenerateIntoSegment)
@@ -1587,7 +1589,7 @@ st.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1587
1589
  } else return b.isDegenerateIntoPoint ? w(h, b, A) : g(b, h, A, P);
1588
1590
  else {
1589
1591
  if (h.isDegenerateIntoPoint)
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);
1592
+ return b.isDegenerateIntoPoint ? b.a.distanceToSquared(h.a) < _i ? (A && (A.start.copy(h.a), A.end.copy(h.a)), !0) : !1 : b.isDegenerateIntoSegment ? w(b, h, A) : x(b, h, A);
1591
1593
  if (b.isDegenerateIntoPoint)
1592
1594
  return x(h, b, A);
1593
1595
  if (b.isDegenerateIntoSegment)
@@ -1613,32 +1615,32 @@ st.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1613
1615
  s.copy(T.normal), r.copy(R.normal);
1614
1616
  const Mt = s.cross(r);
1615
1617
  let vt = 0, Pt = Math.abs(Mt.x);
1616
- const rt = Math.abs(Mt.y);
1617
- rt > Pt && (Pt = rt, vt = 1), Math.abs(Mt.z) > Pt && (vt = 2);
1618
- const at = xs[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, d))
1618
+ const kt = Math.abs(Mt.y);
1619
+ kt > Pt && (Pt = kt, vt = 1), Math.abs(Mt.z) > Pt && (vt = 2);
1620
+ const nt = Ms[vt], Yt = this.a[nt], an = this.b[nt], cn = this.c[nt], ln = b.a[nt], un = b.b[nt], fn = b.c[nt];
1621
+ if (y(this, Yt, an, cn, _, E, v, B, S, l, d))
1620
1622
  return c(this, b, A, P);
1621
- if (y(b, an, cn, ln, L, Y, F, D, U, p, a))
1623
+ if (y(b, ln, un, fn, L, Y, F, D, U, p, a))
1622
1624
  return c(this, b, A, P);
1623
1625
  if (l.y < l.x) {
1624
- const ve = l.y;
1625
- l.y = l.x, l.x = ve, f.copy(d.start), d.start.copy(d.end), d.end.copy(f);
1626
+ const Pe = l.y;
1627
+ l.y = l.x, l.x = Pe, f.copy(d.start), d.start.copy(d.end), d.end.copy(f);
1626
1628
  }
1627
1629
  if (p.y < p.x) {
1628
- const ve = p.y;
1629
- p.y = p.x, p.x = ve, f.copy(a.start), a.start.copy(a.end), a.end.copy(f);
1630
+ const Pe = p.y;
1631
+ p.y = p.x, p.x = Pe, f.copy(a.start), a.start.copy(a.end), a.end.copy(f);
1630
1632
  }
1631
1633
  return l.y < p.x || p.y < l.x ? !1 : (A && (p.x > l.x ? A.start.copy(a.start) : A.start.copy(d.start), p.y < l.y ? A.end.copy(a.end) : A.end.copy(d.end)), !0);
1632
1634
  };
1633
1635
  }();
1634
- st.prototype.distanceToPoint = /* @__PURE__ */ function() {
1636
+ ot.prototype.distanceToPoint = /* @__PURE__ */ function() {
1635
1637
  const n = /* @__PURE__ */ new z();
1636
1638
  return function(i) {
1637
1639
  return this.closestPointToPoint(i, n), i.distanceTo(n);
1638
1640
  };
1639
1641
  }();
1640
- st.prototype.distanceToTriangle = /* @__PURE__ */ function() {
1641
- const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = ["a", "b", "c"], e = /* @__PURE__ */ new dt(), s = /* @__PURE__ */ new dt();
1642
+ ot.prototype.distanceToTriangle = /* @__PURE__ */ function() {
1643
+ const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = ["a", "b", "c"], e = /* @__PURE__ */ new ut(), s = /* @__PURE__ */ new ut();
1642
1644
  return function(o, d = null, a = null) {
1643
1645
  const f = d || a ? e : null;
1644
1646
  if (this.intersectsTriangle(o, f))
@@ -1656,7 +1658,7 @@ st.prototype.distanceToTriangle = /* @__PURE__ */ function() {
1656
1658
  e.set(this[c], this[u]);
1657
1659
  for (let y = 0; y < 3; y++) {
1658
1660
  const g = i[y], x = i[(y + 1) % 3];
1659
- s.set(o[g], o[x]), si(e, s, n, t);
1661
+ s.set(o[g], o[x]), oi(e, s, n, t);
1660
1662
  const w = n.distanceToSquared(t);
1661
1663
  w < l && (l = w, d && d.copy(n), a && a.copy(t));
1662
1664
  }
@@ -1666,7 +1668,7 @@ st.prototype.distanceToTriangle = /* @__PURE__ */ function() {
1666
1668
  }();
1667
1669
  class Q {
1668
1670
  constructor(t, i, e) {
1669
- this.isOrientedBox = !0, this.min = new z(), this.max = new z(), this.matrix = new H(), this.invMatrix = new H(), this.points = new Array(8).fill().map(() => new z()), this.satAxes = new Array(3).fill().map(() => new z()), this.satBounds = new Array(3).fill().map(() => new pt()), this.alignedSatBounds = new Array(3).fill().map(() => new pt()), this.needsUpdate = !1, t && this.min.copy(t), i && this.max.copy(i), e && this.matrix.copy(e);
1671
+ this.isOrientedBox = !0, this.min = new z(), this.max = new z(), this.matrix = new H(), this.invMatrix = new H(), this.points = new Array(8).fill().map(() => new z()), this.satAxes = new Array(3).fill().map(() => new z()), this.satBounds = new Array(3).fill().map(() => new dt()), this.alignedSatBounds = new Array(3).fill().map(() => new dt()), this.needsUpdate = !1, t && this.min.copy(t), i && this.max.copy(i), e && this.matrix.copy(e);
1670
1672
  }
1671
1673
  set(t, i, e) {
1672
1674
  this.min.copy(t), this.max.copy(i), this.matrix.copy(e), this.needsUpdate = !0;
@@ -1694,7 +1696,7 @@ Q.prototype.update = /* @__PURE__ */ function() {
1694
1696
  };
1695
1697
  }();
1696
1698
  Q.prototype.intersectsBox = /* @__PURE__ */ function() {
1697
- const n = /* @__PURE__ */ new pt();
1699
+ const n = /* @__PURE__ */ new dt();
1698
1700
  return function(i) {
1699
1701
  this.needsUpdate && this.update();
1700
1702
  const e = i.min, s = i.max, r = this.satBounds, o = this.satAxes, d = this.alignedSatBounds;
@@ -1707,7 +1709,7 @@ Q.prototype.intersectsBox = /* @__PURE__ */ function() {
1707
1709
  };
1708
1710
  }();
1709
1711
  Q.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1710
- const n = /* @__PURE__ */ new st(), t = /* @__PURE__ */ new Array(3), i = /* @__PURE__ */ new pt(), e = /* @__PURE__ */ new pt(), s = /* @__PURE__ */ new z();
1712
+ const n = /* @__PURE__ */ new ot(), t = /* @__PURE__ */ new Array(3), i = /* @__PURE__ */ new dt(), e = /* @__PURE__ */ new dt(), s = /* @__PURE__ */ new z();
1711
1713
  return function(o) {
1712
1714
  this.needsUpdate && this.update(), o.isExtendedTriangle ? o.needsUpdate && o.update() : (n.copy(o), n.update(), o = n);
1713
1715
  const d = this.satBounds, a = this.satAxes;
@@ -1743,7 +1745,7 @@ Q.prototype.distanceToPoint = function() {
1743
1745
  };
1744
1746
  }();
1745
1747
  Q.prototype.distanceToBox = /* @__PURE__ */ function() {
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();
1748
+ const n = ["x", "y", "z"], t = /* @__PURE__ */ new Array(12).fill().map(() => new ut()), i = /* @__PURE__ */ new Array(12).fill().map(() => new ut()), e = /* @__PURE__ */ new z(), s = /* @__PURE__ */ new z();
1747
1749
  return function(o, d = 0, a = null, f = null) {
1748
1750
  if (this.needsUpdate && this.update(), this.intersectsBox(o))
1749
1751
  return (a || f) && (o.getCenter(s), this.closestPointToPoint(s, e), o.closestPointToPoint(e, s), a && a.copy(e), f && f.copy(s)), 0;
@@ -1777,7 +1779,7 @@ Q.prototype.distanceToBox = /* @__PURE__ */ function() {
1777
1779
  const w = t[x];
1778
1780
  for (let m = 0; m < 12; m++) {
1779
1781
  const h = i[m];
1780
- si(w, h, e, s);
1782
+ oi(w, h, e, s);
1781
1783
  const b = e.distanceToSquared(s);
1782
1784
  if (b < y && (y = b, a && a.copy(e), f && f.copy(s), b < l))
1783
1785
  return Math.sqrt(b);
@@ -1786,57 +1788,57 @@ Q.prototype.distanceToBox = /* @__PURE__ */ function() {
1786
1788
  return Math.sqrt(y);
1787
1789
  };
1788
1790
  }();
1789
- class As extends ii {
1791
+ class vs extends ni {
1790
1792
  constructor() {
1791
- super(() => new st());
1793
+ super(() => new ot());
1792
1794
  }
1793
1795
  }
1794
- const et = /* @__PURE__ */ new As(), Nt = /* @__PURE__ */ new z(), Ee = /* @__PURE__ */ new z();
1795
- function Ms(n, t, i = {}, e = 0, s = 1 / 0) {
1796
+ const et = /* @__PURE__ */ new vs(), Ct = /* @__PURE__ */ new z(), ze = /* @__PURE__ */ new z();
1797
+ function Ps(n, t, i = {}, e = 0, s = 1 / 0) {
1796
1798
  const r = e * e, o = s * s;
1797
1799
  let d = 1 / 0, a = null;
1798
1800
  if (n.shapecast(
1799
1801
  {
1800
- boundsTraverseOrder: (l) => (Nt.copy(t).clamp(l.min, l.max), Nt.distanceToSquared(t)),
1802
+ boundsTraverseOrder: (l) => (Ct.copy(t).clamp(l.min, l.max), Ct.distanceToSquared(t)),
1801
1803
  intersectsBounds: (l, p, c) => c < d && c < o,
1802
1804
  intersectsTriangle: (l, p) => {
1803
- l.closestPointToPoint(t, Nt);
1804
- const c = t.distanceToSquared(Nt);
1805
- return c < d && (Ee.copy(Nt), d = c, a = p), c < r;
1805
+ l.closestPointToPoint(t, Ct);
1806
+ const c = t.distanceToSquared(Ct);
1807
+ return c < d && (ze.copy(Ct), d = c, a = p), c < r;
1806
1808
  }
1807
1809
  }
1808
1810
  ), d === 1 / 0) return null;
1809
1811
  const f = Math.sqrt(d);
1810
- return i.point ? i.point.copy(Ee) : i.point = Ee.clone(), i.distance = f, i.faceIndex = a, i;
1812
+ return i.point ? i.point.copy(ze) : i.point = ze.clone(), i.distance = f, i.faceIndex = a, i;
1811
1813
  }
1812
- const ie = parseInt(Wi) >= 169, vs = 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 Ps(n, t, i, e, s, r, o, d) {
1814
+ const ne = parseInt(Ji) >= 169, Ss = parseInt(Ji) <= 161, bt = /* @__PURE__ */ new z(), xt = /* @__PURE__ */ new z(), At = /* @__PURE__ */ new z(), se = /* @__PURE__ */ new yt(), oe = /* @__PURE__ */ new yt(), re = /* @__PURE__ */ new yt(), Ei = /* @__PURE__ */ new z(), zi = /* @__PURE__ */ new z(), Ui = /* @__PURE__ */ new z(), qt = /* @__PURE__ */ new z();
1815
+ function Ts(n, t, i, e, s, r, o, d) {
1814
1816
  let a;
1815
- if (r === Pn ? a = n.intersectTriangle(e, i, t, !0, s) : a = n.intersectTriangle(t, i, e, r !== Sn, s), a === null) return null;
1817
+ if (r === Tn ? a = n.intersectTriangle(e, i, t, !0, s) : a = n.intersectTriangle(t, i, e, r !== Rn, s), a === null) return null;
1816
1818
  const f = n.origin.distanceTo(s);
1817
1819
  return f < o || f > d ? null : {
1818
1820
  distance: f,
1819
1821
  point: s.clone()
1820
1822
  };
1821
1823
  }
1822
- function Ei(n, t, i, e, s, r, o, d, a, f, l) {
1824
+ function Fi(n, t, i, e, s, r, o, d, a, f, l) {
1823
1825
  bt.fromBufferAttribute(t, r), xt.fromBufferAttribute(t, o), At.fromBufferAttribute(t, d);
1824
- const p = Ps(n, bt, xt, At, qt, a, f, l);
1826
+ const p = Ts(n, bt, xt, At, qt, a, f, l);
1825
1827
  if (p) {
1826
1828
  if (e) {
1827
- ne.fromBufferAttribute(e, r), se.fromBufferAttribute(e, o), oe.fromBufferAttribute(e, d), p.uv = new gt();
1828
- const u = $t.getInterpolation(qt, bt, xt, At, ne, se, oe, p.uv);
1829
- ie || (p.uv = u);
1829
+ se.fromBufferAttribute(e, r), oe.fromBufferAttribute(e, o), re.fromBufferAttribute(e, d), p.uv = new yt();
1830
+ const u = $t.getInterpolation(qt, bt, xt, At, se, oe, re, p.uv);
1831
+ ne || (p.uv = u);
1830
1832
  }
1831
1833
  if (s) {
1832
- ne.fromBufferAttribute(s, r), se.fromBufferAttribute(s, o), oe.fromBufferAttribute(s, d), p.uv1 = new gt();
1833
- const u = $t.getInterpolation(qt, bt, xt, At, ne, se, oe, p.uv1);
1834
- ie || (p.uv1 = u), vs && (p.uv2 = p.uv1);
1834
+ se.fromBufferAttribute(s, r), oe.fromBufferAttribute(s, o), re.fromBufferAttribute(s, d), p.uv1 = new yt();
1835
+ const u = $t.getInterpolation(qt, bt, xt, At, se, oe, re, p.uv1);
1836
+ ne || (p.uv1 = u), Ss && (p.uv2 = p.uv1);
1835
1837
  }
1836
1838
  if (i) {
1837
- Ri.fromBufferAttribute(i, r), Bi.fromBufferAttribute(i, o), _i.fromBufferAttribute(i, d), p.normal = new z();
1838
- const u = $t.getInterpolation(qt, bt, xt, At, Ri, Bi, _i, p.normal);
1839
- p.normal.dot(n.direction) > 0 && p.normal.multiplyScalar(-1), ie || (p.normal = u);
1839
+ Ei.fromBufferAttribute(i, r), zi.fromBufferAttribute(i, o), Ui.fromBufferAttribute(i, d), p.normal = new z();
1840
+ const u = $t.getInterpolation(qt, bt, xt, At, Ei, zi, Ui, p.normal);
1841
+ p.normal.dot(n.direction) > 0 && p.normal.multiplyScalar(-1), ne || (p.normal = u);
1840
1842
  }
1841
1843
  const c = {
1842
1844
  a: r,
@@ -1845,17 +1847,17 @@ function Ei(n, t, i, e, s, r, o, d, a, f, l) {
1845
1847
  normal: new z(),
1846
1848
  materialIndex: 0
1847
1849
  };
1848
- if ($t.getNormal(bt, xt, At, c.normal), p.face = c, p.faceIndex = r, ie) {
1850
+ if ($t.getNormal(bt, xt, At, c.normal), p.face = c, p.faceIndex = r, ne) {
1849
1851
  const u = new z();
1850
1852
  $t.getBarycoord(qt, bt, xt, At, u), p.barycoord = u;
1851
1853
  }
1852
1854
  }
1853
1855
  return p;
1854
1856
  }
1855
- function zi(n) {
1857
+ function $i(n) {
1856
1858
  return n && n.isMaterial ? n.side : n;
1857
1859
  }
1858
- function Me(n, t, i, e, s, r, o) {
1860
+ function ve(n, t, i, e, s, r, o) {
1859
1861
  const d = e * 3;
1860
1862
  let a = d + 0, f = d + 1, l = d + 2;
1861
1863
  const { index: p, groups: c } = n;
@@ -1866,7 +1868,7 @@ function Me(n, t, i, e, s, r, o) {
1866
1868
  for (let m = 0, h = c.length; m < h; m++) {
1867
1869
  const { start: b, count: A, materialIndex: P } = c[m];
1868
1870
  if (w >= b && w < b + A) {
1869
- const M = zi(t[P]), T = Ei(i, u, y, g, x, a, f, l, M, r, o);
1871
+ const M = $i(t[P]), T = Fi(i, u, y, g, x, a, f, l, M, r, o);
1870
1872
  if (T)
1871
1873
  if (T.faceIndex = e, T.face.materialIndex = P, s)
1872
1874
  s.push(T);
@@ -1875,7 +1877,7 @@ function Me(n, t, i, e, s, r, o) {
1875
1877
  }
1876
1878
  }
1877
1879
  } else {
1878
- const w = zi(t), m = Ei(i, u, y, g, x, a, f, l, w, r, o);
1880
+ const w = $i(t), m = Fi(i, u, y, g, x, a, f, l, w, r, o);
1879
1881
  if (m)
1880
1882
  if (m.faceIndex = e, m.face.materialIndex = 0, s)
1881
1883
  s.push(m);
@@ -1889,21 +1891,21 @@ function j(n, t, i, e) {
1889
1891
  let d = t, a = t + 1, f = t + 2;
1890
1892
  i && (d = i.getX(d), a = i.getX(a), f = i.getX(f)), s.x = e.getX(d), s.y = e.getY(d), s.z = e.getZ(d), r.x = e.getX(a), r.y = e.getY(a), r.z = e.getZ(a), o.x = e.getX(f), o.y = e.getY(f), o.z = e.getZ(f);
1891
1893
  }
1892
- function Ss(n, t, i, e, s, r, o, d) {
1894
+ function Rs(n, t, i, e, s, r, o, d) {
1893
1895
  const { geometry: a, _indirectBuffer: f } = n;
1894
1896
  for (let l = e, p = e + s; l < p; l++)
1895
- Me(a, t, i, l, r, o, d);
1897
+ ve(a, t, i, l, r, o, d);
1896
1898
  }
1897
- function Ts(n, t, i, e, s, r, o) {
1899
+ function Bs(n, t, i, e, s, r, o) {
1898
1900
  const { geometry: d, _indirectBuffer: a } = n;
1899
1901
  let f = 1 / 0, l = null;
1900
1902
  for (let p = e, c = e + s; p < c; p++) {
1901
1903
  let u;
1902
- u = Me(d, t, i, p, null, r, o), u && u.distance < f && (l = u, f = u.distance);
1904
+ u = ve(d, t, i, p, null, r, o), u && u.distance < f && (l = u, f = u.distance);
1903
1905
  }
1904
1906
  return l;
1905
1907
  }
1906
- function Rs(n, t, i, e, s, r, o) {
1908
+ function _s(n, t, i, e, s, r, o) {
1907
1909
  const { geometry: d } = i, { index: a } = d, f = d.attributes.position;
1908
1910
  for (let l = n, p = t + n; l < p; l++) {
1909
1911
  let c;
@@ -1912,7 +1914,7 @@ function Rs(n, t, i, e, s, r, o) {
1912
1914
  }
1913
1915
  return !1;
1914
1916
  }
1915
- function Bs(n, t = null) {
1917
+ function Es(n, t = null) {
1916
1918
  t && Array.isArray(t) && (t = new Set(t));
1917
1919
  const i = n.geometry, e = i.index ? i.index.array : null, s = i.attributes.position;
1918
1920
  let r, o, d, a, f = 0;
@@ -1935,7 +1937,7 @@ function Bs(n, t = null) {
1935
1937
  let m = y, h = !1, b = !1;
1936
1938
  if (t) {
1937
1939
  if (!m) {
1938
- const v = x / N + u / X, B = w / N + u / X;
1940
+ const v = x / C + u / X, B = w / C + u / X;
1939
1941
  h = t.has(v), b = t.has(B), m = !h && !b;
1940
1942
  }
1941
1943
  } else
@@ -1955,29 +1957,29 @@ function Bs(n, t = null) {
1955
1957
  }
1956
1958
  }
1957
1959
  }
1958
- function wt(n, t, i, e, s) {
1960
+ function gt(n, t, i, e, s) {
1959
1961
  let r, o, d, a, f, l;
1960
1962
  const p = 1 / i.direction.x, c = 1 / i.direction.y, u = 1 / i.direction.z, y = i.origin.x, g = i.origin.y, x = i.origin.z;
1961
1963
  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
1964
  return p >= 0 ? (r = (w - y) * p, o = (m - y) * p) : (r = (m - y) * p, o = (w - y) * p), c >= 0 ? (d = (h - g) * c, a = (b - g) * c) : (d = (b - g) * c, a = (h - g) * c), r > a || d > o || ((d > r || isNaN(r)) && (r = d), (a < o || isNaN(o)) && (o = a), u >= 0 ? (f = (A - x) * u, l = (P - x) * u) : (f = (P - x) * u, l = (A - x) * u), r > l || f > o) ? !1 : ((f > r || r !== r) && (r = f), (l < o || o !== o) && (o = l), r <= s && o >= e);
1963
1965
  }
1964
- function _s(n, t, i, e, s, r, o, d) {
1966
+ function zs(n, t, i, e, s, r, o, d) {
1965
1967
  const { geometry: a, _indirectBuffer: f } = n;
1966
1968
  for (let l = e, p = e + s; l < p; l++) {
1967
1969
  let c = f ? f[l] : l;
1968
- Me(a, t, i, c, r, o, d);
1970
+ ve(a, t, i, c, r, o, d);
1969
1971
  }
1970
1972
  }
1971
- function Es(n, t, i, e, s, r, o) {
1973
+ function Us(n, t, i, e, s, r, o) {
1972
1974
  const { geometry: d, _indirectBuffer: a } = n;
1973
1975
  let f = 1 / 0, l = null;
1974
1976
  for (let p = e, c = e + s; p < c; p++) {
1975
1977
  let u;
1976
- u = Me(d, t, i, a ? a[p] : p, null, r, o), u && u.distance < f && (l = u, f = u.distance);
1978
+ u = ve(d, t, i, a ? a[p] : p, null, r, o), u && u.distance < f && (l = u, f = u.distance);
1977
1979
  }
1978
1980
  return l;
1979
1981
  }
1980
- function zs(n, t, i, e, s, r, o) {
1982
+ function Fs(n, t, i, e, s, r, o) {
1981
1983
  const { geometry: d } = i, { index: a } = d, f = d.attributes.position;
1982
1984
  for (let l = n, p = t + n; l < p; l++) {
1983
1985
  let c;
@@ -1986,38 +1988,38 @@ function zs(n, t, i, e, s, r, o) {
1986
1988
  }
1987
1989
  return !1;
1988
1990
  }
1989
- function Us(n, t, i, e, s, r, o) {
1990
- I.setBuffer(n._roots[t]), qe(0, n, i, e, s, r, o), I.clearBuffer();
1991
+ function $s(n, t, i, e, s, r, o) {
1992
+ I.setBuffer(n._roots[t]), Oe(0, n, i, e, s, r, o), I.clearBuffer();
1991
1993
  }
1992
- function qe(n, t, i, e, s, r, o) {
1994
+ function Oe(n, t, i, e, s, r, o) {
1993
1995
  const { float32Array: d, uint16Array: a, uint32Array: f } = I, l = n * 2;
1994
1996
  if (q(l, a)) {
1995
1997
  const c = J(n, f), u = Z(l, a);
1996
- Ss(t, i, e, c, u, s, r, o);
1998
+ Rs(t, i, e, c, u, s, r, o);
1997
1999
  } else {
1998
2000
  const c = V(n);
1999
- wt(c, d, e, r, o) && qe(c, t, i, e, s, r, o);
2001
+ gt(c, d, e, r, o) && Oe(c, t, i, e, s, r, o);
2000
2002
  const u = W(n, f);
2001
- wt(u, d, e, r, o) && qe(u, t, i, e, s, r, o);
2003
+ gt(u, d, e, r, o) && Oe(u, t, i, e, s, r, o);
2002
2004
  }
2003
2005
  }
2004
- const Fs = ["x", "y", "z"];
2005
- function $s(n, t, i, e, s, r) {
2006
+ const Is = ["x", "y", "z"];
2007
+ function Ds(n, t, i, e, s, r) {
2006
2008
  I.setBuffer(n._roots[t]);
2007
- const o = Oe(0, n, i, e, s, r);
2009
+ const o = Ve(0, n, i, e, s, r);
2008
2010
  return I.clearBuffer(), o;
2009
2011
  }
2010
- function Oe(n, t, i, e, s, r) {
2012
+ function Ve(n, t, i, e, s, r) {
2011
2013
  const { float32Array: o, uint16Array: d, uint32Array: a } = I;
2012
2014
  let f = n * 2;
2013
2015
  if (q(f, d)) {
2014
2016
  const p = J(n, a), c = Z(f, d);
2015
- return Ts(t, i, e, p, c, s, r);
2017
+ return Bs(t, i, e, p, c, s, r);
2016
2018
  } else {
2017
- const p = ei(n, a), c = Fs[p], y = e.direction[c] >= 0;
2019
+ const p = ii(n, a), c = Is[p], y = e.direction[c] >= 0;
2018
2020
  let g, x;
2019
2021
  y ? (g = V(n), x = W(n, a)) : (g = W(n, a), x = V(n));
2020
- const m = wt(g, o, e, s, r) ? Oe(g, t, i, e, s, r) : null;
2022
+ const m = gt(g, o, e, s, r) ? Ve(g, t, i, e, s, r) : null;
2021
2023
  if (m) {
2022
2024
  const A = m.point[c];
2023
2025
  if (y ? A <= o[x + p] : (
@@ -2026,24 +2028,24 @@ function Oe(n, t, i, e, s, r) {
2026
2028
  ))
2027
2029
  return m;
2028
2030
  }
2029
- const b = wt(x, o, e, s, r) ? Oe(x, t, i, e, s, r) : null;
2031
+ const b = gt(x, o, e, s, r) ? Ve(x, t, i, e, s, r) : null;
2030
2032
  return m && b ? m.distance <= b.distance ? m : b : m || b || null;
2031
2033
  }
2032
2034
  }
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 Is(n, t, i, e) {
2035
+ const ae = /* @__PURE__ */ new it(), Et = /* @__PURE__ */ new ot(), zt = /* @__PURE__ */ new ot(), Ot = /* @__PURE__ */ new H(), Ii = /* @__PURE__ */ new Q(), ce = /* @__PURE__ */ new Q();
2036
+ function Ls(n, t, i, e) {
2035
2037
  I.setBuffer(n._roots[t]);
2036
- const s = Ve(0, n, i, e);
2038
+ const s = We(0, n, i, e);
2037
2039
  return I.clearBuffer(), s;
2038
2040
  }
2039
- function Ve(n, t, i, e, s = null) {
2041
+ function We(n, t, i, e, s = null) {
2040
2042
  const { float32Array: r, uint16Array: o, uint32Array: d } = I;
2041
2043
  let a = n * 2;
2042
- if (s === null && (i.boundingBox || i.computeBoundingBox(), Ui.set(i.boundingBox.min, i.boundingBox.max, e), s = Ui), q(a, o)) {
2044
+ if (s === null && (i.boundingBox || i.computeBoundingBox(), Ii.set(i.boundingBox.min, i.boundingBox.max, e), s = Ii), q(a, o)) {
2043
2045
  const l = t.geometry, p = l.index, c = l.attributes.position, u = i.index, y = i.attributes.position, g = J(n, d), x = Z(a, o);
2044
2046
  if (Ot.copy(e).invert(), i.boundsTree)
2045
- return k(n, r, ae), ae.matrix.copy(Ot), ae.needsUpdate = !0, i.boundsTree.shapecast({
2046
- intersectsBounds: (m) => ae.intersectsBox(m),
2047
+ return k(n, r, ce), ce.matrix.copy(Ot), ce.needsUpdate = !0, i.boundsTree.shapecast({
2048
+ intersectsBounds: (m) => ce.intersectsBox(m),
2047
2049
  intersectsTriangle: (m) => {
2048
2050
  m.a.applyMatrix4(e), m.b.applyMatrix4(e), m.c.applyMatrix4(e), m.needsUpdate = !0;
2049
2051
  for (let h = g * 3, b = (x + g) * 3; h < b; h += 3)
@@ -2053,7 +2055,7 @@ function Ve(n, t, i, e, s = null) {
2053
2055
  }
2054
2056
  });
2055
2057
  {
2056
- const w = Ae(i);
2058
+ const w = Me(i);
2057
2059
  for (let m = g * 3, h = (x + g) * 3; m < h; m += 3) {
2058
2060
  j(Et, m, p, c), Et.a.applyMatrix4(Ot), Et.b.applyMatrix4(Ot), Et.c.applyMatrix4(Ot), Et.needsUpdate = !0;
2059
2061
  for (let b = 0, A = w * 3; b < A; b += 3)
@@ -2063,19 +2065,19 @@ function Ve(n, t, i, e, s = null) {
2063
2065
  }
2064
2066
  } else {
2065
2067
  const l = V(n), p = W(n, d);
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)));
2068
+ return k(l, r, ae), !!(s.intersectsBox(ae) && We(l, t, i, e, s) || (k(p, r, ae), s.intersectsBox(ae) && We(p, t, i, e, s)));
2067
2069
  }
2068
2070
  }
2069
- const ce = /* @__PURE__ */ new H(), ze = /* @__PURE__ */ new Q(), Vt = /* @__PURE__ */ new Q(), Ds = /* @__PURE__ */ new z(), Ls = /* @__PURE__ */ new z(), ks = /* @__PURE__ */ new z(), js = /* @__PURE__ */ new z();
2070
- function Cs(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2071
- t.boundingBox || t.computeBoundingBox(), ze.set(t.boundingBox.min, t.boundingBox.max, i), ze.needsUpdate = !0;
2071
+ const le = /* @__PURE__ */ new H(), Ue = /* @__PURE__ */ new Q(), Vt = /* @__PURE__ */ new Q(), ks = /* @__PURE__ */ new z(), js = /* @__PURE__ */ new z(), Ns = /* @__PURE__ */ new z(), Cs = /* @__PURE__ */ new z();
2072
+ function qs(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2073
+ t.boundingBox || t.computeBoundingBox(), Ue.set(t.boundingBox.min, t.boundingBox.max, i), Ue.needsUpdate = !0;
2072
2074
  const d = n.geometry, a = d.attributes.position, f = d.index, l = t.attributes.position, p = t.index, c = et.getPrimitive(), u = et.getPrimitive();
2073
- let y = Ds, g = Ls, x = null, w = null;
2074
- s && (x = ks, w = js);
2075
+ let y = ks, g = js, x = null, w = null;
2076
+ s && (x = Ns, w = Cs);
2075
2077
  let m = 1 / 0, h = null, b = null;
2076
- return ce.copy(i).invert(), Vt.matrix.copy(ce), n.shapecast(
2078
+ return le.copy(i).invert(), Vt.matrix.copy(le), n.shapecast(
2077
2079
  {
2078
- boundsTraverseOrder: (A) => ze.distanceToBox(A),
2080
+ boundsTraverseOrder: (A) => Ue.distanceToBox(A),
2079
2081
  intersectsBounds: (A, P, M) => M < m && M < o ? (P && (Vt.min.copy(A.min), Vt.max.copy(A.max), Vt.needsUpdate = !0), !0) : !1,
2080
2082
  intersectsRange: (A, P) => {
2081
2083
  if (t.boundsTree)
@@ -2095,7 +2097,7 @@ function Cs(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2095
2097
  }
2096
2098
  });
2097
2099
  {
2098
- const M = Ae(t);
2100
+ const M = Me(t);
2099
2101
  for (let T = 0, R = M; T < R; T++) {
2100
2102
  j(u, 3 * T, p, l), u.a.applyMatrix4(i), u.b.applyMatrix4(i), u.c.applyMatrix4(i), u.needsUpdate = !0;
2101
2103
  for (let v = A, B = A + P; v < B; v++) {
@@ -2108,9 +2110,9 @@ function Cs(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2108
2110
  }
2109
2111
  }
2110
2112
  }
2111
- ), et.releasePrimitive(c), et.releasePrimitive(u), 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);
2113
+ ), et.releasePrimitive(c), et.releasePrimitive(u), 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(le), g.applyMatrix4(le), s.distance = g.sub(s.point).length(), s.faceIndex = b), e);
2112
2114
  }
2113
- function Ns(n, t = null) {
2115
+ function Os(n, t = null) {
2114
2116
  t && Array.isArray(t) && (t = new Set(t));
2115
2117
  const i = n.geometry, e = i.index ? i.index.array : null, s = i.attributes.position;
2116
2118
  let r, o, d, a, f = 0;
@@ -2137,7 +2139,7 @@ function Ns(n, t = null) {
2137
2139
  let m = y, h = !1, b = !1;
2138
2140
  if (t) {
2139
2141
  if (!m) {
2140
- const v = x / N + u / X, B = w / N + u / X;
2142
+ const v = x / C + u / X, B = w / C + u / X;
2141
2143
  h = t.has(v), b = t.has(B), m = !h && !b;
2142
2144
  }
2143
2145
  } else
@@ -2157,38 +2159,38 @@ function Ns(n, t = null) {
2157
2159
  }
2158
2160
  }
2159
2161
  }
2160
- function qs(n, t, i, e, s, r, o) {
2161
- I.setBuffer(n._roots[t]), We(0, n, i, e, s, r, o), I.clearBuffer();
2162
+ function Vs(n, t, i, e, s, r, o) {
2163
+ I.setBuffer(n._roots[t]), Ge(0, n, i, e, s, r, o), I.clearBuffer();
2162
2164
  }
2163
- function We(n, t, i, e, s, r, o) {
2165
+ function Ge(n, t, i, e, s, r, o) {
2164
2166
  const { float32Array: d, uint16Array: a, uint32Array: f } = I, l = n * 2;
2165
2167
  if (q(l, a)) {
2166
2168
  const c = J(n, f), u = Z(l, a);
2167
- _s(t, i, e, c, u, s, r, o);
2169
+ zs(t, i, e, c, u, s, r, o);
2168
2170
  } else {
2169
2171
  const c = V(n);
2170
- wt(c, d, e, r, o) && We(c, t, i, e, s, r, o);
2172
+ gt(c, d, e, r, o) && Ge(c, t, i, e, s, r, o);
2171
2173
  const u = W(n, f);
2172
- wt(u, d, e, r, o) && We(u, t, i, e, s, r, o);
2174
+ gt(u, d, e, r, o) && Ge(u, t, i, e, s, r, o);
2173
2175
  }
2174
2176
  }
2175
- const Os = ["x", "y", "z"];
2176
- function Vs(n, t, i, e, s, r) {
2177
+ const Ws = ["x", "y", "z"];
2178
+ function Gs(n, t, i, e, s, r) {
2177
2179
  I.setBuffer(n._roots[t]);
2178
- const o = Ge(0, n, i, e, s, r);
2180
+ const o = Xe(0, n, i, e, s, r);
2179
2181
  return I.clearBuffer(), o;
2180
2182
  }
2181
- function Ge(n, t, i, e, s, r) {
2183
+ function Xe(n, t, i, e, s, r) {
2182
2184
  const { float32Array: o, uint16Array: d, uint32Array: a } = I;
2183
2185
  let f = n * 2;
2184
2186
  if (q(f, d)) {
2185
2187
  const p = J(n, a), c = Z(f, d);
2186
- return Es(t, i, e, p, c, s, r);
2188
+ return Us(t, i, e, p, c, s, r);
2187
2189
  } else {
2188
- const p = ei(n, a), c = Os[p], y = e.direction[c] >= 0;
2190
+ const p = ii(n, a), c = Ws[p], y = e.direction[c] >= 0;
2189
2191
  let g, x;
2190
2192
  y ? (g = V(n), x = W(n, a)) : (g = W(n, a), x = V(n));
2191
- const m = wt(g, o, e, s, r) ? Ge(g, t, i, e, s, r) : null;
2193
+ const m = gt(g, o, e, s, r) ? Xe(g, t, i, e, s, r) : null;
2192
2194
  if (m) {
2193
2195
  const A = m.point[c];
2194
2196
  if (y ? A <= o[x + p] : (
@@ -2197,24 +2199,24 @@ function Ge(n, t, i, e, s, r) {
2197
2199
  ))
2198
2200
  return m;
2199
2201
  }
2200
- const b = wt(x, o, e, s, r) ? Ge(x, t, i, e, s, r) : null;
2202
+ const b = gt(x, o, e, s, r) ? Xe(x, t, i, e, s, r) : null;
2201
2203
  return m && b ? m.distance <= b.distance ? m : b : m || b || null;
2202
2204
  }
2203
2205
  }
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 Ws(n, t, i, e) {
2206
+ const ue = /* @__PURE__ */ new it(), Ut = /* @__PURE__ */ new ot(), Ft = /* @__PURE__ */ new ot(), Wt = /* @__PURE__ */ new H(), Di = /* @__PURE__ */ new Q(), fe = /* @__PURE__ */ new Q();
2207
+ function Xs(n, t, i, e) {
2206
2208
  I.setBuffer(n._roots[t]);
2207
- const s = Xe(0, n, i, e);
2209
+ const s = Je(0, n, i, e);
2208
2210
  return I.clearBuffer(), s;
2209
2211
  }
2210
- function Xe(n, t, i, e, s = null) {
2212
+ function Je(n, t, i, e, s = null) {
2211
2213
  const { float32Array: r, uint16Array: o, uint32Array: d } = I;
2212
2214
  let a = n * 2;
2213
- if (s === null && (i.boundingBox || i.computeBoundingBox(), Fi.set(i.boundingBox.min, i.boundingBox.max, e), s = Fi), q(a, o)) {
2215
+ if (s === null && (i.boundingBox || i.computeBoundingBox(), Di.set(i.boundingBox.min, i.boundingBox.max, e), s = Di), q(a, o)) {
2214
2216
  const l = t.geometry, p = l.index, c = l.attributes.position, u = i.index, y = i.attributes.position, g = J(n, d), x = Z(a, o);
2215
2217
  if (Wt.copy(e).invert(), i.boundsTree)
2216
- return k(n, r, ue), ue.matrix.copy(Wt), ue.needsUpdate = !0, i.boundsTree.shapecast({
2217
- intersectsBounds: (m) => ue.intersectsBox(m),
2218
+ return k(n, r, fe), fe.matrix.copy(Wt), fe.needsUpdate = !0, i.boundsTree.shapecast({
2219
+ intersectsBounds: (m) => fe.intersectsBox(m),
2218
2220
  intersectsTriangle: (m) => {
2219
2221
  m.a.applyMatrix4(e), m.b.applyMatrix4(e), m.c.applyMatrix4(e), m.needsUpdate = !0;
2220
2222
  for (let h = g, b = x + g; h < b; h++)
@@ -2224,7 +2226,7 @@ function Xe(n, t, i, e, s = null) {
2224
2226
  }
2225
2227
  });
2226
2228
  {
2227
- const w = Ae(i);
2229
+ const w = Me(i);
2228
2230
  for (let m = g, h = x + g; m < h; m++) {
2229
2231
  const b = t.resolveTriangleIndex(m);
2230
2232
  j(Ut, 3 * b, p, c), Ut.a.applyMatrix4(Wt), Ut.b.applyMatrix4(Wt), Ut.c.applyMatrix4(Wt), Ut.needsUpdate = !0;
@@ -2235,19 +2237,19 @@ function Xe(n, t, i, e, s = null) {
2235
2237
  }
2236
2238
  } else {
2237
2239
  const l = V(n), p = W(n, d);
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)));
2240
+ return k(l, r, ue), !!(s.intersectsBox(ue) && Je(l, t, i, e, s) || (k(p, r, ue), s.intersectsBox(ue) && Je(p, t, i, e, s)));
2239
2241
  }
2240
2242
  }
2241
- const fe = /* @__PURE__ */ new H(), Ue = /* @__PURE__ */ new Q(), Gt = /* @__PURE__ */ new Q(), Gs = /* @__PURE__ */ new z(), Xs = /* @__PURE__ */ new z(), Js = /* @__PURE__ */ new z(), Hs = /* @__PURE__ */ new z();
2242
- function Zs(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;
2243
+ const de = /* @__PURE__ */ new H(), Fe = /* @__PURE__ */ new Q(), Gt = /* @__PURE__ */ new Q(), Js = /* @__PURE__ */ new z(), Hs = /* @__PURE__ */ new z(), Zs = /* @__PURE__ */ new z(), Qs = /* @__PURE__ */ new z();
2244
+ function Ys(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2245
+ t.boundingBox || t.computeBoundingBox(), Fe.set(t.boundingBox.min, t.boundingBox.max, i), Fe.needsUpdate = !0;
2244
2246
  const d = n.geometry, a = d.attributes.position, f = d.index, l = t.attributes.position, p = t.index, c = et.getPrimitive(), u = et.getPrimitive();
2245
- let y = Gs, g = Xs, x = null, w = null;
2246
- s && (x = Js, w = Hs);
2247
+ let y = Js, g = Hs, x = null, w = null;
2248
+ s && (x = Zs, w = Qs);
2247
2249
  let m = 1 / 0, h = null, b = null;
2248
- return fe.copy(i).invert(), Gt.matrix.copy(fe), n.shapecast(
2250
+ return de.copy(i).invert(), Gt.matrix.copy(de), n.shapecast(
2249
2251
  {
2250
- boundsTraverseOrder: (A) => Ue.distanceToBox(A),
2252
+ boundsTraverseOrder: (A) => Fe.distanceToBox(A),
2251
2253
  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
2254
  intersectsRange: (A, P) => {
2253
2255
  if (t.boundsTree) {
@@ -2270,7 +2272,7 @@ function Zs(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2270
2272
  }
2271
2273
  });
2272
2274
  } else {
2273
- const M = Ae(t);
2275
+ const M = Me(t);
2274
2276
  for (let T = 0, R = M; T < R; T++) {
2275
2277
  j(u, 3 * T, p, l), u.a.applyMatrix4(i), u.b.applyMatrix4(i), u.c.applyMatrix4(i), u.needsUpdate = !0;
2276
2278
  for (let v = A, B = A + P; v < B; v++) {
@@ -2284,13 +2286,13 @@ function Zs(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2284
2286
  }
2285
2287
  }
2286
2288
  }
2287
- ), et.releasePrimitive(c), et.releasePrimitive(u), 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);
2289
+ ), et.releasePrimitive(c), et.releasePrimitive(u), 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(de), g.applyMatrix4(de), s.distance = g.sub(s.point).length(), s.faceIndex = b), e);
2288
2290
  }
2289
- function $i(n, t, i) {
2291
+ function Li(n, t, i) {
2290
2292
  return n === null ? null : (n.point.applyMatrix4(t.matrixWorld), n.distance = n.point.distanceTo(i.ray.origin), n.object = t, n);
2291
2293
  }
2292
- const de = /* @__PURE__ */ new Q(), pe = /* @__PURE__ */ new Tn(), Ii = /* @__PURE__ */ new z(), Di = /* @__PURE__ */ new H(), Li = /* @__PURE__ */ new z(), Fe = ["getX", "getY", "getZ"];
2293
- class be extends gs {
2294
+ const pe = /* @__PURE__ */ new Q(), me = /* @__PURE__ */ new Bn(), ki = /* @__PURE__ */ new z(), ji = /* @__PURE__ */ new H(), Ni = /* @__PURE__ */ new z(), $e = ["getX", "getY", "getZ"];
2295
+ class xe extends bs {
2294
2296
  static serialize(t, i = {}) {
2295
2297
  i = {
2296
2298
  cloneBuffers: !0,
@@ -2314,11 +2316,11 @@ class be extends gs {
2314
2316
  t.version || (console.warn(
2315
2317
  "MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."
2316
2318
  ), a(r));
2317
- const d = new be(i, { ...e, [ti]: !0 });
2319
+ const d = new xe(i, { ...e, [ei]: !0 });
2318
2320
  if (d._roots = r, d._indirectBuffer = o || null, e.setIndex) {
2319
2321
  const f = i.getIndex();
2320
2322
  if (f === null) {
2321
- const l = new Oi(t.index, 1, !1);
2323
+ const l = new Gi(t.index, 1, !1);
2322
2324
  i.setIndex(l);
2323
2325
  } else f.array !== s && (f.array.set(s), f.needsUpdate = !0);
2324
2326
  }
@@ -2327,8 +2329,8 @@ class be extends gs {
2327
2329
  for (let l = 0; l < f.length; l++) {
2328
2330
  const p = f[l], c = new Uint32Array(p), u = new Uint16Array(p);
2329
2331
  for (let y = 0, g = p.byteLength / X; y < g; y++) {
2330
- const x = N * y, w = 2 * x;
2331
- q(w, u) || (c[x + 6] = c[x + 6] / N - y);
2332
+ const x = C * y, w = 2 * x;
2333
+ q(w, u) || (c[x + 6] = c[x + 6] / C - y);
2332
2334
  }
2333
2335
  }
2334
2336
  }
@@ -2355,7 +2357,7 @@ class be extends gs {
2355
2357
  let l = f + 0, p = f + 1, c = f + 2;
2356
2358
  d && (l = d[l], p = d[p], c = d[c]);
2357
2359
  for (let u = 0; u < 3; u++) {
2358
- const y = o[Fe[u]](l), g = o[Fe[u]](p), x = o[Fe[u]](c);
2360
+ const y = o[$e[u]](l), g = o[$e[u]](p), x = o[$e[u]](c);
2359
2361
  let w = y;
2360
2362
  g < w && (w = g), x < w && (w = x);
2361
2363
  let m = y;
@@ -2387,7 +2389,7 @@ class be extends gs {
2387
2389
  let B = M;
2388
2390
  T > B && (B = T), R > B && (B = R);
2389
2391
  const S = (B - v) / 2, _ = P * 2;
2390
- e[m + _ + 0] = v + S, e[m + _ + 1] = S + (Math.abs(v) + S) * ye;
2392
+ e[m + _ + 0] = v + S, e[m + _ + 1] = S + (Math.abs(v) + S) * ge;
2391
2393
  }
2392
2394
  }
2393
2395
  return e;
@@ -2396,34 +2398,34 @@ class be extends gs {
2396
2398
  const { material: s } = t;
2397
2399
  if (s === void 0)
2398
2400
  return;
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, d = i.far / r;
2401
+ ji.copy(t.matrixWorld).invert(), me.copy(i.ray).applyMatrix4(ji), Ni.setFromMatrixScale(t.matrixWorld), ki.copy(me.direction).multiply(Ni);
2402
+ const r = ki.length(), o = i.near / r, d = i.far / r;
2401
2403
  if (i.firstHitOnly === !0) {
2402
- let a = this.raycastFirst(pe, s, o, d);
2403
- a = $i(a, t, i), a && e.push(a);
2404
+ let a = this.raycastFirst(me, s, o, d);
2405
+ a = Li(a, t, i), a && e.push(a);
2404
2406
  } else {
2405
- const a = this.raycast(pe, s, o, d);
2407
+ const a = this.raycast(me, s, o, d);
2406
2408
  for (let f = 0, l = a.length; f < l; f++) {
2407
- const p = $i(a[f], t, i);
2409
+ const p = Li(a[f], t, i);
2408
2410
  p && e.push(p);
2409
2411
  }
2410
2412
  }
2411
2413
  return e;
2412
2414
  }
2413
2415
  refit(t = null) {
2414
- return (this.indirect ? Ns : Bs)(this, t);
2416
+ return (this.indirect ? Os : Es)(this, t);
2415
2417
  }
2416
2418
  /* Core Cast Functions */
2417
- raycast(t, i = fi, e = 0, s = 1 / 0) {
2418
- const r = this._roots, o = [], d = this.indirect ? qs : Us;
2419
+ raycast(t, i = pi, e = 0, s = 1 / 0) {
2420
+ const r = this._roots, o = [], d = this.indirect ? Vs : $s;
2419
2421
  for (let a = 0, f = r.length; a < f; a++)
2420
2422
  d(this, a, i, t, o, e, s);
2421
2423
  return o;
2422
2424
  }
2423
- raycastFirst(t, i = fi, e = 0, s = 1 / 0) {
2425
+ raycastFirst(t, i = pi, e = 0, s = 1 / 0) {
2424
2426
  const r = this._roots;
2425
2427
  let o = null;
2426
- const d = this.indirect ? Vs : $s;
2428
+ const d = this.indirect ? Gs : Ds;
2427
2429
  for (let a = 0, f = r.length; a < f; a++) {
2428
2430
  const l = d(this, a, i, t, e, s);
2429
2431
  l != null && (o == null || l.distance < o.distance) && (o = l);
@@ -2432,7 +2434,7 @@ class be extends gs {
2432
2434
  }
2433
2435
  intersectsGeometry(t, i) {
2434
2436
  let e = !1;
2435
- const s = this._roots, r = this.indirect ? Ws : Is;
2437
+ const s = this._roots, r = this.indirect ? Xs : Ls;
2436
2438
  for (let o = 0, d = s.length; o < d && (e = r(this, o, t, i), !e); o++)
2437
2439
  ;
2438
2440
  return e;
@@ -2445,7 +2447,7 @@ class be extends gs {
2445
2447
  scratchPrimitive: i,
2446
2448
  // TODO: is the performance significant enough for the added complexity here?
2447
2449
  // can we just use one function?
2448
- iterate: this.indirect ? zs : Rs
2450
+ iterate: this.indirect ? Fs : _s
2449
2451
  }
2450
2452
  );
2451
2453
  return et.releasePrimitive(i), e;
@@ -2467,7 +2469,7 @@ class be extends gs {
2467
2469
  j(l, y * 3, p, c);
2468
2470
  };
2469
2471
  if (r) {
2470
- if (!(t instanceof be))
2472
+ if (!(t instanceof xe))
2471
2473
  throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');
2472
2474
  const y = (g, x, w, m, h, b, A, P) => {
2473
2475
  for (let M = w, T = w + m; M < T; M++) {
@@ -2490,10 +2492,10 @@ class be extends gs {
2490
2492
  }
2491
2493
  /* Derived Cast Functions */
2492
2494
  intersectsBox(t, i) {
2493
- return de.set(t.min, t.max, i), de.needsUpdate = !0, this.shapecast(
2495
+ return pe.set(t.min, t.max, i), pe.needsUpdate = !0, this.shapecast(
2494
2496
  {
2495
- intersectsBounds: (e) => de.intersectsBox(e),
2496
- intersectsTriangle: (e) => de.intersectsTriangle(e)
2497
+ intersectsBounds: (e) => pe.intersectsBox(e),
2498
+ intersectsTriangle: (e) => pe.intersectsTriangle(e)
2497
2499
  }
2498
2500
  );
2499
2501
  }
@@ -2506,7 +2508,7 @@ class be extends gs {
2506
2508
  );
2507
2509
  }
2508
2510
  closestPointToGeometry(t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2509
- return (this.indirect ? Zs : Cs)(
2511
+ return (this.indirect ? Ys : qs)(
2510
2512
  this,
2511
2513
  t,
2512
2514
  i,
@@ -2517,7 +2519,7 @@ class be extends gs {
2517
2519
  );
2518
2520
  }
2519
2521
  closestPointToPoint(t, i = {}, e = 0, s = 1 / 0) {
2520
- return Ms(
2522
+ return Ps(
2521
2523
  this,
2522
2524
  t,
2523
2525
  i,
@@ -2527,31 +2529,31 @@ class be extends gs {
2527
2529
  }
2528
2530
  }
2529
2531
  const It = {
2530
- Mesh: C.prototype.raycast,
2531
- Line: Ye.prototype.raycast,
2532
- LineSegments: Qe.prototype.raycast,
2533
- LineLoop: Gi.prototype.raycast,
2534
- Points: Xi.prototype.raycast,
2535
- BatchedMesh: Bn.prototype.raycast
2536
- }, G = /* @__PURE__ */ new C(), me = [];
2537
- function Qs(n, t) {
2532
+ Mesh: N.prototype.raycast,
2533
+ Line: Ke.prototype.raycast,
2534
+ LineSegments: Ye.prototype.raycast,
2535
+ LineLoop: Hi.prototype.raycast,
2536
+ Points: Zi.prototype.raycast,
2537
+ BatchedMesh: En.prototype.raycast
2538
+ }, G = /* @__PURE__ */ new N(), he = [];
2539
+ function Ks(n, t) {
2538
2540
  if (this.isBatchedMesh)
2539
- Ys.call(this, n, t);
2541
+ to.call(this, n, t);
2540
2542
  else {
2541
2543
  const { geometry: i } = this;
2542
2544
  if (i.boundsTree)
2543
2545
  i.boundsTree.raycastObject3D(this, n, t);
2544
2546
  else {
2545
2547
  let e;
2546
- if (this instanceof C)
2548
+ if (this instanceof N)
2547
2549
  e = It.Mesh;
2548
- else if (this instanceof Qe)
2550
+ else if (this instanceof Ye)
2549
2551
  e = It.LineSegments;
2550
- else if (this instanceof Gi)
2552
+ else if (this instanceof Hi)
2551
2553
  e = It.LineLoop;
2552
- else if (this instanceof Ye)
2554
+ else if (this instanceof Ke)
2553
2555
  e = It.Line;
2554
- else if (this instanceof Xi)
2556
+ else if (this instanceof Zi)
2555
2557
  e = It.Points;
2556
2558
  else
2557
2559
  throw new Error("BVH: Fallback raycast function not found.");
@@ -2559,12 +2561,12 @@ function Qs(n, t) {
2559
2561
  }
2560
2562
  }
2561
2563
  }
2562
- function Ys(n, t) {
2564
+ function to(n, t) {
2563
2565
  if (this.boundsTrees) {
2564
2566
  const i = this.boundsTrees, e = this._drawInfo || this._instanceInfo, s = this._drawRanges || this._geometryInfo, r = this.matrixWorld;
2565
2567
  G.material = this.material, G.geometry = this.geometry;
2566
2568
  const o = G.geometry.boundsTree, d = G.geometry.drawRange;
2567
- G.geometry.boundingSphere === null && (G.geometry.boundingSphere = new Rn());
2569
+ G.geometry.boundingSphere === null && (G.geometry.boundingSphere = new _n());
2568
2570
  for (let a = 0, f = e.length; a < f; a++) {
2569
2571
  if (!this.getVisibleAt(a))
2570
2572
  continue;
@@ -2574,21 +2576,21 @@ function Ys(n, t) {
2574
2576
  const p = s[l];
2575
2577
  G.geometry.setDrawRange(p.start, p.count);
2576
2578
  }
2577
- G.raycast(n, me);
2578
- for (let p = 0, c = me.length; p < c; p++) {
2579
- const u = me[p];
2579
+ G.raycast(n, he);
2580
+ for (let p = 0, c = he.length; p < c; p++) {
2581
+ const u = he[p];
2580
2582
  u.object = this, u.batchId = a, t.push(u);
2581
2583
  }
2582
- me.length = 0;
2584
+ he.length = 0;
2583
2585
  }
2584
2586
  G.geometry.boundsTree = o, G.geometry.drawRange = d, G.material = null, G.geometry = null;
2585
2587
  } else
2586
2588
  It.BatchedMesh.call(this, n, t);
2587
2589
  }
2588
- function $e(n) {
2590
+ function Ie(n) {
2589
2591
  return n.type === "continuous" || !n.limits ? 0 : Math.max(n.limits.lower, Math.min(n.limits.upper, 0));
2590
2592
  }
2591
- class Ks {
2593
+ class eo {
2592
2594
  constructor(t, i) {
2593
2595
  $(this, "root");
2594
2596
  $(this, "visual");
@@ -2622,7 +2624,7 @@ class Ks {
2622
2624
  originQuaternion: Qt(g.origin),
2623
2625
  axis: new z().fromArray(g.axis).normalize()
2624
2626
  };
2625
- this.joints.set(g.id, w), this.specs.set(g.id, g), this.values.set(g.id, $e(g)), this.apply(w, this.values.get(g.id)), p(g.child);
2627
+ this.joints.set(g.id, w), this.specs.set(g.id, g), this.values.set(g.id, Ie(g)), this.apply(w, this.values.get(g.id)), p(g.child);
2626
2628
  }
2627
2629
  l.delete(u);
2628
2630
  }, c = o.length ? o : t.links;
@@ -2637,7 +2639,7 @@ class Ks {
2637
2639
  y && (this.root.add(y), p(u.id));
2638
2640
  }
2639
2641
  if (o.length === 1) {
2640
- const u = Zi(t, o[0].id, d), y = i.bindings.get(o[0].id);
2642
+ const u = Ki(t, o[0].id, d), y = i.bindings.get(o[0].id);
2641
2643
  y && u > 0 && (y.position.z += u);
2642
2644
  }
2643
2645
  for (const u of i.bindings.values()) u.parent === this.root && this.initialRoots.set(u, { position: u.position.clone(), quaternion: u.quaternion.clone() });
@@ -2659,13 +2661,13 @@ class Ks {
2659
2661
  if (!Number.isFinite(i)) throw Xt(`Joint value must be finite: ${t}`, "E_URDF_JOINT_VALUE");
2660
2662
  let s = i;
2661
2663
  if (e.joint.type !== "continuous" && e.joint.limits && (s = Math.max(e.joint.limits.lower, Math.min(e.joint.limits.upper, i))), ["revolute", "continuous", "prismatic"].includes(e.joint.type) || (s = 0), e.joint.mimic) throw Xt(`Mimic joint is controlled by ${e.joint.mimic.joint}: ${t}`, "E_URDF_MIMIC_READONLY");
2662
- const r = xe([...this.specs.values()]).get(t);
2664
+ const r = Ae([...this.specs.values()]).get(t);
2663
2665
  return r && (s = Math.max(r.lower, Math.min(r.upper, s))), this.values.set(t, s), this.applyAll(), this.root.updateMatrixWorld(!0), s;
2664
2666
  }
2665
2667
  resetJoint(t) {
2666
2668
  const i = this.joints.get(t);
2667
2669
  if (!i) throw Xt(`Unknown URDF joint: ${t}`, "E_URDF_JOINT_UNKNOWN");
2668
- this.setJointValue(t, $e(i.joint));
2670
+ this.setJointValue(t, Ie(i.joint));
2669
2671
  }
2670
2672
  syncPhysicsPose(t, i) {
2671
2673
  for (const [e, s] of Object.entries(t)) {
@@ -2682,7 +2684,7 @@ class Ks {
2682
2684
  for (const [t, i] of this.initialRoots)
2683
2685
  t.position.copy(i.position), t.quaternion.copy(i.quaternion);
2684
2686
  for (const t of this.joints.values()) {
2685
- const i = $e(t.joint);
2687
+ const i = Ie(t.joint);
2686
2688
  t.joint.mimic || this.values.set(t.joint.id, i);
2687
2689
  }
2688
2690
  this.applyAll(), this.root.updateMatrixWorld(!0);
@@ -2711,16 +2713,16 @@ class Ks {
2711
2713
  }
2712
2714
  }
2713
2715
  applyAll() {
2714
- const t = Ke([...this.specs.values()], Object.fromEntries(this.values));
2716
+ const t = ti([...this.specs.values()], Object.fromEntries(this.values));
2715
2717
  for (const [i, e] of this.joints)
2716
2718
  this.values.set(i, t[i]), this.apply(e, t[i]);
2717
2719
  }
2718
2720
  preparePicking() {
2719
2721
  const t = /* @__PURE__ */ new Set();
2720
2722
  this.root.traverse((i) => {
2721
- if (!(i instanceof C) || !i.geometry) return;
2723
+ if (!(i instanceof N) || !i.geometry) return;
2722
2724
  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 = Qs, this.pickMeshes.push(i);
2725
+ !e.boundsTree && !t.has(e) && (e.boundsTree = new xe(e, { maxLeafSize: 20, indirect: !0, verbose: !1 }), t.add(e)), i.raycast = Ks, this.pickMeshes.push(i);
2724
2726
  });
2725
2727
  }
2726
2728
  apply(t, i) {
@@ -2730,9 +2732,9 @@ class Ks {
2730
2732
  function Xt(n, t) {
2731
2733
  return Object.assign(new Error(n), { code: t });
2732
2734
  }
2733
- function to(n, t, i = n.source.uri) {
2735
+ function io(n, t, i = n.source.uri) {
2734
2736
  var m;
2735
- const e = so(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();
2737
+ const e = ro(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
2738
  for (const h of r) o.has(h.child) || o.set(h.child, h);
2737
2739
  const d = n.links.filter((h) => !o.has(h.id)), a = /* @__PURE__ */ new Map();
2738
2740
  for (const h of o.values()) a.set(h.parent, [...a.get(h.parent) ?? [], h]);
@@ -2756,19 +2758,19 @@ function to(n, t, i = n.source.uri) {
2756
2758
  source: e.robot
2757
2759
  });
2758
2760
  g.push(x);
2759
- for (const h of n.links) g.push(eo(h, n, e.links.get(h.id), y, c, o));
2760
- const w = xe(n.joints);
2761
- for (const h of n.joints) g.push(io({ ...h, controlLimits: w.get(h.id) }, e.joints.get(h.id), ((m = o.get(h.child)) == null ? void 0 : m.id) === h.id));
2761
+ for (const h of n.links) g.push(no(h, n, e.links.get(h.id), y, c, o));
2762
+ const w = Ae(n.joints);
2763
+ for (const h of n.joints) g.push(so({ ...h, controlLimits: w.get(h.id) }, e.joints.get(h.id), ((m = o.get(h.child)) == null ? void 0 : m.id) === h.id));
2762
2764
  return Object.freeze({
2763
2765
  robotName: n.name,
2764
2766
  sourcePath: i,
2765
2767
  sourceText: t,
2766
2768
  nodes: Object.freeze(g),
2767
2769
  rootEntityId: u,
2768
- issues: Object.freeze(no(n, e))
2770
+ issues: Object.freeze(oo(n, e))
2769
2771
  });
2770
2772
  }
2771
- function eo(n, t, i, e, s, r) {
2773
+ function no(n, t, i, e, s, r) {
2772
2774
  var d, a, f, l;
2773
2775
  const o = r.get(n.id);
2774
2776
  return Object.freeze({
@@ -2787,7 +2789,7 @@ function eo(n, t, i, e, s, r) {
2787
2789
  collisionCount: n.collisions.length
2788
2790
  });
2789
2791
  }
2790
- function io(n, t, i) {
2792
+ function so(n, t, i) {
2791
2793
  return Object.freeze({
2792
2794
  id: `joint:${n.id}`,
2793
2795
  kind: "joint",
@@ -2809,7 +2811,7 @@ function io(n, t, i) {
2809
2811
  ...n.mimic ? { mimic: Object.freeze({ ...n.mimic }) } : {}
2810
2812
  });
2811
2813
  }
2812
- function no(n, t) {
2814
+ function oo(n, t) {
2813
2815
  const i = [], e = (c, u, y, g, x, w) => {
2814
2816
  i.push(Object.freeze({ id: `${c}:${g}`, ruleId: c, severity: "error", title: u, message: y, entityId: g, source: x, values: w ? Object.freeze(w) : void 0 }));
2815
2817
  }, s = new Set(n.links.map((c) => c.id));
@@ -2848,38 +2850,38 @@ function no(n, t) {
2848
2850
  for (const [c, u] of p) u.length > 1 && e("link.multiple-parents", "连杆存在多个父关节", `${c} 同时被 ${u.join("、")} 作为 child。`, `link:${c}`, t.links.get(c), { joints: u });
2849
2851
  for (const c of n.links) {
2850
2852
  const u = c.inertial;
2851
- u && ((!(u.mass > 0) || !Number.isFinite(u.mass)) && e("inertial.mass.invalid", "质量无效", `${c.id} 的质量必须是大于零的有限数。`, `link:${c.id}`, t.links.get(c.id), { mass: u.mass }), Hi(u.tensor) || e("inertial.tensor.invalid", "惯性张量无效", `${c.id} 的惯性张量不是正定的物理惯性张量。`, `link:${c.id}`, t.links.get(c.id), { tensor: u.tensor }));
2853
+ u && ((!(u.mass > 0) || !Number.isFinite(u.mass)) && e("inertial.mass.invalid", "质量无效", `${c.id} 的质量必须是大于零的有限数。`, `link:${c.id}`, t.links.get(c.id), { mass: u.mass }), Yi(u.tensor) || e("inertial.tensor.invalid", "惯性张量无效", `${c.id} 的惯性张量不是正定的物理惯性张量。`, `link:${c.id}`, t.links.get(c.id), { tensor: u.tensor }));
2852
2854
  }
2853
2855
  return i;
2854
2856
  }
2855
- function so(n, t) {
2857
+ function ro(n, t) {
2856
2858
  const i = { robot: void 0, links: /* @__PURE__ */ new Map(), joints: /* @__PURE__ */ new Map() };
2857
- i.robot = ki(n, "robot", void 0, t);
2859
+ i.robot = Ci(n, "robot", void 0, t);
2858
2860
  for (const e of ["link", "joint"]) {
2859
2861
  const s = new RegExp(`<${e}\\b[^>]*\\bname\\s*=\\s*(["'])(.*?)\\1[^>]*>`, "gi");
2860
2862
  for (const r of n.matchAll(s)) {
2861
- const o = r[2], d = ki(n, e, o, t, r.index);
2863
+ const o = r[2], d = Ci(n, e, o, t, r.index);
2862
2864
  d && i[e === "link" ? "links" : "joints"].set(o, d);
2863
2865
  }
2864
2866
  }
2865
2867
  return i;
2866
2868
  }
2867
- function ki(n, t, i, e, s) {
2869
+ function Ci(n, t, i, e, s) {
2868
2870
  const r = s ?? n.search(new RegExp(`<${t}\\b`, "i"));
2869
2871
  if (r < 0) return;
2870
2872
  const o = n.indexOf(">", r);
2871
2873
  if (o < 0) return;
2872
- const a = n.slice(r, o + 1).trimEnd().endsWith("/>") ? o + 1 : n.indexOf(`</${t}>`, o + 1), f = a < 0 ? o + 1 : a + t.length + 3, l = ji(n, r), p = ji(n, f);
2874
+ const a = n.slice(r, o + 1).trimEnd().endsWith("/>") ? o + 1 : n.indexOf(`</${t}>`, o + 1), f = a < 0 ? o + 1 : a + t.length + 3, l = qi(n, r), p = qi(n, f);
2873
2875
  return Object.freeze({ file: e, startOffset: r, endOffset: f, startLine: l.line, startColumn: l.column, endLine: p.line, endColumn: p.column });
2874
2876
  }
2875
- function ji(n, t) {
2877
+ function qi(n, t) {
2876
2878
  const e = n.slice(0, t).split(/\r?\n/);
2877
2879
  return { line: e.length, column: e.at(-1).length + 1 };
2878
2880
  }
2879
- class oo {
2881
+ class ao {
2880
2882
  constructor(t, i, e, s, r) {
2881
2883
  $(this, "kind", "urdf");
2882
- $(this, "overlayRoot", new ut());
2884
+ $(this, "overlayRoot", new lt());
2883
2885
  $(this, "listeners", /* @__PURE__ */ new Set());
2884
2886
  $(this, "revision", 0);
2885
2887
  $(this, "selectedEntityId");
@@ -2922,7 +2924,7 @@ class oo {
2922
2924
  }
2923
2925
  select(t) {
2924
2926
  if (!(this.mode === "dynamics-running" || this.mode === "dynamics-initializing")) {
2925
- if (t !== null && !this.document.nodes.some((i) => i.id === t)) throw ro(`Unknown URDF entity: ${t}`, "E_URDF_ENTITY_UNKNOWN");
2927
+ if (t !== null && !this.document.nodes.some((i) => i.id === t)) throw co(`Unknown URDF entity: ${t}`, "E_URDF_ENTITY_UNKNOWN");
2926
2928
  this.selectedEntityId !== t && (this.selectedEntityId = t, this.rebuildOverlay(), this.publish());
2927
2929
  }
2928
2930
  }
@@ -3008,7 +3010,7 @@ class oo {
3008
3010
  s.updateWorldMatrix(!0, !0);
3009
3011
  const r = new it(), o = (a) => {
3010
3012
  if (!(a !== s && typeof a.userData.urdfEntityId == "string")) {
3011
- a instanceof C && (a.geometry.boundingBox || a.geometry.computeBoundingBox(), a.geometry.boundingBox && r.union(a.geometry.boundingBox.clone().applyMatrix4(a.matrixWorld)));
3013
+ a instanceof N && (a.geometry.boundingBox || a.geometry.computeBoundingBox(), a.geometry.boundingBox && r.union(a.geometry.boundingBox.clone().applyMatrix4(a.matrixWorld)));
3012
3014
  for (const f of a.children) o(f);
3013
3015
  }
3014
3016
  };
@@ -3038,18 +3040,18 @@ class oo {
3038
3040
  return { position: new z().fromArray(e.originPosition).applyMatrix4(s.matrixWorld), quaternion: f, axis: new z().fromArray(e.axis).applyQuaternion(f).normalize() };
3039
3041
  })() : this.binding.jointWorldFrame(e.name);
3040
3042
  if (!r) continue;
3041
- const o = new ut();
3043
+ const o = new lt();
3042
3044
  o.name = `Joint guide:${e.name}`;
3043
- const d = this.guideSize(e.childLink), a = new _n(0.18 * d);
3045
+ const d = this.guideSize(e.childLink), a = new zn(0.18 * d);
3044
3046
  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 f = r.axis.clone().normalize(), l = new di(f, r.position, 0.28 * d, 5625523, 0.045 * d, 0.022 * d);
3047
+ const f = r.axis.clone().normalize(), l = new mi(f, r.position, 0.28 * d, 5625523, 0.045 * d, 0.022 * d);
3046
3048
  if (l.name = `Joint axis:${e.name}`, o.add(l), e.jointType !== "prismatic") {
3047
3049
  const c = (Math.abs(f.z) < 0.9 ? new z(0, 0, 1) : new z(0, 1, 0)).cross(f).normalize(), u = f.clone().cross(c).normalize(), y = 0.09 * d, g = Math.PI * 1.65, x = r.position.clone().addScaledVector(f, 0.085 * d), w = Array.from({ length: 33 }, (A, P) => {
3048
3050
  const M = g * P / 32;
3049
3051
  return x.clone().addScaledVector(c, y * Math.cos(M)).addScaledVector(u, y * Math.sin(M));
3050
- }), m = new Ye(new En().setFromPoints(w), new pi({ color: 16761963 }));
3052
+ }), m = new Ke(new Un().setFromPoints(w), new hi({ color: 16761963 }));
3051
3053
  m.name = `Positive rotation:${e.name}`;
3052
- const h = c.clone().multiplyScalar(-Math.sin(g)).addScaledVector(u, Math.cos(g)), b = new di(h, w[32], 0.03 * d, 16761963, 0.03 * d, 0.022 * d);
3054
+ const h = c.clone().multiplyScalar(-Math.sin(g)).addScaledVector(u, Math.cos(g)), b = new mi(h, w[32], 0.03 * d, 16761963, 0.03 * d, 0.022 * d);
3053
3055
  b.name = `Positive rotation arrow:${e.name}`, o.add(m, b);
3054
3056
  }
3055
3057
  }
@@ -3070,7 +3072,7 @@ class oo {
3070
3072
  r.updateWorldMatrix(!0, !1);
3071
3073
  const o = new z().fromArray(s.origin.position).applyMatrix4(r.matrixWorld), d = e.id === i;
3072
3074
  if (this.overlays.centerOfMass) {
3073
- const u = new Ze(0.025 * this.guideSize(e.id), 32, 16), y = u.toNonIndexed();
3075
+ const u = new Qe(0.025 * this.guideSize(e.id), 32, 16), y = u.toNonIndexed();
3074
3076
  u.dispose();
3075
3077
  const g = y.getAttribute("position"), x = new Float32Array(g.count * 3);
3076
3078
  for (let m = 0; m < g.count; m += 3) {
@@ -3080,13 +3082,13 @@ class oo {
3080
3082
  const P = h * b * A >= 0 ? 1 : 0.015;
3081
3083
  for (let M = 0; M < 9; M++) x[m * 3 + M] = P;
3082
3084
  }
3083
- y.setAttribute("color", new zn(x, 3));
3084
- const w = new C(y, new mi({ color: d ? 16739210 : 16777215, vertexColors: !0, depthTest: !1, depthWrite: !1 }));
3085
+ y.setAttribute("color", new Fn(x, 3));
3086
+ const w = new N(y, new yi({ color: d ? 16739210 : 16777215, vertexColors: !0, depthTest: !1, depthWrite: !1 }));
3085
3087
  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
3088
  }
3087
- const a = this.overlays.inertia ? Cn(s.tensor, s.mass) : null;
3089
+ const a = this.overlays.inertia ? qn(s.tensor, s.mass) : null;
3088
3090
  if (!a) continue;
3089
- const f = new He(1, 1, 1), l = new Qe(new Un(f), new pi({ color: d ? 16736135 : 2211300, transparent: !0, opacity: d ? 0.98 : 0.82, depthTest: !0, depthWrite: !1 })), p = new C(f, new mi({ color: d ? 16739210 : 3262699, transparent: !0, opacity: d ? 0.28 : 0.16, depthTest: !0, depthWrite: !1 }));
3091
+ const f = new Ze(1, 1, 1), l = new Ye(new $n(f), new hi({ color: d ? 16736135 : 2211300, transparent: !0, opacity: d ? 0.98 : 0.82, depthTest: !0, depthWrite: !1 })), p = new N(f, new yi({ color: d ? 16739210 : 3262699, transparent: !0, opacity: d ? 0.28 : 0.16, depthTest: !0, depthWrite: !1 }));
3090
3092
  p.name = `Inertia fill:${e.id}`;
3091
3093
  const c = s.origin.rotationQuaternion ? new K().fromArray(s.origin.rotationQuaternion) : new K().setFromEuler(new Zt(...s.origin.rotationRpy, "ZYX"));
3092
3094
  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);
@@ -3095,7 +3097,7 @@ class oo {
3095
3097
  applySelectionMaterials(t) {
3096
3098
  const i = (e, s) => {
3097
3099
  if (!(!s && typeof e.userData.urdfEntityId == "string")) {
3098
- e instanceof C && e.material && (this.highlightedMaterials.set(e, e.material), e.material = Array.isArray(e.material) ? e.material.map((r) => this.createSelectionMaterial(r)) : this.createSelectionMaterial(e.material));
3100
+ e instanceof N && e.material && (this.highlightedMaterials.set(e, e.material), e.material = Array.isArray(e.material) ? e.material.map((r) => this.createSelectionMaterial(r)) : this.createSelectionMaterial(e.material));
3099
3101
  for (const r of e.children) i(r, !1);
3100
3102
  }
3101
3103
  };
@@ -3106,32 +3108,32 @@ class oo {
3106
3108
  const i = this.selectionMaterials.get(t);
3107
3109
  if (i) return i;
3108
3110
  const e = t.clone(), s = e;
3109
- return (r = s.color) == null || r.set(9425919), s.emissive ? (s.emissive.set(2793430), s.emissiveIntensity = Math.max(s.emissiveIntensity ?? 0, 0.34)) : e instanceof Je && (e.emissive.set(2793430), e.emissiveIntensity = 0.34), e.transparent = t.transparent, e.opacity = t.opacity, e.depthWrite = t.depthWrite, e.needsUpdate = !0, this.selectionMaterials.set(t, e), e;
3111
+ return (r = s.color) == null || r.set(9425919), s.emissive ? (s.emissive.set(2793430), s.emissiveIntensity = Math.max(s.emissiveIntensity ?? 0, 0.34)) : e instanceof He && (e.emissive.set(2793430), e.emissiveIntensity = 0.34), e.transparent = t.transparent, e.opacity = t.opacity, e.depthWrite = t.depthWrite, e.needsUpdate = !0, this.selectionMaterials.set(t, e), e;
3110
3112
  }
3111
3113
  restoreSelectionMaterials() {
3112
3114
  for (const [t, i] of this.highlightedMaterials) t.material = i;
3113
3115
  this.highlightedMaterials.clear();
3114
3116
  }
3115
3117
  }
3116
- function ro(n, t) {
3118
+ function co(n, t) {
3117
3119
  return Object.assign(new Error(n), { code: t });
3118
3120
  }
3119
- async function go(n, t, i) {
3121
+ async function Ao(n, t, i) {
3120
3122
  var _, E, F, D;
3121
3123
  const e = n.entryPath ?? n.filename ?? "asset.urdf";
3122
3124
  (_ = t.reportProgress) == null || _.call(t, "fetch", "正在读取模型描述与依赖资源...");
3123
- let s = await yn(n, i);
3125
+ let s = await wn(n, i);
3124
3126
  const r = t.format === "xacro";
3125
3127
  if (r) {
3126
3128
  (E = t.reportProgress) == null || E.call(t, "xacro", "正在展开 Xacro 宏与依赖文件...");
3127
- const { expandXacro: U } = await import("./xacro-DidnrxXF.js");
3129
+ const { expandXacro: U } = await import("./xacro-BpICdIYd.js");
3128
3130
  s = await U(s, e, i, t.options.xacro, t.signal);
3129
3131
  }
3130
3132
  if (t.signal.aborted) throw Jt();
3131
3133
  (F = t.reportProgress) == null || F.call(t, "parse", "正在解析 URDF 结构与连杆...");
3132
- const o = Nn(s, e, i);
3134
+ const o = On(s, e, i);
3133
3135
  (D = t.reportProgress) == null || D.call(t, "visual", "正在构建运动学预览...");
3134
- const d = await gi(o), a = new Ks(o, d), f = await Wn(o, d), l = o.diagnostics.errors.find((U) => U.code === "E_URDF_INERTIA"), p = o.links.some((U) => U.inertial), c = p && !l, u = new wn(
3136
+ const d = await xi(o), a = new eo(o, d), f = await Xn(o, d), l = o.diagnostics.errors.find((U) => U.code === "E_URDF_INERTIA"), p = o.links.some((U) => U.inertial), c = p && !l, u = new xn(
3135
3137
  a.root,
3136
3138
  t.options.simulationTheme,
3137
3139
  void 0,
@@ -3140,13 +3142,18 @@ async function go(n, t, i) {
3140
3142
  );
3141
3143
  f && (f.root.visible = !1, u.attachAuxiliary(f.root));
3142
3144
  let y = null, g = null, x = null;
3143
- const w = o.diagnostics.warnings[0], m = w ? { ...w, stage: "visual-material" } : null;
3144
- 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;
3145
+ const w = o.diagnostics.warnings[0], m = w ? ai(w, "visual-material") : null;
3146
+ let h = l ? {
3147
+ code: l.code,
3148
+ message: l.message,
3149
+ stage: "physics-validation",
3150
+ notice: ci(l.code, l.source)
3151
+ } : m, b = l ? { status: "unavailable", issue: h } : p ? { status: "available" } : { status: "not-authored" }, A = !1, P = null, M = !1, T = !1;
3145
3152
  const R = () => {
3146
3153
  var L;
3147
3154
  const U = A || !a.root.visible;
3148
3155
  A = !1, u.setRuntime(void 0), g && (g.root.visible = !1), u.replaceModel(a.root, !1), a.root.visible = !0, f && f.sync(), f != null && f.root && (f.root.visible = v.getSnapshot().overlays.collision), x && (x.root.visible = !1), U && ((L = t.reportSessionState) == null || L.call(t)), t.requestRender();
3149
- }, v = new oo(o, to(o, s, r ? `${e} (expanded URDF)` : e), a, {
3156
+ }, v = new ao(o, io(o, s, r ? `${e} (expanded URDF)` : e), a, {
3150
3157
  requestRender() {
3151
3158
  a.root.visible && (f == null || f.sync()), t.requestRender();
3152
3159
  },
@@ -3157,24 +3164,27 @@ async function go(n, t, i) {
3157
3164
  linkObject: (U) => g != null && g.root.visible ? g.objectForLink(U) : a.objectForEntity(`link:${U}`),
3158
3165
  pickRoots: () => A || b.status === "initializing" ? [] : a.pickRoots()
3159
3166
  }, c);
3160
- l && v.setMode("dynamics-unavailable", l.message), u.attachAuxiliary(v.overlayRoot);
3167
+ l && v.setMode(
3168
+ "dynamics-unavailable",
3169
+ ci(l.code, l.source).summary
3170
+ ), u.attachAuxiliary(v.overlayRoot);
3161
3171
  const B = () => !y || !g ? !1 : (y.setJointValues(v.getSnapshot().jointValues), u.replaceModel(g.root, !1), u.setRuntime(y), g.sync(), x == null || x.sync(), a.root.visible = !1, g.root.visible = !0, f && (f.root.visible = !1), x && (x.root.visible = v.getSnapshot().overlays.collision), !0), S = async () => {
3162
- var Mt, vt, Pt;
3172
+ var Mt, vt, Pt, kt;
3163
3173
  if (y || M || !c) return;
3164
3174
  v.setMode("dynamics-initializing"), b = { status: "initializing" }, (Mt = t.reportSessionState) == null || Mt.call(t);
3165
3175
  let U = null, L = null, Y = null;
3166
3176
  try {
3167
- const rt = await Vn(o);
3177
+ const wt = await Gn(o);
3168
3178
  if (t.signal.aborted || M) throw Jt();
3169
- const kt = await import("./mujoco-runtime-DTxVmIzc.js");
3170
- if (U = new kt.MujocoRuntime(), await U.initialize(rt, t.options.mujocoBaseUrl), U.setWorldRotation(ci(u.getUpAxis())), t.signal.aborted || M || (L = new ai(U, await gi(o)), t.signal.aborted || M)) throw Jt();
3171
- const at = await Qi(o);
3172
- if (Y = at ? new ai(U, at) : null, t.signal.aborted || M) throw Jt();
3179
+ const nt = await import("./mujoco-runtime-ZuEJSHnD.js");
3180
+ if (U = new nt.MujocoRuntime(), await U.initialize(wt, t.options.mujocoBaseUrl), U.setWorldRotation(ui(u.getUpAxis())), t.signal.aborted || M || (L = new li(U, await xi(o)), t.signal.aborted || M)) throw Jt();
3181
+ const Yt = await tn(o);
3182
+ if (Y = Yt ? new li(U, Yt) : null, t.signal.aborted || M) throw Jt();
3173
3183
  y = U, U = null, g = L, L = null, g.root.visible = !1, x = Y, Y = null, x && (x.root.visible = !1, u.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();
3174
- } catch (rt) {
3175
- if (Y == null || Y.dispose(), L == null || L.dispose(), U == null || U.dispose(), M || t.signal.aborted || rt instanceof Error && rt.name === "AbortError") return;
3176
- const kt = gn(rt, t.signal, "urdf-physics");
3177
- u.setRuntime(void 0), u.setGroundPlacement("visual"), y == null || y.dispose(), y = null, g == null || g.dispose(), g = null, x && (u.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 });
3184
+ } catch (wt) {
3185
+ if (Y == null || Y.dispose(), L == null || L.dispose(), U == null || U.dispose(), M || t.signal.aborted || wt instanceof Error && wt.name === "AbortError") return;
3186
+ const nt = bn(wt, t.signal, "urdf-physics");
3187
+ u.setRuntime(void 0), u.setGroundPlacement("visual"), y == null || y.dispose(), y = null, g == null || g.dispose(), g = null, x && (u.detachAuxiliary(x.root), x.dispose(), x = null), R(), h = ai(nt, "physics-fallback"), b = { status: "unavailable", issue: h }, v.setMode("dynamics-unavailable", ((Pt = h.notice) == null ? void 0 : Pt.summary) ?? h.message), (kt = t.reportSessionState) == null || kt.call(t), t.reportError(wt, { fatal: !1, stage: "physics-start", code: nt.code });
3178
3188
  }
3179
3189
  };
3180
3190
  return {
@@ -3208,7 +3218,7 @@ async function go(n, t, i) {
3208
3218
  },
3209
3219
  pause() {
3210
3220
  var U;
3211
- T = !1, A = !1, u.endGrab(), y && (a.syncPhysicsPose(y.getJointValues(o.joints.map((L) => L.id)), ao(g.bodyPoses(), ci(u.getUpAxis()))), R(), v.setMode("dynamics-paused")), (U = t.reportSessionState) == null || U.call(t), t.requestRender();
3221
+ T = !1, A = !1, u.endGrab(), y && (a.syncPhysicsPose(y.getJointValues(o.joints.map((L) => L.id)), lo(g.bodyPoses(), ui(u.getUpAxis()))), R(), v.setMode("dynamics-paused")), (U = t.reportSessionState) == null || U.call(t), t.requestRender();
3212
3222
  },
3213
3223
  reset() {
3214
3224
  var U;
@@ -3220,10 +3230,10 @@ async function go(n, t, i) {
3220
3230
  return L && (g == null || g.sync(), x == null || x.sync(), v.syncGuides(), u.updateForceLine()), L;
3221
3231
  },
3222
3232
  beginGrab(U, L, Y) {
3223
- return !!(y && u.beginGrab(U, L, Y));
3233
+ return !!(A && y && u.beginGrab(U, L, Y));
3224
3234
  },
3225
3235
  moveGrab(U, L, Y) {
3226
- y && u.moveGrab(U, L, Y);
3236
+ A && y && u.moveGrab(U, L, Y);
3227
3237
  },
3228
3238
  endGrab() {
3229
3239
  u.endGrab();
@@ -3239,7 +3249,7 @@ async function go(n, t, i) {
3239
3249
  function Jt() {
3240
3250
  return Object.assign(new Error("Simulation load aborted."), { name: "AbortError", code: "E_ABORTED" });
3241
3251
  }
3242
- function ao(n, t) {
3252
+ function lo(n, t) {
3243
3253
  const i = t.clone().invert(), e = /* @__PURE__ */ new Map();
3244
3254
  for (const [s, r] of n)
3245
3255
  e.set(s, {
@@ -3249,5 +3259,5 @@ function ao(n, t) {
3249
3259
  return e;
3250
3260
  }
3251
3261
  export {
3252
- go as loadUrdfSimulation
3262
+ Ao as loadUrdfSimulation
3253
3263
  };