@nebula-spatial/viewer 0.5.2 → 0.5.4

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,31 +1,31 @@
1
1
  var un = Object.defineProperty;
2
2
  var fn = (n, t, i) => t in n ? un(n, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[t] = i;
3
3
  var $ = (n, t, i) => fn(n, typeof t != "symbol" ? t + "" : t, i);
4
- import { b as dn, d as pn, e as oi, c as mn, a as ri, r as hn, S as ai, p as yn } from "./session-2sDMfyTY.js";
5
- import { b as ft, S as gn, m as ci } from "./stage-BrKWuPMa.js";
6
- import { Quaternion as K, Euler as Zt, LoadingManager as Ci, Group as ut, Mesh as C, MeshLambertMaterial as wn, MeshPhongMaterial as li, MeshStandardMaterial as Je, Matrix4 as H, TextureLoader as bn, SRGBColorSpace as xn, RepeatWrapping as An, BoxGeometry as He, SphereGeometry as Ze, CylinderGeometry as Ni, CapsuleGeometry as qi, Vector3 as z, MathUtils as Mn, Matrix3 as ui, Box3 as it, BufferAttribute as Oi, Line3 as dt, Plane as Vi, Vector2 as gt, Triangle as $t, BackSide as vn, DoubleSide as Pn, REVISION as Wi, Ray as Sn, FrontSide as fi, LineSegments as Qe, LineLoop as Gi, Line as Ye, Points as Xi, Sphere as Tn, BatchedMesh as Rn, AxesHelper as Bn, ArrowHelper as di, BufferGeometry as _n, LineBasicMaterial as pi, Float32BufferAttribute as En, MeshBasicMaterial as mi, EdgesGeometry as zn } from "three";
7
- import { GLTFLoader as Un } from "three/examples/jsm/loaders/GLTFLoader.js";
8
- import { ColladaLoader as Fn } from "three/examples/jsm/loaders/ColladaLoader.js";
9
- import { OBJLoader as $n } from "three/examples/jsm/loaders/OBJLoader.js";
10
- import { STLLoader as In } from "three/examples/jsm/loaders/STLLoader.js";
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-um40A-5F.js";
5
+ import { b as ft, S as wn, m as ci } from "./stage-DAhe0IZz.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
11
  function Ji(n) {
12
12
  const t = new Map(n.map((o) => [o.id, o])), i = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Set(), s = (o) => {
13
13
  throw Object.assign(new Error(`Invalid URDF mimic relationship: ${o}`), { code: "E_URDF_MIMIC" });
14
14
  }, r = (o) => {
15
15
  var l;
16
- const f = i.get(o);
17
- if (f) return f;
16
+ const d = i.get(o);
17
+ if (d) return d;
18
18
  const a = t.get(o);
19
19
  if (!a || e.has(o)) return s(o);
20
20
  e.add(o);
21
- let u = { root: o, multiplier: 1, offset: 0 };
21
+ let f = { root: o, multiplier: 1, offset: 0 };
22
22
  if (a.mimic) {
23
23
  const p = a.mimic;
24
24
  if (![p.multiplier, p.offset].every(Number.isFinite) || !["revolute", "continuous", "prismatic"].includes(a.type) || !["revolute", "continuous", "prismatic"].includes(((l = t.get(p.joint)) == null ? void 0 : l.type) ?? "")) return s(o);
25
25
  const c = r(p.joint);
26
- if (u = { root: c.root, multiplier: p.multiplier * c.multiplier, offset: p.multiplier * c.offset + p.offset }, ![u.multiplier, u.offset].every(Number.isFinite)) return s(o);
26
+ if (f = { root: c.root, multiplier: p.multiplier * c.multiplier, offset: p.multiplier * c.offset + p.offset }, ![f.multiplier, f.offset].every(Number.isFinite)) return s(o);
27
27
  }
28
- return e.delete(o), i.set(o, u), u;
28
+ return e.delete(o), i.set(o, f), f;
29
29
  };
30
30
  for (const o of n) r(o.id);
31
31
  return i;
@@ -40,24 +40,24 @@ function xe(n) {
40
40
  if (s.offset < e.limits.lower || s.offset > e.limits.upper) throw new Error(`URDF mimic constant violates limits: ${e.id}`);
41
41
  continue;
42
42
  }
43
- const o = (e.limits.lower - s.offset) / s.multiplier, f = (e.limits.upper - s.offset) / s.multiplier;
44
- if (r.lower = Math.max(r.lower, Math.min(o, f)), r.upper = Math.min(r.upper, Math.max(o, f)), r.lower > r.upper) throw new Error(`URDF mimic limits have no feasible range: ${s.root}`);
43
+ const o = (e.limits.lower - s.offset) / s.multiplier, d = (e.limits.upper - s.offset) / s.multiplier;
44
+ if (r.lower = Math.max(r.lower, Math.min(o, d)), r.upper = Math.min(r.upper, Math.max(o, d)), r.lower > r.upper) throw new Error(`URDF mimic limits have no feasible range: ${s.root}`);
45
45
  }
46
46
  return i;
47
47
  }
48
48
  function Ke(n, t = {}) {
49
49
  const i = Ji(n), e = xe(n);
50
50
  return Object.fromEntries(n.map((s) => {
51
- const r = i.get(s.id), o = e.get(r.root), f = Math.max(o.lower, Math.min(o.upper, t[r.root] ?? 0));
52
- return [s.id, f * r.multiplier + r.offset];
51
+ 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
+ return [s.id, d * r.multiplier + r.offset];
53
53
  }));
54
54
  }
55
55
  function Qt(n) {
56
56
  return n.rotationQuaternion ? new K().fromArray(n.rotationQuaternion).normalize() : new K().setFromEuler(new Zt(n.rotationRpy[0], n.rotationRpy[1], n.rotationRpy[2], "ZYX"));
57
57
  }
58
- function Dn(n) {
58
+ function Ln(n) {
59
59
  const t = /* @__PURE__ */ new Map(), i = (e) => {
60
- if (!(e instanceof wn || e instanceof li)) return e;
60
+ if (!(e instanceof bn || e instanceof li)) return e;
61
61
  const s = t.get(e);
62
62
  if (s) return s;
63
63
  const r = new Je({
@@ -92,8 +92,8 @@ function Dn(n) {
92
92
  });
93
93
  for (const e of t.keys()) e.dispose();
94
94
  }
95
- async function Ln(n, t) {
96
- var p, c, d;
95
+ async function kn(n, t) {
96
+ var p, c, u;
97
97
  const i = await t.text(n), e = new DOMParser().parseFromString(i, "application/xml");
98
98
  if (e.querySelector("parsererror") || e.documentElement.localName !== "COLLADA")
99
99
  throw new Error(`Invalid URDF COLLADA document: ${n}`);
@@ -101,7 +101,7 @@ async function Ln(n, t) {
101
101
  if (!["X_UP", "Y_UP", "Z_UP"].includes(s)) throw new Error(`Unsupported COLLADA up-axis: ${s}`);
102
102
  const r = /* @__PURE__ */ new Map();
103
103
  for (const y of e.querySelectorAll("library_images image init_from")) {
104
- const g = (d = y.textContent) == null ? void 0 : d.trim();
104
+ const g = (u = y.textContent) == null ? void 0 : u.trim();
105
105
  if (!g || g.startsWith("data:")) continue;
106
106
  const x = t.resolve(g, n);
107
107
  await t.ensure(x), r.set(g, t.objectUrl(x));
@@ -113,24 +113,24 @@ async function Ln(n, t) {
113
113
  if (!g) throw new Error(`Unresolved COLLADA image: ${y}`);
114
114
  return g;
115
115
  });
116
- let f;
116
+ let d;
117
117
  const a = new Promise((y) => {
118
- f = y;
118
+ d = y;
119
119
  });
120
- let u;
121
- o.onLoad = f, o.onError = (y) => {
122
- u = y;
120
+ let f;
121
+ o.onLoad = d, o.onError = (y) => {
122
+ f = y;
123
123
  }, o.itemStart("urdf-collada-parse");
124
124
  const l = new ut();
125
125
  try {
126
- const y = new Fn(o).parse(i, "");
126
+ const y = new $n(o).parse(i, "");
127
127
  if (!(y != null && y.scene)) throw new Error(`COLLADA has no scene: ${n}`);
128
- if (l.add(y.scene), s === "X_UP" ? y.scene.rotateY(-Math.PI / 2) : y.scene.rotateX(Math.PI / 2), o.itemEnd("urdf-collada-parse"), await a, u) throw new Error(`COLLADA texture failed to load: ${u}`);
128
+ if (l.add(y.scene), s === "X_UP" ? y.scene.rotateY(-Math.PI / 2) : y.scene.rotateX(Math.PI / 2), o.itemEnd("urdf-collada-parse"), await a, f) throw new Error(`COLLADA texture failed to load: ${f}`);
129
129
  let g = 0;
130
130
  if (l.traverse((x) => {
131
131
  x instanceof C && g++;
132
132
  }), !g) throw new Error(`COLLADA has no visual meshes: ${n}`);
133
- return Dn(l), l.updateMatrixWorld(!0), l;
133
+ return Ln(l), l.updateMatrixWorld(!0), l;
134
134
  } catch (y) {
135
135
  throw ft(l), y;
136
136
  }
@@ -138,34 +138,34 @@ async function Ln(n, t) {
138
138
  function Hi(n) {
139
139
  const [t, i, e, s, r, o] = n;
140
140
  if (![t, i, e, s, r, o].every(Number.isFinite)) return !1;
141
- const f = t * i - s * s, a = t * (i * e - o * o) - s * (s * e - o * r) + r * (s * o - i * r);
142
- return t > 0 && f > 0 && a > 0 ? t <= i + e + 1e-12 && i <= t + e + 1e-12 && e <= t + i + 1e-12 : !1;
141
+ const d = t * i - s * s, a = t * (i * e - o * o) - s * (s * e - o * r) + r * (s * o - i * r);
142
+ return t > 0 && d > 0 && a > 0 ? t <= i + e + 1e-12 && i <= t + e + 1e-12 && e <= t + i + 1e-12 : !1;
143
143
  }
144
- function kn(n, t) {
144
+ function jn(n, t) {
145
145
  if (!(t > 0) || !Number.isFinite(t) || n.length !== 6 || !n.every(Number.isFinite)) return null;
146
146
  const i = [[n[0], n[3], n[4]], [n[3], n[1], n[5]], [n[4], n[5], n[2]]], e = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], s = Math.max(...n.map(Math.abs));
147
147
  for (let a = 0; a < 40; a++) {
148
- let u = 0, l = 1;
149
- for (const [w, m] of [[0, 1], [0, 2], [1, 2]]) Math.abs(i[w][m]) > Math.abs(i[u][l]) && (u = w, l = m);
150
- if (Math.abs(i[u][l]) <= s * 1e-14) break;
151
- const p = 0.5 * Math.atan2(2 * i[u][l], i[l][l] - i[u][u]), c = Math.cos(p), d = Math.sin(p), y = i[u][u], g = i[l][l], x = i[u][l];
148
+ let f = 0, l = 1;
149
+ for (const [w, m] of [[0, 1], [0, 2], [1, 2]]) Math.abs(i[w][m]) > Math.abs(i[f][l]) && (f = w, l = m);
150
+ if (Math.abs(i[f][l]) <= s * 1e-14) break;
151
+ const p = 0.5 * Math.atan2(2 * i[f][l], i[l][l] - i[f][f]), c = Math.cos(p), u = Math.sin(p), y = i[f][f], g = i[l][l], x = i[f][l];
152
152
  for (let w = 0; w < 3; w++) {
153
- if (w !== u && w !== l) {
154
- const b = i[w][u], A = i[w][l];
155
- i[w][u] = i[u][w] = c * b - d * A, i[w][l] = i[l][w] = d * b + c * A;
153
+ if (w !== f && w !== l) {
154
+ const b = i[w][f], A = i[w][l];
155
+ i[w][f] = i[f][w] = c * b - u * A, i[w][l] = i[l][w] = u * b + c * A;
156
156
  }
157
- const m = e[w][u], h = e[w][l];
158
- e[w][u] = c * m - d * h, e[w][l] = d * m + c * h;
157
+ const m = e[w][f], h = e[w][l];
158
+ e[w][f] = c * m - u * h, e[w][l] = u * m + c * h;
159
159
  }
160
- i[u][u] = c * c * y - 2 * d * c * x + d * d * g, i[l][l] = d * d * y + 2 * d * c * x + c * c * g, i[u][l] = i[l][u] = 0;
160
+ i[f][f] = c * c * y - 2 * u * c * x + u * u * g, i[l][l] = u * u * y + 2 * u * c * x + c * c * g, i[f][l] = i[l][f] = 0;
161
161
  }
162
- const r = [i[0][0], i[1][1], i[2][2]], o = r.map((a, u) => 5 * (r[(u + 1) % 3] + r[(u + 2) % 3] - a) / (2 * t));
162
+ const r = [i[0][0], i[1][1], i[2][2]], o = r.map((a, f) => 5 * (r[(f + 1) % 3] + r[(f + 2) % 3] - a) / (2 * t));
163
163
  if (r.some((a) => a <= 0) || o.some((a) => a < -s * 1e-10 / t)) return null;
164
- const f = new H().set(e[0][0], e[0][1], e[0][2], 0, e[1][0], e[1][1], e[1][2], 0, e[2][0], e[2][1], e[2][2], 0, 0, 0, 0, 1);
165
- return { radii: o.map((a) => Math.sqrt(Math.max(0, a))), rotation: new K().setFromRotationMatrix(f) };
164
+ 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
+ return { radii: o.map((a) => Math.sqrt(Math.max(0, a))), rotation: new K().setFromRotationMatrix(d) };
166
166
  }
167
- function jn(n, t) {
168
- const i = kn(n, t);
167
+ function Cn(n, t) {
168
+ const i = jn(n, t);
169
169
  return i ? { size: i.radii.map((e) => e * Math.sqrt(12 / 5)), rotation: i.rotation } : null;
170
170
  }
171
171
  function Lt(n, t) {
@@ -186,66 +186,66 @@ function he(n) {
186
186
  }
187
187
  function hi(n, t, i) {
188
188
  const e = n.querySelector("geometry"), s = e == null ? void 0 : e.querySelector("box");
189
- if (s) return { type: "box", size: Jn(s.getAttribute("size"), 3, "box size") };
189
+ if (s) return { type: "box", size: Hn(s.getAttribute("size"), 3, "box size") };
190
190
  const r = e == null ? void 0 : e.querySelector("sphere");
191
191
  if (r) return { type: "sphere", radius: jt(r.getAttribute("radius"), "sphere radius") };
192
192
  const o = e == null ? void 0 : e.querySelector("cylinder");
193
193
  if (o) return { type: "cylinder", radius: jt(o.getAttribute("radius"), "cylinder radius"), length: jt(o.getAttribute("length"), "cylinder length") };
194
- const f = e == null ? void 0 : e.querySelector("capsule");
195
- if (f) return { type: "capsule", radius: jt(f.getAttribute("radius"), "capsule radius"), length: jt(f.getAttribute("length"), "capsule length") };
196
- const a = e == null ? void 0 : e.querySelector("mesh"), u = a == null ? void 0 : a.getAttribute("filename");
197
- return u ? { type: "mesh", resourcePath: i.resolve(u, t), scale: Lt(a.getAttribute("scale"), [1, 1, 1]) } : null;
194
+ const d = e == null ? void 0 : e.querySelector("capsule");
195
+ if (d) return { type: "capsule", radius: jt(d.getAttribute("radius"), "capsule radius"), length: jt(d.getAttribute("length"), "capsule length") };
196
+ const a = e == null ? void 0 : e.querySelector("mesh"), f = a == null ? void 0 : a.getAttribute("filename");
197
+ return f ? { type: "mesh", resourcePath: i.resolve(f, t), scale: Lt(a.getAttribute("scale"), [1, 1, 1]) } : null;
198
198
  }
199
- function Cn(n, t, i) {
200
- const s = Xn(n, "URDF").querySelector("robot");
199
+ function Nn(n, t, i) {
200
+ const s = Jn(n, "URDF").querySelector("robot");
201
201
  if (!s) throw O("URDF requires a robot root element.", "E_URDF_PARSE");
202
202
  const r = pn(), o = /* @__PURE__ */ new Map();
203
- for (const u of s.children) if (u.tagName === "material" && u.getAttribute("name")) {
204
- const l = u.getAttribute("name");
203
+ for (const f of s.children) if (f.tagName === "material" && f.getAttribute("name")) {
204
+ const l = f.getAttribute("name");
205
205
  if (o.has(l)) throw O(`Duplicate URDF material: ${l}`, "E_URDF_MATERIAL");
206
- o.set(l, u);
206
+ o.set(l, f);
207
207
  }
208
- const f = [...s.querySelectorAll("link")].map((u) => ({
209
- id: ot(u, "name"),
210
- name: ot(u, "name"),
208
+ const d = [...s.querySelectorAll("link")].map((f) => ({
209
+ id: ot(f, "name"),
210
+ name: ot(f, "name"),
211
211
  inertial: (() => {
212
- const l = Hn(u);
213
- return l && (!(l.mass > 0) || !Number.isFinite(l.mass) || !Hi(l.tensor)) && r.errors.push({ code: "E_URDF_INERTIA", message: `连杆 ${u.getAttribute("name")} 的质量或惯性张量无效。`, source: u.getAttribute("name") ?? void 0 }), l;
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
214
  })(),
215
- visuals: [...u.querySelectorAll("visual")].map((l) => {
216
- const p = hi(l, t, i), c = l.querySelector("material"), d = c == null ? void 0 : c.getAttribute("name"), y = d ? o.get(d) : void 0, g = (c == null ? void 0 : c.querySelector("color")) ?? (y == null ? void 0 : y.querySelector("color")), x = (c == null ? void 0 : c.querySelector("texture")) ?? (y == null ? void 0 : y.querySelector("texture"));
217
- d && !y && !g && !x && r.warnings.push({ code: "URDF_MATERIAL_UNRESOLVED", message: `Undefined material: ${d}`, source: u.getAttribute("name") ?? void 0 });
215
+ 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"));
217
+ u && !y && !g && !x && r.warnings.push({ code: "URDF_MATERIAL_UNRESOLVED", message: `Undefined material: ${u}`, source: f.getAttribute("name") ?? void 0 });
218
218
  const w = g ? (g.getAttribute("rgba") ?? "").trim().split(/\s+/).map(Number) : x ? [1, 1, 1, 1] : void 0;
219
- if (w && (w.length !== 4 || w.some((b) => !Number.isFinite(b) || b < 0 || b > 1))) throw O(`Invalid URDF material RGBA: ${d ?? ""}`, "E_URDF_MATERIAL");
219
+ 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
220
  const m = x == null ? void 0 : x.getAttribute("filename");
221
221
  if (x && !m) throw O("URDF texture requires a filename", "E_URDF_MATERIAL");
222
222
  const h = m ? i.resolve(m, t) : void 0;
223
223
  return p ? { origin: he(l), geometry: p, color: w, texturePath: h } : null;
224
224
  }).filter((l) => !!l),
225
- collisions: [...u.querySelectorAll("collision")].map((l) => {
225
+ collisions: [...f.querySelectorAll("collision")].map((l) => {
226
226
  const p = hi(l, t, i);
227
227
  return p ? { origin: he(l), geometry: p } : null;
228
228
  }).filter((l) => !!l)
229
- })), a = [...s.querySelectorAll("joint")].map((u) => {
229
+ })), a = [...s.querySelectorAll("joint")].map((f) => {
230
230
  var w;
231
- const l = u.querySelector("limit"), p = u.querySelector("mimic"), c = p ? { joint: ot(p, "joint"), multiplier: Yt(p.getAttribute("multiplier"), "mimic multiplier") ?? 1, offset: Yt(p.getAttribute("offset"), "mimic offset") ?? 0 } : void 0, d = u.querySelector("dynamics"), y = d ? wi(d.getAttribute("damping"), 0) : 0, g = d ? wi(d.getAttribute("friction"), 0) : 0, x = d && (y > 0 || g > 0) ? { damping: y, friction: g } : void 0;
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;
232
232
  return {
233
- id: ot(u, "name"),
234
- type: u.getAttribute("type") ?? "fixed",
235
- parent: ot(u.querySelector("parent"), "link"),
236
- child: ot(u.querySelector("child"), "link"),
237
- origin: he(u),
238
- axis: Lt(((w = u.querySelector("axis")) == null ? void 0 : w.getAttribute("xyz")) ?? null, [1, 0, 0]),
233
+ id: ot(f, "name"),
234
+ type: f.getAttribute("type") ?? "fixed",
235
+ parent: ot(f.querySelector("parent"), "link"),
236
+ child: ot(f.querySelector("child"), "link"),
237
+ origin: he(f),
238
+ axis: Lt(((w = f.querySelector("axis")) == null ? void 0 : w.getAttribute("xyz")) ?? null, [1, 0, 0]),
239
239
  ...l ? {
240
- limits: { lower: Le(l.getAttribute("lower"), `Joint ${ot(u, "name")} limit lower`), upper: Le(l.getAttribute("upper"), `Joint ${ot(u, "name")} limit upper`) },
241
- effort: Yt(l.getAttribute("effort"), `Joint ${ot(u, "name")} limit effort`),
242
- velocity: Yt(l.getAttribute("velocity"), `Joint ${ot(u, "name")} limit velocity`)
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`)
243
243
  } : {},
244
244
  ...x ? { dynamics: x } : {},
245
245
  ...c ? { mimic: c } : {}
246
246
  };
247
247
  });
248
- return xe(a), s.querySelector("transmission, gazebo") && r.droppedFeatures.push({ code: "UNSUPPORTED_URDF_EXTENSION", message: "URDF transmission/gazebo extensions are not compiled." }), dn({ id: s.getAttribute("name") || t, name: s.getAttribute("name") || t, source: { format: "urdf", uri: t }, links: f, joints: a, diagnostics: r, extension: { files: i } }, { allowInvalidGraph: !0 });
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 });
249
249
  }
250
250
  function yi(n) {
251
251
  const t = Qt(n);
@@ -255,12 +255,12 @@ function Ie(n) {
255
255
  const t = new H(), i = Qt(n);
256
256
  return t.compose(new z().fromArray(n.position), i, new z(1, 1, 1));
257
257
  }
258
- function Nn(n) {
258
+ function qn(n) {
259
259
  if (n.type === "continuous" || !n.limits) return 0;
260
260
  const { lower: t, upper: i } = n.limits;
261
- return !Number.isFinite(t) || !Number.isFinite(i) ? 0 : Mn.clamp(0, t, i);
261
+ return !Number.isFinite(t) || !Number.isFinite(i) ? 0 : vn.clamp(0, t, i);
262
262
  }
263
- function qn(n) {
263
+ function On(n) {
264
264
  let t;
265
265
  if (n.type === "box")
266
266
  t = [n.size[0] / 2, n.size[1] / 2, n.size[2] / 2];
@@ -281,11 +281,11 @@ function Zi(n, t, i) {
281
281
  let e = 0;
282
282
  const s = new Map(n.links.map((l) => [l.id, l])), r = Ke(n.joints), o = (l) => {
283
283
  let p = 1 / 0;
284
- const c = (d, y) => {
285
- const g = s.get(d);
284
+ const c = (u, y) => {
285
+ const g = s.get(u);
286
286
  if (g) {
287
287
  for (const x of g.collisions) {
288
- const w = qn(x.geometry);
288
+ const w = On(x.geometry);
289
289
  if (!w) {
290
290
  l && (e += 1);
291
291
  continue;
@@ -294,20 +294,20 @@ function Zi(n, t, i) {
294
294
  for (const h of w)
295
295
  p = Math.min(p, h.applyMatrix4(m).z);
296
296
  }
297
- for (const x of i.get(d) ?? []) {
297
+ for (const x of i.get(u) ?? []) {
298
298
  const w = y.clone().multiply(Ie(x.origin)), m = l ? r[x.id] : 0;
299
299
  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
300
  }
301
301
  }
302
302
  };
303
303
  return c(t, new H()), p;
304
- }, f = o(!0), a = o(!1), u = Math.min(f, a);
304
+ }, d = o(!0), a = o(!1), f = Math.min(d, a);
305
305
  return e && n.diagnostics.warnings.push({
306
306
  code: "GROUNDING_IGNORED_MESH_COLLIDERS",
307
307
  message: `自动落地忽略了 ${e} 个网格碰撞体`
308
- }), Number.isFinite(u) ? Math.max(0, 0.015 - u) : 0;
308
+ }), Number.isFinite(f) ? Math.max(0, 0.015 - f) : 0;
309
309
  }
310
- async function On(n) {
310
+ async function Vn(n) {
311
311
  const t = n.extension.files, i = /* @__PURE__ */ new Map(), e = new Set(n.joints.map((w) => w.child));
312
312
  for (const w of n.joints) i.set(w.parent, [...i.get(w.parent) ?? [], w]);
313
313
  const s = n.links.filter((w) => !e.has(w.id));
@@ -317,12 +317,12 @@ async function On(n) {
317
317
  code: "AUTO_GROUNDED_FREE_ROOT",
318
318
  message: `自由根初始高度自动抬升 ${r.toFixed(4)} m`
319
319
  });
320
- const o = n.joints.filter((w) => Nn(w) !== 0);
320
+ const o = n.joints.filter((w) => qn(w) !== 0);
321
321
  o.length && n.diagnostics.approximations.push({
322
322
  code: "JOINT_REFERENCE_CLAMPED",
323
323
  message: `${o.length} 个关节的默认参考值已夹到合法限位`
324
324
  });
325
- const f = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), u = [], l = Ke(n.joints), p = async (w) => {
325
+ const d = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), f = [], l = Ke(n.joints), p = async (w) => {
326
326
  var A;
327
327
  if (w.type === "box") return `type="box" size="${w.size.map((P) => P / 2).join(" ")}"`;
328
328
  if (w.type === "sphere") return `type="sphere" size="${w.radius}"`;
@@ -336,7 +336,7 @@ async function On(n) {
336
336
  const P = { name: `mesh_${a.size}`, path: w.resourcePath, scale: w.scale };
337
337
  a.set(h, P);
338
338
  const M = await t.bytes(w.resourcePath);
339
- f.set(`${P.name}.${m}`, M), b = P;
339
+ d.set(`${P.name}.${m}`, M), b = P;
340
340
  }
341
341
  return `type="mesh" mesh="${b.name}"`;
342
342
  }, c = async (w, m) => {
@@ -352,10 +352,10 @@ async function On(n) {
352
352
  }
353
353
  if (!m) P.push("<freejoint/>");
354
354
  else if (["fixed", "planar", "floating"].includes(m.type))
355
- (m == null ? void 0 : m.type) === "floating" && (P.push("<freejoint/>"), u.push(0, 0, 0, 1, 0, 0, 0));
355
+ (m == null ? void 0 : m.type) === "floating" && (P.push("<freejoint/>"), f.push(0, 0, 0, 1, 0, 0, 0));
356
356
  else {
357
357
  const R = m.type === "prismatic" ? "slide" : "hinge", v = m.type !== "continuous" && !!m.limits && Number.isFinite(m.limits.lower) && Number.isFinite(m.limits.upper), B = l[m.id];
358
- u.push(B);
358
+ f.push(B);
359
359
  const S = ((M = m.dynamics) == null ? void 0 : M.damping) ?? 0, _ = ((T = m.dynamics) == null ? void 0 : T.friction) ?? 0;
360
360
  P.push(`<joint name="${St(m.id)}" type="${R}" axis="${m.axis.join(" ")}"${v ? ` limited="true" range="${m.limits.lower} ${m.limits.upper}" ref="0"` : ""} damping="${S}" frictionloss="${_}"/>`);
361
361
  }
@@ -368,51 +368,51 @@ async function On(n) {
368
368
  }
369
369
  for (const R of i.get(w) ?? []) P.push(await c(R.child, R));
370
370
  return P.push("</body>"), P.join("");
371
- }, d = await c(s[0].id), y = [...a.values()].map((w) => {
371
+ }, u = await c(s[0].id), y = [...a.values()].map((w) => {
372
372
  var m;
373
373
  return `<mesh name="${w.name}" file="${w.name}.${(m = w.path.split(".").pop()) == null ? void 0 : m.toLowerCase()}" scale="${w.scale.join(" ")}"/>`;
374
- }).join(""), g = `<keyframe><key name="home" qpos="0 0 ${r} 1 0 0 0 ${u.join(" ")}"/></keyframe>`, x = n.joints.filter((w) => w.mimic).map((w) => {
374
+ }).join(""), g = `<keyframe><key name="home" qpos="0 0 ${r} 1 0 0 0 ${f.join(" ")}"/></keyframe>`, x = n.joints.filter((w) => w.mimic).map((w) => {
375
375
  const m = w.mimic;
376
376
  return `<joint name="mimic_${St(w.id)}" joint1="${St(w.id)}" joint2="${St(m.joint)}" polycoef="${m.offset} ${m.multiplier} 0 0 0"/>`;
377
377
  }).join("");
378
378
  return {
379
379
  format: "mjcf",
380
- files: f,
381
- xml: `<mujoco model="${St(n.name)}"><compiler angle="radian" autolimits="true"/><option gravity="0 0 -9.81"/><asset>${y}</asset><worldbody><geom name="__viewer_default_ground__" type="plane" size="5 5 0.1" contype="1" conaffinity="1" friction="0.8 0.01 0.0002"/>${d}</worldbody>${x ? `<equality>${x}</equality>` : ""}${g}</mujoco>`
380
+ files: d,
381
+ xml: `<mujoco model="${St(n.name)}"><compiler angle="radian" autolimits="true"/><option gravity="0 0 -9.81"/><asset>${y}</asset><worldbody><geom name="__viewer_default_ground__" type="plane" size="5 5 0.1" contype="1" conaffinity="1" friction="0.8 0.01 0.0002"/>${u}</worldbody>${x ? `<equality>${x}</equality>` : ""}${g}</mujoco>`
382
382
  };
383
383
  }
384
384
  async function Qi(n) {
385
385
  const t = n.extension.files, i = new ut();
386
386
  i.name = "URDF authored collisions";
387
- const e = /* @__PURE__ */ new Map(), s = mn();
388
- let r = 0;
389
- for (const o of n.links) {
390
- const f = new ut();
391
- f.name = o.id, f.userData.urdfEntityId = `link:${o.id}`, e.set(o.id, f), i.add(f);
392
- for (const a of o.collisions) {
393
- const u = new ut();
394
- if (u.matrixAutoUpdate = !1, u.matrix.copy(Ie(a.origin)), f.add(u), a.geometry.type === "mesh") {
395
- const l = await De(a.geometry, t, new Je());
396
- l.updateMatrixWorld(!0), l.traverse((p) => {
397
- if (!(p instanceof C)) return;
398
- const c = ri(p.geometry, s, "mesh");
399
- c.matrixAutoUpdate = !1, c.matrix.copy(p.matrixWorld), c.name = `Collision:${o.id}`, c.userData.urdfLink = o.id, u.add(c), r += 1;
400
- }), ft(l);
387
+ const e = /* @__PURE__ */ new Map(), s = mn(), r = hn();
388
+ let o = 0;
389
+ for (const d of n.links) {
390
+ const a = new ut();
391
+ a.name = d.id, a.userData.urdfEntityId = `link:${d.id}`, e.set(d.id, a), i.add(a);
392
+ 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());
396
+ p.updateMatrixWorld(!0), p.traverse((c) => {
397
+ if (!(c instanceof C)) return;
398
+ const u = ri(c.geometry, s, "mesh", r);
399
+ u.matrixAutoUpdate = !1, u.matrix.copy(c.matrixWorld), u.name = `Collision:${d.id}`, u.userData.urdfLink = d.id, l.add(u), o += 1;
400
+ }), ft(p);
401
401
  } else {
402
- const l = Wn(a.geometry);
403
- if (!l) continue;
404
- const p = ri(l, s, "feature");
405
- l.dispose(), p.name = `Collision:${o.id}`, p.userData.urdfLink = o.id, u.add(p), r += 1;
402
+ const p = Gn(f.geometry);
403
+ if (!p) continue;
404
+ const c = ri(p, s, "feature", r);
405
+ p.dispose(), c.name = `Collision:${d.id}`, c.userData.urdfLink = d.id, l.add(c), o += 1;
406
406
  }
407
407
  }
408
408
  }
409
- if (r === 0) {
410
- s.dispose(), ft(i);
409
+ if (o === 0) {
410
+ s.dispose(), r.dispose(), ft(i);
411
411
  return;
412
412
  }
413
413
  return { root: i, bindings: e, expectedLinkCount: e.size };
414
414
  }
415
- async function Vn(n, t) {
415
+ async function Wn(n, t) {
416
416
  const i = await Qi(n);
417
417
  if (!i) return;
418
418
  const e = () => {
@@ -427,7 +427,7 @@ async function Vn(n, t) {
427
427
  ft(i.root);
428
428
  } };
429
429
  }
430
- function Wn(n) {
430
+ function Gn(n) {
431
431
  if (n.type === "box") return new He(...n.size);
432
432
  if (n.type === "sphere") return new Ze(n.radius, 24, 16);
433
433
  if (n.type === "cylinder") {
@@ -449,8 +449,8 @@ async function gi(n) {
449
449
  const r = new ut();
450
450
  r.name = s.id, r.userData.urdfEntityId = `link:${s.id}`, e.set(s.id, r), i.add(r);
451
451
  for (const o of s.visuals) {
452
- const f = await Gn(o, t, n.diagnostics), a = new ut();
453
- a.position.fromArray(o.origin.position), a.quaternion.copy(Qt(o.origin)), a.add(f), r.add(a);
452
+ const d = await Xn(o, t, n.diagnostics), a = new ut();
453
+ a.position.fromArray(o.origin.position), a.quaternion.copy(Qt(o.origin)), a.add(d), r.add(a);
454
454
  }
455
455
  }
456
456
  return { root: i, bindings: e, expectedLinkCount: n.links.length };
@@ -458,7 +458,7 @@ async function gi(n) {
458
458
  throw ft(i), s;
459
459
  }
460
460
  }
461
- async function Gn(n, t, i) {
461
+ async function Xn(n, t, i) {
462
462
  var r;
463
463
  if (n.geometry.type === "mesh" && /\.gl(?:tf|b)$/i.test(n.geometry.resourcePath)) {
464
464
  (n.color || n.texturePath) && i.warnings.push({ code: "URDF_EMBEDDED_MATERIAL_PRESERVED", message: "Embedded glTF materials take precedence over the URDF visual material.", source: n.geometry.resourcePath });
@@ -472,20 +472,20 @@ async function Gn(n, t, i) {
472
472
  const e = oi({ color: n.color });
473
473
  let s;
474
474
  try {
475
- if (n.texturePath && (await t.ensure(n.texturePath), e.map = await new bn().loadAsync(t.objectUrl(n.texturePath)), e.transparent = !0, e.map.colorSpace = xn, e.map.wrapS = e.map.wrapT = An), s = await De(n.geometry, t, e), n.geometry.type === "mesh" && /\.dae$/i.test(n.geometry.resourcePath))
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))
476
476
  if (n.color || n.texturePath) {
477
- const o = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
477
+ const o = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
478
478
  s.traverse((a) => {
479
479
  if (a instanceof C) {
480
- for (const u of Array.isArray(a.material) ? a.material : [a.material]) o.add(u);
480
+ for (const f of Array.isArray(a.material) ? a.material : [a.material]) o.add(f);
481
481
  a.material = e;
482
482
  }
483
483
  });
484
484
  for (const a of o) {
485
- for (const u of Object.values(a)) u != null && u.isTexture && f.add(u);
485
+ for (const f of Object.values(a)) f != null && f.isTexture && d.add(f);
486
486
  a.dispose();
487
487
  }
488
- for (const a of f) a.dispose();
488
+ for (const a of d) a.dispose();
489
489
  } else e.dispose();
490
490
  return e.map && s.traverse((o) => {
491
491
  if (o instanceof C && !o.geometry.getAttribute("uv")) throw O(`URDF texture requires authored UVs: ${n.texturePath}`, "E_URDF_TEXTURE_UV");
@@ -509,28 +509,28 @@ async function De(n, t, i) {
509
509
  const e = (r = n.resourcePath.split(".").pop()) == null ? void 0 : r.toLowerCase();
510
510
  await t.ensure(n.resourcePath);
511
511
  let s;
512
- if (e === "stl") s = new C(new In().parse(await t.getBlob(n.resourcePath).arrayBuffer()), i);
512
+ if (e === "stl") s = new C(new Dn().parse(await t.getBlob(n.resourcePath).arrayBuffer()), i);
513
513
  else if (e === "obj")
514
- s = new $n().parse(await t.getBlob(n.resourcePath).text()), s.traverse((o) => {
514
+ s = new In().parse(await t.getBlob(n.resourcePath).text()), s.traverse((o) => {
515
515
  if (o instanceof C) {
516
- for (const f of Array.isArray(o.material) ? o.material : [o.material]) f.dispose();
516
+ for (const d of Array.isArray(o.material) ? o.material : [o.material]) d.dispose();
517
517
  o.material = i;
518
518
  }
519
519
  });
520
520
  else if (e === "gltf" || e === "glb") {
521
521
  const o = new Ci();
522
- o.setURLModifier((f) => {
522
+ o.setURLModifier((d) => {
523
523
  try {
524
- return t.objectUrl(t.resolve(f, n.resourcePath));
524
+ return t.objectUrl(t.resolve(d, n.resourcePath));
525
525
  } catch {
526
- return f;
526
+ return d;
527
527
  }
528
- }), s = (await new Un(o).parseAsync(await t.getBlob(n.resourcePath).arrayBuffer(), "")).scene;
529
- } else if (e === "dae") s = await Ln(n.resourcePath, t);
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
530
  else throw O(`Unsupported URDF visual mesh: .${e ?? ""}`, "E_URDF_VISUAL");
531
531
  return s.scale.fromArray(n.scale), s;
532
532
  }
533
- function Xn(n, t) {
533
+ function Jn(n, t) {
534
534
  const i = new DOMParser().parseFromString(n, "application/xml"), e = i.querySelector("parsererror");
535
535
  if (e) throw O(`${t} XML parse failed: ${e.textContent ?? ""}`, `E_${t}_PARSE`);
536
536
  return i;
@@ -555,7 +555,7 @@ function jt(n, t) {
555
555
  if (!(i > 0)) throw O(`${t} must be greater than zero.`, "E_URDF_PARSE");
556
556
  return i;
557
557
  }
558
- function Jn(n, t, i) {
558
+ function Hn(n, t, i) {
559
559
  if (n === null || n.trim() === "") throw O(`${i} is required.`, "E_URDF_PARSE");
560
560
  const e = Lt(n, []);
561
561
  if (e.length !== t || e.some((s) => !(s > 0))) throw O(`${i} requires ${t} values greater than zero.`, "E_URDF_PARSE");
@@ -573,17 +573,17 @@ function St(n) {
573
573
  function O(n, t) {
574
574
  return Object.assign(new Error(n), { code: t });
575
575
  }
576
- function Hn(n) {
576
+ function Zn(n) {
577
577
  var o;
578
578
  const t = n.querySelector("inertial");
579
579
  if (!t) return;
580
- const i = t.querySelector("inertia"), e = (o = t.querySelector("mass")) == null ? void 0 : o.getAttribute("value"), s = e == null || e.trim() === "" ? Number.NaN : Number(e), r = ["ixx", "iyy", "izz", "ixy", "ixz", "iyz"].map((f) => {
581
- const a = i == null ? void 0 : i.getAttribute(f);
580
+ const i = t.querySelector("inertia"), e = (o = t.querySelector("mass")) == null ? void 0 : o.getAttribute("value"), s = e == null || e.trim() === "" ? Number.NaN : Number(e), r = ["ixx", "iyy", "izz", "ixy", "ixz", "iyz"].map((d) => {
581
+ const a = i == null ? void 0 : i.getAttribute(d);
582
582
  return a == null || a.trim() === "" ? Number.NaN : Number(a);
583
583
  });
584
584
  return { origin: he(t), mass: s, tensor: r };
585
585
  }
586
- const Yi = 0, Zn = 1, Qn = 2, bi = 2, Pe = 1.25, xi = 1, X = 6 * 4 + 4 + 4, N = X / 4, Ki = 65535, ye = Math.pow(2, -24), ti = Symbol("SKIP_GENERATION"), tn = {
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
587
  strategy: Yi,
588
588
  maxDepth: 40,
589
589
  maxLeafSize: 10,
@@ -618,8 +618,8 @@ function vi(n, t, i) {
618
618
  }
619
619
  function Kt(n, t, i) {
620
620
  for (let e = 0; e < 3; e++) {
621
- const s = t[n + 2 * e], r = t[n + 2 * e + 1], o = s - r, f = s + r;
622
- o < i[e] && (i[e] = o), f > i[e + 3] && (i[e + 3] = f);
621
+ const s = t[n + 2 * e], r = t[n + 2 * e + 1], o = s - r, d = s + r;
622
+ o < i[e] && (i[e] = o), d > i[e + 3] && (i[e + 3] = d);
623
623
  }
624
624
  }
625
625
  function Ct(n) {
@@ -646,44 +646,44 @@ function ei(n, t) {
646
646
  return t[n + 7];
647
647
  }
648
648
  function Se(n, t, i, e, s) {
649
- let r = 1 / 0, o = 1 / 0, f = 1 / 0, a = -1 / 0, u = -1 / 0, l = -1 / 0, p = 1 / 0, c = 1 / 0, d = 1 / 0, y = -1 / 0, g = -1 / 0, x = -1 / 0;
649
+ 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
650
  const w = n.offset || 0;
651
651
  for (let m = (t - w) * 6, h = (t + i - w) * 6; m < h; m += 6) {
652
652
  const b = n[m + 0], A = n[m + 1], P = b - A, M = b + A;
653
653
  P < r && (r = P), M > a && (a = M), b < p && (p = b), b > y && (y = b);
654
654
  const T = n[m + 2], R = n[m + 3], v = T - R, B = T + R;
655
- v < o && (o = v), B > u && (u = B), T < c && (c = T), T > g && (g = T);
655
+ v < o && (o = v), B > f && (f = B), T < c && (c = T), T > g && (g = T);
656
656
  const S = n[m + 4], _ = n[m + 5], E = S - _, F = S + _;
657
- E < f && (f = E), F > l && (l = F), S < d && (d = S), S > x && (x = S);
657
+ E < d && (d = E), F > l && (l = F), S < u && (u = S), S > x && (x = S);
658
658
  }
659
- e[0] = r, e[1] = o, e[2] = f, e[3] = a, e[4] = u, e[5] = l, s[0] = p, s[1] = c, s[2] = d, s[3] = y, s[4] = g, s[5] = x;
659
+ 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
660
  }
661
- const ct = 32, Yn = (n, t) => n.candidate - t.candidate, mt = /* @__PURE__ */ new Array(ct).fill().map(() => ({
661
+ const ct = 32, Kn = (n, t) => n.candidate - t.candidate, mt = /* @__PURE__ */ new Array(ct).fill().map(() => ({
662
662
  count: 0,
663
663
  bounds: new Float32Array(6),
664
664
  rightCacheBounds: new Float32Array(6),
665
665
  leftCacheBounds: new Float32Array(6),
666
666
  candidate: 0
667
667
  })), te = /* @__PURE__ */ new Float32Array(6);
668
- function Kn(n, t, i, e, s, r) {
669
- let o = -1, f = 0;
668
+ function ts(n, t, i, e, s, r) {
669
+ let o = -1, d = 0;
670
670
  if (r === Yi)
671
- o = Ai(t), o !== -1 && (f = (t[o] + t[o + 3]) / 2);
672
- else if (r === Zn)
673
- o = Ai(n), o !== -1 && (f = ts(i, e, s, o));
674
- else if (r === Qn) {
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
675
  const a = Ct(n);
676
- let u = Pe * s;
676
+ let f = Pe * s;
677
677
  const l = i.offset || 0, p = (e - l) * 6, c = (e + s - l) * 6;
678
- for (let d = 0; d < 3; d++) {
679
- const y = t[d], w = (t[d + 3] - y) / ct;
678
+ for (let u = 0; u < 3; u++) {
679
+ const y = t[u], w = (t[u + 3] - y) / ct;
680
680
  if (s < ct / 4) {
681
681
  const m = [...mt];
682
682
  m.length = s;
683
683
  let h = 0;
684
684
  for (let A = p; A < c; A += 6, h++) {
685
685
  const P = m[h];
686
- P.candidate = i[A + 2 * d], P.count = 0;
686
+ P.candidate = i[A + 2 * u], P.count = 0;
687
687
  const {
688
688
  bounds: M,
689
689
  leftCacheBounds: T,
@@ -693,7 +693,7 @@ function Kn(n, t, i, e, s, r) {
693
693
  R[v] = 1 / 0, R[v + 3] = -1 / 0, T[v] = 1 / 0, T[v + 3] = -1 / 0, M[v] = 1 / 0, M[v + 3] = -1 / 0;
694
694
  Kt(A, i, M);
695
695
  }
696
- m.sort(Yn);
696
+ m.sort(Kn);
697
697
  let b = s;
698
698
  for (let A = 0; A < b; A++) {
699
699
  const P = m[A];
@@ -701,7 +701,7 @@ function Kn(n, t, i, e, s, r) {
701
701
  m.splice(A + 1, 1), b--;
702
702
  }
703
703
  for (let A = p; A < c; A += 6) {
704
- const P = i[A + 2 * d];
704
+ const P = i[A + 2 * u];
705
705
  for (let M = 0; M < b; M++) {
706
706
  const T = m[M];
707
707
  P >= T.candidate ? Kt(A, i, T.rightCacheBounds) : (Kt(A, i, T.leftCacheBounds), T.count++);
@@ -714,7 +714,7 @@ function Kn(n, t, i, e, s, r) {
714
714
  let S = 0;
715
715
  T !== 0 && (S = Ct(v) / a);
716
716
  const _ = xi + Pe * (B * M + S * T);
717
- _ < u && (o = d, u = _, f = P.candidate);
717
+ _ < f && (o = u, f = _, d = P.candidate);
718
718
  }
719
719
  } else {
720
720
  for (let b = 0; b < ct; b++) {
@@ -725,7 +725,7 @@ function Kn(n, t, i, e, s, r) {
725
725
  P[M] = 1 / 0, P[M + 3] = -1 / 0;
726
726
  }
727
727
  for (let b = p; b < c; b += 6) {
728
- let M = ~~((i[b + 2 * d] - y) / w);
728
+ let M = ~~((i[b + 2 * u] - y) / w);
729
729
  M >= ct && (M = ct - 1);
730
730
  const T = mt[M];
731
731
  T.count++, Kt(b, i, T.bounds);
@@ -745,18 +745,18 @@ function Kn(n, t, i, e, s, r) {
745
745
  const S = s - h;
746
746
  S !== 0 && (B = Ct(R) / a);
747
747
  const _ = xi + Pe * (v * h + B * S);
748
- _ < u && (o = d, u = _, f = A.candidate);
748
+ _ < f && (o = u, f = _, d = A.candidate);
749
749
  }
750
750
  }
751
751
  }
752
752
  } else
753
753
  console.warn(`BVH: Invalid build strategy value ${r} used.`);
754
- return { axis: o, pos: f };
754
+ return { axis: o, pos: d };
755
755
  }
756
- function ts(n, t, i, e) {
756
+ function es(n, t, i, e) {
757
757
  let s = 0;
758
758
  const r = n.offset;
759
- for (let o = t, f = t + i; o < f; o++)
759
+ for (let o = t, d = t + i; o < d; o++)
760
760
  s += n[(o - r) * 6 + e * 2];
761
761
  return s / i;
762
762
  }
@@ -765,34 +765,34 @@ class Te {
765
765
  this.boundingData = new Float32Array(6);
766
766
  }
767
767
  }
768
- function es(n, t, i, e, s, r) {
769
- let o = e, f = e + s - 1;
770
- const a = r.pos, u = r.axis * 2, l = i.offset || 0;
768
+ function is(n, t, i, e, s, r) {
769
+ let o = e, d = e + s - 1;
770
+ const a = r.pos, f = r.axis * 2, l = i.offset || 0;
771
771
  for (; ; ) {
772
- for (; o <= f && i[(o - l) * 6 + u] < a; )
772
+ for (; o <= d && i[(o - l) * 6 + f] < a; )
773
773
  o++;
774
- for (; o <= f && i[(f - l) * 6 + u] >= a; )
775
- f--;
776
- if (o < f) {
774
+ for (; o <= d && i[(d - l) * 6 + f] >= a; )
775
+ d--;
776
+ if (o < d) {
777
777
  for (let p = 0; p < t; p++) {
778
778
  let c = n[o * t + p];
779
- n[o * t + p] = n[f * t + p], n[f * t + p] = c;
779
+ n[o * t + p] = n[d * t + p], n[d * t + p] = c;
780
780
  }
781
781
  for (let p = 0; p < 6; p++) {
782
- const c = o - l, d = f - l, y = i[c * 6 + p];
783
- i[c * 6 + p] = i[d * 6 + p], i[d * 6 + p] = y;
782
+ const c = o - l, u = d - l, y = i[c * 6 + p];
783
+ i[c * 6 + p] = i[u * 6 + p], i[u * 6 + p] = y;
784
784
  }
785
- o++, f--;
785
+ o++, d--;
786
786
  } else
787
787
  return o;
788
788
  }
789
789
  }
790
790
  let en, ge, ke, nn;
791
- const is = Math.pow(2, 32);
791
+ const ns = Math.pow(2, 32);
792
792
  function je(n) {
793
793
  return "count" in n ? 1 : 1 + je(n.left) + je(n.right);
794
794
  }
795
- function ns(n, t, i) {
795
+ function ss(n, t, i) {
796
796
  return en = new Float32Array(i), ge = new Uint32Array(i), ke = new Uint16Array(i), nn = new Uint8Array(i), Ce(n, t);
797
797
  }
798
798
  function Ce(n, t) {
@@ -802,55 +802,55 @@ function Ce(n, t) {
802
802
  if (s)
803
803
  return t.buffer ? (nn.set(new Uint8Array(t.buffer), n), n + t.buffer.byteLength) : (ge[i + 6] = t.offset, ke[e + 14] = t.count, ke[e + 15] = Ki, n + X);
804
804
  {
805
- const { left: o, right: f, splitAxis: a } = t, u = n + X;
806
- let l = Ce(u, o);
807
- const p = n / X, d = l / X - p;
808
- if (d > is)
805
+ const { left: o, right: d, splitAxis: a } = t, f = n + X;
806
+ let l = Ce(f, o);
807
+ const p = n / X, u = l / X - p;
808
+ if (u > ns)
809
809
  throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");
810
- return ge[i + 6] = d, ge[i + 7] = a, Ce(l, f);
810
+ return ge[i + 6] = u, ge[i + 7] = a, Ce(l, d);
811
811
  }
812
812
  }
813
- function ss(n, t, i, e, s, r) {
813
+ function os(n, t, i, e, s, r) {
814
814
  const {
815
815
  maxDepth: o,
816
- verbose: f,
816
+ verbose: d,
817
817
  maxLeafSize: a,
818
- strategy: u,
818
+ strategy: f,
819
819
  onProgress: l
820
- } = s, p = n.primitiveBuffer, c = n.primitiveBufferStride, d = new Float32Array(6);
820
+ } = s, p = n.primitiveBuffer, c = n.primitiveBufferStride, u = new Float32Array(6);
821
821
  let y = !1;
822
822
  const g = new Te();
823
- return Se(t, i, e, g.boundingData, d), w(g, i, e, d), g;
823
+ return Se(t, i, e, g.boundingData, u), w(g, i, e, u), g;
824
824
  function x(m) {
825
825
  l && l((m - r.offset) / r.count);
826
826
  }
827
827
  function w(m, h, b, A = null, P = 0) {
828
- if (!y && P >= o && (y = !0, f && console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`)), b <= a || P >= o)
828
+ 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
829
  return x(h + b), m.offset = h, m.count = b, m;
830
- const M = Kn(m.boundingData, A, t, h, b, u);
830
+ const M = ts(m.boundingData, A, t, h, b, f);
831
831
  if (M.axis === -1)
832
832
  return x(h + b), m.offset = h, m.count = b, m;
833
- const T = es(p, c, t, h, b, M);
833
+ const T = is(p, c, t, h, b, M);
834
834
  if (T === h || T === h + b)
835
835
  x(h + b), m.offset = h, m.count = b;
836
836
  else {
837
837
  m.splitAxis = M.axis;
838
838
  const R = new Te(), v = h, B = T - h;
839
- m.left = R, Se(t, v, B, R.boundingData, d), w(R, v, B, d, P + 1);
839
+ m.left = R, Se(t, v, B, R.boundingData, u), w(R, v, B, u, P + 1);
840
840
  const S = new Te(), _ = T, E = b - B;
841
- m.right = S, Se(t, _, E, S.boundingData, d), w(S, _, E, d, P + 1);
841
+ m.right = S, Se(t, _, E, S.boundingData, u), w(S, _, E, u, P + 1);
842
842
  }
843
843
  return m;
844
844
  }
845
845
  }
846
- function os(n, t) {
846
+ function rs(n, t) {
847
847
  const i = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, e = n.getRootRanges(t.range), s = e[0], r = e[e.length - 1], o = {
848
848
  offset: s.offset,
849
849
  count: r.offset + r.count - s.offset
850
- }, f = new Float32Array(6 * o.count);
851
- f.offset = o.offset, n.computePrimitiveBounds(o.offset, o.count, f), n._roots = e.map((a) => {
852
- const u = ss(n, f, a.offset, a.count, t, o), l = je(u), p = new i(X * l);
853
- return ns(0, u, p), p;
850
+ }, d = new Float32Array(6 * o.count);
851
+ 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
854
  });
855
855
  }
856
856
  class ii {
@@ -865,7 +865,7 @@ class ii {
865
865
  this._primitives.push(t);
866
866
  }
867
867
  }
868
- class rs {
868
+ class as {
869
869
  constructor() {
870
870
  this.float32Array = null, this.uint16Array = null, this.uint32Array = null;
871
871
  const t = [];
@@ -877,22 +877,22 @@ class rs {
877
877
  };
878
878
  }
879
879
  }
880
- const I = /* @__PURE__ */ new rs();
880
+ const I = /* @__PURE__ */ new as();
881
881
  let yt, Dt;
882
882
  const Tt = [], ee = /* @__PURE__ */ new ii(() => new it());
883
- function as(n, t, i, e, s, r) {
883
+ function cs(n, t, i, e, s, r) {
884
884
  yt = ee.getPrimitive(), Dt = ee.getPrimitive(), Tt.push(yt, Dt), I.setBuffer(n._roots[t]);
885
885
  const o = Ne(0, n.geometry, i, e, s, r);
886
886
  I.clearBuffer(), ee.releasePrimitive(yt), ee.releasePrimitive(Dt), Tt.pop(), Tt.pop();
887
- const f = Tt.length;
888
- return f > 0 && (Dt = Tt[f - 1], yt = Tt[f - 2]), o;
887
+ const d = Tt.length;
888
+ return d > 0 && (Dt = Tt[d - 1], yt = Tt[d - 2]), o;
889
889
  }
890
890
  function Ne(n, t, i, e, s = null, r = 0, o = 0) {
891
- const { float32Array: f, uint16Array: a, uint32Array: u } = I;
891
+ const { float32Array: d, uint16Array: a, uint32Array: f } = I;
892
892
  let l = n * 2;
893
893
  if (q(l, a)) {
894
- const c = J(n, u), d = Z(l, a);
895
- return k(n, f, yt), e(c, d, !1, o, r + n / N, yt);
894
+ const c = J(n, f), u = Z(l, a);
895
+ return k(n, d, yt), e(c, u, !1, o, r + n / N, yt);
896
896
  } else {
897
897
  let v = function(S) {
898
898
  const { uint16Array: _, uint32Array: E } = I;
@@ -907,14 +907,14 @@ function Ne(n, t, i, e, s = null, r = 0, o = 0) {
907
907
  S = W(S, E), F = S * 2;
908
908
  return J(S, E) + Z(F, _);
909
909
  };
910
- const c = V(n), d = W(n, u);
911
- let y = c, g = d, x, w, m, h;
912
- if (s && (m = yt, h = Dt, k(y, f, m), k(g, f, h), x = s(m), w = s(h), w < x)) {
913
- y = d, g = c;
910
+ const c = V(n), u = W(n, f);
911
+ 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)) {
913
+ y = u, g = c;
914
914
  const S = x;
915
915
  x = w, w = S, m = h;
916
916
  }
917
- m || (m = yt, k(y, f, m));
917
+ m || (m = yt, k(y, d, m));
918
918
  const b = q(y * 2, a), A = i(m, b, x, o + 1, r + y / N);
919
919
  let P;
920
920
  if (A === bi) {
@@ -931,7 +931,7 @@ function Ne(n, t, i, e, s = null, r = 0, o = 0) {
931
931
  o + 1
932
932
  );
933
933
  if (P) return !0;
934
- h = Dt, k(g, f, h);
934
+ h = Dt, k(g, d, h);
935
935
  const M = q(g * 2, a), T = i(h, M, w, o + 1, r + g / N);
936
936
  let R;
937
937
  if (T === bi) {
@@ -952,39 +952,39 @@ function Ne(n, t, i, e, s = null, r = 0, o = 0) {
952
952
  }
953
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
954
  let _e = !1;
955
- function cs(n, t, i, e) {
955
+ function ls(n, t, i, e) {
956
956
  if (_e)
957
957
  throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");
958
958
  _e = !0;
959
959
  const s = n._roots, r = t._roots;
960
- let o, f = 0, a = 0;
961
- const u = new H().copy(i).invert();
960
+ let o, d = 0, a = 0;
961
+ const f = new H().copy(i).invert();
962
962
  for (let l = 0, p = s.length; l < p; l++) {
963
963
  Ht.setBuffer(s[l]), a = 0;
964
964
  const c = ht.getPrimitive();
965
- k(0, Ht.float32Array, c), c.applyMatrix4(u);
966
- for (let d = 0, y = r.length; d < y && (we.setBuffer(r[d]), o = nt(
965
+ k(0, Ht.float32Array, c), c.applyMatrix4(f);
966
+ for (let u = 0, y = r.length; u < y && (we.setBuffer(r[u]), o = nt(
967
967
  0,
968
968
  0,
969
969
  i,
970
- u,
971
- e,
972
970
  f,
971
+ e,
972
+ d,
973
973
  a,
974
974
  0,
975
975
  0,
976
976
  c
977
- ), we.clearBuffer(), a += r[d].byteLength / X, !o); d++)
977
+ ), we.clearBuffer(), a += r[u].byteLength / X, !o); u++)
978
978
  ;
979
- if (ht.releasePrimitive(c), Ht.clearBuffer(), f += s[l].byteLength / X, o)
979
+ if (ht.releasePrimitive(c), Ht.clearBuffer(), d += s[l].byteLength / X, o)
980
980
  break;
981
981
  }
982
982
  return _e = !1, o;
983
983
  }
984
- function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
984
+ function nt(n, t, i, e, s, r = 0, o = 0, d = 0, a = 0, f = null, l = !1) {
985
985
  let p, c;
986
986
  l ? (p = we, c = Ht) : (p = Ht, c = we);
987
- const d = 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);
987
+ 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
988
  let M = !1;
989
989
  if (P && A)
990
990
  l ? M = s(
@@ -994,14 +994,14 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
994
994
  Z(n * 2, g),
995
995
  a,
996
996
  o + t / N,
997
- f,
997
+ d,
998
998
  r + n / N
999
999
  ) : M = s(
1000
1000
  J(n, y),
1001
1001
  Z(n * 2, g),
1002
1002
  J(t, w),
1003
1003
  Z(t * 2, m),
1004
- f,
1004
+ d,
1005
1005
  r + n / N,
1006
1006
  a,
1007
1007
  o + t / N
@@ -1010,7 +1010,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
1010
1010
  const T = ht.getPrimitive();
1011
1011
  k(t, x, T), T.applyMatrix4(i);
1012
1012
  const R = V(n), v = W(n, y);
1013
- k(R, d, Rt), k(v, d, Bt);
1013
+ k(R, u, Rt), k(v, u, Bt);
1014
1014
  const B = T.intersectsBox(Rt), S = T.intersectsBox(Bt);
1015
1015
  M = B && nt(
1016
1016
  t,
@@ -1021,7 +1021,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
1021
1021
  o,
1022
1022
  r,
1023
1023
  a,
1024
- f + 1,
1024
+ d + 1,
1025
1025
  T,
1026
1026
  !l
1027
1027
  ) || S && nt(
@@ -1033,14 +1033,14 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
1033
1033
  o,
1034
1034
  r,
1035
1035
  a,
1036
- f + 1,
1036
+ d + 1,
1037
1037
  T,
1038
1038
  !l
1039
1039
  ), ht.releasePrimitive(T);
1040
1040
  } else {
1041
1041
  const T = V(t), R = W(t, w);
1042
1042
  k(T, x, Re), k(R, x, Be);
1043
- const v = u.intersectsBox(Re), B = u.intersectsBox(Be);
1043
+ const v = f.intersectsBox(Re), B = f.intersectsBox(Be);
1044
1044
  if (v && B)
1045
1045
  M = nt(
1046
1046
  n,
@@ -1050,9 +1050,9 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
1050
1050
  s,
1051
1051
  r,
1052
1052
  o,
1053
- f,
1053
+ d,
1054
1054
  a + 1,
1055
- u,
1055
+ f,
1056
1056
  l
1057
1057
  ) || nt(
1058
1058
  n,
@@ -1062,9 +1062,9 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
1062
1062
  s,
1063
1063
  r,
1064
1064
  o,
1065
- f,
1065
+ d,
1066
1066
  a + 1,
1067
- u,
1067
+ f,
1068
1068
  l
1069
1069
  );
1070
1070
  else if (v)
@@ -1077,16 +1077,16 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
1077
1077
  s,
1078
1078
  r,
1079
1079
  o,
1080
- f,
1080
+ d,
1081
1081
  a + 1,
1082
- u,
1082
+ f,
1083
1083
  l
1084
1084
  );
1085
1085
  else {
1086
1086
  const S = ht.getPrimitive();
1087
1087
  S.copy(Re).applyMatrix4(i);
1088
1088
  const _ = V(n), E = W(n, y);
1089
- k(_, d, Rt), k(E, d, Bt);
1089
+ k(_, u, Rt), k(E, u, Bt);
1090
1090
  const F = S.intersectsBox(Rt), D = S.intersectsBox(Bt);
1091
1091
  M = F && nt(
1092
1092
  T,
@@ -1097,7 +1097,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
1097
1097
  o,
1098
1098
  r,
1099
1099
  a,
1100
- f + 1,
1100
+ d + 1,
1101
1101
  S,
1102
1102
  !l
1103
1103
  ) || D && nt(
@@ -1109,7 +1109,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
1109
1109
  o,
1110
1110
  r,
1111
1111
  a,
1112
- f + 1,
1112
+ d + 1,
1113
1113
  S,
1114
1114
  !l
1115
1115
  ), ht.releasePrimitive(S);
@@ -1124,16 +1124,16 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
1124
1124
  s,
1125
1125
  r,
1126
1126
  o,
1127
- f,
1127
+ d,
1128
1128
  a + 1,
1129
- u,
1129
+ f,
1130
1130
  l
1131
1131
  );
1132
1132
  else {
1133
1133
  const S = ht.getPrimitive();
1134
1134
  S.copy(Be).applyMatrix4(i);
1135
1135
  const _ = V(n), E = W(n, y);
1136
- k(_, d, Rt), k(E, d, Bt);
1136
+ k(_, u, Rt), k(E, u, Bt);
1137
1137
  const F = S.intersectsBox(Rt), D = S.intersectsBox(Bt);
1138
1138
  M = F && nt(
1139
1139
  R,
@@ -1144,7 +1144,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
1144
1144
  o,
1145
1145
  r,
1146
1146
  a,
1147
- f + 1,
1147
+ d + 1,
1148
1148
  S,
1149
1149
  !l
1150
1150
  ) || D && nt(
@@ -1156,7 +1156,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
1156
1156
  o,
1157
1157
  r,
1158
1158
  a,
1159
- f + 1,
1159
+ d + 1,
1160
1160
  S,
1161
1161
  !l
1162
1162
  ), ht.releasePrimitive(S);
@@ -1165,7 +1165,7 @@ function nt(n, t, i, e, s, r = 0, o = 0, f = 0, a = 0, u = null, l = !1) {
1165
1165
  return M;
1166
1166
  }
1167
1167
  const Pi = /* @__PURE__ */ new it(), _t = /* @__PURE__ */ new Float32Array(6);
1168
- class ls {
1168
+ class us {
1169
1169
  constructor() {
1170
1170
  this._roots = null, this.primitiveBuffer = null, this.primitiveBufferStride = null;
1171
1171
  }
@@ -1173,7 +1173,7 @@ class ls {
1173
1173
  t = {
1174
1174
  ...tn,
1175
1175
  ...t
1176
- }, os(this, t);
1176
+ }, rs(this, t);
1177
1177
  }
1178
1178
  getRootRanges() {
1179
1179
  throw new Error("BVH: getRootRanges() not implemented");
@@ -1186,20 +1186,20 @@ class ls {
1186
1186
  // writes the union bounds of all primitives in the given range in a min / max format
1187
1187
  // to the buffer
1188
1188
  writePrimitiveRangeBounds(t, i, e, s) {
1189
- let r = 1 / 0, o = 1 / 0, f = 1 / 0, a = -1 / 0, u = -1 / 0, l = -1 / 0;
1189
+ let r = 1 / 0, o = 1 / 0, d = 1 / 0, a = -1 / 0, f = -1 / 0, l = -1 / 0;
1190
1190
  for (let p = t, c = t + i; p < c; p++) {
1191
1191
  this.writePrimitiveBounds(p, _t, 0);
1192
- const [d, y, g, x, w, m] = _t;
1193
- d < r && (r = d), x > a && (a = x), y < o && (o = y), w > u && (u = w), g < f && (f = g), m > l && (l = m);
1192
+ const [u, y, g, x, w, m] = _t;
1193
+ u < r && (r = u), x > a && (a = x), y < o && (o = y), w > f && (f = w), g < d && (d = g), m > l && (l = m);
1194
1194
  }
1195
- return e[s + 0] = r, e[s + 1] = o, e[s + 2] = f, e[s + 3] = a, e[s + 4] = u, e[s + 5] = l, e;
1195
+ return e[s + 0] = r, e[s + 1] = o, e[s + 2] = d, e[s + 3] = a, e[s + 4] = f, e[s + 5] = l, e;
1196
1196
  }
1197
1197
  computePrimitiveBounds(t, i, e) {
1198
1198
  const s = e.offset || 0;
1199
1199
  for (let r = t, o = t + i; r < o; r++) {
1200
1200
  this.writePrimitiveBounds(r, _t, 0);
1201
- const [f, a, u, l, p, c] = _t, d = (f + l) / 2, y = (a + p) / 2, g = (u + c) / 2, x = (l - f) / 2, w = (p - a) / 2, m = (c - u) / 2, h = (r - s) * 6;
1202
- e[h + 0] = d, e[h + 1] = x + (Math.abs(d) + x) * ye, e[h + 2] = y, e[h + 3] = w + (Math.abs(y) + w) * ye, e[h + 4] = g, e[h + 5] = m + (Math.abs(g) + m) * ye;
1201
+ 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;
1203
1203
  }
1204
1204
  return e;
1205
1205
  }
@@ -1211,10 +1211,10 @@ class ls {
1211
1211
  else {
1212
1212
  const e = this._roots;
1213
1213
  for (let s = 0; s < e.length; s++) {
1214
- const r = e[s], o = new Uint32Array(r), f = new Uint16Array(r), a = r.byteLength / X;
1215
- for (let u = 0; u < a; u++) {
1216
- const l = N * u, p = 2 * l;
1217
- q(p, f) && (o[l + 6] += t);
1214
+ const r = e[s], o = new Uint32Array(r), d = new Uint16Array(r), a = r.byteLength / X;
1215
+ for (let f = 0; f < a; f++) {
1216
+ const l = N * f, p = 2 * l;
1217
+ q(p, d) && (o[l + 6] += t);
1218
1218
  }
1219
1219
  }
1220
1220
  }
@@ -1222,31 +1222,31 @@ class ls {
1222
1222
  traverse(t, i = 0) {
1223
1223
  const e = this._roots[i], s = new Uint32Array(e), r = new Uint16Array(e);
1224
1224
  o(0);
1225
- function o(f, a = 0) {
1226
- const u = f * 2, l = q(u, r);
1225
+ function o(d, a = 0) {
1226
+ const f = d * 2, l = q(f, r);
1227
1227
  if (l) {
1228
- const p = s[f + 6], c = r[u + 14];
1229
- t(a, l, new Float32Array(e, f * 4, 6), p, c);
1228
+ const p = s[d + 6], c = r[f + 14];
1229
+ t(a, l, new Float32Array(e, d * 4, 6), p, c);
1230
1230
  } else {
1231
- const p = V(f), c = W(f, s), d = ei(f, s);
1232
- t(a, l, new Float32Array(e, f * 4, 6), d) || (o(p, a + 1), o(c, a + 1));
1231
+ const p = V(d), c = W(d, s), u = ei(d, s);
1232
+ t(a, l, new Float32Array(e, d * 4, 6), u) || (o(p, a + 1), o(c, a + 1));
1233
1233
  }
1234
1234
  }
1235
1235
  }
1236
1236
  refit() {
1237
1237
  const t = this._roots;
1238
1238
  for (let i = 0, e = t.length; i < e; i++) {
1239
- const s = t[i], r = new Uint32Array(s), o = new Uint16Array(s), f = new Float32Array(s), a = s.byteLength / X;
1240
- for (let u = a - 1; u >= 0; u--) {
1241
- const l = u * N, p = l * 2;
1239
+ const s = t[i], r = new Uint32Array(s), o = new Uint16Array(s), d = new Float32Array(s), a = s.byteLength / X;
1240
+ for (let f = a - 1; f >= 0; f--) {
1241
+ const l = f * N, p = l * 2;
1242
1242
  if (q(p, o)) {
1243
- const d = J(l, r), y = Z(p, o);
1244
- this.writePrimitiveRangeBounds(d, y, _t, 0), f.set(_t, l);
1243
+ const u = J(l, r), y = Z(p, o);
1244
+ this.writePrimitiveRangeBounds(u, y, _t, 0), d.set(_t, l);
1245
1245
  } else {
1246
- const d = V(l), y = W(l, r);
1246
+ const u = V(l), y = W(l, r);
1247
1247
  for (let g = 0; g < 3; g++) {
1248
- const x = f[d + g], w = f[d + g + 3], m = f[y + g], h = f[y + g + 3];
1249
- f[l + g] = x < m ? x : m, f[l + g + 3] = w > h ? w : h;
1248
+ const x = d[u + g], w = d[u + g + 3], m = d[y + g], h = d[y + g + 3];
1249
+ d[l + g] = x < m ? x : m, d[l + g + 3] = w > h ? w : h;
1250
1250
  }
1251
1251
  }
1252
1252
  }
@@ -1267,28 +1267,28 @@ class ls {
1267
1267
  intersectsRange: s,
1268
1268
  intersectsPrimitive: r,
1269
1269
  scratchPrimitive: o,
1270
- iterate: f
1270
+ iterate: d
1271
1271
  } = t;
1272
1272
  if (s && r) {
1273
1273
  const p = s;
1274
- s = (c, d, y, g, x) => p(c, d, y, g, x) ? !0 : f(c, d, this, r, y, g, o);
1275
- } else s || (r ? s = (p, c, d, y) => f(p, c, this, r, d, y, o) : s = (p, c, d) => d);
1276
- let a = !1, u = 0;
1274
+ s = (c, u, y, g, x) => p(c, u, y, g, x) ? !0 : d(c, u, this, r, y, g, o);
1275
+ } else s || (r ? s = (p, c, u, y) => d(p, c, this, r, u, y, o) : s = (p, c, u) => u);
1276
+ let a = !1, f = 0;
1277
1277
  const l = this._roots;
1278
1278
  for (let p = 0, c = l.length; p < c; p++) {
1279
- const d = l[p];
1280
- if (a = as(this, p, e, s, i, u), a)
1279
+ const u = l[p];
1280
+ if (a = cs(this, p, e, s, i, f), a)
1281
1281
  break;
1282
- u += d.byteLength / X;
1282
+ f += u.byteLength / X;
1283
1283
  }
1284
1284
  return a;
1285
1285
  }
1286
1286
  bvhcast(t, i, e) {
1287
1287
  let { intersectsRanges: s } = e;
1288
- return cs(this, t, i, s);
1288
+ return ls(this, t, i, s);
1289
1289
  }
1290
1290
  }
1291
- function us() {
1291
+ function fs() {
1292
1292
  return typeof SharedArrayBuffer < "u";
1293
1293
  }
1294
1294
  function ni(n) {
@@ -1297,62 +1297,62 @@ function ni(n) {
1297
1297
  function Ae(n) {
1298
1298
  return ni(n) / 3;
1299
1299
  }
1300
- function fs(n, t = ArrayBuffer) {
1300
+ function ds(n, t = ArrayBuffer) {
1301
1301
  return n > 65535 ? new Uint32Array(new t(4 * n)) : new Uint16Array(new t(2 * n));
1302
1302
  }
1303
- function ds(n, t) {
1303
+ function ps(n, t) {
1304
1304
  if (!n.index) {
1305
- const i = n.attributes.position.count, e = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, s = fs(i, e);
1305
+ const i = n.attributes.position.count, e = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, s = ds(i, e);
1306
1306
  n.setIndex(new Oi(s, 1));
1307
1307
  for (let r = 0; r < i; r++)
1308
1308
  s[r] = r;
1309
1309
  }
1310
1310
  }
1311
- function ps(n, t, i) {
1312
- const e = ni(n) / i, s = t || n.drawRange, r = s.start / i, o = (s.start + s.count) / i, f = Math.max(0, r), a = Math.min(e, o) - f;
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
1313
  return {
1314
- offset: Math.floor(f),
1314
+ offset: Math.floor(d),
1315
1315
  count: Math.floor(a)
1316
1316
  };
1317
1317
  }
1318
- function ms(n, t) {
1318
+ function hs(n, t) {
1319
1319
  return n.groups.map((i) => ({
1320
1320
  offset: i.start / t,
1321
1321
  count: i.count / t
1322
1322
  }));
1323
1323
  }
1324
1324
  function Si(n, t, i) {
1325
- const e = ps(n, t, i), s = ms(n, i);
1325
+ const e = ms(n, t, i), s = hs(n, i);
1326
1326
  if (!s.length)
1327
1327
  return [e];
1328
- const r = [], o = e.offset, f = e.offset + e.count, a = ni(n) / i, u = [];
1328
+ const r = [], o = e.offset, d = e.offset + e.count, a = ni(n) / i, f = [];
1329
1329
  for (const c of s) {
1330
- const { offset: d, count: y } = c, g = d, x = isFinite(y) ? y : a - d, w = d + x;
1331
- g < f && w > o && (u.push({ pos: Math.max(o, g), isStart: !0 }), u.push({ pos: Math.min(f, w), isStart: !1 }));
1330
+ const { offset: u, count: y } = c, g = u, x = isFinite(y) ? y : a - u, w = u + x;
1331
+ g < d && w > o && (f.push({ pos: Math.max(o, g), isStart: !0 }), f.push({ pos: Math.min(d, w), isStart: !1 }));
1332
1332
  }
1333
- u.sort((c, d) => c.pos !== d.pos ? c.pos - d.pos : c.type === "end" ? -1 : 1);
1333
+ f.sort((c, u) => c.pos !== u.pos ? c.pos - u.pos : c.type === "end" ? -1 : 1);
1334
1334
  let l = 0, p = null;
1335
- for (const c of u) {
1336
- const d = c.pos;
1337
- l !== 0 && d !== p && r.push({
1335
+ for (const c of f) {
1336
+ const u = c.pos;
1337
+ l !== 0 && u !== p && r.push({
1338
1338
  offset: p,
1339
- count: d - p
1340
- }), l += c.isStart ? 1 : -1, p = d;
1339
+ count: u - p
1340
+ }), l += c.isStart ? 1 : -1, p = u;
1341
1341
  }
1342
1342
  return r;
1343
1343
  }
1344
- function hs(n, t) {
1345
- const i = n[n.length - 1], e = i.offset + i.count > 2 ** 16, s = n.reduce((u, l) => u + l.count, 0), r = e ? 4 : 2, o = t ? new SharedArrayBuffer(s * r) : new ArrayBuffer(s * r), f = e ? new Uint32Array(o) : new Uint16Array(o);
1344
+ function ys(n, t) {
1345
+ 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
1346
  let a = 0;
1347
- for (let u = 0; u < n.length; u++) {
1348
- const { offset: l, count: p } = n[u];
1347
+ for (let f = 0; f < n.length; f++) {
1348
+ const { offset: l, count: p } = n[f];
1349
1349
  for (let c = 0; c < p; c++)
1350
- f[a + c] = l + c;
1350
+ d[a + c] = l + c;
1351
1351
  a += p;
1352
1352
  }
1353
- return f;
1353
+ return d;
1354
1354
  }
1355
- class ys extends ls {
1355
+ class gs extends us {
1356
1356
  get indirect() {
1357
1357
  return !!this._indirectBuffer;
1358
1358
  }
@@ -1374,7 +1374,7 @@ class ys extends ls {
1374
1374
  if (t.index && t.index.isInterleavedBufferAttribute)
1375
1375
  throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.");
1376
1376
  } else throw new Error("BVH: Only BufferGeometries are supported.");
1377
- if (i.useSharedArrayBuffer && !us())
1377
+ if (i.useSharedArrayBuffer && !fs())
1378
1378
  throw new Error("BVH: SharedArrayBuffer is not available.");
1379
1379
  super(), this.geometry = t, this.resolvePrimitiveIndex = i.indirect ? (e) => this._indirectBuffer[e] : (e) => e, this.primitiveBuffer = null, this.primitiveBufferStride = null, this._indirectBuffer = null, i = {
1380
1380
  ...tn,
@@ -1384,10 +1384,10 @@ class ys extends ls {
1384
1384
  init(t) {
1385
1385
  const { geometry: i, primitiveStride: e } = this;
1386
1386
  if (t.indirect) {
1387
- const s = Si(i, t.range, e), r = hs(s, t.useSharedArrayBuffer);
1387
+ const s = Si(i, t.range, e), r = ys(s, t.useSharedArrayBuffer);
1388
1388
  this._indirectBuffer = r;
1389
1389
  } else
1390
- ds(i, t);
1390
+ ps(i, t);
1391
1391
  super.init(t), !i.boundingBox && t.setBoundingBox && (i.boundingBox = this.getBoundingBox(new it()));
1392
1392
  }
1393
1393
  // Abstract methods to be implemented by subclasses
@@ -1413,7 +1413,7 @@ class pt {
1413
1413
  setFromPoints(t, i) {
1414
1414
  let e = 1 / 0, s = -1 / 0;
1415
1415
  for (let r = 0, o = i.length; r < o; r++) {
1416
- const f = i[r], a = t.dot(f);
1416
+ const d = i[r], a = t.dot(d);
1417
1417
  e = a < e ? a : e, s = a > s ? a : s;
1418
1418
  }
1419
1419
  this.min = e, this.max = s;
@@ -1426,68 +1426,68 @@ pt.prototype.setFromBox = /* @__PURE__ */ function() {
1426
1426
  const n = /* @__PURE__ */ new z();
1427
1427
  return function(i, e) {
1428
1428
  const s = e.min, r = e.max;
1429
- let o = 1 / 0, f = -1 / 0;
1429
+ let o = 1 / 0, d = -1 / 0;
1430
1430
  for (let a = 0; a <= 1; a++)
1431
- for (let u = 0; u <= 1; u++)
1431
+ for (let f = 0; f <= 1; f++)
1432
1432
  for (let l = 0; l <= 1; l++) {
1433
- n.x = s.x * a + r.x * (1 - a), n.y = s.y * u + r.y * (1 - u), n.z = s.z * l + r.z * (1 - l);
1433
+ n.x = s.x * a + r.x * (1 - a), n.y = s.y * f + r.y * (1 - f), n.z = s.z * l + r.z * (1 - l);
1434
1434
  const p = i.dot(n);
1435
- o = Math.min(p, o), f = Math.max(p, f);
1435
+ o = Math.min(p, o), d = Math.max(p, d);
1436
1436
  }
1437
- this.min = o, this.max = f;
1437
+ this.min = o, this.max = d;
1438
1438
  };
1439
1439
  }();
1440
- const gs = /* @__PURE__ */ function() {
1440
+ const ws = /* @__PURE__ */ function() {
1441
1441
  const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new z();
1442
1442
  return function(s, r, o) {
1443
- const f = s.start, a = n, u = r.start, l = t;
1444
- i.subVectors(f, u), n.subVectors(s.end, s.start), t.subVectors(r.end, r.start);
1445
- const p = i.dot(l), c = l.dot(a), d = l.dot(l), y = i.dot(a), x = a.dot(a) * d - c * c;
1443
+ const d = s.start, a = n, f = r.start, l = t;
1444
+ i.subVectors(d, f), n.subVectors(s.end, s.start), t.subVectors(r.end, r.start);
1445
+ const p = i.dot(l), c = l.dot(a), u = l.dot(l), y = i.dot(a), x = a.dot(a) * u - c * c;
1446
1446
  let w, m;
1447
- x !== 0 ? w = (p * c - y * d) / x : w = 0, m = (p + w * c) / d, o.x = w, o.y = m;
1447
+ x !== 0 ? w = (p * c - y * u) / x : w = 0, m = (p + w * c) / u, o.x = w, o.y = m;
1448
1448
  };
1449
1449
  }(), si = /* @__PURE__ */ function() {
1450
1450
  const n = /* @__PURE__ */ new gt(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new z();
1451
- return function(s, r, o, f) {
1452
- gs(s, r, n);
1453
- let a = n.x, u = n.y;
1454
- if (a >= 0 && a <= 1 && u >= 0 && u <= 1) {
1455
- s.at(a, o), r.at(u, f);
1451
+ return function(s, r, o, d) {
1452
+ ws(s, r, n);
1453
+ let a = n.x, f = n.y;
1454
+ if (a >= 0 && a <= 1 && f >= 0 && f <= 1) {
1455
+ s.at(a, o), r.at(f, d);
1456
1456
  return;
1457
1457
  } else if (a >= 0 && a <= 1) {
1458
- u < 0 ? r.at(0, f) : r.at(1, f), s.closestPointToPoint(f, !0, o);
1458
+ f < 0 ? r.at(0, d) : r.at(1, d), s.closestPointToPoint(d, !0, o);
1459
1459
  return;
1460
- } else if (u >= 0 && u <= 1) {
1461
- a < 0 ? s.at(0, o) : s.at(1, o), r.closestPointToPoint(o, !0, f);
1460
+ } else if (f >= 0 && f <= 1) {
1461
+ a < 0 ? s.at(0, o) : s.at(1, o), r.closestPointToPoint(o, !0, d);
1462
1462
  return;
1463
1463
  } else {
1464
1464
  let l;
1465
1465
  a < 0 ? l = s.start : l = s.end;
1466
1466
  let p;
1467
- u < 0 ? p = r.start : p = r.end;
1468
- const c = t, d = i;
1469
- if (s.closestPointToPoint(p, !0, t), r.closestPointToPoint(l, !0, i), c.distanceToSquared(p) <= d.distanceToSquared(l)) {
1470
- o.copy(c), f.copy(p);
1467
+ f < 0 ? p = r.start : p = r.end;
1468
+ const c = t, u = i;
1469
+ if (s.closestPointToPoint(p, !0, t), r.closestPointToPoint(l, !0, i), c.distanceToSquared(p) <= u.distanceToSquared(l)) {
1470
+ o.copy(c), d.copy(p);
1471
1471
  return;
1472
1472
  } else {
1473
- o.copy(l), f.copy(d);
1473
+ o.copy(l), d.copy(u);
1474
1474
  return;
1475
1475
  }
1476
1476
  }
1477
1477
  };
1478
- }(), ws = /* @__PURE__ */ function() {
1478
+ }(), bs = /* @__PURE__ */ function() {
1479
1479
  const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new Vi(), e = /* @__PURE__ */ new dt();
1480
1480
  return function(r, o) {
1481
- const { radius: f, center: a } = r, { a: u, b: l, c: p } = o;
1482
- if (e.start = u, e.end = l, e.closestPointToPoint(a, !0, n).distanceTo(a) <= f || (e.start = u, e.end = p, e.closestPointToPoint(a, !0, n).distanceTo(a) <= f) || (e.start = l, e.end = p, e.closestPointToPoint(a, !0, n).distanceTo(a) <= f)) return !0;
1481
+ const { radius: d, center: a } = r, { a: f, b: l, c: p } = o;
1482
+ 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;
1483
1483
  const g = o.getPlane(i);
1484
- if (Math.abs(g.distanceToPoint(a)) <= f) {
1484
+ if (Math.abs(g.distanceToPoint(a)) <= d) {
1485
1485
  const w = g.projectPoint(a, t);
1486
1486
  if (o.containsPoint(w)) return !0;
1487
1487
  }
1488
1488
  return !1;
1489
1489
  };
1490
- }(), bs = ["x", "y", "z"], lt = 1e-15, Ti = lt * lt;
1490
+ }(), xs = ["x", "y", "z"], lt = 1e-15, Ti = lt * lt;
1491
1491
  function tt(n) {
1492
1492
  return Math.abs(n) < lt;
1493
1493
  }
@@ -1496,35 +1496,35 @@ class st extends $t {
1496
1496
  super(...t), this.isExtendedTriangle = !0, this.satAxes = new Array(4).fill().map(() => new z()), this.satBounds = new Array(4).fill().map(() => new pt()), this.points = [this.a, this.b, this.c], this.plane = new Vi(), this.isDegenerateIntoSegment = !1, this.isDegenerateIntoPoint = !1, this.degenerateSegment = new dt(), this.needsUpdate = !0;
1497
1497
  }
1498
1498
  intersectsSphere(t) {
1499
- return ws(t, this);
1499
+ return bs(t, this);
1500
1500
  }
1501
1501
  update() {
1502
- const t = this.a, i = this.b, e = this.c, s = this.points, r = this.satAxes, o = this.satBounds, f = r[0], a = o[0];
1503
- this.getNormal(f), a.setFromPoints(f, s);
1504
- const u = r[1], l = o[1];
1505
- u.subVectors(t, i), l.setFromPoints(u, s);
1502
+ 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];
1503
+ this.getNormal(d), a.setFromPoints(d, s);
1504
+ const f = r[1], l = o[1];
1505
+ f.subVectors(t, i), l.setFromPoints(f, s);
1506
1506
  const p = r[2], c = o[2];
1507
1507
  p.subVectors(i, e), c.setFromPoints(p, s);
1508
- const d = r[3], y = o[3];
1509
- d.subVectors(e, t), y.setFromPoints(d, s);
1510
- const g = u.length(), x = p.length(), w = d.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(f, t), this.needsUpdate = !1;
1508
+ const u = r[3], y = o[3];
1509
+ u.subVectors(e, t), y.setFromPoints(u, s);
1510
+ 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;
1512
1512
  }
1513
1513
  }
1514
1514
  st.prototype.closestPointToSegment = /* @__PURE__ */ function() {
1515
1515
  const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = /* @__PURE__ */ new dt();
1516
1516
  return function(s, r = null, o = null) {
1517
- const { start: f, end: a } = s, u = this.points;
1517
+ const { start: d, end: a } = s, f = this.points;
1518
1518
  let l, p = 1 / 0;
1519
1519
  for (let c = 0; c < 3; c++) {
1520
- const d = (c + 1) % 3;
1521
- i.start.copy(u[c]), i.end.copy(u[d]), si(i, s, n, t), l = n.distanceToSquared(t), l < p && (p = l, r && r.copy(n), o && o.copy(t));
1520
+ 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));
1522
1522
  }
1523
- return this.closestPointToPoint(f, n), l = f.distanceToSquared(n), l < p && (p = l, r && r.copy(n), o && o.copy(f)), this.closestPointToPoint(a, n), l = a.distanceToSquared(n), l < p && (p = l, r && r.copy(n), o && o.copy(a)), Math.sqrt(p);
1523
+ 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
1524
  };
1525
1525
  }();
1526
1526
  st.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1527
- const n = /* @__PURE__ */ new st(), t = /* @__PURE__ */ new pt(), i = /* @__PURE__ */ new pt(), e = /* @__PURE__ */ new z(), s = /* @__PURE__ */ new z(), r = /* @__PURE__ */ new z(), o = /* @__PURE__ */ new z(), f = /* @__PURE__ */ new dt(), a = /* @__PURE__ */ new dt(), u = /* @__PURE__ */ new z(), l = /* @__PURE__ */ new gt(), p = /* @__PURE__ */ new gt();
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
1528
  function c(h, b, A, P) {
1529
1529
  const M = e;
1530
1530
  !h.isDegenerateIntoPoint && !h.isDegenerateIntoSegment ? M.copy(h.plane.normal) : M.copy(b.plane.normal);
@@ -1540,21 +1540,21 @@ st.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1540
1540
  }
1541
1541
  return A && (P || console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."), A.start.set(0, 0, 0), A.end.set(0, 0, 0)), !0;
1542
1542
  }
1543
- function d(h, b, A, P, M, T, R, v, B, S, _) {
1543
+ function u(h, b, A, P, M, T, R, v, B, S, _) {
1544
1544
  let E = R / (R - v);
1545
1545
  S.x = P + (M - P) * E, _.start.subVectors(b, h).multiplyScalar(E).add(h), E = R / (R - B), S.y = P + (T - P) * E, _.end.subVectors(A, h).multiplyScalar(E).add(h);
1546
1546
  }
1547
1547
  function y(h, b, A, P, M, T, R, v, B, S, _) {
1548
1548
  if (M > 0)
1549
- d(h.c, h.a, h.b, P, b, A, B, R, v, S, _);
1549
+ u(h.c, h.a, h.b, P, b, A, B, R, v, S, _);
1550
1550
  else if (T > 0)
1551
- d(h.b, h.a, h.c, A, b, P, v, R, B, S, _);
1551
+ u(h.b, h.a, h.c, A, b, P, v, R, B, S, _);
1552
1552
  else if (v * B > 0 || R != 0)
1553
- d(h.a, h.b, h.c, b, A, P, R, v, B, S, _);
1553
+ u(h.a, h.b, h.c, b, A, P, R, v, B, S, _);
1554
1554
  else if (v != 0)
1555
- d(h.b, h.a, h.c, A, b, P, v, R, B, S, _);
1555
+ u(h.b, h.a, h.c, A, b, P, v, R, B, S, _);
1556
1556
  else if (B != 0)
1557
- d(h.c, h.a, h.b, P, b, A, B, R, v, S, _);
1557
+ u(h.c, h.a, h.b, P, b, A, B, R, v, S, _);
1558
1558
  else
1559
1559
  return !0;
1560
1560
  return !1;
@@ -1615,20 +1615,20 @@ st.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1615
1615
  let vt = 0, Pt = Math.abs(Mt.x);
1616
1616
  const rt = Math.abs(Mt.y);
1617
1617
  rt > Pt && (Pt = rt, vt = 1), Math.abs(Mt.z) > Pt && (vt = 2);
1618
- const at = bs[vt], sn = this.a[at], on = this.b[at], rn = this.c[at], an = b.a[at], cn = b.b[at], ln = b.c[at];
1619
- if (y(this, sn, on, rn, _, E, v, B, S, l, f))
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))
1620
1620
  return c(this, b, A, P);
1621
1621
  if (y(b, an, cn, ln, L, Y, F, D, U, p, a))
1622
1622
  return c(this, b, A, P);
1623
1623
  if (l.y < l.x) {
1624
1624
  const ve = l.y;
1625
- l.y = l.x, l.x = ve, u.copy(f.start), f.start.copy(f.end), f.end.copy(u);
1625
+ l.y = l.x, l.x = ve, f.copy(d.start), d.start.copy(d.end), d.end.copy(f);
1626
1626
  }
1627
1627
  if (p.y < p.x) {
1628
1628
  const ve = p.y;
1629
- p.y = p.x, p.x = ve, u.copy(a.start), a.start.copy(a.end), a.end.copy(u);
1629
+ p.y = p.x, p.x = ve, f.copy(a.start), a.start.copy(a.end), a.end.copy(f);
1630
1630
  }
1631
- return l.y < p.x || p.y < l.x ? !1 : (A && (p.x > l.x ? A.start.copy(a.start) : A.start.copy(f.start), p.y < l.y ? A.end.copy(a.end) : A.end.copy(f.end)), !0);
1631
+ 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
1632
  };
1633
1633
  }();
1634
1634
  st.prototype.distanceToPoint = /* @__PURE__ */ function() {
@@ -1639,26 +1639,26 @@ st.prototype.distanceToPoint = /* @__PURE__ */ function() {
1639
1639
  }();
1640
1640
  st.prototype.distanceToTriangle = /* @__PURE__ */ function() {
1641
1641
  const n = /* @__PURE__ */ new z(), t = /* @__PURE__ */ new z(), i = ["a", "b", "c"], e = /* @__PURE__ */ new dt(), s = /* @__PURE__ */ new dt();
1642
- return function(o, f = null, a = null) {
1643
- const u = f || a ? e : null;
1644
- if (this.intersectsTriangle(o, u))
1645
- return (f || a) && (f && u.getCenter(f), a && u.getCenter(a)), 0;
1642
+ return function(o, d = null, a = null) {
1643
+ const f = d || a ? e : null;
1644
+ if (this.intersectsTriangle(o, f))
1645
+ return (d || a) && (d && f.getCenter(d), a && f.getCenter(a)), 0;
1646
1646
  let l = 1 / 0;
1647
1647
  for (let p = 0; p < 3; p++) {
1648
1648
  let c;
1649
- const d = i[p], y = o[d];
1650
- this.closestPointToPoint(y, n), c = y.distanceToSquared(n), c < l && (l = c, f && f.copy(n), a && a.copy(y));
1651
- const g = this[d];
1652
- o.closestPointToPoint(g, n), c = g.distanceToSquared(n), c < l && (l = c, f && f.copy(g), a && a.copy(n));
1649
+ const u = i[p], y = o[u];
1650
+ this.closestPointToPoint(y, n), c = y.distanceToSquared(n), c < l && (l = c, d && d.copy(n), a && a.copy(y));
1651
+ const g = this[u];
1652
+ o.closestPointToPoint(g, n), c = g.distanceToSquared(n), c < l && (l = c, d && d.copy(g), a && a.copy(n));
1653
1653
  }
1654
1654
  for (let p = 0; p < 3; p++) {
1655
- const c = i[p], d = i[(p + 1) % 3];
1656
- e.set(this[c], this[d]);
1655
+ const c = i[p], u = i[(p + 1) % 3];
1656
+ e.set(this[c], this[u]);
1657
1657
  for (let y = 0; y < 3; y++) {
1658
1658
  const g = i[y], x = i[(y + 1) % 3];
1659
1659
  s.set(o[g], o[x]), si(e, s, n, t);
1660
1660
  const w = n.distanceToSquared(t);
1661
- w < l && (l = w, f && f.copy(n), a && a.copy(t));
1661
+ w < l && (l = w, d && d.copy(n), a && a.copy(t));
1662
1662
  }
1663
1663
  }
1664
1664
  return Math.sqrt(l);
@@ -1678,16 +1678,16 @@ class Q {
1678
1678
  Q.prototype.update = /* @__PURE__ */ function() {
1679
1679
  return function() {
1680
1680
  const t = this.matrix, i = this.min, e = this.max, s = this.points;
1681
- for (let u = 0; u <= 1; u++)
1681
+ for (let f = 0; f <= 1; f++)
1682
1682
  for (let l = 0; l <= 1; l++)
1683
1683
  for (let p = 0; p <= 1; p++) {
1684
- const c = 1 * u | 2 * l | 4 * p, d = s[c];
1685
- d.x = u ? e.x : i.x, d.y = l ? e.y : i.y, d.z = p ? e.z : i.z, d.applyMatrix4(t);
1684
+ const c = 1 * f | 2 * l | 4 * p, u = s[c];
1685
+ u.x = f ? e.x : i.x, u.y = l ? e.y : i.y, u.z = p ? e.z : i.z, u.applyMatrix4(t);
1686
1686
  }
1687
- const r = this.satBounds, o = this.satAxes, f = s[0];
1688
- for (let u = 0; u < 3; u++) {
1689
- const l = o[u], p = r[u], c = 1 << u, d = s[c];
1690
- l.subVectors(f, d), p.setFromPoints(l, s);
1687
+ const r = this.satBounds, o = this.satAxes, d = s[0];
1688
+ for (let f = 0; f < 3; f++) {
1689
+ const l = o[f], p = r[f], c = 1 << f, u = s[c];
1690
+ l.subVectors(d, u), p.setFromPoints(l, s);
1691
1691
  }
1692
1692
  const a = this.alignedSatBounds;
1693
1693
  a[0].setFromPointsField(s, "x"), a[1].setFromPointsField(s, "y"), a[2].setFromPointsField(s, "z"), this.invMatrix.copy(this.matrix).invert(), this.needsUpdate = !1;
@@ -1697,11 +1697,11 @@ Q.prototype.intersectsBox = /* @__PURE__ */ function() {
1697
1697
  const n = /* @__PURE__ */ new pt();
1698
1698
  return function(i) {
1699
1699
  this.needsUpdate && this.update();
1700
- const e = i.min, s = i.max, r = this.satBounds, o = this.satAxes, f = this.alignedSatBounds;
1701
- if (n.min = e.x, n.max = s.x, f[0].isSeparated(n) || (n.min = e.y, n.max = s.y, f[1].isSeparated(n)) || (n.min = e.z, n.max = s.z, f[2].isSeparated(n))) return !1;
1700
+ const e = i.min, s = i.max, r = this.satBounds, o = this.satAxes, d = this.alignedSatBounds;
1701
+ if (n.min = e.x, n.max = s.x, d[0].isSeparated(n) || (n.min = e.y, n.max = s.y, d[1].isSeparated(n)) || (n.min = e.z, n.max = s.z, d[2].isSeparated(n))) return !1;
1702
1702
  for (let a = 0; a < 3; a++) {
1703
- const u = o[a], l = r[a];
1704
- if (n.setFromBox(u, i), l.isSeparated(n)) return !1;
1703
+ const f = o[a], l = r[a];
1704
+ if (n.setFromBox(f, i), l.isSeparated(n)) return !1;
1705
1705
  }
1706
1706
  return !0;
1707
1707
  };
@@ -1710,22 +1710,22 @@ Q.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1710
1710
  const n = /* @__PURE__ */ new st(), t = /* @__PURE__ */ new Array(3), i = /* @__PURE__ */ new pt(), e = /* @__PURE__ */ new pt(), s = /* @__PURE__ */ new z();
1711
1711
  return function(o) {
1712
1712
  this.needsUpdate && this.update(), o.isExtendedTriangle ? o.needsUpdate && o.update() : (n.copy(o), n.update(), o = n);
1713
- const f = this.satBounds, a = this.satAxes;
1713
+ const d = this.satBounds, a = this.satAxes;
1714
1714
  t[0] = o.a, t[1] = o.b, t[2] = o.c;
1715
1715
  for (let c = 0; c < 3; c++) {
1716
- const d = f[c], y = a[c];
1717
- if (i.setFromPoints(y, t), d.isSeparated(i)) return !1;
1716
+ const u = d[c], y = a[c];
1717
+ if (i.setFromPoints(y, t), u.isSeparated(i)) return !1;
1718
1718
  }
1719
- const u = o.satBounds, l = o.satAxes, p = this.points;
1719
+ const f = o.satBounds, l = o.satAxes, p = this.points;
1720
1720
  for (let c = 0; c < 3; c++) {
1721
- const d = u[c], y = l[c];
1722
- if (i.setFromPoints(y, p), d.isSeparated(i)) return !1;
1721
+ const u = f[c], y = l[c];
1722
+ if (i.setFromPoints(y, p), u.isSeparated(i)) return !1;
1723
1723
  }
1724
1724
  for (let c = 0; c < 3; c++) {
1725
- const d = a[c];
1725
+ const u = a[c];
1726
1726
  for (let y = 0; y < 4; y++) {
1727
1727
  const g = l[y];
1728
- if (s.crossVectors(d, g), i.setFromPoints(s, t), e.setFromPoints(s, p), i.isSeparated(e)) return !1;
1728
+ if (s.crossVectors(u, g), i.setFromPoints(s, t), e.setFromPoints(s, p), i.isSeparated(e)) return !1;
1729
1729
  }
1730
1730
  }
1731
1731
  return !0;
@@ -1744,23 +1744,23 @@ Q.prototype.distanceToPoint = function() {
1744
1744
  }();
1745
1745
  Q.prototype.distanceToBox = /* @__PURE__ */ function() {
1746
1746
  const n = ["x", "y", "z"], t = /* @__PURE__ */ new Array(12).fill().map(() => new dt()), i = /* @__PURE__ */ new Array(12).fill().map(() => new dt()), e = /* @__PURE__ */ new z(), s = /* @__PURE__ */ new z();
1747
- return function(o, f = 0, a = null, u = null) {
1747
+ return function(o, d = 0, a = null, f = null) {
1748
1748
  if (this.needsUpdate && this.update(), this.intersectsBox(o))
1749
- return (a || u) && (o.getCenter(s), this.closestPointToPoint(s, e), o.closestPointToPoint(e, s), a && a.copy(e), u && u.copy(s)), 0;
1750
- const l = f * f, p = o.min, c = o.max, d = this.points;
1749
+ return (a || f) && (o.getCenter(s), this.closestPointToPoint(s, e), o.closestPointToPoint(e, s), a && a.copy(e), f && f.copy(s)), 0;
1750
+ const l = d * d, p = o.min, c = o.max, u = this.points;
1751
1751
  let y = 1 / 0;
1752
1752
  for (let x = 0; x < 8; x++) {
1753
- const w = d[x];
1753
+ const w = u[x];
1754
1754
  s.copy(w).clamp(p, c);
1755
1755
  const m = w.distanceToSquared(s);
1756
- if (m < y && (y = m, a && a.copy(w), u && u.copy(s), m < l))
1756
+ if (m < y && (y = m, a && a.copy(w), f && f.copy(s), m < l))
1757
1757
  return Math.sqrt(m);
1758
1758
  }
1759
1759
  let g = 0;
1760
1760
  for (let x = 0; x < 3; x++)
1761
1761
  for (let w = 0; w <= 1; w++)
1762
1762
  for (let m = 0; m <= 1; m++) {
1763
- const h = (x + 1) % 3, b = (x + 2) % 3, A = w << h | m << b, P = 1 << x | w << h | m << b, M = d[A], T = d[P];
1763
+ const h = (x + 1) % 3, b = (x + 2) % 3, A = w << h | m << b, P = 1 << x | w << h | m << b, M = u[A], T = u[P];
1764
1764
  t[g].set(M, T);
1765
1765
  const v = n[x], B = n[h], S = n[b], _ = i[g], E = _.start, F = _.end;
1766
1766
  E[v] = p[v], E[B] = w ? p[B] : c[B], E[S] = m ? p[S] : c[B], F[v] = c[v], F[B] = w ? p[B] : c[B], F[S] = m ? p[S] : c[B], g++;
@@ -1770,7 +1770,7 @@ Q.prototype.distanceToBox = /* @__PURE__ */ function() {
1770
1770
  for (let m = 0; m <= 1; m++) {
1771
1771
  s.x = x ? c.x : p.x, s.y = w ? c.y : p.y, s.z = m ? c.z : p.z, this.closestPointToPoint(s, e);
1772
1772
  const h = s.distanceToSquared(e);
1773
- if (h < y && (y = h, a && a.copy(e), u && u.copy(s), h < l))
1773
+ if (h < y && (y = h, a && a.copy(e), f && f.copy(s), h < l))
1774
1774
  return Math.sqrt(h);
1775
1775
  }
1776
1776
  for (let x = 0; x < 12; x++) {
@@ -1779,75 +1779,75 @@ Q.prototype.distanceToBox = /* @__PURE__ */ function() {
1779
1779
  const h = i[m];
1780
1780
  si(w, h, e, s);
1781
1781
  const b = e.distanceToSquared(s);
1782
- if (b < y && (y = b, a && a.copy(e), u && u.copy(s), b < l))
1782
+ if (b < y && (y = b, a && a.copy(e), f && f.copy(s), b < l))
1783
1783
  return Math.sqrt(b);
1784
1784
  }
1785
1785
  }
1786
1786
  return Math.sqrt(y);
1787
1787
  };
1788
1788
  }();
1789
- class xs extends ii {
1789
+ class As extends ii {
1790
1790
  constructor() {
1791
1791
  super(() => new st());
1792
1792
  }
1793
1793
  }
1794
- const et = /* @__PURE__ */ new xs(), Nt = /* @__PURE__ */ new z(), Ee = /* @__PURE__ */ new z();
1795
- function As(n, t, i = {}, e = 0, s = 1 / 0) {
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
1796
  const r = e * e, o = s * s;
1797
- let f = 1 / 0, a = null;
1797
+ let d = 1 / 0, a = null;
1798
1798
  if (n.shapecast(
1799
1799
  {
1800
1800
  boundsTraverseOrder: (l) => (Nt.copy(t).clamp(l.min, l.max), Nt.distanceToSquared(t)),
1801
- intersectsBounds: (l, p, c) => c < f && c < o,
1801
+ intersectsBounds: (l, p, c) => c < d && c < o,
1802
1802
  intersectsTriangle: (l, p) => {
1803
1803
  l.closestPointToPoint(t, Nt);
1804
1804
  const c = t.distanceToSquared(Nt);
1805
- return c < f && (Ee.copy(Nt), f = c, a = p), c < r;
1805
+ return c < d && (Ee.copy(Nt), d = c, a = p), c < r;
1806
1806
  }
1807
1807
  }
1808
- ), f === 1 / 0) return null;
1809
- const u = Math.sqrt(f);
1810
- return i.point ? i.point.copy(Ee) : i.point = Ee.clone(), i.distance = u, i.faceIndex = a, i;
1808
+ ), d === 1 / 0) return null;
1809
+ const f = Math.sqrt(d);
1810
+ return i.point ? i.point.copy(Ee) : i.point = Ee.clone(), i.distance = f, i.faceIndex = a, i;
1811
1811
  }
1812
- const ie = parseInt(Wi) >= 169, Ms = parseInt(Wi) <= 161, bt = /* @__PURE__ */ new z(), xt = /* @__PURE__ */ new z(), At = /* @__PURE__ */ new z(), ne = /* @__PURE__ */ new gt(), se = /* @__PURE__ */ new gt(), oe = /* @__PURE__ */ new gt(), Ri = /* @__PURE__ */ new z(), Bi = /* @__PURE__ */ new z(), _i = /* @__PURE__ */ new z(), qt = /* @__PURE__ */ new z();
1813
- function vs(n, t, i, e, s, r, o, f) {
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
1814
  let a;
1815
- if (r === vn ? a = n.intersectTriangle(e, i, t, !0, s) : a = n.intersectTriangle(t, i, e, r !== Pn, s), a === null) return null;
1816
- const u = n.origin.distanceTo(s);
1817
- return u < o || u > f ? null : {
1818
- distance: u,
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;
1816
+ const f = n.origin.distanceTo(s);
1817
+ return f < o || f > d ? null : {
1818
+ distance: f,
1819
1819
  point: s.clone()
1820
1820
  };
1821
1821
  }
1822
- function Ei(n, t, i, e, s, r, o, f, a, u, l) {
1823
- bt.fromBufferAttribute(t, r), xt.fromBufferAttribute(t, o), At.fromBufferAttribute(t, f);
1824
- const p = vs(n, bt, xt, At, qt, a, u, l);
1822
+ function Ei(n, t, i, e, s, r, o, d, a, f, l) {
1823
+ bt.fromBufferAttribute(t, r), xt.fromBufferAttribute(t, o), At.fromBufferAttribute(t, d);
1824
+ const p = Ps(n, bt, xt, At, qt, a, f, l);
1825
1825
  if (p) {
1826
1826
  if (e) {
1827
- ne.fromBufferAttribute(e, r), se.fromBufferAttribute(e, o), oe.fromBufferAttribute(e, f), p.uv = new gt();
1828
- const d = $t.getInterpolation(qt, bt, xt, At, ne, se, oe, p.uv);
1829
- ie || (p.uv = d);
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);
1830
1830
  }
1831
1831
  if (s) {
1832
- ne.fromBufferAttribute(s, r), se.fromBufferAttribute(s, o), oe.fromBufferAttribute(s, f), p.uv1 = new gt();
1833
- const d = $t.getInterpolation(qt, bt, xt, At, ne, se, oe, p.uv1);
1834
- ie || (p.uv1 = d), Ms && (p.uv2 = p.uv1);
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);
1835
1835
  }
1836
1836
  if (i) {
1837
- Ri.fromBufferAttribute(i, r), Bi.fromBufferAttribute(i, o), _i.fromBufferAttribute(i, f), p.normal = new z();
1838
- const d = $t.getInterpolation(qt, bt, xt, At, Ri, Bi, _i, p.normal);
1839
- p.normal.dot(n.direction) > 0 && p.normal.multiplyScalar(-1), ie || (p.normal = d);
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);
1840
1840
  }
1841
1841
  const c = {
1842
1842
  a: r,
1843
1843
  b: o,
1844
- c: f,
1844
+ c: d,
1845
1845
  normal: new z(),
1846
1846
  materialIndex: 0
1847
1847
  };
1848
1848
  if ($t.getNormal(bt, xt, At, c.normal), p.face = c, p.faceIndex = r, ie) {
1849
- const d = new z();
1850
- $t.getBarycoord(qt, bt, xt, At, d), p.barycoord = d;
1849
+ const u = new z();
1850
+ $t.getBarycoord(qt, bt, xt, At, u), p.barycoord = u;
1851
1851
  }
1852
1852
  }
1853
1853
  return p;
@@ -1856,17 +1856,17 @@ function zi(n) {
1856
1856
  return n && n.isMaterial ? n.side : n;
1857
1857
  }
1858
1858
  function Me(n, t, i, e, s, r, o) {
1859
- const f = e * 3;
1860
- let a = f + 0, u = f + 1, l = f + 2;
1859
+ const d = e * 3;
1860
+ let a = d + 0, f = d + 1, l = d + 2;
1861
1861
  const { index: p, groups: c } = n;
1862
- n.index && (a = p.getX(a), u = p.getX(u), l = p.getX(l));
1863
- const { position: d, normal: y, uv: g, uv1: x } = n.attributes;
1862
+ n.index && (a = p.getX(a), f = p.getX(f), l = p.getX(l));
1863
+ const { position: u, normal: y, uv: g, uv1: x } = n.attributes;
1864
1864
  if (Array.isArray(t)) {
1865
1865
  const w = e * 3;
1866
1866
  for (let m = 0, h = c.length; m < h; m++) {
1867
1867
  const { start: b, count: A, materialIndex: P } = c[m];
1868
1868
  if (w >= b && w < b + A) {
1869
- const M = zi(t[P]), T = Ei(i, d, y, g, x, a, u, l, M, r, o);
1869
+ const M = zi(t[P]), T = Ei(i, u, y, g, x, a, f, l, M, r, o);
1870
1870
  if (T)
1871
1871
  if (T.faceIndex = e, T.face.materialIndex = P, s)
1872
1872
  s.push(T);
@@ -1875,7 +1875,7 @@ function Me(n, t, i, e, s, r, o) {
1875
1875
  }
1876
1876
  }
1877
1877
  } else {
1878
- const w = zi(t), m = Ei(i, d, y, g, x, a, u, l, w, r, o);
1878
+ const w = zi(t), m = Ei(i, u, y, g, x, a, f, l, w, r, o);
1879
1879
  if (m)
1880
1880
  if (m.faceIndex = e, m.face.materialIndex = 0, s)
1881
1881
  s.push(m);
@@ -1886,43 +1886,43 @@ function Me(n, t, i, e, s, r, o) {
1886
1886
  }
1887
1887
  function j(n, t, i, e) {
1888
1888
  const s = n.a, r = n.b, o = n.c;
1889
- let f = t, a = t + 1, u = t + 2;
1890
- i && (f = i.getX(f), a = i.getX(a), u = i.getX(u)), s.x = e.getX(f), s.y = e.getY(f), s.z = e.getZ(f), r.x = e.getX(a), r.y = e.getY(a), r.z = e.getZ(a), o.x = e.getX(u), o.y = e.getY(u), o.z = e.getZ(u);
1889
+ let d = t, a = t + 1, f = t + 2;
1890
+ 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
1891
  }
1892
- function Ps(n, t, i, e, s, r, o, f) {
1893
- const { geometry: a, _indirectBuffer: u } = n;
1892
+ function Ss(n, t, i, e, s, r, o, d) {
1893
+ const { geometry: a, _indirectBuffer: f } = n;
1894
1894
  for (let l = e, p = e + s; l < p; l++)
1895
- Me(a, t, i, l, r, o, f);
1895
+ Me(a, t, i, l, r, o, d);
1896
1896
  }
1897
- function Ss(n, t, i, e, s, r, o) {
1898
- const { geometry: f, _indirectBuffer: a } = n;
1899
- let u = 1 / 0, l = null;
1897
+ function Ts(n, t, i, e, s, r, o) {
1898
+ const { geometry: d, _indirectBuffer: a } = n;
1899
+ let f = 1 / 0, l = null;
1900
1900
  for (let p = e, c = e + s; p < c; p++) {
1901
- let d;
1902
- d = Me(f, t, i, p, null, r, o), d && d.distance < u && (l = d, u = d.distance);
1901
+ let u;
1902
+ u = Me(d, t, i, p, null, r, o), u && u.distance < f && (l = u, f = u.distance);
1903
1903
  }
1904
1904
  return l;
1905
1905
  }
1906
- function Ts(n, t, i, e, s, r, o) {
1907
- const { geometry: f } = i, { index: a } = f, u = f.attributes.position;
1906
+ function Rs(n, t, i, e, s, r, o) {
1907
+ const { geometry: d } = i, { index: a } = d, f = d.attributes.position;
1908
1908
  for (let l = n, p = t + n; l < p; l++) {
1909
1909
  let c;
1910
- if (c = l, j(o, c * 3, a, u), o.needsUpdate = !0, e(o, c, s, r))
1910
+ if (c = l, j(o, c * 3, a, f), o.needsUpdate = !0, e(o, c, s, r))
1911
1911
  return !0;
1912
1912
  }
1913
1913
  return !1;
1914
1914
  }
1915
- function Rs(n, t = null) {
1915
+ function Bs(n, t = null) {
1916
1916
  t && Array.isArray(t) && (t = new Set(t));
1917
1917
  const i = n.geometry, e = i.index ? i.index.array : null, s = i.attributes.position;
1918
- let r, o, f, a, u = 0;
1918
+ let r, o, d, a, f = 0;
1919
1919
  const l = n._roots;
1920
- for (let c = 0, d = l.length; c < d; c++)
1921
- r = l[c], o = new Uint32Array(r), f = new Uint16Array(r), a = new Float32Array(r), p(0, u), u += r.byteLength;
1922
- function p(c, d, y = !1) {
1920
+ for (let c = 0, u = l.length; c < u; c++)
1921
+ r = l[c], o = new Uint32Array(r), d = new Uint16Array(r), a = new Float32Array(r), p(0, f), f += r.byteLength;
1922
+ function p(c, u, y = !1) {
1923
1923
  const g = c * 2;
1924
- if (q(g, f)) {
1925
- const x = J(c, o), w = Z(g, f);
1924
+ if (q(g, d)) {
1925
+ const x = J(c, o), w = Z(g, d);
1926
1926
  let m = 1 / 0, h = 1 / 0, b = 1 / 0, A = -1 / 0, P = -1 / 0, M = -1 / 0;
1927
1927
  for (let T = 3 * x, R = 3 * (x + w); T < R; T++) {
1928
1928
  let v = e[T];
@@ -1935,16 +1935,16 @@ function Rs(n, t = null) {
1935
1935
  let m = y, h = !1, b = !1;
1936
1936
  if (t) {
1937
1937
  if (!m) {
1938
- const v = x / N + d / X, B = w / N + d / X;
1938
+ const v = x / N + u / X, B = w / N + u / X;
1939
1939
  h = t.has(v), b = t.has(B), m = !h && !b;
1940
1940
  }
1941
1941
  } else
1942
1942
  h = !0, b = !0;
1943
1943
  const A = m || h, P = m || b;
1944
1944
  let M = !1;
1945
- A && (M = p(x, d, m));
1945
+ A && (M = p(x, u, m));
1946
1946
  let T = !1;
1947
- P && (T = p(w, d, m));
1947
+ P && (T = p(w, u, m));
1948
1948
  const R = M || T;
1949
1949
  if (R)
1950
1950
  for (let v = 0; v < 3; v++) {
@@ -1956,65 +1956,65 @@ function Rs(n, t = null) {
1956
1956
  }
1957
1957
  }
1958
1958
  function wt(n, t, i, e, s) {
1959
- let r, o, f, a, u, l;
1960
- const p = 1 / i.direction.x, c = 1 / i.direction.y, d = 1 / i.direction.z, y = i.origin.x, g = i.origin.y, x = i.origin.z;
1959
+ let r, o, d, a, f, l;
1960
+ 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
1961
  let w = t[n], m = t[n + 3], h = t[n + 1], b = t[n + 3 + 1], A = t[n + 2], P = t[n + 3 + 2];
1962
- return p >= 0 ? (r = (w - y) * p, o = (m - y) * p) : (r = (m - y) * p, o = (w - y) * p), c >= 0 ? (f = (h - g) * c, a = (b - g) * c) : (f = (b - g) * c, a = (h - g) * c), r > a || f > o || ((f > r || isNaN(r)) && (r = f), (a < o || isNaN(o)) && (o = a), d >= 0 ? (u = (A - x) * d, l = (P - x) * d) : (u = (P - x) * d, l = (A - x) * d), r > l || u > o) ? !1 : ((u > r || r !== r) && (r = u), (l < o || o !== o) && (o = l), r <= s && o >= e);
1962
+ 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
1963
  }
1964
- function Bs(n, t, i, e, s, r, o, f) {
1965
- const { geometry: a, _indirectBuffer: u } = n;
1964
+ function _s(n, t, i, e, s, r, o, d) {
1965
+ const { geometry: a, _indirectBuffer: f } = n;
1966
1966
  for (let l = e, p = e + s; l < p; l++) {
1967
- let c = u ? u[l] : l;
1968
- Me(a, t, i, c, r, o, f);
1967
+ let c = f ? f[l] : l;
1968
+ Me(a, t, i, c, r, o, d);
1969
1969
  }
1970
1970
  }
1971
- function _s(n, t, i, e, s, r, o) {
1972
- const { geometry: f, _indirectBuffer: a } = n;
1973
- let u = 1 / 0, l = null;
1971
+ function Es(n, t, i, e, s, r, o) {
1972
+ const { geometry: d, _indirectBuffer: a } = n;
1973
+ let f = 1 / 0, l = null;
1974
1974
  for (let p = e, c = e + s; p < c; p++) {
1975
- let d;
1976
- d = Me(f, t, i, a ? a[p] : p, null, r, o), d && d.distance < u && (l = d, u = d.distance);
1975
+ let u;
1976
+ u = Me(d, t, i, a ? a[p] : p, null, r, o), u && u.distance < f && (l = u, f = u.distance);
1977
1977
  }
1978
1978
  return l;
1979
1979
  }
1980
- function Es(n, t, i, e, s, r, o) {
1981
- const { geometry: f } = i, { index: a } = f, u = f.attributes.position;
1980
+ function zs(n, t, i, e, s, r, o) {
1981
+ const { geometry: d } = i, { index: a } = d, f = d.attributes.position;
1982
1982
  for (let l = n, p = t + n; l < p; l++) {
1983
1983
  let c;
1984
- if (c = i.resolveTriangleIndex(l), j(o, c * 3, a, u), o.needsUpdate = !0, e(o, c, s, r))
1984
+ if (c = i.resolveTriangleIndex(l), j(o, c * 3, a, f), o.needsUpdate = !0, e(o, c, s, r))
1985
1985
  return !0;
1986
1986
  }
1987
1987
  return !1;
1988
1988
  }
1989
- function zs(n, t, i, e, s, r, o) {
1989
+ function Us(n, t, i, e, s, r, o) {
1990
1990
  I.setBuffer(n._roots[t]), qe(0, n, i, e, s, r, o), I.clearBuffer();
1991
1991
  }
1992
1992
  function qe(n, t, i, e, s, r, o) {
1993
- const { float32Array: f, uint16Array: a, uint32Array: u } = I, l = n * 2;
1993
+ const { float32Array: d, uint16Array: a, uint32Array: f } = I, l = n * 2;
1994
1994
  if (q(l, a)) {
1995
- const c = J(n, u), d = Z(l, a);
1996
- Ps(t, i, e, c, d, s, r, o);
1995
+ const c = J(n, f), u = Z(l, a);
1996
+ Ss(t, i, e, c, u, s, r, o);
1997
1997
  } else {
1998
1998
  const c = V(n);
1999
- wt(c, f, e, r, o) && qe(c, t, i, e, s, r, o);
2000
- const d = W(n, u);
2001
- wt(d, f, e, r, o) && qe(d, t, i, e, s, r, o);
1999
+ wt(c, d, e, r, o) && qe(c, t, i, e, s, r, o);
2000
+ const u = W(n, f);
2001
+ wt(u, d, e, r, o) && qe(u, t, i, e, s, r, o);
2002
2002
  }
2003
2003
  }
2004
- const Us = ["x", "y", "z"];
2005
- function Fs(n, t, i, e, s, r) {
2004
+ const Fs = ["x", "y", "z"];
2005
+ function $s(n, t, i, e, s, r) {
2006
2006
  I.setBuffer(n._roots[t]);
2007
2007
  const o = Oe(0, n, i, e, s, r);
2008
2008
  return I.clearBuffer(), o;
2009
2009
  }
2010
2010
  function Oe(n, t, i, e, s, r) {
2011
- const { float32Array: o, uint16Array: f, uint32Array: a } = I;
2012
- let u = n * 2;
2013
- if (q(u, f)) {
2014
- const p = J(n, a), c = Z(u, f);
2015
- return Ss(t, i, e, p, c, s, r);
2011
+ const { float32Array: o, uint16Array: d, uint32Array: a } = I;
2012
+ let f = n * 2;
2013
+ if (q(f, d)) {
2014
+ const p = J(n, a), c = Z(f, d);
2015
+ return Ts(t, i, e, p, c, s, r);
2016
2016
  } else {
2017
- const p = ei(n, a), c = Us[p], y = e.direction[c] >= 0;
2017
+ const p = ei(n, a), c = Fs[p], y = e.direction[c] >= 0;
2018
2018
  let g, x;
2019
2019
  y ? (g = V(n), x = W(n, a)) : (g = W(n, a), x = V(n));
2020
2020
  const m = wt(g, o, e, s, r) ? Oe(g, t, i, e, s, r) : null;
@@ -2031,16 +2031,16 @@ function Oe(n, t, i, e, s, r) {
2031
2031
  }
2032
2032
  }
2033
2033
  const re = /* @__PURE__ */ new it(), Et = /* @__PURE__ */ new st(), zt = /* @__PURE__ */ new st(), Ot = /* @__PURE__ */ new H(), Ui = /* @__PURE__ */ new Q(), ae = /* @__PURE__ */ new Q();
2034
- function $s(n, t, i, e) {
2034
+ function Is(n, t, i, e) {
2035
2035
  I.setBuffer(n._roots[t]);
2036
2036
  const s = Ve(0, n, i, e);
2037
2037
  return I.clearBuffer(), s;
2038
2038
  }
2039
2039
  function Ve(n, t, i, e, s = null) {
2040
- const { float32Array: r, uint16Array: o, uint32Array: f } = I;
2040
+ const { float32Array: r, uint16Array: o, uint32Array: d } = I;
2041
2041
  let a = n * 2;
2042
2042
  if (s === null && (i.boundingBox || i.computeBoundingBox(), Ui.set(i.boundingBox.min, i.boundingBox.max, e), s = Ui), q(a, o)) {
2043
- const l = t.geometry, p = l.index, c = l.attributes.position, d = i.index, y = i.attributes.position, g = J(n, f), x = Z(a, o);
2043
+ 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
2044
  if (Ot.copy(e).invert(), i.boundsTree)
2045
2045
  return k(n, r, ae), ae.matrix.copy(Ot), ae.needsUpdate = !0, i.boundsTree.shapecast({
2046
2046
  intersectsBounds: (m) => ae.intersectsBox(m),
@@ -2057,21 +2057,21 @@ function Ve(n, t, i, e, s = null) {
2057
2057
  for (let m = g * 3, h = (x + g) * 3; m < h; m += 3) {
2058
2058
  j(Et, m, p, c), Et.a.applyMatrix4(Ot), Et.b.applyMatrix4(Ot), Et.c.applyMatrix4(Ot), Et.needsUpdate = !0;
2059
2059
  for (let b = 0, A = w * 3; b < A; b += 3)
2060
- if (j(zt, b, d, y), zt.needsUpdate = !0, Et.intersectsTriangle(zt))
2060
+ if (j(zt, b, u, y), zt.needsUpdate = !0, Et.intersectsTriangle(zt))
2061
2061
  return !0;
2062
2062
  }
2063
2063
  }
2064
2064
  } else {
2065
- const l = V(n), p = W(n, f);
2065
+ const l = V(n), p = W(n, d);
2066
2066
  return k(l, r, re), !!(s.intersectsBox(re) && Ve(l, t, i, e, s) || (k(p, r, re), s.intersectsBox(re) && Ve(p, t, i, e, s)));
2067
2067
  }
2068
2068
  }
2069
- const ce = /* @__PURE__ */ new H(), ze = /* @__PURE__ */ new Q(), Vt = /* @__PURE__ */ new Q(), Is = /* @__PURE__ */ new z(), Ds = /* @__PURE__ */ new z(), Ls = /* @__PURE__ */ new z(), ks = /* @__PURE__ */ new z();
2070
- function js(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
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
2071
  t.boundingBox || t.computeBoundingBox(), ze.set(t.boundingBox.min, t.boundingBox.max, i), ze.needsUpdate = !0;
2072
- const f = n.geometry, a = f.attributes.position, u = f.index, l = t.attributes.position, p = t.index, c = et.getPrimitive(), d = et.getPrimitive();
2073
- let y = Is, g = Ds, x = null, w = null;
2074
- s && (x = Ls, w = ks);
2072
+ 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
2075
  let m = 1 / 0, h = null, b = null;
2076
2076
  return ce.copy(i).invert(), Vt.matrix.copy(ce), n.shapecast(
2077
2077
  {
@@ -2084,10 +2084,10 @@ function js(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2084
2084
  intersectsBounds: (T, R, v) => v < m && v < o,
2085
2085
  intersectsRange: (T, R) => {
2086
2086
  for (let v = T, B = T + R; v < B; v++) {
2087
- j(d, 3 * v, p, l), d.a.applyMatrix4(i), d.b.applyMatrix4(i), d.c.applyMatrix4(i), d.needsUpdate = !0;
2087
+ j(u, 3 * v, p, l), u.a.applyMatrix4(i), u.b.applyMatrix4(i), u.c.applyMatrix4(i), u.needsUpdate = !0;
2088
2088
  for (let S = A, _ = A + P; S < _; S++) {
2089
- j(c, 3 * S, u, a), c.needsUpdate = !0;
2090
- const E = c.distanceToTriangle(d, y, x);
2089
+ j(c, 3 * S, f, a), c.needsUpdate = !0;
2090
+ const E = c.distanceToTriangle(u, y, x);
2091
2091
  if (E < m && (g.copy(y), w && w.copy(x), m = E, h = S, b = v), E < r)
2092
2092
  return !0;
2093
2093
  }
@@ -2097,10 +2097,10 @@ function js(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2097
2097
  {
2098
2098
  const M = Ae(t);
2099
2099
  for (let T = 0, R = M; T < R; T++) {
2100
- j(d, 3 * T, p, l), d.a.applyMatrix4(i), d.b.applyMatrix4(i), d.c.applyMatrix4(i), d.needsUpdate = !0;
2100
+ j(u, 3 * T, p, l), u.a.applyMatrix4(i), u.b.applyMatrix4(i), u.c.applyMatrix4(i), u.needsUpdate = !0;
2101
2101
  for (let v = A, B = A + P; v < B; v++) {
2102
- j(c, 3 * v, u, a), c.needsUpdate = !0;
2103
- const S = c.distanceToTriangle(d, y, x);
2102
+ j(c, 3 * v, f, a), c.needsUpdate = !0;
2103
+ const S = c.distanceToTriangle(u, y, x);
2104
2104
  if (S < m && (g.copy(y), w && w.copy(x), m = S, h = v, b = T), S < r)
2105
2105
  return !0;
2106
2106
  }
@@ -2108,19 +2108,19 @@ function js(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2108
2108
  }
2109
2109
  }
2110
2110
  }
2111
- ), et.releasePrimitive(c), et.releasePrimitive(d), m === 1 / 0 ? null : (e.point ? e.point.copy(g) : e.point = g.clone(), e.distance = m, e.faceIndex = h, s && (s.point ? s.point.copy(w) : s.point = w.clone(), s.point.applyMatrix4(ce), g.applyMatrix4(ce), s.distance = g.sub(s.point).length(), s.faceIndex = b), e);
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);
2112
2112
  }
2113
- function Cs(n, t = null) {
2113
+ function Ns(n, t = null) {
2114
2114
  t && Array.isArray(t) && (t = new Set(t));
2115
2115
  const i = n.geometry, e = i.index ? i.index.array : null, s = i.attributes.position;
2116
- let r, o, f, a, u = 0;
2116
+ let r, o, d, a, f = 0;
2117
2117
  const l = n._roots;
2118
- for (let c = 0, d = l.length; c < d; c++)
2119
- r = l[c], o = new Uint32Array(r), f = new Uint16Array(r), a = new Float32Array(r), p(0, u), u += r.byteLength;
2120
- function p(c, d, y = !1) {
2118
+ for (let c = 0, u = l.length; c < u; c++)
2119
+ r = l[c], o = new Uint32Array(r), d = new Uint16Array(r), a = new Float32Array(r), p(0, f), f += r.byteLength;
2120
+ function p(c, u, y = !1) {
2121
2121
  const g = c * 2;
2122
- if (q(g, f)) {
2123
- const x = J(c, o), w = Z(g, f);
2122
+ if (q(g, d)) {
2123
+ const x = J(c, o), w = Z(g, d);
2124
2124
  let m = 1 / 0, h = 1 / 0, b = 1 / 0, A = -1 / 0, P = -1 / 0, M = -1 / 0;
2125
2125
  for (let T = x, R = x + w; T < R; T++) {
2126
2126
  const v = 3 * n.resolveTriangleIndex(T);
@@ -2137,16 +2137,16 @@ function Cs(n, t = null) {
2137
2137
  let m = y, h = !1, b = !1;
2138
2138
  if (t) {
2139
2139
  if (!m) {
2140
- const v = x / N + d / X, B = w / N + d / X;
2140
+ const v = x / N + u / X, B = w / N + u / X;
2141
2141
  h = t.has(v), b = t.has(B), m = !h && !b;
2142
2142
  }
2143
2143
  } else
2144
2144
  h = !0, b = !0;
2145
2145
  const A = m || h, P = m || b;
2146
2146
  let M = !1;
2147
- A && (M = p(x, d, m));
2147
+ A && (M = p(x, u, m));
2148
2148
  let T = !1;
2149
- P && (T = p(w, d, m));
2149
+ P && (T = p(w, u, m));
2150
2150
  const R = M || T;
2151
2151
  if (R)
2152
2152
  for (let v = 0; v < 3; v++) {
@@ -2157,35 +2157,35 @@ function Cs(n, t = null) {
2157
2157
  }
2158
2158
  }
2159
2159
  }
2160
- function Ns(n, t, i, e, s, r, o) {
2160
+ function qs(n, t, i, e, s, r, o) {
2161
2161
  I.setBuffer(n._roots[t]), We(0, n, i, e, s, r, o), I.clearBuffer();
2162
2162
  }
2163
2163
  function We(n, t, i, e, s, r, o) {
2164
- const { float32Array: f, uint16Array: a, uint32Array: u } = I, l = n * 2;
2164
+ const { float32Array: d, uint16Array: a, uint32Array: f } = I, l = n * 2;
2165
2165
  if (q(l, a)) {
2166
- const c = J(n, u), d = Z(l, a);
2167
- Bs(t, i, e, c, d, s, r, o);
2166
+ const c = J(n, f), u = Z(l, a);
2167
+ _s(t, i, e, c, u, s, r, o);
2168
2168
  } else {
2169
2169
  const c = V(n);
2170
- wt(c, f, e, r, o) && We(c, t, i, e, s, r, o);
2171
- const d = W(n, u);
2172
- wt(d, f, e, r, o) && We(d, t, i, e, s, r, o);
2170
+ wt(c, d, e, r, o) && We(c, t, i, e, s, r, o);
2171
+ const u = W(n, f);
2172
+ wt(u, d, e, r, o) && We(u, t, i, e, s, r, o);
2173
2173
  }
2174
2174
  }
2175
- const qs = ["x", "y", "z"];
2176
- function Os(n, t, i, e, s, r) {
2175
+ const Os = ["x", "y", "z"];
2176
+ function Vs(n, t, i, e, s, r) {
2177
2177
  I.setBuffer(n._roots[t]);
2178
2178
  const o = Ge(0, n, i, e, s, r);
2179
2179
  return I.clearBuffer(), o;
2180
2180
  }
2181
2181
  function Ge(n, t, i, e, s, r) {
2182
- const { float32Array: o, uint16Array: f, uint32Array: a } = I;
2183
- let u = n * 2;
2184
- if (q(u, f)) {
2185
- const p = J(n, a), c = Z(u, f);
2186
- return _s(t, i, e, p, c, s, r);
2182
+ const { float32Array: o, uint16Array: d, uint32Array: a } = I;
2183
+ let f = n * 2;
2184
+ if (q(f, d)) {
2185
+ const p = J(n, a), c = Z(f, d);
2186
+ return Es(t, i, e, p, c, s, r);
2187
2187
  } else {
2188
- const p = ei(n, a), c = qs[p], y = e.direction[c] >= 0;
2188
+ const p = ei(n, a), c = Os[p], y = e.direction[c] >= 0;
2189
2189
  let g, x;
2190
2190
  y ? (g = V(n), x = W(n, a)) : (g = W(n, a), x = V(n));
2191
2191
  const m = wt(g, o, e, s, r) ? Ge(g, t, i, e, s, r) : null;
@@ -2202,16 +2202,16 @@ function Ge(n, t, i, e, s, r) {
2202
2202
  }
2203
2203
  }
2204
2204
  const le = /* @__PURE__ */ new it(), Ut = /* @__PURE__ */ new st(), Ft = /* @__PURE__ */ new st(), Wt = /* @__PURE__ */ new H(), Fi = /* @__PURE__ */ new Q(), ue = /* @__PURE__ */ new Q();
2205
- function Vs(n, t, i, e) {
2205
+ function Ws(n, t, i, e) {
2206
2206
  I.setBuffer(n._roots[t]);
2207
2207
  const s = Xe(0, n, i, e);
2208
2208
  return I.clearBuffer(), s;
2209
2209
  }
2210
2210
  function Xe(n, t, i, e, s = null) {
2211
- const { float32Array: r, uint16Array: o, uint32Array: f } = I;
2211
+ const { float32Array: r, uint16Array: o, uint32Array: d } = I;
2212
2212
  let a = n * 2;
2213
2213
  if (s === null && (i.boundingBox || i.computeBoundingBox(), Fi.set(i.boundingBox.min, i.boundingBox.max, e), s = Fi), q(a, o)) {
2214
- const l = t.geometry, p = l.index, c = l.attributes.position, d = i.index, y = i.attributes.position, g = J(n, f), x = Z(a, o);
2214
+ 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
2215
  if (Wt.copy(e).invert(), i.boundsTree)
2216
2216
  return k(n, r, ue), ue.matrix.copy(Wt), ue.needsUpdate = !0, i.boundsTree.shapecast({
2217
2217
  intersectsBounds: (m) => ue.intersectsBox(m),
@@ -2229,21 +2229,21 @@ function Xe(n, t, i, e, s = null) {
2229
2229
  const b = t.resolveTriangleIndex(m);
2230
2230
  j(Ut, 3 * b, p, c), Ut.a.applyMatrix4(Wt), Ut.b.applyMatrix4(Wt), Ut.c.applyMatrix4(Wt), Ut.needsUpdate = !0;
2231
2231
  for (let A = 0, P = w * 3; A < P; A += 3)
2232
- if (j(Ft, A, d, y), Ft.needsUpdate = !0, Ut.intersectsTriangle(Ft))
2232
+ if (j(Ft, A, u, y), Ft.needsUpdate = !0, Ut.intersectsTriangle(Ft))
2233
2233
  return !0;
2234
2234
  }
2235
2235
  }
2236
2236
  } else {
2237
- const l = V(n), p = W(n, f);
2237
+ const l = V(n), p = W(n, d);
2238
2238
  return k(l, r, le), !!(s.intersectsBox(le) && Xe(l, t, i, e, s) || (k(p, r, le), s.intersectsBox(le) && Xe(p, t, i, e, s)));
2239
2239
  }
2240
2240
  }
2241
- const fe = /* @__PURE__ */ new H(), Ue = /* @__PURE__ */ new Q(), Gt = /* @__PURE__ */ new Q(), Ws = /* @__PURE__ */ new z(), Gs = /* @__PURE__ */ new z(), Xs = /* @__PURE__ */ new z(), Js = /* @__PURE__ */ new z();
2242
- function Hs(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
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
2243
  t.boundingBox || t.computeBoundingBox(), Ue.set(t.boundingBox.min, t.boundingBox.max, i), Ue.needsUpdate = !0;
2244
- const f = n.geometry, a = f.attributes.position, u = f.index, l = t.attributes.position, p = t.index, c = et.getPrimitive(), d = et.getPrimitive();
2245
- let y = Ws, g = Gs, x = null, w = null;
2246
- s && (x = Xs, w = Js);
2244
+ 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
2247
  let m = 1 / 0, h = null, b = null;
2248
2248
  return fe.copy(i).invert(), Gt.matrix.copy(fe), n.shapecast(
2249
2249
  {
@@ -2258,11 +2258,11 @@ function Hs(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2258
2258
  intersectsRange: (T, R) => {
2259
2259
  for (let v = T, B = T + R; v < B; v++) {
2260
2260
  const S = M.resolveTriangleIndex(v);
2261
- j(d, 3 * S, p, l), d.a.applyMatrix4(i), d.b.applyMatrix4(i), d.c.applyMatrix4(i), d.needsUpdate = !0;
2261
+ j(u, 3 * S, p, l), u.a.applyMatrix4(i), u.b.applyMatrix4(i), u.c.applyMatrix4(i), u.needsUpdate = !0;
2262
2262
  for (let _ = A, E = A + P; _ < E; _++) {
2263
2263
  const F = n.resolveTriangleIndex(_);
2264
- j(c, 3 * F, u, a), c.needsUpdate = !0;
2265
- const D = c.distanceToTriangle(d, y, x);
2264
+ j(c, 3 * F, f, a), c.needsUpdate = !0;
2265
+ const D = c.distanceToTriangle(u, y, x);
2266
2266
  if (D < m && (g.copy(y), w && w.copy(x), m = D, h = _, b = v), D < r)
2267
2267
  return !0;
2268
2268
  }
@@ -2272,11 +2272,11 @@ function Hs(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2272
2272
  } else {
2273
2273
  const M = Ae(t);
2274
2274
  for (let T = 0, R = M; T < R; T++) {
2275
- j(d, 3 * T, p, l), d.a.applyMatrix4(i), d.b.applyMatrix4(i), d.c.applyMatrix4(i), d.needsUpdate = !0;
2275
+ j(u, 3 * T, p, l), u.a.applyMatrix4(i), u.b.applyMatrix4(i), u.c.applyMatrix4(i), u.needsUpdate = !0;
2276
2276
  for (let v = A, B = A + P; v < B; v++) {
2277
2277
  const S = n.resolveTriangleIndex(v);
2278
- j(c, 3 * S, u, a), c.needsUpdate = !0;
2279
- const _ = c.distanceToTriangle(d, y, x);
2278
+ j(c, 3 * S, f, a), c.needsUpdate = !0;
2279
+ const _ = c.distanceToTriangle(u, y, x);
2280
2280
  if (_ < m && (g.copy(y), w && w.copy(x), m = _, h = v, b = T), _ < r)
2281
2281
  return !0;
2282
2282
  }
@@ -2284,25 +2284,25 @@ function Hs(n, t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2284
2284
  }
2285
2285
  }
2286
2286
  }
2287
- ), et.releasePrimitive(c), et.releasePrimitive(d), m === 1 / 0 ? null : (e.point ? e.point.copy(g) : e.point = g.clone(), e.distance = m, e.faceIndex = h, s && (s.point ? s.point.copy(w) : s.point = w.clone(), s.point.applyMatrix4(fe), g.applyMatrix4(fe), s.distance = g.sub(s.point).length(), s.faceIndex = b), e);
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);
2288
2288
  }
2289
2289
  function $i(n, t, i) {
2290
2290
  return n === null ? null : (n.point.applyMatrix4(t.matrixWorld), n.distance = n.point.distanceTo(i.ray.origin), n.object = t, n);
2291
2291
  }
2292
- const de = /* @__PURE__ */ new Q(), pe = /* @__PURE__ */ new Sn(), Ii = /* @__PURE__ */ new z(), Di = /* @__PURE__ */ new H(), Li = /* @__PURE__ */ new z(), Fe = ["getX", "getY", "getZ"];
2293
- class be extends ys {
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
2294
  static serialize(t, i = {}) {
2295
2295
  i = {
2296
2296
  cloneBuffers: !0,
2297
2297
  ...i
2298
2298
  };
2299
- const e = t.geometry, s = t._roots, r = t._indirectBuffer, o = e.getIndex(), f = {
2299
+ const e = t.geometry, s = t._roots, r = t._indirectBuffer, o = e.getIndex(), d = {
2300
2300
  version: 1,
2301
2301
  roots: null,
2302
2302
  index: null,
2303
2303
  indirectBuffer: null
2304
2304
  };
2305
- return i.cloneBuffers ? (f.roots = s.map((a) => a.slice()), f.index = o ? o.array.slice() : null, f.indirectBuffer = r ? r.slice() : null) : (f.roots = s, f.index = o ? o.array : null, f.indirectBuffer = r), f;
2305
+ return i.cloneBuffers ? (d.roots = s.map((a) => a.slice()), d.index = o ? o.array.slice() : null, d.indirectBuffer = r ? r.slice() : null) : (d.roots = s, d.index = o ? o.array : null, d.indirectBuffer = r), d;
2306
2306
  }
2307
2307
  static deserialize(t, i, e = {}) {
2308
2308
  e = {
@@ -2314,21 +2314,21 @@ class be extends ys {
2314
2314
  t.version || (console.warn(
2315
2315
  "MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."
2316
2316
  ), a(r));
2317
- const f = new be(i, { ...e, [ti]: !0 });
2318
- if (f._roots = r, f._indirectBuffer = o || null, e.setIndex) {
2319
- const u = i.getIndex();
2320
- if (u === null) {
2317
+ const d = new be(i, { ...e, [ti]: !0 });
2318
+ if (d._roots = r, d._indirectBuffer = o || null, e.setIndex) {
2319
+ const f = i.getIndex();
2320
+ if (f === null) {
2321
2321
  const l = new Oi(t.index, 1, !1);
2322
2322
  i.setIndex(l);
2323
- } else u.array !== s && (u.array.set(s), u.needsUpdate = !0);
2323
+ } else f.array !== s && (f.array.set(s), f.needsUpdate = !0);
2324
2324
  }
2325
- return f;
2326
- function a(u) {
2327
- for (let l = 0; l < u.length; l++) {
2328
- const p = u[l], c = new Uint32Array(p), d = new Uint16Array(p);
2325
+ return d;
2326
+ function a(f) {
2327
+ for (let l = 0; l < f.length; l++) {
2328
+ const p = f[l], c = new Uint32Array(p), u = new Uint16Array(p);
2329
2329
  for (let y = 0, g = p.byteLength / X; y < g; y++) {
2330
2330
  const x = N * y, w = 2 * x;
2331
- q(w, d) || (c[x + 6] = c[x + 6] / N - y);
2331
+ q(w, u) || (c[x + 6] = c[x + 6] / N - y);
2332
2332
  }
2333
2333
  }
2334
2334
  }
@@ -2351,15 +2351,15 @@ class be extends ys {
2351
2351
  }
2352
2352
  // write primitive bounds to the buffer - used only for validateBounds at the moment
2353
2353
  writePrimitiveBounds(t, i, e) {
2354
- const s = this.geometry, r = this._indirectBuffer, o = s.attributes.position, f = s.index ? s.index.array : null, u = (r ? r[t] : t) * 3;
2355
- let l = u + 0, p = u + 1, c = u + 2;
2356
- f && (l = f[l], p = f[p], c = f[c]);
2357
- for (let d = 0; d < 3; d++) {
2358
- const y = o[Fe[d]](l), g = o[Fe[d]](p), x = o[Fe[d]](c);
2354
+ const s = this.geometry, r = this._indirectBuffer, o = s.attributes.position, d = s.index ? s.index.array : null, f = (r ? r[t] : t) * 3;
2355
+ let l = f + 0, p = f + 1, c = f + 2;
2356
+ d && (l = d[l], p = d[p], c = d[c]);
2357
+ for (let u = 0; u < 3; u++) {
2358
+ const y = o[Fe[u]](l), g = o[Fe[u]](p), x = o[Fe[u]](c);
2359
2359
  let w = y;
2360
2360
  g < w && (w = g), x < w && (w = x);
2361
2361
  let m = y;
2362
- g > m && (m = g), x > m && (m = x), i[e + d] = w, i[e + d + 3] = m;
2362
+ g > m && (m = g), x > m && (m = x), i[e + u] = w, i[e + u + 3] = m;
2363
2363
  }
2364
2364
  return i;
2365
2365
  }
@@ -2368,20 +2368,20 @@ class be extends ys {
2368
2368
  // [x_center, x_delta, y_center, y_delta, z_center, z_delta] tuple starting at index (i - offset) * 6,
2369
2369
  // representing the center and half-extent in each dimension of triangle i
2370
2370
  computePrimitiveBounds(t, i, e) {
2371
- const s = this.geometry, r = this._indirectBuffer, o = s.attributes.position, f = s.index ? s.index.array : null, a = o.normalized;
2371
+ const s = this.geometry, r = this._indirectBuffer, o = s.attributes.position, d = s.index ? s.index.array : null, a = o.normalized;
2372
2372
  if (t < 0 || i + t - e.offset > e.length / 6)
2373
2373
  throw new Error("MeshBVH: compute triangle bounds range is invalid.");
2374
- const u = o.array, l = o.offset || 0;
2374
+ const f = o.array, l = o.offset || 0;
2375
2375
  let p = 3;
2376
2376
  o.isInterleavedBufferAttribute && (p = o.data.stride);
2377
- const c = ["getX", "getY", "getZ"], d = e.offset;
2377
+ const c = ["getX", "getY", "getZ"], u = e.offset;
2378
2378
  for (let y = t, g = t + i; y < g; y++) {
2379
- const w = (r ? r[y] : y) * 3, m = (y - d) * 6;
2379
+ const w = (r ? r[y] : y) * 3, m = (y - u) * 6;
2380
2380
  let h = w + 0, b = w + 1, A = w + 2;
2381
- f && (h = f[h], b = f[b], A = f[A]), a || (h = h * p + l, b = b * p + l, A = A * p + l);
2381
+ d && (h = d[h], b = d[b], A = d[A]), a || (h = h * p + l, b = b * p + l, A = A * p + l);
2382
2382
  for (let P = 0; P < 3; P++) {
2383
2383
  let M, T, R;
2384
- a ? (M = o[c[P]](h), T = o[c[P]](b), R = o[c[P]](A)) : (M = u[h + P], T = u[b + P], R = u[A + P]);
2384
+ a ? (M = o[c[P]](h), T = o[c[P]](b), R = o[c[P]](A)) : (M = f[h + P], T = f[b + P], R = f[A + P]);
2385
2385
  let v = M;
2386
2386
  T < v && (v = T), R < v && (v = R);
2387
2387
  let B = M;
@@ -2397,43 +2397,43 @@ class be extends ys {
2397
2397
  if (s === void 0)
2398
2398
  return;
2399
2399
  Di.copy(t.matrixWorld).invert(), pe.copy(i.ray).applyMatrix4(Di), Li.setFromMatrixScale(t.matrixWorld), Ii.copy(pe.direction).multiply(Li);
2400
- const r = Ii.length(), o = i.near / r, f = i.far / r;
2400
+ const r = Ii.length(), o = i.near / r, d = i.far / r;
2401
2401
  if (i.firstHitOnly === !0) {
2402
- let a = this.raycastFirst(pe, s, o, f);
2402
+ let a = this.raycastFirst(pe, s, o, d);
2403
2403
  a = $i(a, t, i), a && e.push(a);
2404
2404
  } else {
2405
- const a = this.raycast(pe, s, o, f);
2406
- for (let u = 0, l = a.length; u < l; u++) {
2407
- const p = $i(a[u], t, i);
2405
+ const a = this.raycast(pe, s, o, d);
2406
+ for (let f = 0, l = a.length; f < l; f++) {
2407
+ const p = $i(a[f], t, i);
2408
2408
  p && e.push(p);
2409
2409
  }
2410
2410
  }
2411
2411
  return e;
2412
2412
  }
2413
2413
  refit(t = null) {
2414
- return (this.indirect ? Cs : Rs)(this, t);
2414
+ return (this.indirect ? Ns : Bs)(this, t);
2415
2415
  }
2416
2416
  /* Core Cast Functions */
2417
2417
  raycast(t, i = fi, e = 0, s = 1 / 0) {
2418
- const r = this._roots, o = [], f = this.indirect ? Ns : zs;
2419
- for (let a = 0, u = r.length; a < u; a++)
2420
- f(this, a, i, t, o, e, s);
2418
+ const r = this._roots, o = [], d = this.indirect ? qs : Us;
2419
+ for (let a = 0, f = r.length; a < f; a++)
2420
+ d(this, a, i, t, o, e, s);
2421
2421
  return o;
2422
2422
  }
2423
2423
  raycastFirst(t, i = fi, e = 0, s = 1 / 0) {
2424
2424
  const r = this._roots;
2425
2425
  let o = null;
2426
- const f = this.indirect ? Os : Fs;
2427
- for (let a = 0, u = r.length; a < u; a++) {
2428
- const l = f(this, a, i, t, e, s);
2426
+ const d = this.indirect ? Vs : $s;
2427
+ for (let a = 0, f = r.length; a < f; a++) {
2428
+ const l = d(this, a, i, t, e, s);
2429
2429
  l != null && (o == null || l.distance < o.distance) && (o = l);
2430
2430
  }
2431
2431
  return o;
2432
2432
  }
2433
2433
  intersectsGeometry(t, i) {
2434
2434
  let e = !1;
2435
- const s = this._roots, r = this.indirect ? Vs : $s;
2436
- for (let o = 0, f = s.length; o < f && (e = r(this, o, t, i), !e); o++)
2435
+ const s = this._roots, r = this.indirect ? Ws : Is;
2436
+ for (let o = 0, d = s.length; o < d && (e = r(this, o, t, i), !e); o++)
2437
2437
  ;
2438
2438
  return e;
2439
2439
  }
@@ -2445,7 +2445,7 @@ class be extends ys {
2445
2445
  scratchPrimitive: i,
2446
2446
  // TODO: is the performance significant enough for the added complexity here?
2447
2447
  // can we just use one function?
2448
- iterate: this.indirect ? Es : Ts
2448
+ iterate: this.indirect ? zs : Rs
2449
2449
  }
2450
2450
  );
2451
2451
  return et.releasePrimitive(i), e;
@@ -2455,12 +2455,12 @@ class be extends ys {
2455
2455
  intersectsRanges: s,
2456
2456
  intersectsTriangles: r
2457
2457
  } = e;
2458
- const o = et.getPrimitive(), f = this.geometry.index, a = this.geometry.attributes.position, u = this.indirect ? (y) => {
2458
+ const o = et.getPrimitive(), d = this.geometry.index, a = this.geometry.attributes.position, f = this.indirect ? (y) => {
2459
2459
  const g = this.resolveTriangleIndex(y);
2460
- j(o, g * 3, f, a);
2460
+ j(o, g * 3, d, a);
2461
2461
  } : (y) => {
2462
- j(o, y * 3, f, a);
2463
- }, l = et.getPrimitive(), p = t.geometry.index, c = t.geometry.attributes.position, d = t.indirect ? (y) => {
2462
+ j(o, y * 3, d, a);
2463
+ }, l = et.getPrimitive(), p = t.geometry.index, c = t.geometry.attributes.position, u = t.indirect ? (y) => {
2464
2464
  const g = t.resolveTriangleIndex(y);
2465
2465
  j(l, g * 3, p, c);
2466
2466
  } : (y) => {
@@ -2471,9 +2471,9 @@ class be extends ys {
2471
2471
  throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');
2472
2472
  const y = (g, x, w, m, h, b, A, P) => {
2473
2473
  for (let M = w, T = w + m; M < T; M++) {
2474
- d(M), l.a.applyMatrix4(i), l.b.applyMatrix4(i), l.c.applyMatrix4(i), l.needsUpdate = !0;
2474
+ u(M), l.a.applyMatrix4(i), l.b.applyMatrix4(i), l.c.applyMatrix4(i), l.needsUpdate = !0;
2475
2475
  for (let R = g, v = g + x; R < v; R++)
2476
- if (u(R), o.needsUpdate = !0, r(o, l, R, M, h, b, A, P))
2476
+ if (f(R), o.needsUpdate = !0, r(o, l, R, M, h, b, A, P))
2477
2477
  return !0;
2478
2478
  }
2479
2479
  return !1;
@@ -2506,7 +2506,7 @@ class be extends ys {
2506
2506
  );
2507
2507
  }
2508
2508
  closestPointToGeometry(t, i, e = {}, s = {}, r = 0, o = 1 / 0) {
2509
- return (this.indirect ? Hs : js)(
2509
+ return (this.indirect ? Zs : Cs)(
2510
2510
  this,
2511
2511
  t,
2512
2512
  i,
@@ -2517,7 +2517,7 @@ class be extends ys {
2517
2517
  );
2518
2518
  }
2519
2519
  closestPointToPoint(t, i = {}, e = 0, s = 1 / 0) {
2520
- return As(
2520
+ return Ms(
2521
2521
  this,
2522
2522
  t,
2523
2523
  i,
@@ -2532,11 +2532,11 @@ const It = {
2532
2532
  LineSegments: Qe.prototype.raycast,
2533
2533
  LineLoop: Gi.prototype.raycast,
2534
2534
  Points: Xi.prototype.raycast,
2535
- BatchedMesh: Rn.prototype.raycast
2535
+ BatchedMesh: Bn.prototype.raycast
2536
2536
  }, G = /* @__PURE__ */ new C(), me = [];
2537
- function Zs(n, t) {
2537
+ function Qs(n, t) {
2538
2538
  if (this.isBatchedMesh)
2539
- Qs.call(this, n, t);
2539
+ Ys.call(this, n, t);
2540
2540
  else {
2541
2541
  const { geometry: i } = this;
2542
2542
  if (i.boundsTree)
@@ -2559,13 +2559,13 @@ function Zs(n, t) {
2559
2559
  }
2560
2560
  }
2561
2561
  }
2562
- function Qs(n, t) {
2562
+ function Ys(n, t) {
2563
2563
  if (this.boundsTrees) {
2564
2564
  const i = this.boundsTrees, e = this._drawInfo || this._instanceInfo, s = this._drawRanges || this._geometryInfo, r = this.matrixWorld;
2565
2565
  G.material = this.material, G.geometry = this.geometry;
2566
- const o = G.geometry.boundsTree, f = G.geometry.drawRange;
2567
- G.geometry.boundingSphere === null && (G.geometry.boundingSphere = new Tn());
2568
- for (let a = 0, u = e.length; a < u; a++) {
2566
+ const o = G.geometry.boundsTree, d = G.geometry.drawRange;
2567
+ G.geometry.boundingSphere === null && (G.geometry.boundingSphere = new Rn());
2568
+ for (let a = 0, f = e.length; a < f; a++) {
2569
2569
  if (!this.getVisibleAt(a))
2570
2570
  continue;
2571
2571
  const l = e[a].geometryIndex;
@@ -2576,19 +2576,19 @@ function Qs(n, t) {
2576
2576
  }
2577
2577
  G.raycast(n, me);
2578
2578
  for (let p = 0, c = me.length; p < c; p++) {
2579
- const d = me[p];
2580
- d.object = this, d.batchId = a, t.push(d);
2579
+ const u = me[p];
2580
+ u.object = this, u.batchId = a, t.push(u);
2581
2581
  }
2582
2582
  me.length = 0;
2583
2583
  }
2584
- G.geometry.boundsTree = o, G.geometry.drawRange = f, G.material = null, G.geometry = null;
2584
+ G.geometry.boundsTree = o, G.geometry.drawRange = d, G.material = null, G.geometry = null;
2585
2585
  } else
2586
2586
  It.BatchedMesh.call(this, n, t);
2587
2587
  }
2588
2588
  function $e(n) {
2589
2589
  return n.type === "continuous" || !n.limits ? 0 : Math.max(n.limits.lower, Math.min(n.limits.upper, 0));
2590
2590
  }
2591
- class Ys {
2591
+ class Ks {
2592
2592
  constructor(t, i) {
2593
2593
  $(this, "root");
2594
2594
  $(this, "visual");
@@ -2599,19 +2599,19 @@ class Ys {
2599
2599
  $(this, "disposed", !1);
2600
2600
  $(this, "initialRoots", /* @__PURE__ */ new Map());
2601
2601
  this.visual = i, this.root = i.root;
2602
- const e = new Set(t.links.map((d) => d.id)), s = t.joints.filter((d) => e.has(d.parent) && e.has(d.child) && d.parent !== d.child), r = new Set(s.map((d) => d.child)), o = t.links.filter((d) => !r.has(d.id)), f = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
2603
- for (const d of s)
2604
- a.has(d.child) || (a.add(d.child), f.set(d.parent, [...f.get(d.parent) ?? [], d]));
2605
- const u = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), p = (d) => {
2606
- if (l.has(d)) return;
2607
- l.add(d), u.add(d);
2608
- const y = i.bindings.get(d);
2602
+ const e = new Set(t.links.map((u) => u.id)), s = t.joints.filter((u) => e.has(u.parent) && e.has(u.child) && u.parent !== u.child), r = new Set(s.map((u) => u.child)), o = t.links.filter((u) => !r.has(u.id)), d = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
2603
+ for (const u of s)
2604
+ a.has(u.child) || (a.add(u.child), d.set(u.parent, [...d.get(u.parent) ?? [], u]));
2605
+ const f = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), p = (u) => {
2606
+ if (l.has(u)) return;
2607
+ l.add(u), f.add(u);
2608
+ const y = i.bindings.get(u);
2609
2609
  if (!y) {
2610
- l.delete(d);
2610
+ l.delete(u);
2611
2611
  return;
2612
2612
  }
2613
- for (const g of f.get(d) ?? []) {
2614
- if (l.has(g.child) || u.has(g.child)) continue;
2613
+ for (const g of d.get(u) ?? []) {
2614
+ if (l.has(g.child) || f.has(g.child)) continue;
2615
2615
  const x = i.bindings.get(g.child);
2616
2616
  if (!x) continue;
2617
2617
  y.add(x);
@@ -2624,23 +2624,23 @@ class Ys {
2624
2624
  };
2625
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);
2626
2626
  }
2627
- l.delete(d);
2627
+ l.delete(u);
2628
2628
  }, c = o.length ? o : t.links;
2629
- for (const d of c) {
2630
- if (u.has(d.id)) continue;
2631
- const y = i.bindings.get(d.id);
2632
- y && (this.root.add(y), p(d.id));
2629
+ for (const u of c) {
2630
+ if (f.has(u.id)) continue;
2631
+ const y = i.bindings.get(u.id);
2632
+ y && (this.root.add(y), p(u.id));
2633
2633
  }
2634
- for (const d of t.links) {
2635
- if (u.has(d.id)) continue;
2636
- const y = i.bindings.get(d.id);
2637
- y && (this.root.add(y), p(d.id));
2634
+ for (const u of t.links) {
2635
+ if (f.has(u.id)) continue;
2636
+ const y = i.bindings.get(u.id);
2637
+ y && (this.root.add(y), p(u.id));
2638
2638
  }
2639
2639
  if (o.length === 1) {
2640
- const d = Zi(t, o[0].id, f), y = i.bindings.get(o[0].id);
2641
- y && d > 0 && (y.position.z += d);
2640
+ const u = Zi(t, o[0].id, d), y = i.bindings.get(o[0].id);
2641
+ y && u > 0 && (y.position.z += u);
2642
2642
  }
2643
- for (const d of i.bindings.values()) d.parent === this.root && this.initialRoots.set(d, { position: d.position.clone(), quaternion: d.quaternion.clone() });
2643
+ for (const u of i.bindings.values()) u.parent === this.root && this.initialRoots.set(u, { position: u.position.clone(), quaternion: u.quaternion.clone() });
2644
2644
  this.applyAll(), this.preparePicking(), this.root.updateMatrixWorld(!0);
2645
2645
  }
2646
2646
  pickRoots() {
@@ -2720,7 +2720,7 @@ class Ys {
2720
2720
  this.root.traverse((i) => {
2721
2721
  if (!(i instanceof C) || !i.geometry) return;
2722
2722
  const e = i.geometry;
2723
- !e.boundsTree && !t.has(e) && (e.boundsTree = new be(e, { maxLeafSize: 20, indirect: !0, verbose: !1 }), t.add(e)), i.raycast = Zs, this.pickMeshes.push(i);
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);
2724
2724
  });
2725
2725
  }
2726
2726
  apply(t, i) {
@@ -2730,46 +2730,46 @@ class Ys {
2730
2730
  function Xt(n, t) {
2731
2731
  return Object.assign(new Error(n), { code: t });
2732
2732
  }
2733
- function Ks(n, t, i = n.source.uri) {
2733
+ function to(n, t, i = n.source.uri) {
2734
2734
  var m;
2735
- const e = no(t, i), s = new Set(n.links.map((h) => h.id)), r = n.joints.filter((h) => s.has(h.parent) && s.has(h.child) && h.parent !== h.child), o = /* @__PURE__ */ new Map();
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();
2736
2736
  for (const h of r) o.has(h.child) || o.set(h.child, h);
2737
- const f = n.links.filter((h) => !o.has(h.id)), a = /* @__PURE__ */ new Map();
2737
+ const d = n.links.filter((h) => !o.has(h.id)), a = /* @__PURE__ */ new Map();
2738
2738
  for (const h of o.values()) a.set(h.parent, [...a.get(h.parent) ?? [], h]);
2739
- const u = [], l = /* @__PURE__ */ new Set(), p = (h) => {
2739
+ const f = [], l = /* @__PURE__ */ new Set(), p = (h) => {
2740
2740
  if (!l.has(h)) {
2741
2741
  l.add(h);
2742
2742
  for (const b of a.get(h) ?? []) p(b.child);
2743
2743
  }
2744
2744
  };
2745
- for (const h of f)
2746
- u.push(h), p(h.id);
2747
- for (const h of n.links) l.has(h.id) || (u.push(h), p(h.id));
2748
- const c = new Set(u.map((h) => h.id)), d = `robot:${n.name}`, y = /* @__PURE__ */ new Map();
2745
+ for (const h of d)
2746
+ f.push(h), p(h.id);
2747
+ for (const h of n.links) l.has(h.id) || (f.push(h), p(h.id));
2748
+ const c = new Set(f.map((h) => h.id)), u = `robot:${n.name}`, y = /* @__PURE__ */ new Map();
2749
2749
  for (const h of n.joints) y.set(h.parent, [...y.get(h.parent) ?? [], `joint:${h.id}`]);
2750
2750
  const g = [], x = Object.freeze({
2751
- id: d,
2751
+ id: u,
2752
2752
  kind: "robot",
2753
2753
  name: n.name,
2754
- childIds: u.map((h) => `link:${h.id}`),
2755
- rootLinkIds: u.map((h) => h.id),
2754
+ childIds: f.map((h) => `link:${h.id}`),
2755
+ rootLinkIds: f.map((h) => h.id),
2756
2756
  source: e.robot
2757
2757
  });
2758
2758
  g.push(x);
2759
- for (const h of n.links) g.push(to(h, n, e.links.get(h.id), y, c, o));
2759
+ for (const h of n.links) g.push(eo(h, n, e.links.get(h.id), y, c, o));
2760
2760
  const w = xe(n.joints);
2761
- for (const h of n.joints) g.push(eo({ ...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.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));
2762
2762
  return Object.freeze({
2763
2763
  robotName: n.name,
2764
2764
  sourcePath: i,
2765
2765
  sourceText: t,
2766
2766
  nodes: Object.freeze(g),
2767
- rootEntityId: d,
2768
- issues: Object.freeze(io(n, e))
2767
+ rootEntityId: u,
2768
+ issues: Object.freeze(no(n, e))
2769
2769
  });
2770
2770
  }
2771
- function to(n, t, i, e, s, r) {
2772
- var f, a, u, l;
2771
+ function eo(n, t, i, e, s, r) {
2772
+ var d, a, f, l;
2773
2773
  const o = r.get(n.id);
2774
2774
  return Object.freeze({
2775
2775
  id: `link:${n.id}`,
@@ -2778,16 +2778,16 @@ function to(n, t, i, e, s, r) {
2778
2778
  parentId: o ? `joint:${o.id}` : `robot:${t.name}`,
2779
2779
  childIds: Object.freeze(e.get(n.id) ?? []),
2780
2780
  source: i,
2781
- mass: (f = n.inertial) == null ? void 0 : f.mass,
2781
+ mass: (d = n.inertial) == null ? void 0 : d.mass,
2782
2782
  centerOfMass: (a = n.inertial) == null ? void 0 : a.origin.position,
2783
- inertiaTensor: (u = n.inertial) == null ? void 0 : u.tensor,
2783
+ inertiaTensor: (f = n.inertial) == null ? void 0 : f.tensor,
2784
2784
  inertiaMass: (l = n.inertial) == null ? void 0 : l.mass,
2785
2785
  inertialRotationRpy: n.inertial ? Object.freeze([...n.inertial.origin.rotationRpy]) : void 0,
2786
2786
  visualCount: n.visuals.length,
2787
2787
  collisionCount: n.collisions.length
2788
2788
  });
2789
2789
  }
2790
- function eo(n, t, i) {
2790
+ function io(n, t, i) {
2791
2791
  return Object.freeze({
2792
2792
  id: `joint:${n.id}`,
2793
2793
  kind: "joint",
@@ -2809,57 +2809,57 @@ function eo(n, t, i) {
2809
2809
  ...n.mimic ? { mimic: Object.freeze({ ...n.mimic }) } : {}
2810
2810
  });
2811
2811
  }
2812
- function io(n, t) {
2813
- const i = [], e = (c, d, y, g, x, w) => {
2814
- i.push(Object.freeze({ id: `${c}:${g}`, ruleId: c, severity: "error", title: d, message: y, entityId: g, source: x, values: w ? Object.freeze(w) : void 0 }));
2812
+ function no(n, t) {
2813
+ const i = [], e = (c, u, y, g, x, w) => {
2814
+ 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
2815
  }, s = new Set(n.links.map((c) => c.id));
2816
2816
  for (const c of n.joints)
2817
2817
  s.has(c.parent) || e("joint.parent.missing", "父连杆不存在", `${c.id} 引用了不存在的 parent link ${c.parent}。`, `joint:${c.id}`, t.joints.get(c.id), { parent: c.parent }), s.has(c.child) || e("joint.child.missing", "子连杆不存在", `${c.id} 引用了不存在的 child link ${c.child}。`, `joint:${c.id}`, t.joints.get(c.id), { child: c.child });
2818
- const r = n.links.filter((c) => !n.joints.some((d) => s.has(d.parent) && d.child === c.id));
2818
+ const r = n.links.filter((c) => !n.joints.some((u) => s.has(u.parent) && u.child === c.id));
2819
2819
  r.length !== 1 && e("robot.root.count", "根连杆数量无效", `URDF 必须恰好有一个根连杆,当前为 ${r.length} 个。`, `robot:${n.name}`, t.robot, { roots: r.map((c) => c.id) });
2820
2820
  const o = /* @__PURE__ */ new Map();
2821
2821
  for (const c of n.joints) s.has(c.parent) && s.has(c.child) && o.set(c.parent, [...o.get(c.parent) ?? [], c.child]);
2822
- const f = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
2823
- let u = null;
2824
- const l = (c, d) => {
2825
- if (!u) {
2822
+ const d = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
2823
+ let f = null;
2824
+ const l = (c, u) => {
2825
+ if (!f) {
2826
2826
  if (a.has(c)) {
2827
- const y = d.indexOf(c);
2828
- u = [...d.slice(Math.max(0, y)), c];
2827
+ const y = u.indexOf(c);
2828
+ f = [...u.slice(Math.max(0, y)), c];
2829
2829
  return;
2830
2830
  }
2831
- if (!f.has(c)) {
2831
+ if (!d.has(c)) {
2832
2832
  a.add(c);
2833
- for (const y of o.get(c) ?? []) l(y, [...d, c]);
2834
- a.delete(c), f.add(c);
2833
+ for (const y of o.get(c) ?? []) l(y, [...u, c]);
2834
+ a.delete(c), d.add(c);
2835
2835
  }
2836
2836
  }
2837
2837
  };
2838
2838
  for (const c of n.links) l(c.id, []);
2839
- u && e("robot.graph.cycle", "运动学结构存在环", `运动学链形成循环:${u.join(" → ")}。`, `robot:${n.name}`, t.robot, { cycle: u });
2839
+ f && e("robot.graph.cycle", "运动学结构存在环", `运动学链形成循环:${f.join(" → ")}。`, `robot:${n.name}`, t.robot, { cycle: f });
2840
2840
  const p = /* @__PURE__ */ new Map();
2841
2841
  for (const c of n.joints) {
2842
2842
  if (p.set(c.child, [...p.get(c.child) ?? [], c.id]), c.parent === c.child && e("joint.self-reference", "关节父子连杆相同", `${c.id} 的 parent 和 child 都是 ${c.parent}。`, `joint:${c.id}`, t.joints.get(c.id)), ["revolute", "continuous", "prismatic"].includes(c.type)) {
2843
- const d = c.axis.reduce((y, g) => y + g * g, 0);
2844
- (!Number.isFinite(d) || d <= Number.EPSILON) && e("joint.axis.zero", "关节轴无效", `${c.id} 的 axis 是零向量。`, `joint:${c.id}`, t.joints.get(c.id), { axis: c.axis });
2843
+ const u = c.axis.reduce((y, g) => y + g * g, 0);
2844
+ (!Number.isFinite(u) || u <= Number.EPSILON) && e("joint.axis.zero", "关节轴无效", `${c.id} 的 axis 是零向量。`, `joint:${c.id}`, t.joints.get(c.id), { axis: c.axis });
2845
2845
  }
2846
2846
  c.type !== "continuous" && c.limits && c.limits.lower > c.limits.upper && e("joint.limit.order", "关节限位上下界无效", `${c.id} 的 lower ${c.limits.lower} 大于 upper ${c.limits.upper}。`, `joint:${c.id}`, t.joints.get(c.id), { ...c.limits });
2847
2847
  }
2848
- for (const [c, d] of p) d.length > 1 && e("link.multiple-parents", "连杆存在多个父关节", `${c} 同时被 ${d.join("、")} 作为 child。`, `link:${c}`, t.links.get(c), { joints: d });
2848
+ 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
2849
  for (const c of n.links) {
2850
- const d = c.inertial;
2851
- d && ((!(d.mass > 0) || !Number.isFinite(d.mass)) && e("inertial.mass.invalid", "质量无效", `${c.id} 的质量必须是大于零的有限数。`, `link:${c.id}`, t.links.get(c.id), { mass: d.mass }), Hi(d.tensor) || e("inertial.tensor.invalid", "惯性张量无效", `${c.id} 的惯性张量不是正定的物理惯性张量。`, `link:${c.id}`, t.links.get(c.id), { tensor: d.tensor }));
2850
+ 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 }));
2852
2852
  }
2853
2853
  return i;
2854
2854
  }
2855
- function no(n, t) {
2855
+ function so(n, t) {
2856
2856
  const i = { robot: void 0, links: /* @__PURE__ */ new Map(), joints: /* @__PURE__ */ new Map() };
2857
2857
  i.robot = ki(n, "robot", void 0, t);
2858
2858
  for (const e of ["link", "joint"]) {
2859
2859
  const s = new RegExp(`<${e}\\b[^>]*\\bname\\s*=\\s*(["'])(.*?)\\1[^>]*>`, "gi");
2860
2860
  for (const r of n.matchAll(s)) {
2861
- const o = r[2], f = ki(n, e, o, t, r.index);
2862
- f && i[e === "link" ? "links" : "joints"].set(o, f);
2861
+ const o = r[2], d = ki(n, e, o, t, r.index);
2862
+ d && i[e === "link" ? "links" : "joints"].set(o, d);
2863
2863
  }
2864
2864
  }
2865
2865
  return i;
@@ -2869,14 +2869,14 @@ function ki(n, t, i, e, s) {
2869
2869
  if (r < 0) return;
2870
2870
  const o = n.indexOf(">", r);
2871
2871
  if (o < 0) return;
2872
- const a = n.slice(r, o + 1).trimEnd().endsWith("/>") ? o + 1 : n.indexOf(`</${t}>`, o + 1), u = a < 0 ? o + 1 : a + t.length + 3, l = ji(n, r), p = ji(n, u);
2873
- return Object.freeze({ file: e, startOffset: r, endOffset: u, startLine: l.line, startColumn: l.column, endLine: p.line, endColumn: p.column });
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);
2873
+ return Object.freeze({ file: e, startOffset: r, endOffset: f, startLine: l.line, startColumn: l.column, endLine: p.line, endColumn: p.column });
2874
2874
  }
2875
2875
  function ji(n, t) {
2876
2876
  const e = n.slice(0, t).split(/\r?\n/);
2877
2877
  return { line: e.length, column: e.at(-1).length + 1 };
2878
2878
  }
2879
- class so {
2879
+ class oo {
2880
2880
  constructor(t, i, e, s, r) {
2881
2881
  $(this, "kind", "urdf");
2882
2882
  $(this, "overlayRoot", new ut());
@@ -2896,8 +2896,8 @@ class so {
2896
2896
  $(this, "labelAnchors", /* @__PURE__ */ new Map());
2897
2897
  $(this, "modelSize", 1);
2898
2898
  $(this, "disposed", !1);
2899
- var o, f;
2900
- this.asset = t, this.document = i, this.binding = e, this.options = s, this.selectedEntityId = ((o = i.nodes.find((a) => a.kind === "joint")) == null ? void 0 : o.id) ?? ((f = i.nodes.find((a) => a.kind === "link")) == null ? void 0 : f.id) ?? i.rootEntityId, this.mode = "kinematic", this.dynamicsAvailable = r, this.overlayRoot.name = "URDF review overlays", this.measureGuideSizes(), this.rebuildOverlay();
2899
+ var o, d;
2900
+ this.asset = t, this.document = i, this.binding = e, this.options = s, this.selectedEntityId = ((o = i.nodes.find((a) => a.kind === "joint")) == null ? void 0 : o.id) ?? ((d = i.nodes.find((a) => a.kind === "link")) == null ? void 0 : d.id) ?? i.rootEntityId, this.mode = "kinematic", this.dynamicsAvailable = r, this.overlayRoot.name = "URDF review overlays", this.measureGuideSizes(), this.rebuildOverlay();
2901
2901
  }
2902
2902
  getSnapshot() {
2903
2903
  return Object.freeze({
@@ -2922,7 +2922,7 @@ class so {
2922
2922
  }
2923
2923
  select(t) {
2924
2924
  if (!(this.mode === "dynamics-running" || this.mode === "dynamics-initializing")) {
2925
- if (t !== null && !this.document.nodes.some((i) => i.id === t)) throw oo(`Unknown URDF entity: ${t}`, "E_URDF_ENTITY_UNKNOWN");
2925
+ if (t !== null && !this.document.nodes.some((i) => i.id === t)) throw ro(`Unknown URDF entity: ${t}`, "E_URDF_ENTITY_UNKNOWN");
2926
2926
  this.selectedEntityId !== t && (this.selectedEntityId = t, this.rebuildOverlay(), this.publish());
2927
2927
  }
2928
2928
  }
@@ -3009,13 +3009,13 @@ class so {
3009
3009
  const r = new it(), o = (a) => {
3010
3010
  if (!(a !== s && typeof a.userData.urdfEntityId == "string")) {
3011
3011
  a instanceof C && (a.geometry.boundingBox || a.geometry.computeBoundingBox(), a.geometry.boundingBox && r.union(a.geometry.boundingBox.clone().applyMatrix4(a.matrixWorld)));
3012
- for (const u of a.children) o(u);
3012
+ for (const f of a.children) o(f);
3013
3013
  }
3014
3014
  };
3015
3015
  if (o(s), r.isEmpty()) continue;
3016
3016
  this.labelAnchors.set(e.name, r.getCenter(new z()).applyMatrix4(s.matrixWorld.clone().invert()));
3017
- const f = r.getSize(new z()).length();
3018
- Number.isFinite(f) && f > 0 && (this.guideSizes.set(e.name, f), t.union(r));
3017
+ const d = r.getSize(new z()).length();
3018
+ Number.isFinite(d) && d > 0 && (this.guideSizes.set(e.name, d), t.union(r));
3019
3019
  }
3020
3020
  const i = t.getSize(new z()).length();
3021
3021
  Number.isFinite(i) && i > 0 && (this.modelSize = i);
@@ -3034,28 +3034,28 @@ class so {
3034
3034
  if (e.kind !== "joint" || !this.overlays.jointAxis && e.id !== (i == null ? void 0 : i.id)) continue;
3035
3035
  const s = this.linkObject(e.parentLink), r = s ? (() => {
3036
3036
  s.updateWorldMatrix(!0, !1);
3037
- const u = s.getWorldQuaternion(new K()).multiply(new K().setFromEuler(new Zt(...e.originRotationRpy, "ZYX")));
3038
- return { position: new z().fromArray(e.originPosition).applyMatrix4(s.matrixWorld), quaternion: u, axis: new z().fromArray(e.axis).applyQuaternion(u).normalize() };
3037
+ const f = s.getWorldQuaternion(new K()).multiply(new K().setFromEuler(new Zt(...e.originRotationRpy, "ZYX")));
3038
+ return { position: new z().fromArray(e.originPosition).applyMatrix4(s.matrixWorld), quaternion: f, axis: new z().fromArray(e.axis).applyQuaternion(f).normalize() };
3039
3039
  })() : this.binding.jointWorldFrame(e.name);
3040
3040
  if (!r) continue;
3041
3041
  const o = new ut();
3042
3042
  o.name = `Joint guide:${e.name}`;
3043
- const f = this.guideSize(e.childLink), a = new Bn(0.18 * f);
3043
+ const d = this.guideSize(e.childLink), a = new _n(0.18 * d);
3044
3044
  if (a.name = `Joint frame:${e.name}`, a.position.copy(r.position), a.quaternion.copy(r.quaternion), o.add(a), ["revolute", "continuous", "prismatic"].includes(e.jointType)) {
3045
- const u = r.axis.clone().normalize(), l = new di(u, r.position, 0.28 * f, 5625523, 0.045 * f, 0.022 * f);
3045
+ const f = r.axis.clone().normalize(), l = new di(f, r.position, 0.28 * d, 5625523, 0.045 * d, 0.022 * d);
3046
3046
  if (l.name = `Joint axis:${e.name}`, o.add(l), e.jointType !== "prismatic") {
3047
- const c = (Math.abs(u.z) < 0.9 ? new z(0, 0, 1) : new z(0, 1, 0)).cross(u).normalize(), d = u.clone().cross(c).normalize(), y = 0.09 * f, g = Math.PI * 1.65, x = r.position.clone().addScaledVector(u, 0.085 * f), w = Array.from({ length: 33 }, (A, P) => {
3047
+ 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
3048
  const M = g * P / 32;
3049
- return x.clone().addScaledVector(c, y * Math.cos(M)).addScaledVector(d, y * Math.sin(M));
3050
- }), m = new Ye(new _n().setFromPoints(w), new pi({ color: 16761963 }));
3049
+ 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 }));
3051
3051
  m.name = `Positive rotation:${e.name}`;
3052
- const h = c.clone().multiplyScalar(-Math.sin(g)).addScaledVector(d, Math.cos(g)), b = new di(h, w[32], 0.03 * f, 16761963, 0.03 * f, 0.022 * f);
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);
3053
3053
  b.name = `Positive rotation arrow:${e.name}`, o.add(m, b);
3054
3054
  }
3055
3055
  }
3056
- o.traverse((u) => {
3057
- u.renderOrder = 1001;
3058
- const l = u.material;
3056
+ o.traverse((f) => {
3057
+ f.renderOrder = 1001;
3058
+ const l = f.material;
3059
3059
  for (const p of Array.isArray(l) ? l : l ? [l] : [])
3060
3060
  p.depthTest = !1, p.depthWrite = !1, p.transparent = !0;
3061
3061
  }), this.overlayRoot.add(o), s && this.trackGuide(o, s);
@@ -3068,10 +3068,10 @@ class so {
3068
3068
  const s = e.inertial, r = this.linkObject(e.id);
3069
3069
  if (!s || !r) continue;
3070
3070
  r.updateWorldMatrix(!0, !1);
3071
- const o = new z().fromArray(s.origin.position).applyMatrix4(r.matrixWorld), f = e.id === i;
3071
+ const o = new z().fromArray(s.origin.position).applyMatrix4(r.matrixWorld), d = e.id === i;
3072
3072
  if (this.overlays.centerOfMass) {
3073
- const d = new Ze(0.025 * this.guideSize(e.id), 32, 16), y = d.toNonIndexed();
3074
- d.dispose();
3073
+ const u = new Ze(0.025 * this.guideSize(e.id), 32, 16), y = u.toNonIndexed();
3074
+ u.dispose();
3075
3075
  const g = y.getAttribute("position"), x = new Float32Array(g.count * 3);
3076
3076
  for (let m = 0; m < g.count; m += 3) {
3077
3077
  let h = 0, b = 0, A = 0;
@@ -3080,13 +3080,13 @@ class so {
3080
3080
  const P = h * b * A >= 0 ? 1 : 0.015;
3081
3081
  for (let M = 0; M < 9; M++) x[m * 3 + M] = P;
3082
3082
  }
3083
- y.setAttribute("color", new En(x, 3));
3084
- const w = new C(y, new mi({ color: f ? 16739210 : 16777215, vertexColors: !0, depthTest: !1, depthWrite: !1 }));
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
3085
  w.quaternion.copy(r.getWorldQuaternion(new K())), w.position.copy(o), w.renderOrder = 1002, w.name = `Center of mass:${e.id}`, this.overlayRoot.add(w), this.trackGuide(w, r);
3086
3086
  }
3087
- const a = this.overlays.inertia ? jn(s.tensor, s.mass) : null;
3087
+ const a = this.overlays.inertia ? Cn(s.tensor, s.mass) : null;
3088
3088
  if (!a) continue;
3089
- const u = new He(1, 1, 1), l = new Qe(new zn(u), new pi({ color: f ? 16736135 : 2211300, transparent: !0, opacity: f ? 0.98 : 0.82, depthTest: !0, depthWrite: !1 })), p = new C(u, new mi({ color: f ? 16739210 : 3262699, transparent: !0, opacity: f ? 0.28 : 0.16, depthTest: !0, depthWrite: !1 }));
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 }));
3090
3090
  p.name = `Inertia fill:${e.id}`;
3091
3091
  const c = s.origin.rotationQuaternion ? new K().fromArray(s.origin.rotationQuaternion) : new K().setFromEuler(new Zt(...s.origin.rotationRpy, "ZYX"));
3092
3092
  l.position.copy(o), l.scale.fromArray(a.size), l.quaternion.copy(r.getWorldQuaternion(new K())).multiply(c).multiply(a.rotation), l.renderOrder = 1001, l.name = `Inertia:${e.id}`, p.position.copy(l.position), p.quaternion.copy(l.quaternion), p.scale.copy(l.scale), p.renderOrder = 1e3, this.overlayRoot.add(p, l), this.trackGuide(p, r), this.trackGuide(l, r);
@@ -3113,73 +3113,79 @@ class so {
3113
3113
  this.highlightedMaterials.clear();
3114
3114
  }
3115
3115
  }
3116
- function oo(n, t) {
3116
+ function ro(n, t) {
3117
3117
  return Object.assign(new Error(n), { code: t });
3118
3118
  }
3119
- async function yo(n, t, i) {
3119
+ async function go(n, t, i) {
3120
3120
  var _, E, F, D;
3121
3121
  const e = n.entryPath ?? n.filename ?? "asset.urdf";
3122
3122
  (_ = t.reportProgress) == null || _.call(t, "fetch", "正在读取模型描述与依赖资源...");
3123
- let s = await hn(n, i);
3123
+ let s = await yn(n, i);
3124
3124
  const r = t.format === "xacro";
3125
3125
  if (r) {
3126
3126
  (E = t.reportProgress) == null || E.call(t, "xacro", "正在展开 Xacro 宏与依赖文件...");
3127
- const { expandXacro: U } = await import("./xacro-Cl87kJRU.js");
3127
+ const { expandXacro: U } = await import("./xacro-DPEhwEml.js");
3128
3128
  s = await U(s, e, i, t.options.xacro, t.signal);
3129
3129
  }
3130
3130
  if (t.signal.aborted) throw Jt();
3131
3131
  (F = t.reportProgress) == null || F.call(t, "parse", "正在解析 URDF 结构与连杆...");
3132
- const o = Cn(s, e, i);
3132
+ const o = Nn(s, e, i);
3133
3133
  (D = t.reportProgress) == null || D.call(t, "visual", "正在构建运动学预览...");
3134
- const f = await gi(o), a = new Ys(o, f), u = await Vn(o, f), l = o.diagnostics.errors.find((U) => U.code === "E_URDF_INERTIA"), p = o.links.some((U) => U.inertial), c = p && !l, d = new gn(a.root, t.options.simulationTheme, void 0);
3135
- u && (u.root.visible = !1, d.attachAuxiliary(u.root));
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(
3135
+ a.root,
3136
+ t.options.simulationTheme,
3137
+ void 0,
3138
+ "simulation",
3139
+ c ? "physics" : "visual"
3140
+ );
3141
+ f && (f.root.visible = !1, u.attachAuxiliary(f.root));
3136
3142
  let y = null, g = null, x = null;
3137
3143
  const w = o.diagnostics.warnings[0], m = w ? { ...w, stage: "visual-material" } : null;
3138
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;
3139
3145
  const R = () => {
3140
3146
  var L;
3141
3147
  const U = A || !a.root.visible;
3142
- A = !1, d.setRuntime(void 0), g && (g.root.visible = !1), d.replaceModel(a.root, !1), a.root.visible = !0, u && u.sync(), u != null && u.root && (u.root.visible = v.getSnapshot().overlays.collision), x && (x.root.visible = !1), U && ((L = t.reportSessionState) == null || L.call(t)), t.requestRender();
3143
- }, v = new so(o, Ks(o, s, r ? `${e} (expanded URDF)` : e), a, {
3148
+ 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, {
3144
3150
  requestRender() {
3145
- a.root.visible && (u == null || u.sync()), t.requestRender();
3151
+ a.root.visible && (f == null || f.sync()), t.requestRender();
3146
3152
  },
3147
3153
  setCollisionVisible(U) {
3148
- u && (u.root.visible = U && a.root.visible), x && (x.root.visible = U && (g == null ? void 0 : g.root.visible) === !0);
3154
+ f && (f.root.visible = U && a.root.visible), x && (x.root.visible = U && (g == null ? void 0 : g.root.visible) === !0);
3149
3155
  },
3150
3156
  enterKinematicPreview: R,
3151
3157
  linkObject: (U) => g != null && g.root.visible ? g.objectForLink(U) : a.objectForEntity(`link:${U}`),
3152
3158
  pickRoots: () => A || b.status === "initializing" ? [] : a.pickRoots()
3153
3159
  }, c);
3154
- l && v.setMode("dynamics-unavailable", l.message), d.attachAuxiliary(v.overlayRoot);
3155
- const B = () => !y || !g ? !1 : (y.setJointValues(v.getSnapshot().jointValues), d.replaceModel(g.root, !1), d.setRuntime(y), g.sync(), x == null || x.sync(), a.root.visible = !1, g.root.visible = !0, u && (u.root.visible = !1), x && (x.root.visible = v.getSnapshot().overlays.collision), !0), S = async () => {
3160
+ l && v.setMode("dynamics-unavailable", l.message), u.attachAuxiliary(v.overlayRoot);
3161
+ 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 () => {
3156
3162
  var Mt, vt, Pt;
3157
3163
  if (y || M || !c) return;
3158
3164
  v.setMode("dynamics-initializing"), b = { status: "initializing" }, (Mt = t.reportSessionState) == null || Mt.call(t);
3159
3165
  let U = null, L = null, Y = null;
3160
3166
  try {
3161
- const rt = await On(o);
3167
+ const rt = await Vn(o);
3162
3168
  if (t.signal.aborted || M) throw Jt();
3163
- const kt = await import("./mujoco-runtime-7xiBQNJm.js");
3164
- if (U = new kt.MujocoRuntime(), await U.initialize(rt, t.options.mujocoBaseUrl), U.setWorldRotation(ci(d.getUpAxis())), t.signal.aborted || M || (L = new ai(U, await gi(o)), t.signal.aborted || M)) throw Jt();
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();
3165
3171
  const at = await Qi(o);
3166
3172
  if (Y = at ? new ai(U, at) : null, t.signal.aborted || M) throw Jt();
3167
- y = U, U = null, g = L, L = null, g.root.visible = !1, x = Y, Y = null, x && (x.root.visible = !1, d.attachAuxiliary(x.root)), b = { status: "ready" }, h = m, T && (B(), A = !0, v.setMode("dynamics-running")), (vt = t.reportSessionState) == null || vt.call(t), t.requestRender();
3173
+ 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();
3168
3174
  } catch (rt) {
3169
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;
3170
- const kt = yn(rt, t.signal, "urdf-physics");
3171
- d.setRuntime(void 0), y == null || y.dispose(), y = null, g == null || g.dispose(), g = null, x && (d.detachAuxiliary(x.root), x.dispose(), x = null), R(), h = { ...kt, stage: "physics-fallback" }, b = { status: "unavailable", issue: h }, v.setMode("dynamics-unavailable", h.message), (Pt = t.reportSessionState) == null || Pt.call(t), t.reportError(rt, { fatal: !1, stage: "physics-start", code: kt.code });
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 });
3172
3178
  }
3173
3179
  };
3174
3180
  return {
3175
3181
  asset: o,
3176
- stage: d,
3182
+ stage: u,
3177
3183
  inspection: v,
3178
3184
  autoPlay: !1,
3179
- root: d.root,
3185
+ root: u.root,
3180
3186
  get capabilities() {
3181
3187
  const U = b.status === "initializing", L = b.status === "unavailable" || b.status === "not-authored";
3182
- return { canPlay: !U && !L, canPause: y !== null, canReset: !0, hasPhysics: y !== null, canToggleGround: !0, canToggleCollision: u !== void 0 || x !== null, canReorientUpAxis: !0 };
3188
+ return { canPlay: !U && !L, canPause: y !== null, canReset: !0, hasPhysics: y !== null, canToggleGround: !0, canToggleCollision: f !== void 0 || x !== null, canReorientUpAxis: !0 };
3183
3189
  },
3184
3190
  get physics() {
3185
3191
  return b;
@@ -3202,38 +3208,38 @@ async function yo(n, t, i) {
3202
3208
  },
3203
3209
  pause() {
3204
3210
  var U;
3205
- T = !1, A = !1, d.endGrab(), y && (a.syncPhysicsPose(y.getJointValues(o.joints.map((L) => L.id)), ro(g.bodyPoses(), ci(d.getUpAxis()))), R(), v.setMode("dynamics-paused")), (U = t.reportSessionState) == null || U.call(t), t.requestRender();
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();
3206
3212
  },
3207
3213
  reset() {
3208
3214
  var U;
3209
- T = !1, d.endGrab(), y && (y.reset(), g == null || g.sync(), x == null || x.sync()), v.resetPose(), d.resetGround(), (U = t.reportSessionState) == null || U.call(t), t.requestRender();
3215
+ T = !1, u.endGrab(), y && (y.reset(), g == null || g.sync(), x == null || x.sync()), v.resetPose(), u.resetGround(), (U = t.reportSessionState) == null || U.call(t), t.requestRender();
3210
3216
  },
3211
3217
  step(U) {
3212
3218
  if (!y || !A) return !1;
3213
3219
  const L = y.step(U);
3214
- return L && (g == null || g.sync(), x == null || x.sync(), v.syncGuides(), d.updateForceLine()), L;
3220
+ return L && (g == null || g.sync(), x == null || x.sync(), v.syncGuides(), u.updateForceLine()), L;
3215
3221
  },
3216
3222
  beginGrab(U, L, Y) {
3217
- return !!(y && d.beginGrab(U, L, Y));
3223
+ return !!(y && u.beginGrab(U, L, Y));
3218
3224
  },
3219
3225
  moveGrab(U, L, Y) {
3220
- y && d.moveGrab(U, L, Y);
3226
+ y && u.moveGrab(U, L, Y);
3221
3227
  },
3222
3228
  endGrab() {
3223
- d.endGrab();
3229
+ u.endGrab();
3224
3230
  },
3225
3231
  setCollisionVisible(U) {
3226
- u && (u.root.visible = U && a.root.visible), x && (x.root.visible = U && (g == null ? void 0 : g.root.visible) === !0);
3232
+ f && (f.root.visible = U && a.root.visible), x && (x.root.visible = U && (g == null ? void 0 : g.root.visible) === !0);
3227
3233
  },
3228
3234
  dispose() {
3229
- M || (M = !0, A = !1, v.dispose(), u && (d.detachAuxiliary(u.root), u.dispose()), x && (d.detachAuxiliary(x.root), x.dispose()), d.setRuntime(void 0), g == null || g.dispose(), a.dispose(), y == null || y.dispose(), d.dispose());
3235
+ M || (M = !0, A = !1, v.dispose(), f && (u.detachAuxiliary(f.root), f.dispose()), x && (u.detachAuxiliary(x.root), x.dispose()), u.setRuntime(void 0), g == null || g.dispose(), a.dispose(), y == null || y.dispose(), u.dispose());
3230
3236
  }
3231
3237
  };
3232
3238
  }
3233
3239
  function Jt() {
3234
3240
  return Object.assign(new Error("Simulation load aborted."), { name: "AbortError", code: "E_ABORTED" });
3235
3241
  }
3236
- function ro(n, t) {
3242
+ function ao(n, t) {
3237
3243
  const i = t.clone().invert(), e = /* @__PURE__ */ new Map();
3238
3244
  for (const [s, r] of n)
3239
3245
  e.set(s, {
@@ -3243,5 +3249,5 @@ function ro(n, t) {
3243
3249
  return e;
3244
3250
  }
3245
3251
  export {
3246
- yo as loadUrdfSimulation
3252
+ go as loadUrdfSimulation
3247
3253
  };