@thinkersteps_labs/3d-viewer-core 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -24,17 +24,17 @@ class De extends Error {
24
24
  }
25
25
  }
26
26
  class Nt extends Error {
27
- constructor(e, i, r) {
27
+ constructor(e, i, o) {
28
28
  super(e);
29
29
  re(this, "status");
30
30
  re(this, "url");
31
- this.name = "NetworkError", this.status = i, this.url = r, Object.setPrototypeOf(this, Nt.prototype);
31
+ this.name = "NetworkError", this.status = i, this.url = o, Object.setPrototypeOf(this, Nt.prototype);
32
32
  }
33
33
  }
34
34
  function Vt(n) {
35
35
  n.position.set(0, 0, 0), n.scale.set(1, 1, 1), n.updateMatrixWorld(!0);
36
- const t = new v.Box3().setFromObject(n), e = t.getCenter(new v.Vector3()), i = t.getSize(new v.Vector3()), r = Math.max(i.x, i.y, i.z), o = r > 0 ? 1 / r : 1;
37
- n.scale.setScalar(o), n.position.sub(e.multiplyScalar(o)), n.updateMatrixWorld(!0);
36
+ const t = new v.Box3().setFromObject(n), e = t.getCenter(new v.Vector3()), i = t.getSize(new v.Vector3()), o = Math.max(i.x, i.y, i.z), r = o > 0 ? 1 / o : 1;
37
+ n.scale.setScalar(r), n.position.sub(e.multiplyScalar(r)), n.updateMatrixWorld(!0);
38
38
  }
39
39
  const Ti = "https://www.gstatic.com/draco/versioned/decoders/1.5.6/";
40
40
  if (typeof globalThis.FileReader > "u") {
@@ -48,12 +48,12 @@ if (typeof globalThis.FileReader > "u") {
48
48
  readAsArrayBuffer(e) {
49
49
  e.arrayBuffer().then(
50
50
  (i) => {
51
- var r, o;
52
- this.result = i, (r = this.onload) == null || r.call(this), (o = this.onloadend) == null || o.call(this);
51
+ var o, r;
52
+ this.result = i, (o = this.onload) == null || o.call(this), (r = this.onloadend) == null || r.call(this);
53
53
  },
54
54
  (i) => {
55
- var r, o;
56
- (r = this.onerror) == null || r.call(this, i), (o = this.onloadend) == null || o.call(this);
55
+ var o, r;
56
+ (o = this.onerror) == null || o.call(this, i), (r = this.onloadend) == null || r.call(this);
57
57
  }
58
58
  );
59
59
  }
@@ -61,12 +61,12 @@ if (typeof globalThis.FileReader > "u") {
61
61
  e.arrayBuffer().then(
62
62
  (i) => {
63
63
  var s, a;
64
- const r = globalThis.Buffer, o = r ? r.from(i).toString("base64") : "";
65
- this.result = `data:${e.type};base64,${o}`, (s = this.onload) == null || s.call(this), (a = this.onloadend) == null || a.call(this);
64
+ const o = globalThis.Buffer, r = o ? o.from(i).toString("base64") : "";
65
+ this.result = `data:${e.type};base64,${r}`, (s = this.onload) == null || s.call(this), (a = this.onloadend) == null || a.call(this);
66
66
  },
67
67
  (i) => {
68
- var r, o;
69
- (r = this.onerror) == null || r.call(this, i), (o = this.onloadend) == null || o.call(this);
68
+ var o, r;
69
+ (o = this.onerror) == null || o.call(this, i), (r = this.onloadend) == null || r.call(this);
70
70
  }
71
71
  );
72
72
  }
@@ -96,9 +96,9 @@ function Ci(n) {
96
96
  };
97
97
  }
98
98
  async function So(n, t, e) {
99
- const { loader: i, dispose: r } = Ci({ dracoDecoderPath: e });
99
+ const { loader: i, dispose: o } = Ci({ dracoDecoderPath: e });
100
100
  try {
101
- const o = await new Promise((s, a) => {
101
+ const r = await new Promise((s, a) => {
102
102
  i.parse(
103
103
  n.data,
104
104
  "",
@@ -106,11 +106,11 @@ async function So(n, t, e) {
106
106
  a
107
107
  );
108
108
  });
109
- return Vt(o.scene), { scene: o.scene, animations: o.animations, warnings: t };
110
- } catch (o) {
111
- throw new De("Failed to parse GLTF/GLB", o);
109
+ return Vt(r.scene), { scene: r.scene, warnings: t };
110
+ } catch (r) {
111
+ throw new De("Failed to parse GLTF/GLB", r);
112
112
  } finally {
113
- r();
113
+ o();
114
114
  }
115
115
  }
116
116
  async function To(n, t) {
@@ -121,19 +121,19 @@ async function To(n, t) {
121
121
  throw new De("Failed to load STL parser module. Please check your network connection.", c);
122
122
  }
123
123
  const i = new e();
124
- let r;
124
+ let o;
125
125
  try {
126
- r = i.parse(n.data);
126
+ o = i.parse(n.data);
127
127
  } catch (c) {
128
128
  throw new De("Failed to parse STL", c);
129
129
  }
130
- const o = new v.MeshPhysicalMaterial({
130
+ const r = new v.MeshPhysicalMaterial({
131
131
  name: "metal",
132
132
  color: 12632256,
133
133
  metalness: 1,
134
134
  roughness: 0.1,
135
135
  envMapIntensity: 1
136
- }), s = new v.Mesh(r, o);
136
+ }), s = new v.Mesh(o, r);
137
137
  s.name = "metal";
138
138
  const a = new v.Group();
139
139
  return a.add(s), Vt(a), { scene: a, warnings: t };
@@ -150,21 +150,21 @@ async function Co(n, t) {
150
150
  throw new De("Failed to load OBJ parser module. Please check your network connection.", a);
151
151
  }
152
152
  n.mtlData || t.push("No material file provided; default material applied");
153
- let r;
153
+ let o;
154
154
  if (n.mtlData) {
155
155
  const a = new i(), c = new TextDecoder().decode(n.mtlData);
156
156
  try {
157
- r = a.parse(c, ""), r.preload();
157
+ o = a.parse(c, ""), o.preload();
158
158
  } catch {
159
- t.push("Failed to parse MTL file; default material applied"), r = void 0;
159
+ t.push("Failed to parse MTL file; default material applied"), o = void 0;
160
160
  }
161
161
  }
162
- const o = new e();
163
- r && o.setMaterials(r);
162
+ const r = new e();
163
+ o && r.setMaterials(o);
164
164
  let s;
165
165
  try {
166
166
  const a = new TextDecoder().decode(n.data);
167
- s = o.parse(a);
167
+ s = r.parse(a);
168
168
  } catch (a) {
169
169
  throw new De("Failed to parse OBJ", a);
170
170
  }
@@ -178,18 +178,18 @@ async function Bo(n) {
178
178
  throw new De("Failed to load GLTFExporter module. Please check your network connection.", i);
179
179
  }
180
180
  const e = new t();
181
- return new Promise((i, r) => {
181
+ return new Promise((i, o) => {
182
182
  e.parse(
183
183
  n,
184
- (o) => {
185
- if (o instanceof ArrayBuffer)
186
- i(o);
184
+ (r) => {
185
+ if (r instanceof ArrayBuffer)
186
+ i(r);
187
187
  else {
188
- const s = JSON.stringify(o), a = new TextEncoder().encode(s);
188
+ const s = JSON.stringify(r), a = new TextEncoder().encode(s);
189
189
  i(a.buffer);
190
190
  }
191
191
  },
192
- r,
192
+ o,
193
193
  { binary: !0 }
194
194
  );
195
195
  });
@@ -207,11 +207,11 @@ class Io {
207
207
  }
208
208
  emit(t, e) {
209
209
  var i;
210
- (i = this._listeners.get(t)) == null || i.forEach((r) => {
210
+ (i = this._listeners.get(t)) == null || i.forEach((o) => {
211
211
  try {
212
- r(e);
213
- } catch (o) {
214
- console.error(`[3d-viewer] uncaught listener error on "${String(t)}":`, o);
212
+ o(e);
213
+ } catch (r) {
214
+ console.error(`[3d-viewer] uncaught listener error on "${String(t)}":`, r);
215
215
  }
216
216
  });
217
217
  }
@@ -251,9 +251,9 @@ async function qn(n) {
251
251
  const t = new Uint8Array(n);
252
252
  if (t.length >= 2 && t[0] === 31 && t[1] === 139 && typeof DecompressionStream < "u")
253
253
  try {
254
- const e = new DecompressionStream("gzip"), i = new Blob([n]).stream().pipeThrough(e), r = await new Response(i).arrayBuffer();
255
- if (r.byteLength > 0)
256
- return r;
254
+ const e = new DecompressionStream("gzip"), i = new Blob([n]).stream().pipeThrough(e), o = await new Response(i).arrayBuffer();
255
+ if (o.byteLength > 0)
256
+ return o;
257
257
  } catch (e) {
258
258
  console.warn("[fetchSource] Decompression failed, proceeding with original buffer:", e);
259
259
  }
@@ -283,18 +283,18 @@ async function Eo(n, t) {
283
283
  const s = i.headers.get("content-type") ?? "";
284
284
  e = Do(s);
285
285
  }
286
- let r = await i.arrayBuffer();
287
- if (r = await qn(r), e || (e = On(r)), !e)
286
+ let o = await i.arrayBuffer();
287
+ if (o = await qn(o), e || (e = On(o)), !e)
288
288
  throw new Cn("unknown");
289
- let o;
289
+ let r;
290
290
  if (n.mtlUrl) {
291
291
  const s = await fetch(n.mtlUrl, {
292
292
  headers: n.headers,
293
293
  signal: t
294
294
  });
295
- s.ok && (o = await s.arrayBuffer());
295
+ s.ok && (r = await s.arrayBuffer());
296
296
  }
297
- return { data: r, mtlData: o, format: e };
297
+ return { data: o, mtlData: r, format: e };
298
298
  }
299
299
  const _o = ["glb", "gltf", "obj", "stl"];
300
300
  function No(n) {
@@ -315,22 +315,21 @@ function Rs(n) {
315
315
  }
316
316
  async function Lo(n, t, e, i) {
317
317
  e == null || e(0);
318
- const r = await Eo(n, t);
318
+ const o = await Eo(n, t);
319
319
  e == null || e(0.3);
320
- const { scene: o, animations: s, warnings: a } = await Ao(r, i == null ? void 0 : i.dracoDecoderPath);
320
+ const { scene: r, warnings: s } = await Ao(o, i == null ? void 0 : i.dracoDecoderPath);
321
321
  e == null || e(0.7);
322
- const c = r.format === "glb" ? r.data : await Bo(o);
322
+ const a = o.format === "glb" ? o.data : await Bo(r);
323
323
  e == null || e(1);
324
- let u = 0;
325
- return o.traverse((f) => {
326
- f.isMesh && u++;
324
+ let c = 0;
325
+ return r.traverse((u) => {
326
+ u.isMesh && c++;
327
327
  }), {
328
- glb: c,
329
- scene: o,
330
- animations: s,
331
- sourceFormat: r.format,
332
- meshCount: u,
333
- warnings: a
328
+ glb: a,
329
+ scene: r,
330
+ sourceFormat: o.format,
331
+ meshCount: c,
332
+ warnings: s
334
333
  };
335
334
  }
336
335
  const zo = ["stone", "diamond", "gem", "jewel", "crystal"], ko = ["metal", "gold", "silver", "platinum", "band", "ring", "prong", "shank"];
@@ -356,17 +355,17 @@ function Uo(n, t, e) {
356
355
  if (!e.has(u))
357
356
  return e.add(u), u;
358
357
  }
359
- let i = n.name ? n.name.trim() : "mesh", r = n.parent;
360
- for (; r && r !== t; )
361
- r.name && r.name.trim() && (i = `${r.name.trim()}/${i}`), r = r.parent;
362
- let o = i, s = 1;
363
- for (; e.has(o); )
364
- o = `${i}_${s++}`;
365
- return e.add(o), o;
358
+ let i = n.name ? n.name.trim() : "mesh", o = n.parent;
359
+ for (; o && o !== t; )
360
+ o.name && o.name.trim() && (i = `${o.name.trim()}/${i}`), o = o.parent;
361
+ let r = i, s = 1;
362
+ for (; e.has(r); )
363
+ r = `${i}_${s++}`;
364
+ return e.add(r), r;
366
365
  }
367
366
  function Vo(n) {
368
- var r, o, s;
369
- if (Array.isArray((r = n.userData) == null ? void 0 : r.originalSlots) && n.userData.originalSlots.length > 0)
367
+ var o, r, s;
368
+ if (Array.isArray((o = n.userData) == null ? void 0 : o.originalSlots) && n.userData.originalSlots.length > 0)
370
369
  return n.userData.originalSlots;
371
370
  if (Array.isArray(n.material))
372
371
  return n.material.map((a, c) => {
@@ -378,7 +377,7 @@ function Vo(n) {
378
377
  index: c
379
378
  };
380
379
  });
381
- const t = n.material, e = ((o = t == null ? void 0 : t.name) == null ? void 0 : o.trim()) || (n.name ? `${n.name}_mat` : "default");
380
+ const t = n.material, e = ((r = t == null ? void 0 : t.name) == null ? void 0 : r.trim()) || (n.name ? `${n.name}_mat` : "default");
382
381
  return [
383
382
  {
384
383
  slotId: typeof ((s = t == null ? void 0 : t.userData) == null ? void 0 : s.slotId) == "string" && t.userData.slotId || `slot_0_${Wn(e)}`,
@@ -388,36 +387,36 @@ function Vo(n) {
388
387
  ];
389
388
  }
390
389
  function Go(n, t) {
391
- const e = `${n} ${t}`, i = $n(e, zo), r = $n(e, ko);
390
+ const e = `${n} ${t}`, i = $n(e, zo), o = $n(e, ko);
392
391
  return i ? "stone" : "metal";
393
392
  }
394
393
  function Yn(n, t) {
395
394
  const e = [], i = /* @__PURE__ */ new Set();
396
- return n.traverse((r) => {
395
+ return n.traverse((o) => {
397
396
  var l;
398
- if (!(r instanceof v.Mesh)) return;
399
- const o = r, s = Uo(o, n, i);
400
- o.userData.partId = s;
401
- const a = Vo(o);
402
- o.userData.originalSlots = a;
397
+ if (!(o instanceof v.Mesh)) return;
398
+ const r = o, s = Uo(r, n, i);
399
+ r.userData.partId = s;
400
+ const a = Vo(r);
401
+ r.userData.originalSlots = a;
403
402
  const c = ((l = a[0]) == null ? void 0 : l.materialName) ?? "";
404
- o.userData.originalMaterialName = c;
405
- const u = a.map((m) => m.materialName).join(" "), f = o.uuid in t || s in t, d = t[s] ?? t[o.uuid];
403
+ r.userData.originalMaterialName = c;
404
+ const u = a.map((m) => m.materialName).join(" "), f = r.uuid in t || s in t, d = t[s] ?? t[r.uuid];
406
405
  f && d ? e.push({
407
- meshId: o.uuid,
406
+ meshId: r.uuid,
408
407
  partId: s,
409
- meshName: o.name,
408
+ meshName: r.name,
410
409
  materialName: c,
411
410
  slots: a,
412
411
  type: d,
413
412
  overridden: !0
414
413
  }) : e.push({
415
- meshId: o.uuid,
414
+ meshId: r.uuid,
416
415
  partId: s,
417
- meshName: o.name,
416
+ meshName: r.name,
418
417
  materialName: c,
419
418
  slots: a,
420
- type: Go(o.name, u),
419
+ type: Go(r.name, u),
421
420
  overridden: !1
422
421
  });
423
422
  }), e;
@@ -426,8 +425,8 @@ function Xn(n) {
426
425
  const t = /* @__PURE__ */ new Map();
427
426
  for (const e of n)
428
427
  for (const i of e.slots) {
429
- const r = t.get(i.slotId);
430
- r ? (r.partIds.includes(e.partId) || r.partIds.push(e.partId), r.meshIds.includes(e.meshId) || r.meshIds.push(e.meshId), r.type !== "stone" && e.type === "stone" && (r.type = "stone")) : t.set(i.slotId, {
428
+ const o = t.get(i.slotId);
429
+ o ? (o.partIds.includes(e.partId) || o.partIds.push(e.partId), o.meshIds.includes(e.meshId) || o.meshIds.push(e.meshId), o.type !== "stone" && e.type === "stone" && (o.type = "stone")) : t.set(i.slotId, {
431
430
  slotId: i.slotId,
432
431
  name: i.materialName,
433
432
  type: e.type,
@@ -530,8 +529,8 @@ const Kn = /* @__PURE__ */ new WeakMap();
530
529
  function qo(n) {
531
530
  var g, x;
532
531
  n.boundingSphere || n.computeBoundingSphere();
533
- const t = (g = n.boundingSphere) != null && g.center ? n.boundingSphere.center.clone() : new v.Vector3(), e = ((x = n.boundingSphere) == null ? void 0 : x.radius) ?? 1, i = Math.max(e, 0.01), r = n.getAttribute("position");
534
- if (!r || r.count === 0)
532
+ const t = (g = n.boundingSphere) != null && g.center ? n.boundingSphere.center.clone() : new v.Vector3(), e = ((x = n.boundingSphere) == null ? void 0 : x.radius) ?? 1, i = Math.max(e, 0.01), o = n.getAttribute("position");
533
+ if (!o || o.count === 0)
535
534
  return {
536
535
  centroid: t,
537
536
  radius: i,
@@ -540,12 +539,12 @@ function qo(n) {
540
539
  isBakeable: !1,
541
540
  flippedWinding: !1
542
541
  };
543
- const o = n.getIndex(), s = o ? o.count / 3 : r.count / 3;
542
+ const r = n.getIndex(), s = r ? r.count / 3 : o.count / 3;
544
543
  let a = 0, c = 0, u = 0;
545
544
  const f = new v.Vector3(), d = new v.Vector3(), l = new v.Vector3(), m = new v.Vector3(), p = new v.Vector3(), w = new v.Vector3(), y = new v.Vector3();
546
545
  for (let b = 0; b < s; b++) {
547
- const A = o ? o.getX(b * 3) : b * 3, S = o ? o.getX(b * 3 + 1) : b * 3 + 1, B = o ? o.getX(b * 3 + 2) : b * 3 + 2;
548
- f.fromBufferAttribute(r, A).sub(t).divideScalar(i), d.fromBufferAttribute(r, S).sub(t).divideScalar(i), l.fromBufferAttribute(r, B).sub(t).divideScalar(i), m.subVectors(d, f), p.subVectors(l, f), w.crossVectors(m, p);
546
+ const A = r ? r.getX(b * 3) : b * 3, S = r ? r.getX(b * 3 + 1) : b * 3 + 1, B = r ? r.getX(b * 3 + 2) : b * 3 + 2;
547
+ f.fromBufferAttribute(o, A).sub(t).divideScalar(i), d.fromBufferAttribute(o, S).sub(t).divideScalar(i), l.fromBufferAttribute(o, B).sub(t).divideScalar(i), m.subVectors(d, f), p.subVectors(l, f), w.crossVectors(m, p);
549
548
  const R = w.length();
550
549
  if (R < 1e-12) continue;
551
550
  const T = R * 0.5;
@@ -566,11 +565,11 @@ function qo(n) {
566
565
  function $o(n, t) {
567
566
  const e = n.getIndex() !== null, i = e ? n.toNonIndexed() : n;
568
567
  try {
569
- const r = i.getAttribute("position");
570
- if (!r) return new Float32Array(0);
571
- const o = r.count, s = new Float32Array(o * 4), a = new v.Vector3(), c = new v.Vector3(), u = new v.Vector3(), f = new v.Vector3(), d = new v.Vector3(), l = new v.Vector3(), m = t.flippedWinding ? -1 : 1;
572
- for (let p = 0; p < o; p += 3) {
573
- a.fromBufferAttribute(r, p).sub(t.centroid).divideScalar(t.radius), c.fromBufferAttribute(r, p + 1).sub(t.centroid).divideScalar(t.radius), u.fromBufferAttribute(r, p + 2).sub(t.centroid).divideScalar(t.radius), f.subVectors(c, a), d.subVectors(u, a), l.crossVectors(f, d).multiplyScalar(m);
568
+ const o = i.getAttribute("position");
569
+ if (!o) return new Float32Array(0);
570
+ const r = o.count, s = new Float32Array(r * 4), a = new v.Vector3(), c = new v.Vector3(), u = new v.Vector3(), f = new v.Vector3(), d = new v.Vector3(), l = new v.Vector3(), m = t.flippedWinding ? -1 : 1;
571
+ for (let p = 0; p < r; p += 3) {
572
+ a.fromBufferAttribute(o, p).sub(t.centroid).divideScalar(t.radius), c.fromBufferAttribute(o, p + 1).sub(t.centroid).divideScalar(t.radius), u.fromBufferAttribute(o, p + 2).sub(t.centroid).divideScalar(t.radius), f.subVectors(c, a), d.subVectors(u, a), l.crossVectors(f, d).multiplyScalar(m);
574
573
  const w = l.length();
575
574
  w > 1e-12 ? l.divideScalar(w) : l.set(0, 1, 0);
576
575
  const y = a.dot(l);
@@ -587,18 +586,18 @@ function $o(n, t) {
587
586
  function Wo(n, t) {
588
587
  const e = Kn.get(n);
589
588
  if (e) return e;
590
- const i = n.getAttribute("position"), r = n.getIndex();
591
- let o = 2166136261;
589
+ const i = n.getAttribute("position"), o = n.getIndex();
590
+ let r = 2166136261;
592
591
  const s = (u) => {
593
- o ^= u & 255, o = Math.imul(o, 16777619), o ^= u >> 8 & 255, o = Math.imul(o, 16777619), o ^= u >> 16 & 255, o = Math.imul(o, 16777619), o ^= u >> 24 & 255, o = Math.imul(o, 16777619);
592
+ r ^= u & 255, r = Math.imul(r, 16777619), r ^= u >> 8 & 255, r = Math.imul(r, 16777619), r ^= u >> 16 & 255, r = Math.imul(r, 16777619), r ^= u >> 24 & 255, r = Math.imul(r, 16777619);
594
593
  };
595
- if (s(t.triangleCount), r)
596
- for (let u = 0; u < r.count; u++)
597
- s(r.getX(u));
594
+ if (s(t.triangleCount), o)
595
+ for (let u = 0; u < o.count; u++)
596
+ s(o.getX(u));
598
597
  const a = new v.Vector3();
599
598
  for (let u = 0; u < i.count; u++)
600
599
  a.fromBufferAttribute(i, u).sub(t.centroid).divideScalar(t.radius), s(Math.round(a.x * 1e4)), s(Math.round(a.y * 1e4)), s(Math.round(a.z * 1e4));
601
- const c = (o >>> 0).toString(16);
600
+ const c = (r >>> 0).toString(16);
602
601
  return Kn.set(n, c), c;
603
602
  }
604
603
  const Pi = 0, Yo = 1, Ri = 2, Jn = 2, jt = 1.25, jn = 1, te = 6 * 4 + 4 + 4, j = te / 4, Bn = 65535, Xo = Bn << 16, Dt = Math.pow(2, -24), In = Symbol("SKIP_GENERATION"), Fi = {
@@ -619,8 +618,8 @@ function W(n, t, e) {
619
618
  function dn(n) {
620
619
  let t = -1, e = -1 / 0;
621
620
  for (let i = 0; i < 3; i++) {
622
- const r = n[i + 3] - n[i];
623
- r > e && (e = r, t = i);
621
+ const o = n[i + 3] - n[i];
622
+ o > e && (e = o, t = i);
624
623
  }
625
624
  return t;
626
625
  }
@@ -628,15 +627,15 @@ function Zn(n, t) {
628
627
  t.set(n);
629
628
  }
630
629
  function Qn(n, t, e) {
631
- let i, r;
632
- for (let o = 0; o < 3; o++) {
633
- const s = o + 3;
634
- i = n[o], r = t[o], e[o] = i < r ? i : r, i = n[s], r = t[s], e[s] = i > r ? i : r;
630
+ let i, o;
631
+ for (let r = 0; r < 3; r++) {
632
+ const s = r + 3;
633
+ i = n[r], o = t[r], e[r] = i < o ? i : o, i = n[s], o = t[s], e[s] = i > o ? i : o;
635
634
  }
636
635
  }
637
636
  function yt(n, t, e) {
638
637
  for (let i = 0; i < 3; i++) {
639
- const r = t[n + 2 * i], o = t[n + 2 * i + 1], s = r - o, a = r + o;
638
+ const o = t[n + 2 * i], r = t[n + 2 * i + 1], s = o - r, a = o + r;
640
639
  s < e[i] && (e[i] = s), a > e[i + 3] && (e[i + 3] = a);
641
640
  }
642
641
  }
@@ -663,18 +662,18 @@ function ee(n, t) {
663
662
  function Gt(n, t) {
664
663
  return t[n + 7];
665
664
  }
666
- function Zt(n, t, e, i, r) {
667
- let o = 1 / 0, s = 1 / 0, a = 1 / 0, c = -1 / 0, u = -1 / 0, f = -1 / 0, d = 1 / 0, l = 1 / 0, m = 1 / 0, p = -1 / 0, w = -1 / 0, y = -1 / 0;
665
+ function Zt(n, t, e, i, o) {
666
+ let r = 1 / 0, s = 1 / 0, a = 1 / 0, c = -1 / 0, u = -1 / 0, f = -1 / 0, d = 1 / 0, l = 1 / 0, m = 1 / 0, p = -1 / 0, w = -1 / 0, y = -1 / 0;
668
667
  const M = n.offset || 0;
669
668
  for (let h = (t - M) * 6, g = (t + e - M) * 6; h < g; h += 6) {
670
669
  const x = n[h + 0], b = n[h + 1], A = x - b, S = x + b;
671
- A < o && (o = A), S > c && (c = S), x < d && (d = x), x > p && (p = x);
670
+ A < r && (r = A), S > c && (c = S), x < d && (d = x), x > p && (p = x);
672
671
  const B = n[h + 2], R = n[h + 3], T = B - R, P = B + R;
673
672
  T < s && (s = T), P > u && (u = P), B < l && (l = B), B > w && (w = B);
674
673
  const C = n[h + 4], F = n[h + 5], D = C - F, L = C + F;
675
674
  D < a && (a = D), L > f && (f = L), C < m && (m = C), C > y && (y = C);
676
675
  }
677
- i[0] = o, i[1] = s, i[2] = a, i[3] = c, i[4] = u, i[5] = f, r[0] = d, r[1] = l, r[2] = m, r[3] = p, r[4] = w, r[5] = y;
676
+ i[0] = r, i[1] = s, i[2] = a, i[3] = c, i[4] = u, i[5] = f, o[0] = d, o[1] = l, o[2] = m, o[3] = p, o[4] = w, o[5] = y;
678
677
  }
679
678
  const we = 32, Ko = (n, t) => n.candidate - t.candidate, Be = /* @__PURE__ */ new Array(we).fill().map(() => ({
680
679
  count: 0,
@@ -683,21 +682,21 @@ const we = 32, Ko = (n, t) => n.candidate - t.candidate, Be = /* @__PURE__ */ ne
683
682
  leftCacheBounds: new Float32Array(6),
684
683
  candidate: 0
685
684
  })), gt = /* @__PURE__ */ new Float32Array(6);
686
- function Jo(n, t, e, i, r, o) {
685
+ function Jo(n, t, e, i, o, r) {
687
686
  let s = -1, a = 0;
688
- if (o === Pi)
687
+ if (r === Pi)
689
688
  s = dn(t), s !== -1 && (a = (t[s] + t[s + 3]) / 2);
690
- else if (o === Yo)
691
- s = dn(n), s !== -1 && (a = jo(e, i, r, s));
692
- else if (o === Ri) {
689
+ else if (r === Yo)
690
+ s = dn(n), s !== -1 && (a = jo(e, i, o, s));
691
+ else if (r === Ri) {
693
692
  const c = tt(n);
694
- let u = jt * r;
695
- const f = e.offset || 0, d = (i - f) * 6, l = (i + r - f) * 6;
693
+ let u = jt * o;
694
+ const f = e.offset || 0, d = (i - f) * 6, l = (i + o - f) * 6;
696
695
  for (let m = 0; m < 3; m++) {
697
696
  const p = t[m], M = (t[m + 3] - p) / we;
698
- if (r < we / 4) {
697
+ if (o < we / 4) {
699
698
  const h = [...Be];
700
- h.length = r;
699
+ h.length = o;
701
700
  let g = 0;
702
701
  for (let b = d; b < l; b += 6, g++) {
703
702
  const A = h[g];
@@ -712,7 +711,7 @@ function Jo(n, t, e, i, r, o) {
712
711
  yt(b, e, S);
713
712
  }
714
713
  h.sort(Ko);
715
- let x = r;
714
+ let x = o;
716
715
  for (let b = 0; b < x; b++) {
717
716
  const A = h[b];
718
717
  for (; b + 1 < x && h[b + 1].candidate === A.candidate; )
@@ -726,7 +725,7 @@ function Jo(n, t, e, i, r, o) {
726
725
  }
727
726
  }
728
727
  for (let b = 0; b < x; b++) {
729
- const A = h[b], S = A.count, B = r - A.count, R = A.leftCacheBounds, T = A.rightCacheBounds;
728
+ const A = h[b], S = A.count, B = o - A.count, R = A.leftCacheBounds, T = A.rightCacheBounds;
730
729
  let P = 0;
731
730
  S !== 0 && (P = tt(R) / c);
732
731
  let C = 0;
@@ -760,7 +759,7 @@ function Jo(n, t, e, i, r, o) {
760
759
  A !== 0 && (g === 0 ? Zn(S, gt) : Qn(S, gt, gt)), g += A;
761
760
  let T = 0, P = 0;
762
761
  g !== 0 && (T = tt(gt) / c);
763
- const C = r - g;
762
+ const C = o - g;
764
763
  C !== 0 && (P = tt(R) / c);
765
764
  const F = jn + jt * (T * g + P * C);
766
765
  F < u && (s = m, u = F, a = b.candidate);
@@ -768,24 +767,24 @@ function Jo(n, t, e, i, r, o) {
768
767
  }
769
768
  }
770
769
  } else
771
- console.warn(`BVH: Invalid build strategy value ${o} used.`);
770
+ console.warn(`BVH: Invalid build strategy value ${r} used.`);
772
771
  return { axis: s, pos: a };
773
772
  }
774
773
  function jo(n, t, e, i) {
775
- let r = 0;
776
- const o = n.offset;
774
+ let o = 0;
775
+ const r = n.offset;
777
776
  for (let s = t, a = t + e; s < a; s++)
778
- r += n[(s - o) * 6 + i * 2];
779
- return r / e;
777
+ o += n[(s - r) * 6 + i * 2];
778
+ return o / e;
780
779
  }
781
780
  class Qt {
782
781
  constructor() {
783
782
  this.boundingData = new Float32Array(6);
784
783
  }
785
784
  }
786
- function Zo(n, t, e, i, r, o) {
787
- let s = i, a = i + r - 1;
788
- const c = o.pos, u = o.axis * 2, f = e.offset || 0;
785
+ function Zo(n, t, e, i, o, r) {
786
+ let s = i, a = i + o - 1;
787
+ const c = r.pos, u = r.axis * 2, f = e.offset || 0;
789
788
  for (; ; ) {
790
789
  for (; s <= a && e[(s - f) * 6 + u] < c; )
791
790
  s++;
@@ -814,10 +813,10 @@ function er(n, t, e) {
814
813
  return Di = new Float32Array(e), Et = new Uint32Array(e), mn = new Uint16Array(e), Ei = new Uint8Array(e), hn(n, t);
815
814
  }
816
815
  function hn(n, t) {
817
- const e = n / 4, i = n / 2, r = "count" in t, o = t.boundingData;
816
+ const e = n / 4, i = n / 2, o = "count" in t, r = t.boundingData;
818
817
  for (let s = 0; s < 6; s++)
819
- Di[e + s] = o[s];
820
- if (r)
818
+ Di[e + s] = r[s];
819
+ if (o)
821
820
  return t.buffer ? (Ei.set(new Uint8Array(t.buffer), n), n + t.buffer.byteLength) : (Et[e + 6] = t.offset, mn[i + 14] = t.count, mn[i + 15] = Bn, n + te);
822
821
  {
823
822
  const { left: s, right: a, splitAxis: c } = t, u = n + te;
@@ -828,7 +827,7 @@ function hn(n, t) {
828
827
  return Et[e + 6] = m, Et[e + 7] = c, hn(f, a);
829
828
  }
830
829
  }
831
- function tr(n, t, e, i, r, o) {
830
+ function tr(n, t, e, i, o, r) {
832
831
  const {
833
832
  maxDepth: s,
834
833
  verbose: a,
@@ -836,12 +835,12 @@ function tr(n, t, e, i, r, o) {
836
835
  _strictLeafSize: u = 1 / 0,
837
836
  strategy: f,
838
837
  onProgress: d
839
- } = r, l = n.primitiveBuffer, m = n.primitiveBufferStride, p = new Float32Array(6);
838
+ } = o, l = n.primitiveBuffer, m = n.primitiveBufferStride, p = new Float32Array(6);
840
839
  let w = !1;
841
840
  const y = new Qt();
842
841
  return Zt(t, e, i, y.boundingData, p), h(y, e, i, p), y;
843
842
  function M(g) {
844
- d && d((g - o.offset) / o.count);
843
+ d && d((g - r.offset) / r.count);
845
844
  }
846
845
  function h(g, x, b, A = null, S = 0) {
847
846
  !w && S >= s && (w = !0, a && console.warn(`BVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`));
@@ -863,9 +862,9 @@ function tr(n, t, e, i, r, o) {
863
862
  }
864
863
  }
865
864
  function nr(n, t) {
866
- const e = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, i = n.getRootRanges(t.range), r = i[0], o = i[i.length - 1], s = {
867
- offset: r.offset,
868
- count: o.offset + o.count - r.offset
865
+ const e = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, i = n.getRootRanges(t.range), o = i[0], r = i[i.length - 1], s = {
866
+ offset: o.offset,
867
+ count: r.offset + r.count - o.offset
869
868
  }, a = new Float32Array(6 * s.count);
870
869
  a.offset = s.offset, n.computePrimitiveBounds(s.offset, s.count, a), n._roots = i.map((c) => {
871
870
  const u = tr(n, a, c.offset, c.count, t, s), f = pn(u), d = new e(te * f);
@@ -899,19 +898,19 @@ class ir {
899
898
  const O = /* @__PURE__ */ new ir();
900
899
  let Pe, Qe;
901
900
  const Ge = [], vt = /* @__PURE__ */ new Pn(() => new ve());
902
- function or(n, t, e, i, r, o) {
901
+ function or(n, t, e, i, o, r) {
903
902
  Pe = vt.getPrimitive(), Qe = vt.getPrimitive(), Ge.push(Pe, Qe), O.setBuffer(n._roots[t]);
904
- const s = yn(0, n.geometry, e, i, r, o);
903
+ const s = yn(0, n.geometry, e, i, o, r);
905
904
  O.clearBuffer(), vt.releasePrimitive(Pe), vt.releasePrimitive(Qe), Ge.pop(), Ge.pop();
906
905
  const a = Ge.length;
907
906
  return a > 0 && (Qe = Ge[a - 1], Pe = Ge[a - 2]), s;
908
907
  }
909
- function yn(n, t, e, i, r = null, o = 0, s = 0) {
908
+ function yn(n, t, e, i, o = null, r = 0, s = 0) {
910
909
  const { float32Array: a, uint16Array: c, uint32Array: u } = O;
911
910
  let f = n * 2;
912
911
  if (Y(f, c)) {
913
912
  const l = Z(n, u), m = ie(f, c);
914
- return W(n, a, Pe), i(l, m, !1, s, o + n / j, Pe);
913
+ return W(n, a, Pe), i(l, m, !1, s, r + n / j, Pe);
915
914
  } else {
916
915
  let T = function(C) {
917
916
  const { uint16Array: F, uint32Array: D } = O;
@@ -928,42 +927,42 @@ function yn(n, t, e, i, r = null, o = 0, s = 0) {
928
927
  };
929
928
  const l = Q(n), m = ee(n, u);
930
929
  let p = l, w = m, y, M, h, g;
931
- if (r && (h = Pe, g = Qe, W(p, a, h), W(w, a, g), y = r(h), M = r(g), M < y)) {
930
+ if (o && (h = Pe, g = Qe, W(p, a, h), W(w, a, g), y = o(h), M = o(g), M < y)) {
932
931
  p = m, w = l;
933
932
  const C = y;
934
933
  y = M, M = C, h = g;
935
934
  }
936
935
  h || (h = Pe, W(p, a, h));
937
- const x = Y(p * 2, c), b = e(h, x, y, s + 1, o + p / j);
936
+ const x = Y(p * 2, c), b = e(h, x, y, s + 1, r + p / j);
938
937
  let A;
939
938
  if (b === Jn) {
940
939
  const C = T(p), D = P(p) - C;
941
- A = i(C, D, !0, s + 1, o + p / j, h);
940
+ A = i(C, D, !0, s + 1, r + p / j, h);
942
941
  } else
943
942
  A = b && yn(
944
943
  p,
945
944
  t,
946
945
  e,
947
946
  i,
948
- r,
949
947
  o,
948
+ r,
950
949
  s + 1
951
950
  );
952
951
  if (A) return !0;
953
952
  g = Qe, W(w, a, g);
954
- const S = Y(w * 2, c), B = e(g, S, M, s + 1, o + w / j);
953
+ const S = Y(w * 2, c), B = e(g, S, M, s + 1, r + w / j);
955
954
  let R;
956
955
  if (B === Jn) {
957
956
  const C = T(w), D = P(w) - C;
958
- R = i(C, D, !0, s + 1, o + w / j, g);
957
+ R = i(C, D, !0, s + 1, r + w / j, g);
959
958
  } else
960
959
  R = B && yn(
961
960
  w,
962
961
  t,
963
962
  e,
964
963
  i,
965
- r,
966
964
  o,
965
+ r,
967
966
  s + 1
968
967
  );
969
968
  return !!R;
@@ -975,14 +974,14 @@ function rr(n, t, e, i) {
975
974
  if (nn)
976
975
  throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");
977
976
  nn = !0;
978
- const r = n._roots, o = t._roots;
977
+ const o = n._roots, r = t._roots;
979
978
  let s, a = 0, c = 0;
980
979
  const u = new Re().copy(e).invert();
981
- for (let f = 0, d = r.length; f < d; f++) {
982
- ft.setBuffer(r[f]), c = 0;
980
+ for (let f = 0, d = o.length; f < d; f++) {
981
+ ft.setBuffer(o[f]), c = 0;
983
982
  const l = Ie.getPrimitive();
984
983
  W(0, ft.float32Array, l), l.applyMatrix4(u);
985
- for (let m = 0, p = o.length; m < p && (Lt.setBuffer(o[m]), s = me(
984
+ for (let m = 0, p = r.length; m < p && (Lt.setBuffer(r[m]), s = me(
986
985
  0,
987
986
  0,
988
987
  e,
@@ -993,20 +992,20 @@ function rr(n, t, e, i) {
993
992
  0,
994
993
  0,
995
994
  l
996
- ), Lt.clearBuffer(), c += o[m].byteLength / te, !s); m++)
995
+ ), Lt.clearBuffer(), c += r[m].byteLength / te, !s); m++)
997
996
  ;
998
- if (Ie.releasePrimitive(l), ft.clearBuffer(), a += r[f].byteLength / te, s)
997
+ if (Ie.releasePrimitive(l), ft.clearBuffer(), a += o[f].byteLength / te, s)
999
998
  break;
1000
999
  }
1001
1000
  return nn = !1, s;
1002
1001
  }
1003
- function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1002
+ function me(n, t, e, i, o, r = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1004
1003
  let d, l;
1005
1004
  f ? (d = Lt, l = ft) : (d = ft, l = Lt);
1006
1005
  const m = d.float32Array, p = d.uint32Array, w = d.uint16Array, y = l.float32Array, M = l.uint32Array, h = l.uint16Array, g = n * 2, x = t * 2, b = Y(g, w), A = Y(x, h);
1007
1006
  let S = !1;
1008
1007
  if (A && b)
1009
- f ? S = r(
1008
+ f ? S = o(
1010
1009
  Z(t, M),
1011
1010
  ie(t * 2, h),
1012
1011
  Z(n, p),
@@ -1014,14 +1013,14 @@ function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1014
1013
  c,
1015
1014
  s + t / j,
1016
1015
  a,
1017
- o + n / j
1018
- ) : S = r(
1016
+ r + n / j
1017
+ ) : S = o(
1019
1018
  Z(n, p),
1020
1019
  ie(n * 2, w),
1021
1020
  Z(t, M),
1022
1021
  ie(t * 2, h),
1023
1022
  a,
1024
- o + n / j,
1023
+ r + n / j,
1025
1024
  c,
1026
1025
  s + t / j
1027
1026
  );
@@ -1036,9 +1035,9 @@ function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1036
1035
  R,
1037
1036
  i,
1038
1037
  e,
1039
- r,
1040
- s,
1041
1038
  o,
1039
+ s,
1040
+ r,
1042
1041
  c,
1043
1042
  a + 1,
1044
1043
  B,
@@ -1048,9 +1047,9 @@ function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1048
1047
  T,
1049
1048
  i,
1050
1049
  e,
1051
- r,
1052
- s,
1053
1050
  o,
1051
+ s,
1052
+ r,
1054
1053
  c,
1055
1054
  a + 1,
1056
1055
  B,
@@ -1066,8 +1065,8 @@ function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1066
1065
  B,
1067
1066
  e,
1068
1067
  i,
1069
- r,
1070
1068
  o,
1069
+ r,
1071
1070
  s,
1072
1071
  a,
1073
1072
  c + 1,
@@ -1078,8 +1077,8 @@ function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1078
1077
  R,
1079
1078
  e,
1080
1079
  i,
1081
- r,
1082
1080
  o,
1081
+ r,
1083
1082
  s,
1084
1083
  a,
1085
1084
  c + 1,
@@ -1093,8 +1092,8 @@ function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1093
1092
  B,
1094
1093
  e,
1095
1094
  i,
1096
- r,
1097
1095
  o,
1096
+ r,
1098
1097
  s,
1099
1098
  a,
1100
1099
  c + 1,
@@ -1112,9 +1111,9 @@ function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1112
1111
  F,
1113
1112
  i,
1114
1113
  e,
1115
- r,
1116
- s,
1117
1114
  o,
1115
+ s,
1116
+ r,
1118
1117
  c,
1119
1118
  a + 1,
1120
1119
  C,
@@ -1124,9 +1123,9 @@ function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1124
1123
  D,
1125
1124
  i,
1126
1125
  e,
1127
- r,
1128
- s,
1129
1126
  o,
1127
+ s,
1128
+ r,
1130
1129
  c,
1131
1130
  a + 1,
1132
1131
  C,
@@ -1140,8 +1139,8 @@ function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1140
1139
  R,
1141
1140
  e,
1142
1141
  i,
1143
- r,
1144
1142
  o,
1143
+ r,
1145
1144
  s,
1146
1145
  a,
1147
1146
  c + 1,
@@ -1159,9 +1158,9 @@ function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1159
1158
  F,
1160
1159
  i,
1161
1160
  e,
1162
- r,
1163
- s,
1164
1161
  o,
1162
+ s,
1163
+ r,
1165
1164
  c,
1166
1165
  a + 1,
1167
1166
  C,
@@ -1171,9 +1170,9 @@ function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1171
1170
  D,
1172
1171
  i,
1173
1172
  e,
1174
- r,
1175
- s,
1176
1173
  o,
1174
+ s,
1175
+ r,
1177
1176
  c,
1178
1177
  a + 1,
1179
1178
  C,
@@ -1186,47 +1185,47 @@ function me(n, t, e, i, r, o = 0, s = 0, a = 0, c = 0, u = null, f = !1) {
1186
1185
  const on = new class {
1187
1186
  constructor() {
1188
1187
  let n = null, t = null, e = null, i = !1;
1189
- this.root = null, this.buffer = null, this.uint32Array = null, this.uint16Array = null, this.setBVH = (o, s) => {
1188
+ this.root = null, this.buffer = null, this.uint32Array = null, this.uint16Array = null, this.setBVH = (r, s) => {
1190
1189
  if (i)
1191
1190
  throw new Error("BVHTraversalHelper: cannot call setBVH during an active traversal.");
1192
- this.root = s, this.buffer = n = o._roots[s], this.uint16Array = e = new Uint16Array(n), this.uint32Array = t = new Uint32Array(n);
1191
+ this.root = s, this.buffer = n = r._roots[s], this.uint16Array = e = new Uint16Array(n), this.uint32Array = t = new Uint32Array(n);
1193
1192
  }, this.reset = () => {
1194
1193
  this.root = null, this.buffer = n = null, this.uint16Array = e = null, this.uint32Array = t = null;
1195
- }, this.getRangeStart = (o) => {
1196
- let s = o * 2;
1194
+ }, this.getRangeStart = (r) => {
1195
+ let s = r * 2;
1197
1196
  for (; !Y(s, e); )
1198
- o = Q(o), s = o * 2;
1199
- return Z(o, t);
1200
- }, this.getRangeEnd = (o) => {
1201
- let s = o * 2;
1197
+ r = Q(r), s = r * 2;
1198
+ return Z(r, t);
1199
+ }, this.getRangeEnd = (r) => {
1200
+ let s = r * 2;
1202
1201
  for (; !Y(s, e); )
1203
- o = ee(o, t), s = o * 2;
1204
- return Z(o, t) + ie(s, e);
1202
+ r = ee(r, t), s = r * 2;
1203
+ return Z(r, t) + ie(s, e);
1205
1204
  };
1206
- const r = (o, s, a) => {
1205
+ const o = (r, s, a) => {
1207
1206
  const c = s * 2, u = Y(c, e);
1208
- if (!o(a, u, s) && !u) {
1207
+ if (!r(a, u, s) && !u) {
1209
1208
  const d = Q(s), l = ee(s, t);
1210
- r(o, d, a + 1), r(o, l, a + 1);
1209
+ o(r, d, a + 1), o(r, l, a + 1);
1211
1210
  }
1212
1211
  };
1213
- this.traverseBuffer = (o) => {
1212
+ this.traverseBuffer = (r) => {
1214
1213
  if (i)
1215
1214
  throw new Error("BVHTraversalHelper: cannot start a traversal during an active traversal.");
1216
1215
  i = !0;
1217
1216
  try {
1218
- r(o, 0, 0);
1217
+ o(r, 0, 0);
1219
1218
  } finally {
1220
1219
  i = !1;
1221
1220
  }
1222
- }, this.traverse = (o) => {
1221
+ }, this.traverse = (r) => {
1223
1222
  this.traverseBuffer((s, a, c) => {
1224
1223
  if (a) {
1225
1224
  const u = c * 2, f = t[c + 6], d = e[u + 14];
1226
- return o(s, a, new Float32Array(n, c * 4, 6), f, d);
1225
+ return r(s, a, new Float32Array(n, c * 4, 6), f, d);
1227
1226
  } else {
1228
1227
  const u = Gt(c, t);
1229
- return o(s, a, new Float32Array(n, c * 4, 6), u);
1228
+ return r(s, a, new Float32Array(n, c * 4, 6), u);
1230
1229
  }
1231
1230
  });
1232
1231
  };
@@ -1255,20 +1254,20 @@ class sr {
1255
1254
  }
1256
1255
  // writes the union bounds of all primitives in the given range in a min / max format
1257
1256
  // to the buffer
1258
- writePrimitiveRangeBounds(t, e, i, r) {
1259
- let o = 1 / 0, s = 1 / 0, a = 1 / 0, c = -1 / 0, u = -1 / 0, f = -1 / 0;
1257
+ writePrimitiveRangeBounds(t, e, i, o) {
1258
+ let r = 1 / 0, s = 1 / 0, a = 1 / 0, c = -1 / 0, u = -1 / 0, f = -1 / 0;
1260
1259
  for (let d = t, l = t + e; d < l; d++) {
1261
1260
  this.writePrimitiveBounds(d, qe, 0);
1262
1261
  const [m, p, w, y, M, h] = qe;
1263
- m < o && (o = m), y > c && (c = y), p < s && (s = p), M > u && (u = M), w < a && (a = w), h > f && (f = h);
1262
+ m < r && (r = m), y > c && (c = y), p < s && (s = p), M > u && (u = M), w < a && (a = w), h > f && (f = h);
1264
1263
  }
1265
- return i[r + 0] = o, i[r + 1] = s, i[r + 2] = a, i[r + 3] = c, i[r + 4] = u, i[r + 5] = f, i;
1264
+ return i[o + 0] = r, i[o + 1] = s, i[o + 2] = a, i[o + 3] = c, i[o + 4] = u, i[o + 5] = f, i;
1266
1265
  }
1267
1266
  computePrimitiveBounds(t, e, i) {
1268
- const r = i.offset || 0;
1269
- for (let o = t, s = t + e; o < s; o++) {
1270
- this.writePrimitiveBounds(o, qe, 0);
1271
- const [a, c, u, f, d, l] = qe, m = (a + f) / 2, p = (c + d) / 2, w = (u + l) / 2, y = (f - a) / 2, M = (d - c) / 2, h = (l - u) / 2, g = (o - r) * 6;
1267
+ const o = i.offset || 0;
1268
+ for (let r = t, s = t + e; r < s; r++) {
1269
+ this.writePrimitiveBounds(r, qe, 0);
1270
+ const [a, c, u, f, d, l] = qe, m = (a + f) / 2, p = (c + d) / 2, w = (u + l) / 2, y = (f - a) / 2, M = (d - c) / 2, h = (l - u) / 2, g = (r - o) * 6;
1272
1271
  i[g + 0] = m, i[g + 1] = y + (Math.abs(m) + y) * Dt, i[g + 2] = p, i[g + 3] = M + (Math.abs(p) + M) * Dt, i[g + 4] = w, i[g + 5] = h + (Math.abs(w) + h) * Dt;
1273
1272
  }
1274
1273
  return i;
@@ -1281,12 +1280,12 @@ class sr {
1281
1280
  shiftPrimitiveOffsets(t) {
1282
1281
  const e = this._indirectBuffer;
1283
1282
  if (e)
1284
- for (let i = 0, r = e.length; i < r; i++)
1283
+ for (let i = 0, o = e.length; i < o; i++)
1285
1284
  e[i] += t;
1286
1285
  else {
1287
1286
  const i = this._roots;
1288
- for (let r = 0; r < i.length; r++) {
1289
- const o = i[r], s = new Uint32Array(o), a = new Uint16Array(o), c = o.byteLength / te;
1287
+ for (let o = 0; o < i.length; o++) {
1288
+ const r = i[o], s = new Uint32Array(r), a = new Uint16Array(r), c = r.byteLength / te;
1290
1289
  for (let u = 0; u < c; u++) {
1291
1290
  const f = j * u, d = 2 * f;
1292
1291
  Y(d, a) && (s[f + 6] += t);
@@ -1314,14 +1313,14 @@ class sr {
1314
1313
  refit() {
1315
1314
  const t = this._roots;
1316
1315
  for (let e = 0, i = t.length; e < i; e++) {
1317
- const r = t[e], o = new Uint32Array(r), s = new Uint16Array(r), a = new Float32Array(r), c = r.byteLength / te;
1316
+ const o = t[e], r = new Uint32Array(o), s = new Uint16Array(o), a = new Float32Array(o), c = o.byteLength / te;
1318
1317
  for (let u = c - 1; u >= 0; u--) {
1319
1318
  const f = u * j, d = f * 2;
1320
1319
  if (Y(d, s)) {
1321
- const m = Z(f, o), p = ie(d, s);
1320
+ const m = Z(f, r), p = ie(d, s);
1322
1321
  this.writePrimitiveRangeBounds(m, p, qe, 0), a.set(qe, f);
1323
1322
  } else {
1324
- const m = Q(f), p = ee(f, o);
1323
+ const m = Q(f), p = ee(f, r);
1325
1324
  for (let w = 0; w < 3; w++) {
1326
1325
  const y = a[m + w], M = a[m + w + 3], h = a[p + w], g = a[p + w + 3];
1327
1326
  a[f + w] = y < h ? y : h, a[f + w + 3] = M > g ? M : g;
@@ -1359,20 +1358,20 @@ class sr {
1359
1358
  let {
1360
1359
  boundsTraverseOrder: e,
1361
1360
  intersectsBounds: i,
1362
- intersectsRange: r,
1363
- intersectsPrimitive: o,
1361
+ intersectsRange: o,
1362
+ intersectsPrimitive: r,
1364
1363
  scratchPrimitive: s,
1365
1364
  iterate: a
1366
1365
  } = t;
1367
- if (r && o) {
1368
- const d = r;
1369
- r = (l, m, p, w, y) => d(l, m, p, w, y) ? !0 : a(l, m, this, o, p, w, s);
1370
- } else r || (o ? r = (d, l, m, p) => a(d, l, this, o, m, p, s) : r = (d, l, m) => m);
1366
+ if (o && r) {
1367
+ const d = o;
1368
+ o = (l, m, p, w, y) => d(l, m, p, w, y) ? !0 : a(l, m, this, r, p, w, s);
1369
+ } else o || (r ? o = (d, l, m, p) => a(d, l, this, r, m, p, s) : o = (d, l, m) => m);
1371
1370
  let c = !1, u = 0;
1372
1371
  const f = this._roots;
1373
1372
  for (let d = 0, l = f.length; d < l; d++) {
1374
1373
  const m = f[d];
1375
- if (c = or(this, d, i, r, e, u), c)
1374
+ if (c = or(this, d, i, o, e, u), c)
1376
1375
  break;
1377
1376
  u += m.byteLength / te;
1378
1377
  }
@@ -1390,8 +1389,8 @@ class sr {
1390
1389
  * @returns {boolean}
1391
1390
  */
1392
1391
  bvhcast(t, e, i) {
1393
- let { intersectsRanges: r } = i;
1394
- return rr(this, t, e, r);
1392
+ let { intersectsRanges: o } = i;
1393
+ return rr(this, t, e, o);
1395
1394
  }
1396
1395
  }
1397
1396
  function ar() {
@@ -1408,14 +1407,14 @@ function _i(n, t = ArrayBuffer) {
1408
1407
  }
1409
1408
  function cr(n, t) {
1410
1409
  if (!n.index) {
1411
- const e = n.attributes.position.count, i = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, r = _i(e, i);
1412
- n.setIndex(new Tn(r, 1));
1413
- for (let o = 0; o < e; o++)
1414
- r[o] = o;
1410
+ const e = n.attributes.position.count, i = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, o = _i(e, i);
1411
+ n.setIndex(new Tn(o, 1));
1412
+ for (let r = 0; r < e; r++)
1413
+ o[r] = r;
1415
1414
  }
1416
1415
  }
1417
1416
  function lr(n, t, e) {
1418
- const i = Ht(n) / e, r = t || n.drawRange, o = r.start / e, s = (r.start + r.count) / e, a = Math.max(0, o), c = Math.min(i, s) - a;
1417
+ const i = Ht(n) / e, o = t || n.drawRange, r = o.start / e, s = (o.start + o.count) / e, a = Math.max(0, r), c = Math.min(i, s) - a;
1419
1418
  return {
1420
1419
  offset: Math.floor(a),
1421
1420
  count: Math.floor(c)
@@ -1428,11 +1427,11 @@ function ur(n, t) {
1428
1427
  }));
1429
1428
  }
1430
1429
  function ti(n, t, e) {
1431
- const i = lr(n, t, e), r = ur(n, e);
1432
- if (!r.length)
1430
+ const i = lr(n, t, e), o = ur(n, e);
1431
+ if (!o.length)
1433
1432
  return [i];
1434
- const o = [], s = i.offset, a = i.offset + i.count, c = Ht(n) / e, u = [];
1435
- for (const l of r) {
1433
+ const r = [], s = i.offset, a = i.offset + i.count, c = Ht(n) / e, u = [];
1434
+ for (const l of o) {
1436
1435
  const { offset: m, count: p } = l, w = m, y = isFinite(p) ? p : c - m, M = m + y;
1437
1436
  w < a && M > s && (u.push({ pos: Math.max(s, w), isStart: !0 }), u.push({ pos: Math.min(a, M), isStart: !1 }));
1438
1437
  }
@@ -1440,15 +1439,15 @@ function ti(n, t, e) {
1440
1439
  let f = 0, d = null;
1441
1440
  for (const l of u) {
1442
1441
  const m = l.pos;
1443
- f !== 0 && m !== d && o.push({
1442
+ f !== 0 && m !== d && r.push({
1444
1443
  offset: d,
1445
1444
  count: m - d
1446
1445
  }), f += l.isStart ? 1 : -1, d = m;
1447
1446
  }
1448
- return o;
1447
+ return r;
1449
1448
  }
1450
1449
  function fr(n, t) {
1451
- const e = n[n.length - 1], i = e.offset + e.count > 2 ** 16, r = n.reduce((u, f) => u + f.count, 0), o = i ? 4 : 2, s = t ? new SharedArrayBuffer(r * o) : new ArrayBuffer(r * o), a = i ? new Uint32Array(s) : new Uint16Array(s);
1450
+ const e = n[n.length - 1], i = e.offset + e.count > 2 ** 16, o = n.reduce((u, f) => u + f.count, 0), r = i ? 4 : 2, s = t ? new SharedArrayBuffer(o * r) : new ArrayBuffer(o * r), a = i ? new Uint32Array(s) : new Uint16Array(s);
1452
1451
  let c = 0;
1453
1452
  for (let u = 0; u < n.length; u++) {
1454
1453
  const { offset: f, count: d } = n[u];
@@ -1495,8 +1494,8 @@ class dr extends sr {
1495
1494
  init(t) {
1496
1495
  const { geometry: e, primitiveStride: i } = this;
1497
1496
  if (t.indirect) {
1498
- const r = ti(e, t.range, i), o = fr(r, t.useSharedArrayBuffer);
1499
- this._indirectBuffer = o;
1497
+ const o = ti(e, t.range, i), r = fr(o, t.useSharedArrayBuffer);
1498
+ this._indirectBuffer = r;
1500
1499
  } else
1501
1500
  cr(e, t);
1502
1501
  super.init(t), !e.boundingBox && t.setBoundingBox && (e.boundingBox = this.getBoundingBox(new ve()));
@@ -1514,20 +1513,20 @@ class Te {
1514
1513
  this.min = 1 / 0, this.max = -1 / 0;
1515
1514
  }
1516
1515
  setFromPointsField(t, e) {
1517
- let i = 1 / 0, r = -1 / 0;
1518
- for (let o = 0, s = t.length; o < s; o++) {
1519
- const c = t[o][e];
1520
- i = c < i ? c : i, r = c > r ? c : r;
1516
+ let i = 1 / 0, o = -1 / 0;
1517
+ for (let r = 0, s = t.length; r < s; r++) {
1518
+ const c = t[r][e];
1519
+ i = c < i ? c : i, o = c > o ? c : o;
1521
1520
  }
1522
- this.min = i, this.max = r;
1521
+ this.min = i, this.max = o;
1523
1522
  }
1524
1523
  setFromPoints(t, e) {
1525
- let i = 1 / 0, r = -1 / 0;
1526
- for (let o = 0, s = e.length; o < s; o++) {
1527
- const a = e[o], c = t.dot(a);
1528
- i = c < i ? c : i, r = c > r ? c : r;
1524
+ let i = 1 / 0, o = -1 / 0;
1525
+ for (let r = 0, s = e.length; r < s; r++) {
1526
+ const a = e[r], c = t.dot(a);
1527
+ i = c < i ? c : i, o = c > o ? c : o;
1529
1528
  }
1530
- this.min = i, this.max = r;
1529
+ this.min = i, this.max = o;
1531
1530
  }
1532
1531
  isSeparated(t) {
1533
1532
  return this.min > t.max || t.min > this.max;
@@ -1536,12 +1535,12 @@ class Te {
1536
1535
  Te.prototype.setFromBox = /* @__PURE__ */ function() {
1537
1536
  const n = /* @__PURE__ */ new U();
1538
1537
  return function(e, i) {
1539
- const r = i.min, o = i.max;
1538
+ const o = i.min, r = i.max;
1540
1539
  let s = 1 / 0, a = -1 / 0;
1541
1540
  for (let c = 0; c <= 1; c++)
1542
1541
  for (let u = 0; u <= 1; u++)
1543
1542
  for (let f = 0; f <= 1; f++) {
1544
- n.x = r.x * c + o.x * (1 - c), n.y = r.y * u + o.y * (1 - u), n.z = r.z * f + o.z * (1 - f);
1543
+ n.x = o.x * c + r.x * (1 - c), n.y = o.y * u + r.y * (1 - u), n.z = o.z * f + r.z * (1 - f);
1545
1544
  const d = e.dot(n);
1546
1545
  s = Math.min(d, s), a = Math.max(d, a);
1547
1546
  }
@@ -1550,34 +1549,34 @@ Te.prototype.setFromBox = /* @__PURE__ */ function() {
1550
1549
  }();
1551
1550
  const mr = /* @__PURE__ */ function() {
1552
1551
  const n = /* @__PURE__ */ new U(), t = /* @__PURE__ */ new U(), e = /* @__PURE__ */ new U();
1553
- return function(r, o, s) {
1554
- const a = r.start, c = n, u = o.start, f = t;
1555
- e.subVectors(a, u), n.subVectors(r.end, r.start), t.subVectors(o.end, o.start);
1552
+ return function(o, r, s) {
1553
+ const a = o.start, c = n, u = r.start, f = t;
1554
+ e.subVectors(a, u), n.subVectors(o.end, o.start), t.subVectors(r.end, r.start);
1556
1555
  const d = e.dot(f), l = f.dot(c), m = f.dot(f), p = e.dot(c), y = c.dot(c) * m - l * l;
1557
1556
  let M, h;
1558
1557
  y !== 0 ? M = (d * l - p * m) / y : M = 0, h = (d + M * l) / m, s.x = M, s.y = h;
1559
1558
  };
1560
1559
  }(), Rn = /* @__PURE__ */ function() {
1561
1560
  const n = /* @__PURE__ */ new Fe(), t = /* @__PURE__ */ new U(), e = /* @__PURE__ */ new U();
1562
- return function(r, o, s, a) {
1563
- mr(r, o, n);
1561
+ return function(o, r, s, a) {
1562
+ mr(o, r, n);
1564
1563
  let c = n.x, u = n.y;
1565
1564
  if (c >= 0 && c <= 1 && u >= 0 && u <= 1) {
1566
- r.at(c, s), o.at(u, a);
1565
+ o.at(c, s), r.at(u, a);
1567
1566
  return;
1568
1567
  } else if (c >= 0 && c <= 1) {
1569
- u < 0 ? o.at(0, a) : o.at(1, a), r.closestPointToPoint(a, !0, s);
1568
+ u < 0 ? r.at(0, a) : r.at(1, a), o.closestPointToPoint(a, !0, s);
1570
1569
  return;
1571
1570
  } else if (u >= 0 && u <= 1) {
1572
- c < 0 ? r.at(0, s) : r.at(1, s), o.closestPointToPoint(s, !0, a);
1571
+ c < 0 ? o.at(0, s) : o.at(1, s), r.closestPointToPoint(s, !0, a);
1573
1572
  return;
1574
1573
  } else {
1575
1574
  let f;
1576
- c < 0 ? f = r.start : f = r.end;
1575
+ c < 0 ? f = o.start : f = o.end;
1577
1576
  let d;
1578
- u < 0 ? d = o.start : d = o.end;
1577
+ u < 0 ? d = r.start : d = r.end;
1579
1578
  const l = t, m = e;
1580
- if (r.closestPointToPoint(d, !0, t), o.closestPointToPoint(f, !0, e), l.distanceToSquared(d) <= m.distanceToSquared(f)) {
1579
+ if (o.closestPointToPoint(d, !0, t), r.closestPointToPoint(f, !0, e), l.distanceToSquared(d) <= m.distanceToSquared(f)) {
1581
1580
  s.copy(l), a.copy(d);
1582
1581
  return;
1583
1582
  } else {
@@ -1588,8 +1587,8 @@ const mr = /* @__PURE__ */ function() {
1588
1587
  };
1589
1588
  }(), pr = /* @__PURE__ */ function() {
1590
1589
  const n = /* @__PURE__ */ new U(), t = /* @__PURE__ */ new U(), e = /* @__PURE__ */ new Mi(), i = /* @__PURE__ */ new Se();
1591
- return function(o, s) {
1592
- const { radius: a, center: c } = o, { a: u, b: f, c: d } = s;
1590
+ return function(r, s) {
1591
+ const { radius: a, center: c } = r, { a: u, b: f, c: d } = s;
1593
1592
  if (i.start = u, i.end = f, i.closestPointToPoint(c, !0, n).distanceTo(c) <= a || (i.start = u, i.end = d, i.closestPointToPoint(c, !0, n).distanceTo(c) <= a) || (i.start = f, i.end = d, i.closestPointToPoint(c, !0, n).distanceTo(c) <= a)) return !0;
1594
1593
  const w = s.getPlane(e);
1595
1594
  if (Math.abs(w.distanceToPoint(c)) <= a) {
@@ -1615,32 +1614,32 @@ class he extends je {
1615
1614
  return pr(t, this);
1616
1615
  }
1617
1616
  update() {
1618
- const t = this.a, e = this.b, i = this.c, r = this.points, o = this.satAxes, s = this.satBounds, a = o[0], c = s[0];
1619
- this.getNormal(a), c.setFromPoints(a, r);
1620
- const u = o[1], f = s[1];
1621
- u.subVectors(t, e), f.setFromPoints(u, r);
1622
- const d = o[2], l = s[2];
1623
- d.subVectors(e, i), l.setFromPoints(d, r);
1624
- const m = o[3], p = s[3];
1625
- m.subVectors(i, t), p.setFromPoints(m, r);
1617
+ const t = this.a, e = this.b, i = this.c, o = this.points, r = this.satAxes, s = this.satBounds, a = r[0], c = s[0];
1618
+ this.getNormal(a), c.setFromPoints(a, o);
1619
+ const u = r[1], f = s[1];
1620
+ u.subVectors(t, e), f.setFromPoints(u, o);
1621
+ const d = r[2], l = s[2];
1622
+ d.subVectors(e, i), l.setFromPoints(d, o);
1623
+ const m = r[3], p = s[3];
1624
+ m.subVectors(i, t), p.setFromPoints(m, o);
1626
1625
  const w = u.length(), y = d.length(), M = m.length();
1627
1626
  this.isDegenerateIntoPoint = !1, this.isDegenerateIntoSegment = !1, w < Me ? y < Me || M < Me ? this.isDegenerateIntoPoint = !0 : (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(t), this.degenerateSegment.end.copy(i)) : y < Me ? M < Me ? this.isDegenerateIntoPoint = !0 : (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(e), this.degenerateSegment.end.copy(t)) : M < Me && (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(i), this.degenerateSegment.end.copy(e)), this.plane.setFromNormalAndCoplanarPoint(a, t), this.needsUpdate = !1;
1628
1627
  }
1629
1628
  }
1630
1629
  he.prototype.closestPointToSegment = /* @__PURE__ */ function() {
1631
1630
  const n = /* @__PURE__ */ new U(), t = /* @__PURE__ */ new U(), e = /* @__PURE__ */ new Se();
1632
- return function(r, o = null, s = null) {
1633
- const { start: a, end: c } = r, u = this.points;
1631
+ return function(o, r = null, s = null) {
1632
+ const { start: a, end: c } = o, u = this.points;
1634
1633
  let f, d = 1 / 0;
1635
1634
  for (let l = 0; l < 3; l++) {
1636
1635
  const m = (l + 1) % 3;
1637
- e.start.copy(u[l]), e.end.copy(u[m]), Rn(e, r, n, t), f = n.distanceToSquared(t), f < d && (d = f, o && o.copy(n), s && s.copy(t));
1636
+ e.start.copy(u[l]), e.end.copy(u[m]), Rn(e, o, n, t), f = n.distanceToSquared(t), f < d && (d = f, r && r.copy(n), s && s.copy(t));
1638
1637
  }
1639
- return this.closestPointToPoint(a, n), f = a.distanceToSquared(n), f < d && (d = f, o && o.copy(n), s && s.copy(a)), this.closestPointToPoint(c, n), f = c.distanceToSquared(n), f < d && (d = f, o && o.copy(n), s && s.copy(c)), Math.sqrt(d);
1638
+ return this.closestPointToPoint(a, n), f = a.distanceToSquared(n), f < d && (d = f, r && r.copy(n), s && s.copy(a)), this.closestPointToPoint(c, n), f = c.distanceToSquared(n), f < d && (d = f, r && r.copy(n), s && s.copy(c)), Math.sqrt(d);
1640
1639
  };
1641
1640
  }();
1642
1641
  he.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1643
- const n = /* @__PURE__ */ new he(), t = /* @__PURE__ */ new Te(), e = /* @__PURE__ */ new Te(), i = /* @__PURE__ */ new U(), r = /* @__PURE__ */ new U(), o = /* @__PURE__ */ new U(), s = /* @__PURE__ */ new U(), a = /* @__PURE__ */ new Se(), c = /* @__PURE__ */ new Se(), u = /* @__PURE__ */ new U(), f = /* @__PURE__ */ new Fe(), d = /* @__PURE__ */ new Fe();
1642
+ const n = /* @__PURE__ */ new he(), t = /* @__PURE__ */ new Te(), e = /* @__PURE__ */ new Te(), i = /* @__PURE__ */ new U(), o = /* @__PURE__ */ new U(), r = /* @__PURE__ */ new U(), s = /* @__PURE__ */ new U(), a = /* @__PURE__ */ new Se(), c = /* @__PURE__ */ new Se(), u = /* @__PURE__ */ new U(), f = /* @__PURE__ */ new Fe(), d = /* @__PURE__ */ new Fe();
1644
1643
  function l(g, x, b, A) {
1645
1644
  const S = i;
1646
1645
  !g.isDegenerateIntoPoint && !g.isDegenerateIntoSegment ? S.copy(g.plane.normal) : S.copy(x.plane.normal);
@@ -1690,7 +1689,7 @@ he.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1690
1689
  function h(g, x, b, A) {
1691
1690
  if (g.isDegenerateIntoSegment)
1692
1691
  if (x.isDegenerateIntoSegment) {
1693
- const S = g.degenerateSegment, B = x.degenerateSegment, R = r, T = o;
1692
+ const S = g.degenerateSegment, B = x.degenerateSegment, R = o, T = r;
1694
1693
  S.delta(R), B.delta(T);
1695
1694
  const P = i.subVectors(B.start, S.start), C = R.x * T.y - R.y * T.x;
1696
1695
  if (ue(C))
@@ -1726,8 +1725,8 @@ he.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1726
1725
  const q = L * V, $ = L * ne;
1727
1726
  if (q > 0 && $ > 0)
1728
1727
  return !1;
1729
- r.copy(B.normal), o.copy(R.normal);
1730
- const G = r.cross(o);
1728
+ o.copy(B.normal), r.copy(R.normal);
1729
+ const G = o.cross(r);
1731
1730
  let X = 0, se = Math.abs(G.x);
1732
1731
  const ce = Math.abs(G.y);
1733
1732
  ce > se && (se = ce, X = 1), Math.abs(G.z) > se && (X = 2);
@@ -1754,7 +1753,7 @@ he.prototype.distanceToPoint = /* @__PURE__ */ function() {
1754
1753
  };
1755
1754
  }();
1756
1755
  he.prototype.distanceToTriangle = /* @__PURE__ */ function() {
1757
- const n = /* @__PURE__ */ new U(), t = /* @__PURE__ */ new U(), e = ["a", "b", "c"], i = /* @__PURE__ */ new Se(), r = /* @__PURE__ */ new Se();
1756
+ const n = /* @__PURE__ */ new U(), t = /* @__PURE__ */ new U(), e = ["a", "b", "c"], i = /* @__PURE__ */ new Se(), o = /* @__PURE__ */ new Se();
1758
1757
  return function(s, a = null, c = null) {
1759
1758
  const u = a || c ? i : null;
1760
1759
  if (this.intersectsTriangle(s, u, !0))
@@ -1772,7 +1771,7 @@ he.prototype.distanceToTriangle = /* @__PURE__ */ function() {
1772
1771
  i.set(this[l], this[m]);
1773
1772
  for (let p = 0; p < 3; p++) {
1774
1773
  const w = e[p], y = e[(p + 1) % 3];
1775
- r.set(s[w], s[y]), Rn(i, r, n, t);
1774
+ o.set(s[w], s[y]), Rn(i, o, n, t);
1776
1775
  const M = n.distanceToSquared(t);
1777
1776
  M < f && (f = M, a && a.copy(n), c && c.copy(t));
1778
1777
  }
@@ -1799,37 +1798,37 @@ class ae {
1799
1798
  }
1800
1799
  ae.prototype.update = /* @__PURE__ */ function() {
1801
1800
  return function() {
1802
- const t = this.matrix, e = this.min, i = this.max, r = this.points;
1801
+ const t = this.matrix, e = this.min, i = this.max, o = this.points;
1803
1802
  for (let u = 0; u <= 1; u++)
1804
1803
  for (let f = 0; f <= 1; f++)
1805
1804
  for (let d = 0; d <= 1; d++) {
1806
- const l = 1 * u | 2 * f | 4 * d, m = r[l];
1805
+ const l = 1 * u | 2 * f | 4 * d, m = o[l];
1807
1806
  m.x = u ? i.x : e.x, m.y = f ? i.y : e.y, m.z = d ? i.z : e.z, m.applyMatrix4(t);
1808
1807
  }
1809
- const o = this.satBounds, s = this.satAxes, a = r[0];
1808
+ const r = this.satBounds, s = this.satAxes, a = o[0];
1810
1809
  for (let u = 0; u < 3; u++) {
1811
- const f = s[u], d = o[u], l = 1 << u, m = r[l];
1812
- f.subVectors(a, m), d.setFromPoints(f, r);
1810
+ const f = s[u], d = r[u], l = 1 << u, m = o[l];
1811
+ f.subVectors(a, m), d.setFromPoints(f, o);
1813
1812
  }
1814
1813
  const c = this.alignedSatBounds;
1815
- c[0].setFromPointsField(r, "x"), c[1].setFromPointsField(r, "y"), c[2].setFromPointsField(r, "z"), this.invMatrix.copy(this.matrix).invert(), this.needsUpdate = !1;
1814
+ c[0].setFromPointsField(o, "x"), c[1].setFromPointsField(o, "y"), c[2].setFromPointsField(o, "z"), this.invMatrix.copy(this.matrix).invert(), this.needsUpdate = !1;
1816
1815
  };
1817
1816
  }();
1818
1817
  ae.prototype.intersectsBox = /* @__PURE__ */ function() {
1819
1818
  const n = /* @__PURE__ */ new Te();
1820
1819
  return function(e) {
1821
1820
  this.needsUpdate && this.update();
1822
- const i = e.min, r = e.max, o = this.satBounds, s = this.satAxes, a = this.alignedSatBounds;
1823
- if (n.min = i.x, n.max = r.x, a[0].isSeparated(n) || (n.min = i.y, n.max = r.y, a[1].isSeparated(n)) || (n.min = i.z, n.max = r.z, a[2].isSeparated(n))) return !1;
1821
+ const i = e.min, o = e.max, r = this.satBounds, s = this.satAxes, a = this.alignedSatBounds;
1822
+ if (n.min = i.x, n.max = o.x, a[0].isSeparated(n) || (n.min = i.y, n.max = o.y, a[1].isSeparated(n)) || (n.min = i.z, n.max = o.z, a[2].isSeparated(n))) return !1;
1824
1823
  for (let c = 0; c < 3; c++) {
1825
- const u = s[c], f = o[c];
1824
+ const u = s[c], f = r[c];
1826
1825
  if (n.setFromBox(u, e), f.isSeparated(n)) return !1;
1827
1826
  }
1828
1827
  return !0;
1829
1828
  };
1830
1829
  }();
1831
1830
  ae.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1832
- const n = /* @__PURE__ */ new he(), t = /* @__PURE__ */ new Array(3), e = /* @__PURE__ */ new Te(), i = /* @__PURE__ */ new Te(), r = /* @__PURE__ */ new U();
1831
+ const n = /* @__PURE__ */ new he(), t = /* @__PURE__ */ new Array(3), e = /* @__PURE__ */ new Te(), i = /* @__PURE__ */ new Te(), o = /* @__PURE__ */ new U();
1833
1832
  return function(s) {
1834
1833
  this.needsUpdate && this.update(), s.isExtendedTriangle ? s.needsUpdate && s.update() : (n.copy(s), n.update(), s = n);
1835
1834
  const a = this.satBounds, c = this.satAxes;
@@ -1847,7 +1846,7 @@ ae.prototype.intersectsTriangle = /* @__PURE__ */ function() {
1847
1846
  const m = c[l];
1848
1847
  for (let p = 0; p < 4; p++) {
1849
1848
  const w = f[p];
1850
- if (r.crossVectors(m, w), e.setFromPoints(r, t), i.setFromPoints(r, d), e.isSeparated(i)) return !1;
1849
+ if (o.crossVectors(m, w), e.setFromPoints(o, t), i.setFromPoints(o, d), e.isSeparated(i)) return !1;
1851
1850
  }
1852
1851
  }
1853
1852
  return !0;
@@ -1865,17 +1864,17 @@ ae.prototype.distanceToPoint = function() {
1865
1864
  };
1866
1865
  }();
1867
1866
  ae.prototype.distanceToBox = /* @__PURE__ */ function() {
1868
- const n = ["x", "y", "z"], t = /* @__PURE__ */ new Array(12).fill().map(() => new Se()), e = /* @__PURE__ */ new Array(12).fill().map(() => new Se()), i = /* @__PURE__ */ new U(), r = /* @__PURE__ */ new U();
1867
+ const n = ["x", "y", "z"], t = /* @__PURE__ */ new Array(12).fill().map(() => new Se()), e = /* @__PURE__ */ new Array(12).fill().map(() => new Se()), i = /* @__PURE__ */ new U(), o = /* @__PURE__ */ new U();
1869
1868
  return function(s, a = 0, c = null, u = null) {
1870
1869
  if (this.needsUpdate && this.update(), this.intersectsBox(s))
1871
- return (c || u) && (s.getCenter(r), this.closestPointToPoint(r, i), s.closestPointToPoint(i, r), c && c.copy(i), u && u.copy(r)), 0;
1870
+ return (c || u) && (s.getCenter(o), this.closestPointToPoint(o, i), s.closestPointToPoint(i, o), c && c.copy(i), u && u.copy(o)), 0;
1872
1871
  const f = a * a, d = s.min, l = s.max, m = this.points;
1873
1872
  let p = 1 / 0;
1874
1873
  for (let y = 0; y < 8; y++) {
1875
1874
  const M = m[y];
1876
- r.copy(M).clamp(d, l);
1877
- const h = M.distanceToSquared(r);
1878
- if (h < p && (p = h, c && c.copy(M), u && u.copy(r), h < f))
1875
+ o.copy(M).clamp(d, l);
1876
+ const h = M.distanceToSquared(o);
1877
+ if (h < p && (p = h, c && c.copy(M), u && u.copy(o), h < f))
1879
1878
  return Math.sqrt(h);
1880
1879
  }
1881
1880
  let w = 0;
@@ -1890,18 +1889,18 @@ ae.prototype.distanceToBox = /* @__PURE__ */ function() {
1890
1889
  for (let y = 0; y <= 1; y++)
1891
1890
  for (let M = 0; M <= 1; M++)
1892
1891
  for (let h = 0; h <= 1; h++) {
1893
- r.x = y ? l.x : d.x, r.y = M ? l.y : d.y, r.z = h ? l.z : d.z, this.closestPointToPoint(r, i);
1894
- const g = r.distanceToSquared(i);
1895
- if (g < p && (p = g, c && c.copy(i), u && u.copy(r), g < f))
1892
+ o.x = y ? l.x : d.x, o.y = M ? l.y : d.y, o.z = h ? l.z : d.z, this.closestPointToPoint(o, i);
1893
+ const g = o.distanceToSquared(i);
1894
+ if (g < p && (p = g, c && c.copy(i), u && u.copy(o), g < f))
1896
1895
  return Math.sqrt(g);
1897
1896
  }
1898
1897
  for (let y = 0; y < 12; y++) {
1899
1898
  const M = t[y];
1900
1899
  for (let h = 0; h < 12; h++) {
1901
1900
  const g = e[h];
1902
- Rn(M, g, i, r);
1903
- const x = i.distanceToSquared(r);
1904
- if (x < p && (p = x, c && c.copy(i), u && u.copy(r), x < f))
1901
+ Rn(M, g, i, o);
1902
+ const x = i.distanceToSquared(o);
1903
+ if (x < p && (p = x, c && c.copy(i), u && u.copy(o), x < f))
1905
1904
  return Math.sqrt(x);
1906
1905
  }
1907
1906
  }
@@ -1914,8 +1913,8 @@ class yr extends Pn {
1914
1913
  }
1915
1914
  }
1916
1915
  const fe = /* @__PURE__ */ new yr(), nt = /* @__PURE__ */ new U(), rn = /* @__PURE__ */ new U();
1917
- function gr(n, t, e = {}, i = 0, r = 1 / 0) {
1918
- const o = i * i, s = r * r;
1916
+ function gr(n, t, e = {}, i = 0, o = 1 / 0) {
1917
+ const r = i * i, s = o * o;
1919
1918
  let a = 1 / 0, c = null;
1920
1919
  if (n.shapecast(
1921
1920
  {
@@ -1924,7 +1923,7 @@ function gr(n, t, e = {}, i = 0, r = 1 / 0) {
1924
1923
  intersectsTriangle: (f, d) => {
1925
1924
  f.closestPointToPoint(t, nt);
1926
1925
  const l = t.distanceToSquared(nt);
1927
- return l < a && (rn.copy(nt), a = l, c = d), l < o;
1926
+ return l < a && (rn.copy(nt), a = l, c = d), l < r;
1928
1927
  }
1929
1928
  }
1930
1929
  ), a === 1 / 0) return null;
@@ -1932,42 +1931,42 @@ function gr(n, t, e = {}, i = 0, r = 1 / 0) {
1932
1931
  return e.point ? e.point.copy(rn) : e.point = rn.clone(), e.distance = u, e.faceIndex = c, e;
1933
1932
  }
1934
1933
  const bt = parseInt(Ai) >= 169, vr = parseInt(Ai) <= 161, ze = /* @__PURE__ */ new U(), ke = /* @__PURE__ */ new U(), Ue = /* @__PURE__ */ new U(), xt = /* @__PURE__ */ new Fe(), wt = /* @__PURE__ */ new Fe(), Mt = /* @__PURE__ */ new Fe(), ii = /* @__PURE__ */ new U(), oi = /* @__PURE__ */ new U(), ri = /* @__PURE__ */ new U(), it = /* @__PURE__ */ new U();
1935
- function br(n, t, e, i, r, o, s, a) {
1934
+ function br(n, t, e, i, o, r, s, a) {
1936
1935
  let c;
1937
- if (o === lo ? c = n.intersectTriangle(i, e, t, !0, r) : c = n.intersectTriangle(t, e, i, o !== uo, r), c === null) return null;
1938
- const u = n.origin.distanceTo(r);
1936
+ if (r === lo ? c = n.intersectTriangle(i, e, t, !0, o) : c = n.intersectTriangle(t, e, i, r !== uo, o), c === null) return null;
1937
+ const u = n.origin.distanceTo(o);
1939
1938
  return u < s || u > a ? null : {
1940
1939
  distance: u,
1941
- point: r.clone()
1940
+ point: o.clone()
1942
1941
  };
1943
1942
  }
1944
- function si(n, t, e, i, r, o, s, a, c, u, f) {
1945
- ze.fromBufferAttribute(t, o), ke.fromBufferAttribute(t, s), Ue.fromBufferAttribute(t, a);
1943
+ function si(n, t, e, i, o, r, s, a, c, u, f) {
1944
+ ze.fromBufferAttribute(t, r), ke.fromBufferAttribute(t, s), Ue.fromBufferAttribute(t, a);
1946
1945
  const d = br(n, ze, ke, Ue, it, c, u, f);
1947
1946
  if (d) {
1948
1947
  if (i) {
1949
- xt.fromBufferAttribute(i, o), wt.fromBufferAttribute(i, s), Mt.fromBufferAttribute(i, a), d.uv = new Fe();
1948
+ xt.fromBufferAttribute(i, r), wt.fromBufferAttribute(i, s), Mt.fromBufferAttribute(i, a), d.uv = new Fe();
1950
1949
  const m = je.getInterpolation(it, ze, ke, Ue, xt, wt, Mt, d.uv);
1951
1950
  bt || (d.uv = m);
1952
1951
  }
1953
- if (r) {
1954
- xt.fromBufferAttribute(r, o), wt.fromBufferAttribute(r, s), Mt.fromBufferAttribute(r, a), d.uv1 = new Fe();
1952
+ if (o) {
1953
+ xt.fromBufferAttribute(o, r), wt.fromBufferAttribute(o, s), Mt.fromBufferAttribute(o, a), d.uv1 = new Fe();
1955
1954
  const m = je.getInterpolation(it, ze, ke, Ue, xt, wt, Mt, d.uv1);
1956
1955
  bt || (d.uv1 = m), vr && (d.uv2 = d.uv1);
1957
1956
  }
1958
1957
  if (e) {
1959
- ii.fromBufferAttribute(e, o), oi.fromBufferAttribute(e, s), ri.fromBufferAttribute(e, a), d.normal = new U();
1958
+ ii.fromBufferAttribute(e, r), oi.fromBufferAttribute(e, s), ri.fromBufferAttribute(e, a), d.normal = new U();
1960
1959
  const m = je.getInterpolation(it, ze, ke, Ue, ii, oi, ri, d.normal);
1961
1960
  d.normal.dot(n.direction) > 0 && d.normal.multiplyScalar(-1), bt || (d.normal = m);
1962
1961
  }
1963
1962
  const l = {
1964
- a: o,
1963
+ a: r,
1965
1964
  b: s,
1966
1965
  c: a,
1967
1966
  normal: new U(),
1968
1967
  materialIndex: 0
1969
1968
  };
1970
- if (je.getNormal(ze, ke, Ue, l.normal), d.face = l, d.faceIndex = o, bt) {
1969
+ if (je.getNormal(ze, ke, Ue, l.normal), d.face = l, d.faceIndex = r, bt) {
1971
1970
  const m = new U();
1972
1971
  je.getBarycoord(it, ze, ke, Ue, m), d.barycoord = m;
1973
1972
  }
@@ -1977,7 +1976,7 @@ function si(n, t, e, i, r, o, s, a, c, u, f) {
1977
1976
  function ai(n) {
1978
1977
  return n && n.isMaterial ? n.side : n;
1979
1978
  }
1980
- function qt(n, t, e, i, r, o, s) {
1979
+ function qt(n, t, e, i, o, r, s) {
1981
1980
  const a = i * 3;
1982
1981
  let c = a + 0, u = a + 1, f = a + 2;
1983
1982
  const { index: d, groups: l } = n;
@@ -1988,59 +1987,59 @@ function qt(n, t, e, i, r, o, s) {
1988
1987
  for (let h = 0, g = l.length; h < g; h++) {
1989
1988
  const { start: x, count: b, materialIndex: A } = l[h];
1990
1989
  if (M >= x && M < x + b) {
1991
- const S = ai(t[A]), B = si(e, m, p, w, y, c, u, f, S, o, s);
1990
+ const S = ai(t[A]), B = si(e, m, p, w, y, c, u, f, S, r, s);
1992
1991
  if (B)
1993
- if (B.faceIndex = i, B.face.materialIndex = A, r)
1994
- r.push(B);
1992
+ if (B.faceIndex = i, B.face.materialIndex = A, o)
1993
+ o.push(B);
1995
1994
  else
1996
1995
  return B;
1997
1996
  }
1998
1997
  }
1999
1998
  } else {
2000
- const M = ai(t), h = si(e, m, p, w, y, c, u, f, M, o, s);
1999
+ const M = ai(t), h = si(e, m, p, w, y, c, u, f, M, r, s);
2001
2000
  if (h)
2002
- if (h.faceIndex = i, h.face.materialIndex = 0, r)
2003
- r.push(h);
2001
+ if (h.faceIndex = i, h.face.materialIndex = 0, o)
2002
+ o.push(h);
2004
2003
  else
2005
2004
  return h;
2006
2005
  }
2007
2006
  return null;
2008
2007
  }
2009
2008
  function J(n, t, e, i) {
2010
- const r = n.a, o = n.b, s = n.c;
2009
+ const o = n.a, r = n.b, s = n.c;
2011
2010
  let a = t, c = t + 1, u = t + 2;
2012
- e && (a = e.getX(a), c = e.getX(c), u = e.getX(u)), r.x = i.getX(a), r.y = i.getY(a), r.z = i.getZ(a), o.x = i.getX(c), o.y = i.getY(c), o.z = i.getZ(c), s.x = i.getX(u), s.y = i.getY(u), s.z = i.getZ(u);
2011
+ e && (a = e.getX(a), c = e.getX(c), u = e.getX(u)), o.x = i.getX(a), o.y = i.getY(a), o.z = i.getZ(a), r.x = i.getX(c), r.y = i.getY(c), r.z = i.getZ(c), s.x = i.getX(u), s.y = i.getY(u), s.z = i.getZ(u);
2013
2012
  }
2014
- function xr(n, t, e, i, r, o, s, a) {
2013
+ function xr(n, t, e, i, o, r, s, a) {
2015
2014
  const { geometry: c, _indirectBuffer: u } = n;
2016
- for (let f = i, d = i + r; f < d; f++)
2017
- qt(c, t, e, f, o, s, a);
2015
+ for (let f = i, d = i + o; f < d; f++)
2016
+ qt(c, t, e, f, r, s, a);
2018
2017
  }
2019
- function wr(n, t, e, i, r, o, s) {
2018
+ function wr(n, t, e, i, o, r, s) {
2020
2019
  const { geometry: a, _indirectBuffer: c } = n;
2021
2020
  let u = 1 / 0, f = null;
2022
- for (let d = i, l = i + r; d < l; d++) {
2021
+ for (let d = i, l = i + o; d < l; d++) {
2023
2022
  let m;
2024
- m = qt(a, t, e, d, null, o, s), m && m.distance < u && (f = m, u = m.distance);
2023
+ m = qt(a, t, e, d, null, r, s), m && m.distance < u && (f = m, u = m.distance);
2025
2024
  }
2026
2025
  return f;
2027
2026
  }
2028
- function Mr(n, t, e, i, r, o, s) {
2027
+ function Mr(n, t, e, i, o, r, s) {
2029
2028
  const { geometry: a } = e, { index: c } = a, u = a.attributes.position;
2030
2029
  for (let f = n, d = t + n; f < d; f++) {
2031
2030
  let l;
2032
- if (l = f, J(s, l * 3, c, u), s.needsUpdate = !0, i(s, l, r, o))
2031
+ if (l = f, J(s, l * 3, c, u), s.needsUpdate = !0, i(s, l, o, r))
2033
2032
  return !0;
2034
2033
  }
2035
2034
  return !1;
2036
2035
  }
2037
2036
  function Ar(n, t = null) {
2038
2037
  t && Array.isArray(t) && (t = new Set(t));
2039
- const e = n.geometry, i = e.index ? e.index.array : null, r = e.attributes.position;
2040
- let o, s, a, c, u = 0;
2038
+ const e = n.geometry, i = e.index ? e.index.array : null, o = e.attributes.position;
2039
+ let r, s, a, c, u = 0;
2041
2040
  const f = n._roots;
2042
2041
  for (let l = 0, m = f.length; l < m; l++)
2043
- o = f[l], s = new Uint32Array(o), a = new Uint16Array(o), c = new Float32Array(o), d(0, u), u += o.byteLength;
2042
+ r = f[l], s = new Uint32Array(r), a = new Uint16Array(r), c = new Float32Array(r), d(0, u), u += r.byteLength;
2044
2043
  function d(l, m, p = !1) {
2045
2044
  const w = l * 2;
2046
2045
  if (Y(w, a)) {
@@ -2048,7 +2047,7 @@ function Ar(n, t = null) {
2048
2047
  let h = 1 / 0, g = 1 / 0, x = 1 / 0, b = -1 / 0, A = -1 / 0, S = -1 / 0;
2049
2048
  for (let B = 3 * y, R = 3 * (y + M); B < R; B++) {
2050
2049
  let T = i[B];
2051
- const P = r.getX(T), C = r.getY(T), F = r.getZ(T);
2050
+ const P = o.getX(T), C = o.getY(T), F = o.getZ(T);
2052
2051
  P < h && (h = P), P > b && (b = P), C < g && (g = C), C > A && (A = C), F < x && (x = F), F > S && (S = F);
2053
2052
  }
2054
2053
  return c[l + 0] !== h || c[l + 1] !== g || c[l + 2] !== x || c[l + 3] !== b || c[l + 4] !== A || c[l + 5] !== S ? (c[l + 0] = h, c[l + 1] = g, c[l + 2] = x, c[l + 3] = b, c[l + 4] = A, c[l + 5] = S, !0) : !1;
@@ -2077,69 +2076,69 @@ function Ar(n, t = null) {
2077
2076
  }
2078
2077
  }
2079
2078
  }
2080
- function _e(n, t, e, i, r) {
2081
- let o, s, a, c, u, f;
2079
+ function _e(n, t, e, i, o) {
2080
+ let r, s, a, c, u, f;
2082
2081
  const d = 1 / e.direction.x, l = 1 / e.direction.y, m = 1 / e.direction.z, p = e.origin.x, w = e.origin.y, y = e.origin.z;
2083
2082
  let M = t[n], h = t[n + 3], g = t[n + 1], x = t[n + 3 + 1], b = t[n + 2], A = t[n + 3 + 2];
2084
- return d >= 0 ? (o = (M - p) * d, s = (h - p) * d) : (o = (h - p) * d, s = (M - p) * d), l >= 0 ? (a = (g - w) * l, c = (x - w) * l) : (a = (x - w) * l, c = (g - w) * l), o > c || a > s || ((a > o || isNaN(o)) && (o = a), (c < s || isNaN(s)) && (s = c), m >= 0 ? (u = (b - y) * m, f = (A - y) * m) : (u = (A - y) * m, f = (b - y) * m), o > f || u > s) ? !1 : ((u > o || o !== o) && (o = u), (f < s || s !== s) && (s = f), o <= r && s >= i);
2083
+ return d >= 0 ? (r = (M - p) * d, s = (h - p) * d) : (r = (h - p) * d, s = (M - p) * d), l >= 0 ? (a = (g - w) * l, c = (x - w) * l) : (a = (x - w) * l, c = (g - w) * l), r > c || a > s || ((a > r || isNaN(r)) && (r = a), (c < s || isNaN(s)) && (s = c), m >= 0 ? (u = (b - y) * m, f = (A - y) * m) : (u = (A - y) * m, f = (b - y) * m), r > f || u > s) ? !1 : ((u > r || r !== r) && (r = u), (f < s || s !== s) && (s = f), r <= o && s >= i);
2085
2084
  }
2086
- function Sr(n, t, e, i, r, o, s, a) {
2085
+ function Sr(n, t, e, i, o, r, s, a) {
2087
2086
  const { geometry: c, _indirectBuffer: u } = n;
2088
- for (let f = i, d = i + r; f < d; f++) {
2087
+ for (let f = i, d = i + o; f < d; f++) {
2089
2088
  let l = u ? u[f] : f;
2090
- qt(c, t, e, l, o, s, a);
2089
+ qt(c, t, e, l, r, s, a);
2091
2090
  }
2092
2091
  }
2093
- function Tr(n, t, e, i, r, o, s) {
2092
+ function Tr(n, t, e, i, o, r, s) {
2094
2093
  const { geometry: a, _indirectBuffer: c } = n;
2095
2094
  let u = 1 / 0, f = null;
2096
- for (let d = i, l = i + r; d < l; d++) {
2095
+ for (let d = i, l = i + o; d < l; d++) {
2097
2096
  let m;
2098
- m = qt(a, t, e, c ? c[d] : d, null, o, s), m && m.distance < u && (f = m, u = m.distance);
2097
+ m = qt(a, t, e, c ? c[d] : d, null, r, s), m && m.distance < u && (f = m, u = m.distance);
2099
2098
  }
2100
2099
  return f;
2101
2100
  }
2102
- function Cr(n, t, e, i, r, o, s) {
2101
+ function Cr(n, t, e, i, o, r, s) {
2103
2102
  const { geometry: a } = e, { index: c } = a, u = a.attributes.position;
2104
2103
  for (let f = n, d = t + n; f < d; f++) {
2105
2104
  let l;
2106
- if (l = e.resolveTriangleIndex(f), J(s, l * 3, c, u), s.needsUpdate = !0, i(s, l, r, o))
2105
+ if (l = e.resolveTriangleIndex(f), J(s, l * 3, c, u), s.needsUpdate = !0, i(s, l, o, r))
2107
2106
  return !0;
2108
2107
  }
2109
2108
  return !1;
2110
2109
  }
2111
- function Br(n, t, e, i, r, o, s) {
2112
- O.setBuffer(n._roots[t]), gn(0, n, e, i, r, o, s), O.clearBuffer();
2110
+ function Br(n, t, e, i, o, r, s) {
2111
+ O.setBuffer(n._roots[t]), gn(0, n, e, i, o, r, s), O.clearBuffer();
2113
2112
  }
2114
- function gn(n, t, e, i, r, o, s) {
2113
+ function gn(n, t, e, i, o, r, s) {
2115
2114
  const { float32Array: a, uint16Array: c, uint32Array: u } = O, f = n * 2;
2116
2115
  if (Y(f, c)) {
2117
2116
  const l = Z(n, u), m = ie(f, c);
2118
- xr(t, e, i, l, m, r, o, s);
2117
+ xr(t, e, i, l, m, o, r, s);
2119
2118
  } else {
2120
2119
  const l = Q(n);
2121
- _e(l, a, i, o, s) && gn(l, t, e, i, r, o, s);
2120
+ _e(l, a, i, r, s) && gn(l, t, e, i, o, r, s);
2122
2121
  const m = ee(n, u);
2123
- _e(m, a, i, o, s) && gn(m, t, e, i, r, o, s);
2122
+ _e(m, a, i, r, s) && gn(m, t, e, i, o, r, s);
2124
2123
  }
2125
2124
  }
2126
2125
  const Ir = ["x", "y", "z"];
2127
- function Pr(n, t, e, i, r, o) {
2126
+ function Pr(n, t, e, i, o, r) {
2128
2127
  O.setBuffer(n._roots[t]);
2129
- const s = vn(0, n, e, i, r, o);
2128
+ const s = vn(0, n, e, i, o, r);
2130
2129
  return O.clearBuffer(), s;
2131
2130
  }
2132
- function vn(n, t, e, i, r, o) {
2131
+ function vn(n, t, e, i, o, r) {
2133
2132
  const { float32Array: s, uint16Array: a, uint32Array: c } = O;
2134
2133
  let u = n * 2;
2135
2134
  if (Y(u, a)) {
2136
2135
  const d = Z(n, c), l = ie(u, a);
2137
- return wr(t, e, i, d, l, r, o);
2136
+ return wr(t, e, i, d, l, o, r);
2138
2137
  } else {
2139
2138
  const d = Gt(n, c), l = Ir[d], p = i.direction[l] >= 0;
2140
2139
  let w, y;
2141
2140
  p ? (w = Q(n), y = ee(n, c)) : (w = ee(n, c), y = Q(n));
2142
- const h = _e(w, s, i, r, o) ? vn(w, t, e, i, r, o) : null;
2141
+ const h = _e(w, s, i, o, r) ? vn(w, t, e, i, o, r) : null;
2143
2142
  if (h) {
2144
2143
  const b = h.point[l];
2145
2144
  if (p ? b <= s[y + d] : (
@@ -2148,23 +2147,23 @@ function vn(n, t, e, i, r, o) {
2148
2147
  ))
2149
2148
  return h;
2150
2149
  }
2151
- const x = _e(y, s, i, r, o) ? vn(y, t, e, i, r, o) : null;
2150
+ const x = _e(y, s, i, o, r) ? vn(y, t, e, i, o, r) : null;
2152
2151
  return h && x ? h.distance <= x.distance ? h : x : h || x || null;
2153
2152
  }
2154
2153
  }
2155
2154
  const At = /* @__PURE__ */ new ve(), $e = /* @__PURE__ */ new he(), We = /* @__PURE__ */ new he(), ot = /* @__PURE__ */ new Re(), ci = /* @__PURE__ */ new ae(), St = /* @__PURE__ */ new ae();
2156
2155
  function Rr(n, t, e, i) {
2157
2156
  O.setBuffer(n._roots[t]);
2158
- const r = bn(0, n, e, i);
2159
- return O.clearBuffer(), r;
2157
+ const o = bn(0, n, e, i);
2158
+ return O.clearBuffer(), o;
2160
2159
  }
2161
- function bn(n, t, e, i, r = null) {
2162
- const { float32Array: o, uint16Array: s, uint32Array: a } = O;
2160
+ function bn(n, t, e, i, o = null) {
2161
+ const { float32Array: r, uint16Array: s, uint32Array: a } = O;
2163
2162
  let c = n * 2;
2164
- if (r === null && (e.boundingBox || e.computeBoundingBox(), ci.set(e.boundingBox.min, e.boundingBox.max, i), r = ci), Y(c, s)) {
2163
+ if (o === null && (e.boundingBox || e.computeBoundingBox(), ci.set(e.boundingBox.min, e.boundingBox.max, i), o = ci), Y(c, s)) {
2165
2164
  const f = t.geometry, d = f.index, l = f.attributes.position, m = e.index, p = e.attributes.position, w = Z(n, a), y = ie(c, s);
2166
2165
  if (ot.copy(i).invert(), e.boundsTree)
2167
- return W(n, o, St), St.matrix.copy(ot), St.needsUpdate = !0, e.boundsTree.shapecast({
2166
+ return W(n, r, St), St.matrix.copy(ot), St.needsUpdate = !0, e.boundsTree.shapecast({
2168
2167
  intersectsBounds: (h) => St.intersectsBox(h),
2169
2168
  intersectsTriangle: (h) => {
2170
2169
  h.a.applyMatrix4(i), h.b.applyMatrix4(i), h.c.applyMatrix4(i), h.needsUpdate = !0;
@@ -2185,15 +2184,15 @@ function bn(n, t, e, i, r = null) {
2185
2184
  }
2186
2185
  } else {
2187
2186
  const f = Q(n), d = ee(n, a);
2188
- return W(f, o, At), !!(r.intersectsBox(At) && bn(f, t, e, i, r) || (W(d, o, At), r.intersectsBox(At) && bn(d, t, e, i, r)));
2187
+ return W(f, r, At), !!(o.intersectsBox(At) && bn(f, t, e, i, o) || (W(d, r, At), o.intersectsBox(At) && bn(d, t, e, i, o)));
2189
2188
  }
2190
2189
  }
2191
2190
  const Tt = /* @__PURE__ */ new Re(), sn = /* @__PURE__ */ new ae(), rt = /* @__PURE__ */ new ae(), Fr = /* @__PURE__ */ new U(), Dr = /* @__PURE__ */ new U(), Er = /* @__PURE__ */ new U(), _r = /* @__PURE__ */ new U();
2192
- function Nr(n, t, e, i = {}, r = {}, o = 0, s = 1 / 0) {
2191
+ function Nr(n, t, e, i = {}, o = {}, r = 0, s = 1 / 0) {
2193
2192
  t.boundingBox || t.computeBoundingBox(), sn.set(t.boundingBox.min, t.boundingBox.max, e), sn.needsUpdate = !0;
2194
2193
  const a = n.geometry, c = a.attributes.position, u = a.index, f = t.attributes.position, d = t.index, l = fe.getPrimitive(), m = fe.getPrimitive();
2195
2194
  let p = Fr, w = Dr, y = null, M = null;
2196
- r && (y = Er, M = _r);
2195
+ o && (y = Er, M = _r);
2197
2196
  let h = 1 / 0, g = null, x = null;
2198
2197
  return Tt.copy(e).invert(), rt.matrix.copy(Tt), n.shapecast(
2199
2198
  {
@@ -2210,7 +2209,7 @@ function Nr(n, t, e, i = {}, r = {}, o = 0, s = 1 / 0) {
2210
2209
  for (let C = b, F = b + A; C < F; C++) {
2211
2210
  J(l, 3 * C, u, c), l.needsUpdate = !0;
2212
2211
  const D = l.distanceToTriangle(m, p, y);
2213
- if (D < h && (w.copy(p), M && M.copy(y), h = D, g = C, x = T), D < o)
2212
+ if (D < h && (w.copy(p), M && M.copy(y), h = D, g = C, x = T), D < r)
2214
2213
  return !0;
2215
2214
  }
2216
2215
  }
@@ -2223,22 +2222,22 @@ function Nr(n, t, e, i = {}, r = {}, o = 0, s = 1 / 0) {
2223
2222
  for (let T = b, P = b + A; T < P; T++) {
2224
2223
  J(l, 3 * T, u, c), l.needsUpdate = !0;
2225
2224
  const C = l.distanceToTriangle(m, p, y);
2226
- if (C < h && (w.copy(p), M && M.copy(y), h = C, g = T, x = B), C < o)
2225
+ if (C < h && (w.copy(p), M && M.copy(y), h = C, g = T, x = B), C < r)
2227
2226
  return !0;
2228
2227
  }
2229
2228
  }
2230
2229
  }
2231
2230
  }
2232
2231
  }
2233
- ), fe.releasePrimitive(l), fe.releasePrimitive(m), h === 1 / 0 ? null : (i.point ? i.point.copy(w) : i.point = w.clone(), i.distance = h, i.faceIndex = g, r && (r.point ? r.point.copy(M) : r.point = M.clone(), r.point.applyMatrix4(Tt), w.applyMatrix4(Tt), r.distance = w.sub(r.point).length(), r.faceIndex = x), i);
2232
+ ), fe.releasePrimitive(l), fe.releasePrimitive(m), h === 1 / 0 ? null : (i.point ? i.point.copy(w) : i.point = w.clone(), i.distance = h, i.faceIndex = g, o && (o.point ? o.point.copy(M) : o.point = M.clone(), o.point.applyMatrix4(Tt), w.applyMatrix4(Tt), o.distance = w.sub(o.point).length(), o.faceIndex = x), i);
2234
2233
  }
2235
2234
  function Lr(n, t = null) {
2236
2235
  t && Array.isArray(t) && (t = new Set(t));
2237
- const e = n.geometry, i = e.index ? e.index.array : null, r = e.attributes.position;
2238
- let o, s, a, c, u = 0;
2236
+ const e = n.geometry, i = e.index ? e.index.array : null, o = e.attributes.position;
2237
+ let r, s, a, c, u = 0;
2239
2238
  const f = n._roots;
2240
2239
  for (let l = 0, m = f.length; l < m; l++)
2241
- o = f[l], s = new Uint32Array(o), a = new Uint16Array(o), c = new Float32Array(o), d(0, u), u += o.byteLength;
2240
+ r = f[l], s = new Uint32Array(r), a = new Uint16Array(r), c = new Float32Array(r), d(0, u), u += r.byteLength;
2242
2241
  function d(l, m, p = !1) {
2243
2242
  const w = l * 2;
2244
2243
  if (Y(w, a)) {
@@ -2249,7 +2248,7 @@ function Lr(n, t = null) {
2249
2248
  for (let P = 0; P < 3; P++) {
2250
2249
  let C = T + P;
2251
2250
  C = i ? i[C] : C;
2252
- const F = r.getX(C), D = r.getY(C), L = r.getZ(C);
2251
+ const F = o.getX(C), D = o.getY(C), L = o.getZ(C);
2253
2252
  F < h && (h = F), F > b && (b = F), D < g && (g = D), D > A && (A = D), L < x && (x = L), L > S && (S = L);
2254
2253
  }
2255
2254
  }
@@ -2279,38 +2278,38 @@ function Lr(n, t = null) {
2279
2278
  }
2280
2279
  }
2281
2280
  }
2282
- function zr(n, t, e, i, r, o, s) {
2283
- O.setBuffer(n._roots[t]), xn(0, n, e, i, r, o, s), O.clearBuffer();
2281
+ function zr(n, t, e, i, o, r, s) {
2282
+ O.setBuffer(n._roots[t]), xn(0, n, e, i, o, r, s), O.clearBuffer();
2284
2283
  }
2285
- function xn(n, t, e, i, r, o, s) {
2284
+ function xn(n, t, e, i, o, r, s) {
2286
2285
  const { float32Array: a, uint16Array: c, uint32Array: u } = O, f = n * 2;
2287
2286
  if (Y(f, c)) {
2288
2287
  const l = Z(n, u), m = ie(f, c);
2289
- Sr(t, e, i, l, m, r, o, s);
2288
+ Sr(t, e, i, l, m, o, r, s);
2290
2289
  } else {
2291
2290
  const l = Q(n);
2292
- _e(l, a, i, o, s) && xn(l, t, e, i, r, o, s);
2291
+ _e(l, a, i, r, s) && xn(l, t, e, i, o, r, s);
2293
2292
  const m = ee(n, u);
2294
- _e(m, a, i, o, s) && xn(m, t, e, i, r, o, s);
2293
+ _e(m, a, i, r, s) && xn(m, t, e, i, o, r, s);
2295
2294
  }
2296
2295
  }
2297
2296
  const kr = ["x", "y", "z"];
2298
- function Ur(n, t, e, i, r, o) {
2297
+ function Ur(n, t, e, i, o, r) {
2299
2298
  O.setBuffer(n._roots[t]);
2300
- const s = wn(0, n, e, i, r, o);
2299
+ const s = wn(0, n, e, i, o, r);
2301
2300
  return O.clearBuffer(), s;
2302
2301
  }
2303
- function wn(n, t, e, i, r, o) {
2302
+ function wn(n, t, e, i, o, r) {
2304
2303
  const { float32Array: s, uint16Array: a, uint32Array: c } = O;
2305
2304
  let u = n * 2;
2306
2305
  if (Y(u, a)) {
2307
2306
  const d = Z(n, c), l = ie(u, a);
2308
- return Tr(t, e, i, d, l, r, o);
2307
+ return Tr(t, e, i, d, l, o, r);
2309
2308
  } else {
2310
2309
  const d = Gt(n, c), l = kr[d], p = i.direction[l] >= 0;
2311
2310
  let w, y;
2312
2311
  p ? (w = Q(n), y = ee(n, c)) : (w = ee(n, c), y = Q(n));
2313
- const h = _e(w, s, i, r, o) ? wn(w, t, e, i, r, o) : null;
2312
+ const h = _e(w, s, i, o, r) ? wn(w, t, e, i, o, r) : null;
2314
2313
  if (h) {
2315
2314
  const b = h.point[l];
2316
2315
  if (p ? b <= s[y + d] : (
@@ -2319,23 +2318,23 @@ function wn(n, t, e, i, r, o) {
2319
2318
  ))
2320
2319
  return h;
2321
2320
  }
2322
- const x = _e(y, s, i, r, o) ? wn(y, t, e, i, r, o) : null;
2321
+ const x = _e(y, s, i, o, r) ? wn(y, t, e, i, o, r) : null;
2323
2322
  return h && x ? h.distance <= x.distance ? h : x : h || x || null;
2324
2323
  }
2325
2324
  }
2326
2325
  const Ct = /* @__PURE__ */ new ve(), Ye = /* @__PURE__ */ new he(), Xe = /* @__PURE__ */ new he(), st = /* @__PURE__ */ new Re(), li = /* @__PURE__ */ new ae(), Bt = /* @__PURE__ */ new ae();
2327
2326
  function Vr(n, t, e, i) {
2328
2327
  O.setBuffer(n._roots[t]);
2329
- const r = Mn(0, n, e, i);
2330
- return O.clearBuffer(), r;
2328
+ const o = Mn(0, n, e, i);
2329
+ return O.clearBuffer(), o;
2331
2330
  }
2332
- function Mn(n, t, e, i, r = null) {
2333
- const { float32Array: o, uint16Array: s, uint32Array: a } = O;
2331
+ function Mn(n, t, e, i, o = null) {
2332
+ const { float32Array: r, uint16Array: s, uint32Array: a } = O;
2334
2333
  let c = n * 2;
2335
- if (r === null && (e.boundingBox || e.computeBoundingBox(), li.set(e.boundingBox.min, e.boundingBox.max, i), r = li), Y(c, s)) {
2334
+ if (o === null && (e.boundingBox || e.computeBoundingBox(), li.set(e.boundingBox.min, e.boundingBox.max, i), o = li), Y(c, s)) {
2336
2335
  const f = t.geometry, d = f.index, l = f.attributes.position, m = e.index, p = e.attributes.position, w = Z(n, a), y = ie(c, s);
2337
2336
  if (st.copy(i).invert(), e.boundsTree)
2338
- return W(n, o, Bt), Bt.matrix.copy(st), Bt.needsUpdate = !0, e.boundsTree.shapecast({
2337
+ return W(n, r, Bt), Bt.matrix.copy(st), Bt.needsUpdate = !0, e.boundsTree.shapecast({
2339
2338
  intersectsBounds: (h) => Bt.intersectsBox(h),
2340
2339
  intersectsTriangle: (h) => {
2341
2340
  h.a.applyMatrix4(i), h.b.applyMatrix4(i), h.c.applyMatrix4(i), h.needsUpdate = !0;
@@ -2357,15 +2356,15 @@ function Mn(n, t, e, i, r = null) {
2357
2356
  }
2358
2357
  } else {
2359
2358
  const f = Q(n), d = ee(n, a);
2360
- return W(f, o, Ct), !!(r.intersectsBox(Ct) && Mn(f, t, e, i, r) || (W(d, o, Ct), r.intersectsBox(Ct) && Mn(d, t, e, i, r)));
2359
+ return W(f, r, Ct), !!(o.intersectsBox(Ct) && Mn(f, t, e, i, o) || (W(d, r, Ct), o.intersectsBox(Ct) && Mn(d, t, e, i, o)));
2361
2360
  }
2362
2361
  }
2363
2362
  const It = /* @__PURE__ */ new Re(), an = /* @__PURE__ */ new ae(), at = /* @__PURE__ */ new ae(), Gr = /* @__PURE__ */ new U(), Hr = /* @__PURE__ */ new U(), Or = /* @__PURE__ */ new U(), qr = /* @__PURE__ */ new U();
2364
- function $r(n, t, e, i = {}, r = {}, o = 0, s = 1 / 0) {
2363
+ function $r(n, t, e, i = {}, o = {}, r = 0, s = 1 / 0) {
2365
2364
  t.boundingBox || t.computeBoundingBox(), an.set(t.boundingBox.min, t.boundingBox.max, e), an.needsUpdate = !0;
2366
2365
  const a = n.geometry, c = a.attributes.position, u = a.index, f = t.attributes.position, d = t.index, l = fe.getPrimitive(), m = fe.getPrimitive();
2367
2366
  let p = Gr, w = Hr, y = null, M = null;
2368
- r && (y = Or, M = qr);
2367
+ o && (y = Or, M = qr);
2369
2368
  let h = 1 / 0, g = null, x = null;
2370
2369
  return It.copy(e).invert(), at.matrix.copy(It), n.shapecast(
2371
2370
  {
@@ -2385,7 +2384,7 @@ function $r(n, t, e, i = {}, r = {}, o = 0, s = 1 / 0) {
2385
2384
  const L = n.resolveTriangleIndex(F);
2386
2385
  J(l, 3 * L, u, c), l.needsUpdate = !0;
2387
2386
  const V = l.distanceToTriangle(m, p, y);
2388
- if (V < h && (w.copy(p), M && M.copy(y), h = V, g = F, x = T), V < o)
2387
+ if (V < h && (w.copy(p), M && M.copy(y), h = V, g = F, x = T), V < r)
2389
2388
  return !0;
2390
2389
  }
2391
2390
  }
@@ -2399,14 +2398,14 @@ function $r(n, t, e, i = {}, r = {}, o = 0, s = 1 / 0) {
2399
2398
  const C = n.resolveTriangleIndex(T);
2400
2399
  J(l, 3 * C, u, c), l.needsUpdate = !0;
2401
2400
  const F = l.distanceToTriangle(m, p, y);
2402
- if (F < h && (w.copy(p), M && M.copy(y), h = F, g = T, x = B), F < o)
2401
+ if (F < h && (w.copy(p), M && M.copy(y), h = F, g = T, x = B), F < r)
2403
2402
  return !0;
2404
2403
  }
2405
2404
  }
2406
2405
  }
2407
2406
  }
2408
2407
  }
2409
- ), fe.releasePrimitive(l), fe.releasePrimitive(m), h === 1 / 0 ? null : (i.point ? i.point.copy(w) : i.point = w.clone(), i.distance = h, i.faceIndex = g, r && (r.point ? r.point.copy(M) : r.point = M.clone(), r.point.applyMatrix4(It), w.applyMatrix4(It), r.distance = w.sub(r.point).length(), r.faceIndex = x), i);
2408
+ ), fe.releasePrimitive(l), fe.releasePrimitive(m), h === 1 / 0 ? null : (i.point ? i.point.copy(w) : i.point = w.clone(), i.distance = h, i.faceIndex = g, o && (o.point ? o.point.copy(M) : o.point = M.clone(), o.point.applyMatrix4(It), w.applyMatrix4(It), o.distance = w.sub(o.point).length(), o.faceIndex = x), i);
2410
2409
  }
2411
2410
  function ui(n, t, e) {
2412
2411
  return n === null ? null : (n.point.applyMatrix4(t.matrixWorld), n.distance = n.point.distanceTo(e.ray.origin), n.object = t, n);
@@ -2434,13 +2433,13 @@ class zt extends dr {
2434
2433
  cloneBuffers: !0,
2435
2434
  ...e
2436
2435
  };
2437
- const i = t.geometry, r = t._roots, o = t._indirectBuffer, s = i.getIndex(), a = {
2436
+ const i = t.geometry, o = t._roots, r = t._indirectBuffer, s = i.getIndex(), a = {
2438
2437
  version: 1,
2439
2438
  roots: null,
2440
2439
  index: null,
2441
2440
  indirectBuffer: null
2442
2441
  };
2443
- return e.cloneBuffers ? (a.roots = r.map((c) => c.slice()), a.index = s ? s.array.slice() : null, a.indirectBuffer = o ? o.slice() : null) : (a.roots = r, a.index = s ? s.array : null, a.indirectBuffer = o), a;
2442
+ return e.cloneBuffers ? (a.roots = o.map((c) => c.slice()), a.index = s ? s.array.slice() : null, a.indirectBuffer = r ? r.slice() : null) : (a.roots = o, a.index = s ? s.array : null, a.indirectBuffer = r), a;
2444
2443
  }
2445
2444
  /**
2446
2445
  * Returns a new MeshBVH instance from the serialized data. `geometry` is the geometry used
@@ -2461,17 +2460,17 @@ class zt extends dr {
2461
2460
  indirect: !!t.indirectBuffer,
2462
2461
  ...i
2463
2462
  };
2464
- const { index: r, roots: o, indirectBuffer: s } = t;
2463
+ const { index: o, roots: r, indirectBuffer: s } = t;
2465
2464
  t.version || (console.warn(
2466
2465
  "MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."
2467
- ), c(o));
2466
+ ), c(r));
2468
2467
  const a = new zt(e, { ...i, [In]: !0 });
2469
- if (a._roots = o, a._indirectBuffer = s || null, i.setIndex) {
2468
+ if (a._roots = r, a._indirectBuffer = s || null, i.setIndex) {
2470
2469
  const u = e.getIndex();
2471
2470
  if (u === null) {
2472
2471
  const f = new Tn(t.index, 1, !1);
2473
2472
  e.setIndex(f);
2474
- } else u.array !== r && (u.array.set(r), u.needsUpdate = !0);
2473
+ } else u.array !== o && (u.array.set(o), u.needsUpdate = !0);
2475
2474
  }
2476
2475
  return a;
2477
2476
  function c(u) {
@@ -2519,7 +2518,7 @@ class zt extends dr {
2519
2518
  }
2520
2519
  // write primitive bounds to the buffer - used only for validateBounds at the moment
2521
2520
  writePrimitiveBounds(t, e, i) {
2522
- const r = this.geometry, o = this._indirectBuffer, s = r.attributes.position, a = r.index ? r.index.array : null, u = (o ? o[t] : t) * 3;
2521
+ const o = this.geometry, r = this._indirectBuffer, s = o.attributes.position, a = o.index ? o.index.array : null, u = (r ? r[t] : t) * 3;
2523
2522
  let f = u + 0, d = u + 1, l = u + 2;
2524
2523
  a && (f = a[f], d = a[d], l = a[l]);
2525
2524
  for (let m = 0; m < 3; m++) {
@@ -2536,7 +2535,7 @@ class zt extends dr {
2536
2535
  // [x_center, x_delta, y_center, y_delta, z_center, z_delta] tuple starting at index (i - offset) * 6,
2537
2536
  // representing the center and half-extent in each dimension of triangle i
2538
2537
  computePrimitiveBounds(t, e, i) {
2539
- const r = this.geometry, o = this._indirectBuffer, s = r.attributes.position, a = r.index ? r.index.array : null, c = s.normalized;
2538
+ const o = this.geometry, r = this._indirectBuffer, s = o.attributes.position, a = o.index ? o.index.array : null, c = s.normalized;
2540
2539
  if (t < 0 || e + t - i.offset > i.length / 6)
2541
2540
  throw new Error("MeshBVH: compute triangle bounds range is invalid.");
2542
2541
  const u = s.array, f = s.offset || 0;
@@ -2544,7 +2543,7 @@ class zt extends dr {
2544
2543
  s.isInterleavedBufferAttribute && (d = s.data.stride);
2545
2544
  const l = ["getX", "getY", "getZ"], m = i.offset;
2546
2545
  for (let p = t, w = t + e; p < w; p++) {
2547
- const M = (o ? o[p] : p) * 3, h = (p - m) * 6;
2546
+ const M = (r ? r[p] : p) * 3, h = (p - m) * 6;
2548
2547
  let g = M + 0, x = M + 1, b = M + 2;
2549
2548
  a && (g = a[g], x = a[x], b = a[b]), c || (g = g * d + f, x = x * d + f, b = b * d + f);
2550
2549
  for (let A = 0; A < 3; A++) {
@@ -2570,16 +2569,16 @@ class zt extends dr {
2570
2569
  * @returns {Array<Intersection>}
2571
2570
  */
2572
2571
  raycastObject3D(t, e, i = []) {
2573
- const { material: r } = t;
2574
- if (r === void 0)
2572
+ const { material: o } = t;
2573
+ if (o === void 0)
2575
2574
  return;
2576
2575
  di.copy(t.matrixWorld).invert(), Rt.copy(e.ray).applyMatrix4(di), mi.setFromMatrixScale(t.matrixWorld), fi.copy(Rt.direction).multiply(mi);
2577
- const o = fi.length(), s = e.near / o, a = e.far / o;
2576
+ const r = fi.length(), s = e.near / r, a = e.far / r;
2578
2577
  if (e.firstHitOnly === !0) {
2579
- let c = this.raycastFirst(Rt, r, s, a);
2578
+ let c = this.raycastFirst(Rt, o, s, a);
2580
2579
  c = ui(c, t, e), c && i.push(c);
2581
2580
  } else {
2582
- const c = this.raycast(Rt, r, s, a);
2581
+ const c = this.raycast(Rt, o, s, a);
2583
2582
  for (let u = 0, f = c.length; u < f; u++) {
2584
2583
  const d = ui(c[u], t, e);
2585
2584
  d && i.push(d);
@@ -2618,10 +2617,10 @@ class zt extends dr {
2618
2617
  * @param {number} [far=Infinity]
2619
2618
  * @returns {Array<Intersection>}
2620
2619
  */
2621
- raycast(t, e = kn, i = 0, r = 1 / 0) {
2622
- const o = this._roots, s = [], a = this.indirect ? zr : Br;
2623
- for (let c = 0, u = o.length; c < u; c++)
2624
- a(this, c, e, t, s, i, r);
2620
+ raycast(t, e = kn, i = 0, o = 1 / 0) {
2621
+ const r = this._roots, s = [], a = this.indirect ? zr : Br;
2622
+ for (let c = 0, u = r.length; c < u; c++)
2623
+ a(this, c, e, t, s, i, o);
2625
2624
  return s;
2626
2625
  }
2627
2626
  /**
@@ -2635,12 +2634,12 @@ class zt extends dr {
2635
2634
  * @param {number} [far=Infinity]
2636
2635
  * @returns {Intersection|null}
2637
2636
  */
2638
- raycastFirst(t, e = kn, i = 0, r = 1 / 0) {
2639
- const o = this._roots;
2637
+ raycastFirst(t, e = kn, i = 0, o = 1 / 0) {
2638
+ const r = this._roots;
2640
2639
  let s = null;
2641
2640
  const a = this.indirect ? Ur : Pr;
2642
- for (let c = 0, u = o.length; c < u; c++) {
2643
- const f = a(this, c, e, t, i, r);
2641
+ for (let c = 0, u = r.length; c < u; c++) {
2642
+ const f = a(this, c, e, t, i, o);
2644
2643
  f != null && (s == null || f.distance < s.distance) && (s = f);
2645
2644
  }
2646
2645
  return s;
@@ -2659,8 +2658,8 @@ class zt extends dr {
2659
2658
  */
2660
2659
  intersectsGeometry(t, e) {
2661
2660
  let i = !1;
2662
- const r = this._roots, o = this.indirect ? Vr : Rr;
2663
- for (let s = 0, a = r.length; s < a && (i = o(this, s, t, e), !i); s++)
2661
+ const o = this._roots, r = this.indirect ? Vr : Rr;
2662
+ for (let s = 0, a = o.length; s < a && (i = r(this, s, t, e), !i); s++)
2664
2663
  ;
2665
2664
  return i;
2666
2665
  }
@@ -2708,8 +2707,8 @@ class zt extends dr {
2708
2707
  */
2709
2708
  bvhcast(t, e, i) {
2710
2709
  let {
2711
- intersectsRanges: r,
2712
- intersectsTriangles: o
2710
+ intersectsRanges: o,
2711
+ intersectsTriangles: r
2713
2712
  } = i;
2714
2713
  const s = fe.getPrimitive(), a = this.geometry.index, c = this.geometry.attributes.position, u = this.indirect ? (p) => {
2715
2714
  const w = this.resolveTriangleIndex(p);
@@ -2722,27 +2721,27 @@ class zt extends dr {
2722
2721
  } : (p) => {
2723
2722
  J(f, p * 3, d, l);
2724
2723
  };
2725
- if (o) {
2724
+ if (r) {
2726
2725
  if (!(t instanceof zt))
2727
2726
  throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');
2728
2727
  const p = (w, y, M, h, g, x, b, A) => {
2729
2728
  for (let S = M, B = M + h; S < B; S++) {
2730
2729
  m(S), f.a.applyMatrix4(e), f.b.applyMatrix4(e), f.c.applyMatrix4(e), f.needsUpdate = !0;
2731
2730
  for (let R = w, T = w + y; R < T; R++)
2732
- if (u(R), s.needsUpdate = !0, o(s, f, R, S, g, x, b, A))
2731
+ if (u(R), s.needsUpdate = !0, r(s, f, R, S, g, x, b, A))
2733
2732
  return !0;
2734
2733
  }
2735
2734
  return !1;
2736
2735
  };
2737
- if (r) {
2738
- const w = r;
2739
- r = function(y, M, h, g, x, b, A, S) {
2736
+ if (o) {
2737
+ const w = o;
2738
+ o = function(y, M, h, g, x, b, A, S) {
2740
2739
  return w(y, M, h, g, x, b, A, S) ? !0 : p(y, M, h, g, x, b, A, S);
2741
2740
  };
2742
2741
  } else
2743
- r = p;
2742
+ o = p;
2744
2743
  }
2745
- return super.bvhcast(t, e, { intersectsRanges: r });
2744
+ return super.bvhcast(t, e, { intersectsRanges: o });
2746
2745
  }
2747
2746
  /* Derived Cast Functions */
2748
2747
  /**
@@ -2805,14 +2804,14 @@ class zt extends dr {
2805
2804
  * @param {number} [maxThreshold=Infinity]
2806
2805
  * @returns {HitPointInfo|null}
2807
2806
  */
2808
- closestPointToGeometry(t, e, i = {}, r = {}, o = 0, s = 1 / 0) {
2807
+ closestPointToGeometry(t, e, i = {}, o = {}, r = 0, s = 1 / 0) {
2809
2808
  return (this.indirect ? $r : Nr)(
2810
2809
  this,
2811
2810
  t,
2812
2811
  e,
2813
2812
  i,
2814
- r,
2815
2813
  o,
2814
+ r,
2816
2815
  s
2817
2816
  );
2818
2817
  }
@@ -2835,13 +2834,13 @@ class zt extends dr {
2835
2834
  * @param {number} [maxThreshold=Infinity]
2836
2835
  * @returns {HitPointInfo|null}
2837
2836
  */
2838
- closestPointToPoint(t, e = {}, i = 0, r = 1 / 0) {
2837
+ closestPointToPoint(t, e = {}, i = 0, o = 1 / 0) {
2839
2838
  return gr(
2840
2839
  this,
2841
2840
  t,
2842
2841
  e,
2843
2842
  i,
2844
- r
2843
+ o
2845
2844
  );
2846
2845
  }
2847
2846
  }
@@ -2897,14 +2896,14 @@ class Ni extends un {
2897
2896
  * @returns {void}
2898
2897
  */
2899
2898
  updateFrom(t) {
2900
- const e = this.overrideItemSize, i = t.itemSize, r = t.count;
2899
+ const e = this.overrideItemSize, i = t.itemSize, o = t.count;
2901
2900
  if (e !== null) {
2902
- if (i * r % e !== 0)
2901
+ if (i * o % e !== 0)
2903
2902
  throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");
2904
- t.itemSize = e, t.count = r * i / e;
2903
+ t.itemSize = e, t.count = o * i / e;
2905
2904
  }
2906
- const o = t.itemSize, s = t.count, a = t.normalized, c = t.array.constructor, u = c.BYTES_PER_ELEMENT;
2907
- let f = this._forcedType, d = o;
2905
+ const r = t.itemSize, s = t.count, a = t.normalized, c = t.array.constructor, u = c.BYTES_PER_ELEMENT;
2906
+ let f = this._forcedType, d = r;
2908
2907
  if (f === null)
2909
2908
  switch (c) {
2910
2909
  case Float32Array:
@@ -2921,16 +2920,16 @@ class Ni extends un {
2921
2920
  f = Jt;
2922
2921
  break;
2923
2922
  }
2924
- let l, m, p, w, y = Wr(o);
2923
+ let l, m, p, w, y = Wr(r);
2925
2924
  switch (f) {
2926
2925
  case ut:
2927
- p = 1, m = Yr(o), a && u === 1 ? (w = c, y += "8", c === Uint8Array ? l = Un : (l = Vn, y += "_SNORM")) : (w = Float32Array, y += "32F", l = ut);
2926
+ p = 1, m = Yr(r), a && u === 1 ? (w = c, y += "8", c === Uint8Array ? l = Un : (l = Vn, y += "_SNORM")) : (w = Float32Array, y += "32F", l = ut);
2928
2927
  break;
2929
2928
  case Jt:
2930
- y += u * 8 + "I", p = a ? Math.pow(2, c.BYTES_PER_ELEMENT * 8 - 1) : 1, m = pi(o), u === 1 ? (w = Int8Array, l = Vn) : u === 2 ? (w = Int16Array, l = po) : (w = Int32Array, l = Jt);
2929
+ y += u * 8 + "I", p = a ? Math.pow(2, c.BYTES_PER_ELEMENT * 8 - 1) : 1, m = pi(r), u === 1 ? (w = Int8Array, l = Vn) : u === 2 ? (w = Int16Array, l = po) : (w = Int32Array, l = Jt);
2931
2930
  break;
2932
2931
  case lt:
2933
- y += u * 8 + "UI", p = a ? Math.pow(2, c.BYTES_PER_ELEMENT * 8 - 1) : 1, m = pi(o), u === 1 ? (w = Uint8Array, l = Un) : u === 2 ? (w = Uint16Array, l = mo) : (w = Uint32Array, l = lt);
2932
+ y += u * 8 + "UI", p = a ? Math.pow(2, c.BYTES_PER_ELEMENT * 8 - 1) : 1, m = pi(r), u === 1 ? (w = Uint8Array, l = Un) : u === 2 ? (w = Uint16Array, l = mo) : (w = Uint32Array, l = lt);
2934
2933
  break;
2935
2934
  }
2936
2935
  d === 3 && (m === _t || m === fn) && (d = 4);
@@ -2938,9 +2937,9 @@ class Ni extends un {
2938
2937
  t.normalized = !1;
2939
2938
  for (let b = 0; b < s; b++) {
2940
2939
  const A = d * b;
2941
- g[A] = t.getX(b) / p, o >= 2 && (g[A + 1] = t.getY(b) / p), o >= 3 && (g[A + 2] = t.getZ(b) / p, d === 4 && (g[A + 3] = 1)), o >= 4 && (g[A + 3] = t.getW(b) / p);
2940
+ g[A] = t.getX(b) / p, r >= 2 && (g[A + 1] = t.getY(b) / p), r >= 3 && (g[A + 2] = t.getZ(b) / p, d === 4 && (g[A + 3] = 1)), r >= 4 && (g[A + 3] = t.getW(b) / p);
2942
2941
  }
2943
- t.normalized = x, this.internalFormat = y, this.format = m, this.type = l, this.image.width = M, this.image.height = M, this.image.data = g, this.needsUpdate = !0, this.dispose(), t.itemSize = i, t.count = r;
2942
+ t.normalized = x, this.internalFormat = y, this.format = m, this.type = l, this.image.width = M, this.image.height = M, this.image.data = g, this.needsUpdate = !0, this.dispose(), t.itemSize = i, t.count = o;
2944
2943
  }
2945
2944
  }
2946
2945
  class Xr extends Ni {
@@ -2971,8 +2970,8 @@ class Li {
2971
2970
  if (e.index)
2972
2971
  this._cachedIndexAttr = e.index.clone();
2973
2972
  else {
2974
- const r = _i(Ht(e));
2975
- this._cachedIndexAttr = new Tn(r, 1, !1);
2973
+ const o = _i(Ht(e));
2974
+ this._cachedIndexAttr = new Tn(o, 1, !1);
2976
2975
  }
2977
2976
  Jr(e, i, this._cachedIndexAttr), this.index.updateFrom(this._cachedIndexAttr);
2978
2977
  } else
@@ -2984,29 +2983,29 @@ class Li {
2984
2983
  * @returns {void}
2985
2984
  */
2986
2985
  dispose() {
2987
- const { index: t, position: e, bvhBounds: i, bvhContents: r } = this;
2988
- t && t.dispose(), e && e.dispose(), i && i.dispose(), r && r.dispose();
2986
+ const { index: t, position: e, bvhBounds: i, bvhContents: o } = this;
2987
+ t && t.dispose(), e && e.dispose(), i && i.dispose(), o && o.dispose();
2989
2988
  }
2990
2989
  }
2991
2990
  function Jr(n, t, e) {
2992
- const i = e.array, r = n.index ? n.index.array : null;
2993
- for (let o = 0, s = t.length; o < s; o++) {
2994
- const a = 3 * o, c = 3 * t[o];
2991
+ const i = e.array, o = n.index ? n.index.array : null;
2992
+ for (let r = 0, s = t.length; r < s; r++) {
2993
+ const a = 3 * r, c = 3 * t[r];
2995
2994
  for (let u = 0; u < 3; u++)
2996
- i[a + u] = r ? r[c + u] : c + u;
2995
+ i[a + u] = o ? o[c + u] : c + u;
2997
2996
  }
2998
2997
  }
2999
2998
  function jr(n, t, e) {
3000
2999
  const i = n._roots;
3001
3000
  if (i.length !== 1)
3002
3001
  throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");
3003
- const r = i[0], o = new Uint16Array(r), s = new Uint32Array(r), a = new Float32Array(r), c = r.byteLength / te, u = 2 * Math.ceil(Math.sqrt(c / 2)), f = new Float32Array(4 * u * u), d = Math.ceil(Math.sqrt(c)), l = new Uint32Array(2 * d * d);
3002
+ const o = i[0], r = new Uint16Array(o), s = new Uint32Array(o), a = new Float32Array(o), c = o.byteLength / te, u = 2 * Math.ceil(Math.sqrt(c / 2)), f = new Float32Array(4 * u * u), d = Math.ceil(Math.sqrt(c)), l = new Uint32Array(2 * d * d);
3004
3003
  for (let m = 0; m < c; m++) {
3005
3004
  const p = m * te / 4, w = p * 2, y = p;
3006
3005
  for (let M = 0; M < 3; M++)
3007
3006
  f[8 * m + 0 + M] = a[y + 0 + M], f[8 * m + 4 + M] = a[y + 3 + M];
3008
- if (Y(w, o)) {
3009
- const M = ie(w, o), h = Z(p, s), g = Xo | M;
3007
+ if (Y(w, r)) {
3008
+ const M = ie(w, r), h = Z(p, s), g = Xo | M;
3010
3009
  l[m * 2 + 0] = g, l[m * 2 + 1] = h;
3011
3010
  } else {
3012
3011
  const M = s[p + 6], h = Gt(p, s);
@@ -3633,15 +3632,15 @@ class as {
3633
3632
  return this.cache.get(t);
3634
3633
  }
3635
3634
  acquire(t, e, i) {
3636
- const r = qo(t);
3637
- if (!r.isBakeable)
3635
+ const o = qo(t);
3636
+ if (!o.isBakeable)
3638
3637
  return null;
3639
- const o = (i == null ? void 0 : i.resolution) ?? 256, s = `${Wo(t, r)}_${o}`, a = this.cache.get(s);
3640
- return a ? (a.disposalTimer !== null && (clearTimeout(a.disposalTimer), a.disposalTimer = null), a.refCount++, a.handle) : this.bake(t, r, s, e, o);
3638
+ const r = (i == null ? void 0 : i.resolution) ?? 256, s = `${Wo(t, o)}_${r}`, a = this.cache.get(s);
3639
+ return a ? (a.disposalTimer !== null && (clearTimeout(a.disposalTimer), a.disposalTimer = null), a.refCount++, a.handle) : this.bake(t, o, s, e, r);
3641
3640
  }
3642
- bake(t, e, i, r, o) {
3641
+ bake(t, e, i, o, r) {
3643
3642
  var u;
3644
- const s = !((u = r.capabilities) != null && u.isWebGL2), a = new v.WebGLCubeRenderTarget(o, {
3643
+ const s = !((u = o.capabilities) != null && u.isWebGL2), a = new v.WebGLCubeRenderTarget(r, {
3645
3644
  type: s ? v.UnsignedByteType : v.HalfFloatType,
3646
3645
  format: v.RGBAFormat,
3647
3646
  depthBuffer: !0,
@@ -3649,7 +3648,7 @@ class as {
3649
3648
  minFilter: v.NearestFilter,
3650
3649
  magFilter: v.NearestFilter
3651
3650
  });
3652
- this.renderToTarget(t, e, r, a, s);
3651
+ this.renderToTarget(t, e, o, a, s);
3653
3652
  const c = {
3654
3653
  key: i,
3655
3654
  texture: a.texture,
@@ -3663,15 +3662,15 @@ class as {
3663
3662
  refCount: 1,
3664
3663
  disposalTimer: null,
3665
3664
  geometryRef: new WeakRef(t),
3666
- resolution: o,
3665
+ resolution: r,
3667
3666
  analysis: e
3668
3667
  }), c;
3669
3668
  }
3670
- renderToTarget(t, e, i, r, o) {
3669
+ renderToTarget(t, e, i, o, r) {
3671
3670
  var u, f;
3672
3671
  const s = t.getIndex() ? t.toNonIndexed() : t.clone(), a = $o(s, e);
3673
3672
  s.setAttribute("aFacet", new v.BufferAttribute(a, 4)), console.log("[DiamondBaker] renderToTarget called", {
3674
- isUnorm: o,
3673
+ isUnorm: r,
3675
3674
  triangleCount: e.triangleCount,
3676
3675
  centroid: e.centroid.toArray(),
3677
3676
  radius: e.radius,
@@ -3690,7 +3689,7 @@ class as {
3690
3689
  depthTest: !0,
3691
3690
  depthWrite: !0,
3692
3691
  toneMapped: !1,
3693
- defines: o ? { GEM_NORMALS_UNORM: 1 } : {},
3692
+ defines: r ? { GEM_NORMALS_UNORM: 1 } : {},
3694
3693
  uniforms: {
3695
3694
  uCentroid: { value: e.centroid },
3696
3695
  uRadius: { value: e.radius }
@@ -3699,7 +3698,7 @@ class as {
3699
3698
  try {
3700
3699
  const d = new v.Scene(), l = new v.Mesh(s, c);
3701
3700
  d.add(l);
3702
- const m = Math.max(1e-3, e.radius * 1e-3), p = Math.max(2.5, e.radius * 3), w = new v.CubeCamera(m, p, r);
3701
+ const m = Math.max(1e-3, e.radius * 1e-3), p = Math.max(2.5, e.radius * 3), w = new v.CubeCamera(m, p, o);
3703
3702
  w.position.copy(e.centroid);
3704
3703
  const y = ((f = i.getRenderTarget) == null ? void 0 : f.call(i)) ?? null, M = i.autoClear, h = i.toneMapping, g = new v.Color();
3705
3704
  i.getClearColor && i.getClearColor(g);
@@ -3727,15 +3726,15 @@ class as {
3727
3726
  }
3728
3727
  onContextRestored(t) {
3729
3728
  var e;
3730
- for (const [i, r] of this.cache.entries()) {
3731
- const o = r.geometryRef.deref();
3732
- if (!o) {
3733
- r.disposalTimer !== null && (clearTimeout(r.disposalTimer), r.disposalTimer = null), r.renderTarget.dispose(), this.cache.delete(i);
3729
+ for (const [i, o] of this.cache.entries()) {
3730
+ const r = o.geometryRef.deref();
3731
+ if (!r) {
3732
+ o.disposalTimer !== null && (clearTimeout(o.disposalTimer), o.disposalTimer = null), o.renderTarget.dispose(), this.cache.delete(i);
3734
3733
  continue;
3735
3734
  }
3736
3735
  const s = !((e = t.capabilities) != null && e.isWebGL2);
3737
- r.renderTarget.dispose();
3738
- const a = new v.WebGLCubeRenderTarget(r.resolution, {
3736
+ o.renderTarget.dispose();
3737
+ const a = new v.WebGLCubeRenderTarget(o.resolution, {
3739
3738
  type: s ? v.UnsignedByteType : v.HalfFloatType,
3740
3739
  format: v.RGBAFormat,
3741
3740
  depthBuffer: !0,
@@ -3743,13 +3742,13 @@ class as {
3743
3742
  minFilter: v.NearestFilter,
3744
3743
  magFilter: v.NearestFilter
3745
3744
  });
3746
- r.renderTarget = a, r.handle.texture = a.texture, r.handle.encoding = s ? "unorm" : "signed", this.renderToTarget(o, r.analysis, t, a, s);
3745
+ o.renderTarget = a, o.handle.texture = a.texture, o.handle.encoding = s ? "unorm" : "signed", this.renderToTarget(r, o.analysis, t, a, s);
3747
3746
  }
3748
3747
  }
3749
3748
  }
3750
3749
  const ct = new as(), hi = new v.Matrix4();
3751
3750
  class et extends v.ShaderMaterial {
3752
- constructor(e, i, r, o = {}) {
3751
+ constructor(e, i, o, r = {}) {
3753
3752
  const s = e.bvh ?? new Li();
3754
3753
  super({
3755
3754
  vertexShader: rs,
@@ -3759,22 +3758,22 @@ class et extends v.ShaderMaterial {
3759
3758
  USE_CUBE_ENV: 1,
3760
3759
  MAX_BOUNCES: 5,
3761
3760
  ...e.encoding === "unorm" ? { GEM_NORMALS_UNORM: 1 } : {},
3762
- ...o.useCorrectFresnel ? { USE_CORRECT_FRESNEL: 1 } : {},
3763
- ...o.correctDispersionSign ? { CORRECT_DISPERSION_SIGN: 1 } : {},
3764
- ...o.accumulateTIR ? { ACCUMULATE_TIR: 1 } : {}
3761
+ ...r.useCorrectFresnel ? { USE_CORRECT_FRESNEL: 1 } : {},
3762
+ ...r.correctDispersionSign ? { CORRECT_DISPERSION_SIGN: 1 } : {},
3763
+ ...r.accumulateTIR ? { ACCUMULATE_TIR: 1 } : {}
3765
3764
  },
3766
3765
  uniforms: {
3767
3766
  bvh: { value: s },
3768
3767
  envMap: { value: i },
3769
3768
  envRotationMatrix: { value: new v.Matrix3() },
3770
3769
  cameraPos: { value: new v.Vector3() },
3771
- ior: { value: r.ior ?? 2.417 },
3772
- dispersion: { value: r.dispersion ?? 0.012 },
3773
- absorption: { value: 1 + (r.absorptionFactor ?? 0) * 2 },
3774
- envIntensity: { value: r.envMapIntensity ?? 2.2 },
3770
+ ior: { value: o.ior ?? 2.417 },
3771
+ dispersion: { value: o.dispersion ?? 0.012 },
3772
+ absorption: { value: 1 + (o.absorptionFactor ?? 0) * 2 },
3773
+ envIntensity: { value: o.envMapIntensity ?? 2.2 },
3775
3774
  gamma: { value: 1 },
3776
- color: { value: new v.Color(r.hex) },
3777
- rgbBoost: { value: new v.Vector3(...r.boostFactors ?? [1.3, 1.3, 1.3]) },
3775
+ color: { value: new v.Color(o.hex) },
3776
+ rgbBoost: { value: new v.Vector3(...o.boostFactors ?? [1.3, 1.3, 1.3]) },
3778
3777
  transmission: { value: 0 },
3779
3778
  reflectivity: { value: 0.46 },
3780
3779
  facetSharpness: { value: 1 },
@@ -3786,10 +3785,10 @@ class et extends v.ShaderMaterial {
3786
3785
  uCentroid: { value: e.centroid ? e.centroid.clone() : new v.Vector3() },
3787
3786
  uRadius: { value: e.radius ?? 1 },
3788
3787
  uCamLocal: { value: new v.Vector3() },
3789
- refractiveIndex: { value: r.ior ?? 2.417 },
3790
- rIndexDelta: { value: r.dispersion ?? 0.012 },
3791
- absorptionFactor: { value: r.absorptionFactor ?? 0 },
3792
- gemColor: { value: new v.Color(r.hex) },
3788
+ refractiveIndex: { value: o.ior ?? 2.417 },
3789
+ rIndexDelta: { value: o.dispersion ?? 0.012 },
3790
+ absorptionFactor: { value: o.absorptionFactor ?? 0 },
3791
+ gemColor: { value: new v.Color(o.hex) },
3793
3792
  uExhaustionResidual: { value: 0.5 },
3794
3793
  bounces: { value: 5 },
3795
3794
  uSplitBounces: { value: 2 },
@@ -3812,19 +3811,19 @@ class et extends v.ShaderMaterial {
3812
3811
  }
3813
3812
  updatePreset(e) {
3814
3813
  if (this.uniforms.color && this.uniforms.color.value.set(e.hex), this.uniforms.gemColor && this.uniforms.gemColor.value.set(e.hex), this.uniforms.ior && (this.uniforms.ior.value = e.ior ?? 2.417), this.uniforms.refractiveIndex && (this.uniforms.refractiveIndex.value = e.ior ?? 2.417), this.uniforms.dispersion && (this.uniforms.dispersion.value = e.dispersion ?? 0.012), this.uniforms.rIndexDelta && (this.uniforms.rIndexDelta.value = e.dispersion ?? 0.012), this.uniforms.absorption && (this.uniforms.absorption.value = 1 + (e.absorptionFactor ?? 0) * 2), this.uniforms.absorptionFactor && (this.uniforms.absorptionFactor.value = e.absorptionFactor ?? 0), this.uniforms.rgbBoost) {
3815
- const [i, r, o] = e.boostFactors ?? [2, 2, 2];
3816
- this.uniforms.rgbBoost.value.set(i, r, o);
3814
+ const [i, o, r] = e.boostFactors ?? [2, 2, 2];
3815
+ this.uniforms.rgbBoost.value.set(i, o, r);
3817
3816
  }
3818
3817
  this.uniformsNeedUpdate = !0;
3819
3818
  }
3820
3819
  }
3821
3820
  const kt = /* @__PURE__ */ new Map();
3822
3821
  function Fn(n, t, e, i = {}) {
3823
- const r = `${i.useCorrectFresnel ? "_cf" : ""}${i.correctDispersionSign ? "_cd" : ""}${i.accumulateTIR ? "_at" : ""}`, o = `${n.key}_${e.id}_${e.hex}${r}`, s = kt.get(o);
3822
+ const o = `${i.useCorrectFresnel ? "_cf" : ""}${i.correctDispersionSign ? "_cd" : ""}${i.accumulateTIR ? "_at" : ""}`, r = `${n.key}_${e.id}_${e.hex}${o}`, s = kt.get(r);
3824
3823
  if (s)
3825
3824
  return s.refCount++, s.material;
3826
3825
  const a = new et(n, t, e, i);
3827
- return kt.set(o, { material: a, refCount: 1 }), a;
3826
+ return kt.set(r, { material: a, refCount: 1 }), a;
3828
3827
  }
3829
3828
  function zi(n) {
3830
3829
  for (const [t, e] of kt.entries())
@@ -3841,12 +3840,12 @@ class cs extends v.Scene {
3841
3840
  side: v.BackSide
3842
3841
  }), i = new v.Mesh(t, e);
3843
3842
  this.add(i);
3844
- const r = new v.PlaneGeometry(16, 16), o = new v.MeshBasicMaterial({
3843
+ const o = new v.PlaneGeometry(16, 16), r = new v.MeshBasicMaterial({
3845
3844
  color: 16777215,
3846
3845
  side: v.DoubleSide
3847
3846
  });
3848
- o.color.setScalar(4);
3849
- const s = new v.Mesh(r, o);
3847
+ r.color.setScalar(4);
3848
+ const s = new v.Mesh(o, r);
3850
3849
  s.position.set(0, 14, 0), s.rotation.x = Math.PI / 2, this.add(s);
3851
3850
  const a = new v.PlaneGeometry(12, 16), c = new v.MeshBasicMaterial({
3852
3851
  color: 16777215,
@@ -3899,8 +3898,8 @@ class cs extends v.Scene {
3899
3898
  function ls(n, t) {
3900
3899
  const e = new v.PMREMGenerator(t);
3901
3900
  e.compileEquirectangularShader();
3902
- const i = new cs(), r = e.fromScene(i).texture;
3903
- return n.environment = r, i.dispose(), e.dispose(), r;
3901
+ const i = new cs(), o = e.fromScene(i).texture;
3902
+ return n.environment = o, i.dispose(), e.dispose(), o;
3904
3903
  }
3905
3904
  class yi extends v.Scene {
3906
3905
  constructor() {
@@ -3910,7 +3909,7 @@ class yi extends v.Scene {
3910
3909
  side: v.BackSide
3911
3910
  }), i = new v.Mesh(t, e);
3912
3911
  this.add(i);
3913
- const r = [
3912
+ const o = [
3914
3913
  { pos: [0, 15, 8], size: [10, 8], intensity: 4.5 },
3915
3914
  // Front-top key
3916
3915
  { pos: [0, 15, -8], size: [10, 8], intensity: 4 },
@@ -3920,19 +3919,19 @@ class yi extends v.Scene {
3920
3919
  { pos: [9, 14, 0], size: [8, 10], intensity: 4 }
3921
3920
  // Right-top fill
3922
3921
  ];
3923
- for (const y of r) {
3922
+ for (const y of o) {
3924
3923
  const M = new v.PlaneGeometry(y.size[0], y.size[1]), h = new v.MeshBasicMaterial({ color: 16777215, side: v.DoubleSide });
3925
3924
  h.color.setScalar(y.intensity);
3926
3925
  const g = new v.Mesh(M, h);
3927
3926
  g.position.set(y.pos[0], y.pos[1], y.pos[2]), g.lookAt(0, 0, 0), this.add(g);
3928
3927
  }
3929
- const o = [
3928
+ const r = [
3930
3929
  { pos: [-13, 8, 6], size: [8, 9], intensity: 3.5 },
3931
3930
  { pos: [13, 8, 6], size: [8, 9], intensity: 3.5 },
3932
3931
  { pos: [0, 8, 14], size: [10, 7], intensity: 3.8 },
3933
3932
  { pos: [0, 8, -14], size: [10, 7], intensity: 3.2 }
3934
3933
  ];
3935
- for (const y of o) {
3934
+ for (const y of r) {
3936
3935
  const M = new v.PlaneGeometry(y.size[0], y.size[1]), h = new v.MeshBasicMaterial({ color: 16777215, side: v.DoubleSide });
3937
3936
  h.color.setScalar(y.intensity);
3938
3937
  const g = new v.Mesh(M, h);
@@ -4000,14 +3999,14 @@ function An(n, t, e = 512) {
4000
3999
  generateMipmaps: !1,
4001
4000
  minFilter: v.LinearFilter,
4002
4001
  magFilter: v.LinearFilter
4003
- }), r = new v.CubeCamera(0.1, 100, i), o = new yi(), s = n != null && n.getRenderTarget ? n.getRenderTarget() : null;
4004
- return r.update(n, o), n != null && n.setRenderTarget && n.setRenderTarget(s), o instanceof yi && o.dispose(), i.texture;
4002
+ }), o = new v.CubeCamera(0.1, 100, i), r = new yi(), s = n != null && n.getRenderTarget ? n.getRenderTarget() : null;
4003
+ return o.update(n, r), n != null && n.setRenderTarget && n.setRenderTarget(s), r instanceof yi && r.dispose(), i.texture;
4005
4004
  }
4006
4005
  async function gi(n, t) {
4007
4006
  const e = new v.PMREMGenerator(t);
4008
4007
  e.compileEquirectangularShader();
4009
- function i(o) {
4010
- const s = e.fromEquirectangular(o);
4008
+ function i(r) {
4009
+ const s = e.fromEquirectangular(r);
4011
4010
  let a;
4012
4011
  try {
4013
4012
  a = new v.WebGLCubeRenderTarget(512, {
@@ -4016,10 +4015,10 @@ async function gi(n, t) {
4016
4015
  generateMipmaps: !0,
4017
4016
  minFilter: v.LinearMipmapLinearFilter,
4018
4017
  magFilter: v.LinearFilter
4019
- }), a.fromEquirectangularTexture(t, o);
4018
+ }), a.fromEquirectangularTexture(t, r);
4020
4019
  } catch {
4021
4020
  }
4022
- return o.dispose(), e.dispose(), {
4021
+ return r.dispose(), e.dispose(), {
4023
4022
  renderTarget: s,
4024
4023
  texture: s.texture,
4025
4024
  gemRenderTarget: a,
@@ -4029,25 +4028,25 @@ async function gi(n, t) {
4029
4028
  }
4030
4029
  };
4031
4030
  }
4032
- const r = typeof n == "string" ? n.toLowerCase().includes(".exr") : n instanceof ArrayBuffer && n.byteLength >= 4 && new Uint8Array(n, 0, 4)[0] === 118 && new Uint8Array(n, 0, 4)[1] === 47;
4031
+ const o = typeof n == "string" ? n.toLowerCase().includes(".exr") : n instanceof ArrayBuffer && n.byteLength >= 4 && new Uint8Array(n, 0, 4)[0] === 118 && new Uint8Array(n, 0, 4)[1] === 47;
4033
4032
  if (n instanceof ArrayBuffer)
4034
4033
  try {
4035
- if (r) {
4036
- const o = new Hn().parse(n), s = new v.DataTexture(o.data, o.width, o.height, o.format, o.type);
4034
+ if (o) {
4035
+ const r = new Hn().parse(n), s = new v.DataTexture(r.data, r.width, r.height, r.format, r.type);
4037
4036
  return s.needsUpdate = !0, i(s);
4038
4037
  } else {
4039
- const o = new Gn().parse(n);
4040
- return i(o);
4038
+ const r = new Gn().parse(n);
4039
+ return i(r);
4041
4040
  }
4042
- } catch (o) {
4043
- throw e.dispose(), o;
4041
+ } catch (r) {
4042
+ throw e.dispose(), r;
4044
4043
  }
4045
- return new Promise((o, s) => {
4046
- r ? new Hn().load(
4044
+ return new Promise((r, s) => {
4045
+ o ? new Hn().load(
4047
4046
  n,
4048
4047
  (a) => {
4049
4048
  try {
4050
- o(i(a));
4049
+ r(i(a));
4051
4050
  } catch (c) {
4052
4051
  a.dispose(), e.dispose(), s(c);
4053
4052
  }
@@ -4060,7 +4059,7 @@ async function gi(n, t) {
4060
4059
  n,
4061
4060
  (a) => {
4062
4061
  try {
4063
- o(i(a));
4062
+ r(i(a));
4064
4063
  } catch (c) {
4065
4064
  a.dispose(), e.dispose(), s(c);
4066
4065
  }
@@ -4083,8 +4082,8 @@ function us(n) {
4083
4082
  setBoundingBox: !1
4084
4083
  });
4085
4084
  e.boundsTree = i;
4086
- const r = new Li();
4087
- return r.updateFrom(i), vi.set(n, r), r;
4085
+ const o = new Li();
4086
+ return o.updateFrom(i), vi.set(n, o), o;
4088
4087
  }
4089
4088
  function ki(n) {
4090
4089
  return typeof n == "string" ? JSON.parse(n) : n;
@@ -4409,8 +4408,8 @@ function Ui(n) {
4409
4408
  }
4410
4409
  const bi = new v.Matrix4();
4411
4410
  class Ae extends v.ShaderMaterial {
4412
- constructor(e, i, r, o = {}) {
4413
- const a = o.quality ? Ui(o.quality).rayBounces : o.rayBounces ?? 5, c = i.isCubeTexture === !0, u = r.boostFactors ?? [1, 1, 1], [f, d, l] = u;
4411
+ constructor(e, i, o, r = {}) {
4412
+ const a = r.quality ? Ui(r.quality).rayBounces : r.rayBounces ?? 5, c = i.isCubeTexture === !0, u = o.boostFactors ?? [1, 1, 1], [f, d, l] = u;
4414
4413
  super({
4415
4414
  vertexShader: ds,
4416
4415
  fragmentShader: ms,
@@ -4418,7 +4417,7 @@ class Ae extends v.ShaderMaterial {
4418
4417
  defines: {
4419
4418
  RAY_BOUNCES: a,
4420
4419
  ENV_MAP_TYPE: c ? 0 : 1,
4421
- DIA_ORIENT_ENVMAP: o.orientEnvMap ? 1 : 0,
4420
+ DIA_ORIENT_ENVMAP: r.orientEnvMap ? 1 : 0,
4422
4421
  HAS_GEM_INCLUSIONS: 0,
4423
4422
  GEM_NORMALS_UNORM: e.encoding === "unorm" ? 1 : 0
4424
4423
  },
@@ -4435,18 +4434,18 @@ class Ae extends v.ShaderMaterial {
4435
4434
  // Environment
4436
4435
  envMap: { value: i },
4437
4436
  envMapRotation: { value: 0 },
4438
- envMapIntensity: { value: r.envMapIntensity ?? 1 },
4437
+ envMapIntensity: { value: o.envMapIntensity ?? 1 },
4439
4438
  // Material
4440
- refractiveIndex: { value: r.ior ?? 2.6 },
4441
- rIndexDelta: { value: r.dispersion ?? 0.012 },
4442
- absorptionFactor: { value: r.absorptionFactor ?? 1 },
4443
- squashFactor: { value: r.squashFactor ?? 0.98 },
4444
- geometryFactor: { value: r.geometryFactor ?? 0.5 },
4445
- gammaFactor: { value: r.gammaFactor ?? 1 },
4446
- ambientFloor: { value: r.ambientFloor ?? 0.05 },
4439
+ refractiveIndex: { value: o.ior ?? 2.6 },
4440
+ rIndexDelta: { value: o.dispersion ?? 0.012 },
4441
+ absorptionFactor: { value: o.absorptionFactor ?? 1 },
4442
+ squashFactor: { value: o.squashFactor ?? 0.98 },
4443
+ geometryFactor: { value: o.geometryFactor ?? 0.5 },
4444
+ gammaFactor: { value: o.gammaFactor ?? 1 },
4445
+ ambientFloor: { value: o.ambientFloor ?? 0.05 },
4447
4446
  reflectivity: { value: 0.5 },
4448
4447
  boostFactors: { value: new v.Vector3(f, d, l) },
4449
- color: { value: new v.Color(r.hex) },
4448
+ color: { value: new v.Color(o.hex) },
4450
4449
  colorCorrection: { value: new v.Vector3(1, 1, 1) },
4451
4450
  transmission: { value: 0 },
4452
4451
  clampHDR: { value: !1 },
@@ -4461,21 +4460,21 @@ class Ae extends v.ShaderMaterial {
4461
4460
  re(this, "bakeHandle");
4462
4461
  re(this, "preset");
4463
4462
  re(this, "onBeforeRender");
4464
- this.bakeHandle = e, this.preset = { ...r }, this.onBeforeRender = (m, p, w, y, M) => {
4463
+ this.bakeHandle = e, this.preset = { ...o }, this.onBeforeRender = (m, p, w, y, M) => {
4465
4464
  w.getWorldPosition(this.uniforms.cameraPosition.value), this.uniforms.modelOffsetMatrix.value.copy(M.matrixWorld), bi.copy(M.matrixWorld).invert(), this.uniforms.modelOffsetMatrixInv.value.copy(bi), this.uniforms.viewMatrixUniform.value.copy(w.matrixWorldInverse);
4466
4465
  };
4467
4466
  }
4468
4467
  updatePreset(e) {
4469
4468
  if (this.preset = { ...this.preset, ...e }, this.uniforms.refractiveIndex.value = e.ior ?? 2.6, this.uniforms.rIndexDelta.value = e.dispersion ?? 0.012, this.uniforms.absorptionFactor.value = e.absorptionFactor ?? 1, this.uniforms.color.value.set(e.hex), e.squashFactor !== void 0 && (this.uniforms.squashFactor.value = e.squashFactor), e.geometryFactor !== void 0 && (this.uniforms.geometryFactor.value = e.geometryFactor), e.gammaFactor !== void 0 && (this.uniforms.gammaFactor.value = e.gammaFactor), e.envMapIntensity !== void 0 && (this.uniforms.envMapIntensity.value = e.envMapIntensity), e.ambientFloor !== void 0 && (this.uniforms.ambientFloor.value = e.ambientFloor), e.boostFactors) {
4470
- const [i, r, o] = e.boostFactors;
4471
- this.uniforms.boostFactors.value.set(i, r, o);
4469
+ const [i, o, r] = e.boostFactors;
4470
+ this.uniforms.boostFactors.value.set(i, o, r);
4472
4471
  }
4473
4472
  this.uniformsNeedUpdate = !0;
4474
4473
  }
4475
4474
  setEnvMap(e) {
4476
4475
  this.uniforms.envMap.value = e;
4477
- const r = e.isCubeTexture === !0 ? 0 : 1;
4478
- this.defines.ENV_MAP_TYPE !== r && (this.defines.ENV_MAP_TYPE = r, this.needsUpdate = !0);
4476
+ const o = e.isCubeTexture === !0 ? 0 : 1;
4477
+ this.defines.ENV_MAP_TYPE !== o && (this.defines.ENV_MAP_TYPE = o, this.needsUpdate = !0);
4479
4478
  }
4480
4479
  clone() {
4481
4480
  var i;
@@ -4493,7 +4492,7 @@ class Ae extends v.ShaderMaterial {
4493
4492
  }
4494
4493
  const Ut = /* @__PURE__ */ new Map();
4495
4494
  function Vi(n, t, e, i = {}) {
4496
- const r = i.quality ?? `b${i.rayBounces ?? 5}`, o = i.orientEnvMap ? "_o1" : "_o0", s = `ref_${n.key}_${e.id}_${e.hex}_${r}${o}`, a = Ut.get(s);
4495
+ const o = i.quality ?? `b${i.rayBounces ?? 5}`, r = i.orientEnvMap ? "_o1" : "_o0", s = `ref_${n.key}_${e.id}_${e.hex}_${o}${r}`, a = Ut.get(s);
4497
4496
  if (a)
4498
4497
  return a.refCount++, a.material;
4499
4498
  const c = new Ae(n, t, e, i);
@@ -4507,46 +4506,46 @@ function Gi(n) {
4507
4506
  }
4508
4507
  }
4509
4508
  function Ke(n, t, e) {
4510
- const i = Bi.find((o) => o.id === t) ?? Ee.find((o) => o.id === t), r = Array.isArray(n.material) ? e !== void 0 ? n.material[e] ? [n.material[e]] : [] : n.material : e === void 0 || e === 0 ? n.material ? [n.material] : [] : [];
4511
- for (const o of r)
4512
- o && o instanceof v.MeshStandardMaterial && (o.color.set(i ? i.hex : t), o.metalness = (i == null ? void 0 : i.metalness) ?? o.metalness ?? 1, o.roughness = (i == null ? void 0 : i.roughness) ?? o.roughness, o.envMapIntensity = 1.2, o instanceof v.MeshPhysicalMaterial && (o.clearcoat > 0 && (o.clearcoat = 0, o.needsUpdate = !0), i != null && i.specularColor && (o.specularColor ? o.specularColor.set(i.specularColor) : o.specularColor = new v.Color(i.specularColor)), (i == null ? void 0 : i.ior) !== void 0 && (o.ior = i.ior)));
4509
+ const i = Bi.find((r) => r.id === t) ?? Ee.find((r) => r.id === t), o = Array.isArray(n.material) ? e !== void 0 ? n.material[e] ? [n.material[e]] : [] : n.material : e === void 0 || e === 0 ? n.material ? [n.material] : [] : [];
4510
+ for (const r of o)
4511
+ r && r instanceof v.MeshStandardMaterial && (r.color.set(i ? i.hex : t), r.metalness = (i == null ? void 0 : i.metalness) ?? r.metalness ?? 1, r.roughness = (i == null ? void 0 : i.roughness) ?? r.roughness, r.envMapIntensity = 1.2, r instanceof v.MeshPhysicalMaterial && (r.clearcoat > 0 && (r.clearcoat = 0, r.needsUpdate = !0), i != null && i.specularColor && (r.specularColor ? r.specularColor.set(i.specularColor) : r.specularColor = new v.Color(i.specularColor)), (i == null ? void 0 : i.ior) !== void 0 && (r.ior = i.ior)));
4513
4512
  }
4514
4513
  function Je(n, t, e) {
4515
- const i = Ii.find((o) => o.id === t) ?? pe.find((o) => o.id === t), r = Array.isArray(n.material) ? e !== void 0 ? n.material[e] ? [n.material[e]] : [] : n.material : e === void 0 || e === 0 ? n.material ? [n.material] : [] : [];
4516
- for (const o of r)
4517
- if (o) {
4518
- if (o instanceof Ae)
4519
- i ? o.updatePreset(i) : (o.uniforms.color.value.set(t), o.uniformsNeedUpdate = !0);
4520
- else if (o instanceof et)
4514
+ const i = Ii.find((r) => r.id === t) ?? pe.find((r) => r.id === t), o = Array.isArray(n.material) ? e !== void 0 ? n.material[e] ? [n.material[e]] : [] : n.material : e === void 0 || e === 0 ? n.material ? [n.material] : [] : [];
4515
+ for (const r of o)
4516
+ if (r) {
4517
+ if (r instanceof Ae)
4518
+ i ? r.updatePreset(i) : (r.uniforms.color.value.set(t), r.uniformsNeedUpdate = !0);
4519
+ else if (r instanceof et)
4521
4520
  if (i) {
4522
- const s = o.bakeHandle, a = Fn(
4521
+ const s = r.bakeHandle, a = Fn(
4523
4522
  s,
4524
- o.uniforms.envMap.value,
4523
+ r.uniforms.envMap.value,
4525
4524
  i
4526
4525
  );
4527
- if (a !== o)
4528
- if (zi(o), Array.isArray(n.material)) {
4529
- const c = n.material.indexOf(o);
4526
+ if (a !== r)
4527
+ if (zi(r), Array.isArray(n.material)) {
4528
+ const c = n.material.indexOf(r);
4530
4529
  c !== -1 && (n.material[c] = a);
4531
4530
  } else
4532
4531
  n.material = a;
4533
4532
  else
4534
- o.updatePreset(i);
4533
+ r.updatePreset(i);
4535
4534
  } else
4536
- o.uniforms.color.value.set(t), o.uniformsNeedUpdate = !0;
4537
- else if (o instanceof v.MeshPhysicalMaterial) {
4538
- o.color.set(i ? i.hex : t), i && (o.ior = i.ior, o.roughness = i.roughness, i.specularColor && (o.specularColor ? o.specularColor.set(i.specularColor) : o.specularColor = new v.Color(i.specularColor)), i.attenuationColor && (o.attenuationColor ? o.attenuationColor.set(i.attenuationColor) : o.attenuationColor = new v.Color(i.attenuationColor), o.attenuationDistance = i.attenuationDistance ?? 0.5));
4539
- const s = o.transmission > 0, a = o.transparent !== !1;
4540
- o.transmission = 0, o.transparent = !1, o.envMapIntensity = 3, (s || a) && (o.needsUpdate = !0);
4535
+ r.uniforms.color.value.set(t), r.uniformsNeedUpdate = !0;
4536
+ else if (r instanceof v.MeshPhysicalMaterial) {
4537
+ r.color.set(i ? i.hex : t), i && (r.ior = i.ior, r.roughness = i.roughness, i.specularColor && (r.specularColor ? r.specularColor.set(i.specularColor) : r.specularColor = new v.Color(i.specularColor)), i.attenuationColor && (r.attenuationColor ? r.attenuationColor.set(i.attenuationColor) : r.attenuationColor = new v.Color(i.attenuationColor), r.attenuationDistance = i.attenuationDistance ?? 0.5));
4538
+ const s = r.transmission > 0, a = r.transparent !== !1;
4539
+ r.transmission = 0, r.transparent = !1, r.envMapIntensity = 3, (s || a) && (r.needsUpdate = !0);
4541
4540
  }
4542
4541
  }
4543
4542
  }
4544
- function xi(n, t, e, i, r = "reference") {
4543
+ function xi(n, t, e, i, o = "reference") {
4545
4544
  var f, d, l;
4546
- const o = Array.isArray(n.material) ? n.material[0] : n.material, s = o instanceof v.MeshPhysicalMaterial, a = o instanceof et, c = s && o.metalness > 0.5;
4545
+ const r = Array.isArray(n.material) ? n.material[0] : n.material, s = r instanceof v.MeshPhysicalMaterial, a = r instanceof et, c = s && r.metalness > 0.5;
4547
4546
  if (t === "metal") {
4548
4547
  if (!s || !c) {
4549
- const m = o, p = new v.MeshPhysicalMaterial({
4548
+ const m = r, p = new v.MeshPhysicalMaterial({
4550
4549
  color: m instanceof v.MeshStandardMaterial ? m.color.clone() : new v.Color("#C0C0C0"),
4551
4550
  metalness: 1,
4552
4551
  roughness: 0,
@@ -4554,13 +4553,13 @@ function xi(n, t, e, i, r = "reference") {
4554
4553
  envMapIntensity: 1,
4555
4554
  side: v.DoubleSide
4556
4555
  });
4557
- o instanceof et ? zi(o) : o instanceof Ae ? Gi(o) : m == null || m.dispose(), m != null && m.name && (p.name = m.name), m != null && m.userData && (p.userData = { ...m.userData, ...p.userData }), n.material = p;
4556
+ r instanceof et ? zi(r) : r instanceof Ae ? Gi(r) : m == null || m.dispose(), m != null && m.name && (p.name = m.name), m != null && m.userData && (p.userData = { ...m.userData, ...p.userData }), n.material = p;
4558
4557
  }
4559
4558
  return;
4560
4559
  }
4561
- const u = o instanceof Ae;
4560
+ const u = r instanceof Ae;
4562
4561
  if (a || u) {
4563
- i && (u ? o.setEnvMap(i) : o.uniforms.envMap.value = i);
4562
+ i && (u ? r.setEnvMap(i) : r.uniforms.envMap.value = i);
4564
4563
  return;
4565
4564
  }
4566
4565
  if (e) {
@@ -4580,14 +4579,14 @@ function xi(n, t, e, i, r = "reference") {
4580
4579
  if (m) {
4581
4580
  const p = i ?? An(e);
4582
4581
  let w;
4583
- r === "reference" && !m.key.startsWith("bvh_") ? w = Vi(m, p, pe[0]) : w = Fn(m, p, pe[0]);
4584
- const y = o;
4582
+ o === "reference" && !m.key.startsWith("bvh_") ? w = Vi(m, p, pe[0]) : w = Fn(m, p, pe[0]);
4583
+ const y = r;
4585
4584
  y == null || y.dispose(), y != null && y.name && (w.name = y.name), y != null && y.userData && (w.userData = { ...y.userData, ...w.userData }), n.material = w;
4586
4585
  return;
4587
4586
  }
4588
4587
  }
4589
4588
  if (!s || c) {
4590
- const m = o, p = new v.MeshPhysicalMaterial({
4589
+ const m = r, p = new v.MeshPhysicalMaterial({
4591
4590
  color: m instanceof v.MeshStandardMaterial ? m.color.clone() : new v.Color("#FFFFFF"),
4592
4591
  metalness: 0,
4593
4592
  transmission: 0,
@@ -4601,10 +4600,10 @@ function xi(n, t, e, i, r = "reference") {
4601
4600
  }
4602
4601
  }
4603
4602
  function ps(n, t, e = !0) {
4604
- let i, r = !0, o = "high", s;
4605
- t instanceof v.PerspectiveCamera ? (i = t, typeof e == "boolean" ? r = e : e && typeof e == "object" && (r = e.antialias ?? !0, e.quality && (o = e.quality), s = e.onResize)) : typeof t == "boolean" ? r = t : t && typeof t == "object" && (r = t.antialias ?? !0, t.quality && (o = t.quality), s = t.onResize);
4603
+ let i, o = !0, r = "high", s;
4604
+ t instanceof v.PerspectiveCamera ? (i = t, typeof e == "boolean" ? o = e : e && typeof e == "object" && (o = e.antialias ?? !0, e.quality && (r = e.quality), s = e.onResize)) : typeof t == "boolean" ? o = t : t && typeof t == "object" && (o = t.antialias ?? !0, t.quality && (r = t.quality), s = t.onResize);
4606
4605
  const a = new v.WebGLRenderer({
4607
- antialias: r,
4606
+ antialias: o,
4608
4607
  alpha: !1,
4609
4608
  powerPreference: "default"
4610
4609
  });
@@ -4616,7 +4615,7 @@ function ps(n, t, e = !0) {
4616
4615
  let p = 1;
4617
4616
  d === "low" ? p = 1 : d === "medium" ? p = Math.min(m, l ? 1.25 : 1.5) : d === "high" && (p = Math.min(m, l ? 1.5 : 2)), a.setPixelRatio(p), c && (s == null || s());
4618
4617
  }
4619
- u(o), c = !0;
4618
+ u(r), c = !0;
4620
4619
  let f = null;
4621
4620
  return typeof ResizeObserver < "u" && (f = new ResizeObserver(() => {
4622
4621
  const d = n.clientWidth, l = n.clientHeight;
@@ -4632,20 +4631,20 @@ function ps(n, t, e = !0) {
4632
4631
  function hs(n = 1710618, t = 25) {
4633
4632
  const e = new v.Scene(), i = n === "studio" ? 1447448 : n;
4634
4633
  e.background = new v.Color(i);
4635
- const r = new v.PerspectiveCamera(
4634
+ const o = new v.PerspectiveCamera(
4636
4635
  t,
4637
4636
  1,
4638
4637
  // aspect updated on resize
4639
4638
  0.01,
4640
4639
  1e3
4641
4640
  );
4642
- r.position.set(0, 0, 3);
4643
- const o = new v.DirectionalLight("#ffffff", 1);
4644
- o.position.set(5, 8, 5), e.add(o);
4641
+ o.position.set(0, 0, 3);
4642
+ const r = new v.DirectionalLight("#ffffff", 1);
4643
+ r.position.set(5, 8, 5), e.add(r);
4645
4644
  const s = new v.DirectionalLight("#e0e8ff", 0.4);
4646
4645
  return s.position.set(-5, 3, -5), e.add(s), {
4647
4646
  scene: e,
4648
- camera: r,
4647
+ camera: o,
4649
4648
  dispose: () => {
4650
4649
  e.clear();
4651
4650
  }
@@ -4657,14 +4656,14 @@ function ys(n, t, e) {
4657
4656
  function gs(n, t, e = {}) {
4658
4657
  const i = new wo(n, t);
4659
4658
  i.enableDamping = !0, i.dampingFactor = 0.05, i.screenSpacePanning = !1, i.autoRotate = e.autoRotate ?? !1, i.autoRotateSpeed = e.autoRotateSpeed ?? 2;
4660
- const r = n.position.clone(), o = i.target.clone();
4659
+ const o = n.position.clone(), r = i.target.clone();
4661
4660
  function s() {
4662
- n.position.copy(r), i.target.copy(o), i.update();
4661
+ n.position.copy(o), i.target.copy(r), i.update();
4663
4662
  }
4664
4663
  return {
4665
4664
  controls: i,
4666
- initialPosition: r,
4667
- initialTarget: o,
4665
+ initialPosition: o,
4666
+ initialTarget: r,
4668
4667
  resetCamera: s,
4669
4668
  dispose: () => {
4670
4669
  i.dispose();
@@ -4672,10 +4671,10 @@ function gs(n, t, e = {}) {
4672
4671
  };
4673
4672
  }
4674
4673
  function wi(n, t, e, i = {}) {
4675
- const r = "controls" in e ? e.controls : e, s = new v.Box3().setFromObject(n).getBoundingSphere(new v.Sphere()), a = s.radius > 0 ? s.radius : 1, c = v.MathUtils.degToRad(t.fov), u = a / Math.tan(c / 2) * 1.15;
4676
- r.target.copy(s.center), t.position.set(s.center.x, s.center.y, s.center.z + u), t.near = a * 0.01, t.far = a * 100, t.updateProjectionMatrix(), r.minDistance = i.minZoom ?? a * 0.5, r.maxDistance = i.maxZoom ?? a * 6, r.update();
4674
+ const o = "controls" in e ? e.controls : e, s = new v.Box3().setFromObject(n).getBoundingSphere(new v.Sphere()), a = s.radius > 0 ? s.radius : 1, c = v.MathUtils.degToRad(t.fov), u = a / Math.tan(c / 2) * 1.15;
4675
+ o.target.copy(s.center), t.position.set(s.center.x, s.center.y, s.center.z + u), t.near = a * 0.01, t.far = a * 100, t.updateProjectionMatrix(), o.minDistance = i.minZoom ?? a * 0.5, o.maxDistance = i.maxZoom ?? a * 6, o.update();
4677
4676
  }
4678
- function vs(n, t, e, i, r, o = () => [], s) {
4677
+ function vs(n, t, e, i, o, r = () => [], s) {
4679
4678
  const a = new v.Raycaster(), c = new v.Vector2();
4680
4679
  let u = null, f;
4681
4680
  const d = new v.Color();
@@ -4708,10 +4707,10 @@ function vs(n, t, e, i, r, o = () => [], s) {
4708
4707
  $ && (d.copy($.emissive), l = $.emissiveIntensity, $.emissive.set(16777215), $.emissiveIntensity = 0.3);
4709
4708
  }
4710
4709
  (V = n.domElement) != null && V.style && (n.domElement.style.cursor = "pointer");
4711
- const q = o().find(($) => $.meshId === D.uuid);
4710
+ const q = r().find(($) => $.meshId === D.uuid);
4712
4711
  if (q) {
4713
4712
  const $ = L !== void 0 && q.slots[L] !== void 0 ? L : 0, G = q.slots[$];
4714
- r.emit("partHover", {
4713
+ o.emit("partHover", {
4715
4714
  meshId: q.meshId,
4716
4715
  partId: q.partId,
4717
4716
  type: q.type,
@@ -4720,9 +4719,9 @@ function vs(n, t, e, i, r, o = () => [], s) {
4720
4719
  materialName: (G == null ? void 0 : G.materialName) ?? q.materialName
4721
4720
  });
4722
4721
  } else
4723
- r.emit("partHover", null);
4722
+ o.emit("partHover", null);
4724
4723
  } else
4725
- (ne = n.domElement) != null && ne.style && (n.domElement.style.cursor = "default"), r.emit("partHover", null);
4724
+ (ne = n.domElement) != null && ne.style && (n.domElement.style.cursor = "default"), o.emit("partHover", null);
4726
4725
  }
4727
4726
  }
4728
4727
  function A() {
@@ -4757,10 +4756,10 @@ function vs(n, t, e, i, r, o = () => [], s) {
4757
4756
  }
4758
4757
  }
4759
4758
  if ($) {
4760
- const X = o().find((se) => se.meshId === $.uuid);
4759
+ const X = r().find((se) => se.meshId === $.uuid);
4761
4760
  if (X) {
4762
4761
  const se = G !== void 0 && X.slots[G] !== void 0 ? G : 0, ce = X.slots[se];
4763
- r.emit("partSelected", {
4762
+ o.emit("partSelected", {
4764
4763
  meshId: X.meshId,
4765
4764
  partId: X.partId,
4766
4765
  type: X.type,
@@ -4786,19 +4785,19 @@ function vs(n, t, e, i, r, o = () => [], s) {
4786
4785
  invalidateMeshes: h
4787
4786
  };
4788
4787
  }
4789
- function bs(n, t, e, i, r, o, s, a) {
4788
+ function bs(n, t, e, i, o, r, s, a) {
4790
4789
  const c = {
4791
4790
  metalColor: n,
4792
4791
  stoneColor: t,
4793
4792
  parts: { ...e },
4794
4793
  cameraState: {
4795
4794
  position: i.position.toArray(),
4796
- target: r.target.toArray()
4795
+ target: o.target.toArray()
4797
4796
  }
4798
4797
  };
4799
- return o && Object.keys(o).length > 0 && (c.materialColors = { ...o }), s && Object.keys(s).length > 0 && (c.partColors = { ...s }), c;
4798
+ return r && Object.keys(r).length > 0 && (c.materialColors = { ...r }), s && Object.keys(s).length > 0 && (c.partColors = { ...s }), c;
4800
4799
  }
4801
- function xs(n, t, e, i, r, o, s) {
4800
+ function xs(n, t, e, i, o, r, s) {
4802
4801
  var f, d;
4803
4802
  const a = [], c = [], u = [];
4804
4803
  (!(s != null && s.currentColor) || s.currentColor.metalColor !== n.metalColor) && t(n.metalColor), (!(s != null && s.currentColor) || s.currentColor.stoneColor !== n.stoneColor) && e(n.stoneColor);
@@ -4813,7 +4812,7 @@ function xs(n, t, e, i, r, o, s) {
4813
4812
  const y = l.lastIndexOf(":");
4814
4813
  y > 0 && !isNaN(Number(l.slice(y + 1))) && (p = l.slice(0, y), w = Number(l.slice(y + 1))), s.availablePartIds && !s.availablePartIds.has(p) && (a.push(p), u.push(`Part '${p}' not found in model`), console.warn(`[3d-viewer] Part '${p}' not found in loaded model`)), s.setPartColor(p, m, w);
4815
4814
  }
4816
- return n.cameraState && (r.position.fromArray(n.cameraState.position), o.target.fromArray(n.cameraState.target), o.update()), {
4815
+ return n.cameraState && (o.position.fromArray(n.cameraState.position), r.target.fromArray(n.cameraState.target), r.update()), {
4817
4816
  success: !0,
4818
4817
  unresolvedParts: a.length > 0 ? a : void 0,
4819
4818
  unresolvedMaterials: c.length > 0 ? c : void 0,
@@ -4838,14 +4837,14 @@ function ws(n, t = 1.2) {
4838
4837
  Ft++, e = ge;
4839
4838
  } else
4840
4839
  e = new v.Texture(), e.needsUpdate = !0;
4841
- const r = new v.PlaneGeometry(t * 2, t * 2);
4842
- r.rotateX(-Math.PI / 2);
4843
- const o = new v.MeshBasicMaterial({
4840
+ const o = new v.PlaneGeometry(t * 2, t * 2);
4841
+ o.rotateX(-Math.PI / 2);
4842
+ const r = new v.MeshBasicMaterial({
4844
4843
  map: e,
4845
4844
  transparent: !0,
4846
4845
  opacity: 0.85,
4847
4846
  depthWrite: !1
4848
- }), s = new v.Mesh(r, o);
4847
+ }), s = new v.Mesh(o, r);
4849
4848
  s.position.y = -0.5, s.renderOrder = -1, n.add(s);
4850
4849
  let a = !1;
4851
4850
  return {
@@ -4857,27 +4856,27 @@ function ws(n, t = 1.2) {
4857
4856
  s.scale.setScalar(c);
4858
4857
  },
4859
4858
  dispose: () => {
4860
- a || (a = !0, n.remove(s), r.dispose(), o.dispose(), i && e === ge ? (Ft--, Ft <= 0 && (ge == null || ge.dispose(), ge = null, Ft = 0)) : e.dispose());
4859
+ a || (a = !0, n.remove(s), o.dispose(), r.dispose(), i && e === ge ? (Ft--, Ft <= 0 && (ge == null || ge.dispose(), ge = null, Ft = 0)) : e.dispose());
4861
4860
  }
4862
4861
  };
4863
4862
  }
4864
4863
  function ln(n) {
4865
4864
  n.traverse((t) => {
4866
4865
  var e;
4867
- t instanceof v.Mesh && ((e = t.geometry) == null || e.dispose(), (Array.isArray(t.material) ? t.material : [t.material]).forEach((r) => {
4868
- var o, s, a, c, u;
4869
- r instanceof v.MeshStandardMaterial && ((o = r.map) == null || o.dispose(), (s = r.normalMap) == null || s.dispose(), (a = r.roughnessMap) == null || a.dispose(), (c = r.metalnessMap) == null || c.dispose(), (u = r.envMap) == null || u.dispose()), r.dispose();
4866
+ t instanceof v.Mesh && ((e = t.geometry) == null || e.dispose(), (Array.isArray(t.material) ? t.material : [t.material]).forEach((o) => {
4867
+ var r, s, a, c, u;
4868
+ o instanceof v.MeshStandardMaterial && ((r = o.map) == null || r.dispose(), (s = o.normalMap) == null || s.dispose(), (a = o.roughnessMap) == null || a.dispose(), (c = o.metalnessMap) == null || c.dispose(), (u = o.envMap) == null || u.dispose()), o.dispose();
4870
4869
  }));
4871
4870
  });
4872
4871
  }
4873
4872
  function Vs(n, t = {}) {
4874
4873
  var Ln, zn;
4875
- const e = new Io(), i = hs(t.background ?? 16777215, t.fov ?? 25), { scene: r, camera: o, dispose: s } = i, a = ps(
4874
+ const e = new Io(), i = hs(t.background ?? 16777215, t.fov ?? 25), { scene: o, camera: r, dispose: s } = i, a = ps(
4876
4875
  n,
4877
- o,
4876
+ r,
4878
4877
  { ...t, onResize: () => G() }
4879
- ), { renderer: c } = a, u = gs(o, c.domElement, t), f = u.controls, d = ws(r);
4880
- t.shadows === !1 && d.setVisible(!1), ls(r, c);
4878
+ ), { renderer: c } = a, u = gs(r, c.domElement, t), f = u.controls, d = ws(o);
4879
+ t.shadows === !1 && d.setVisible(!1), ls(o, c);
4881
4880
  let l;
4882
4881
  try {
4883
4882
  l = An(c);
@@ -4895,7 +4894,7 @@ function Vs(n, t = {}) {
4895
4894
  async function h(I) {
4896
4895
  try {
4897
4896
  const E = await gi(I, c);
4898
- m == null || m.dispose(), m = E, r.environment = E.texture, t.gemEnvUrl || (l = E.gemTexture ?? E.texture, A == null || A.traverse((N) => {
4897
+ m == null || m.dispose(), m = E, o.environment = E.texture, t.gemEnvUrl || (l = E.gemTexture ?? E.texture, A == null || A.traverse((N) => {
4899
4898
  N instanceof v.Mesh && (N.material instanceof Ae ? N.material.setEnvMap(l) : N.material instanceof et && (N.material.uniforms.envMap.value = l));
4900
4899
  })), G();
4901
4900
  } catch (E) {
@@ -4926,7 +4925,7 @@ function Vs(n, t = {}) {
4926
4925
  function X() {
4927
4926
  if (ne = 0, q) return;
4928
4927
  const I = !!f.update(), E = f.autoRotate === !0;
4929
- ($ || I || E) && ($ = !1, c.render(r, o)), (I || E) && ne === 0 && !q && typeof requestAnimationFrame < "u" && (ne = requestAnimationFrame(X));
4928
+ ($ || I || E) && ($ = !1, c.render(o, r)), (I || E) && ne === 0 && !q && typeof requestAnimationFrame < "u" && (ne = requestAnimationFrame(X));
4930
4929
  }
4931
4930
  function se() {
4932
4931
  q = typeof document < "u" ? document.hidden : !1, q || G();
@@ -4938,8 +4937,8 @@ function Vs(n, t = {}) {
4938
4937
  (zn = f.addEventListener) == null || zn.call(f, "change", ce), G();
4939
4938
  const Dn = vs(
4940
4939
  c,
4941
- r,
4942
4940
  o,
4941
+ r,
4943
4942
  f,
4944
4943
  e,
4945
4944
  () => S,
@@ -5038,11 +5037,11 @@ function Vs(n, t = {}) {
5038
5037
  }
5039
5038
  }
5040
5039
  if (z.aborted) return;
5041
- e.emit("loading", { progress: 0.9 }), A && (r.remove(A), ln(A), A = null), A = de, r.add(A), S = Yn(A, R), B = Xn(S), A.traverse((le) => {
5040
+ e.emit("loading", { progress: 0.9 }), A && (o.remove(A), ln(A), A = null), A = de, o.add(A), S = Yn(A, R), B = Xn(S), A.traverse((le) => {
5042
5041
  if (!(le instanceof v.Mesh)) return;
5043
5042
  const Le = S.find((Kt) => Kt.meshId === le.uuid), Xt = (Le == null ? void 0 : Le.type) ?? "metal";
5044
5043
  xi(le, Xt, c, l, t.diamondMode ?? "reference"), Le ? be(le, Le) : Xt === "metal" ? Ke(le, C) : Je(le, F);
5045
- }), y !== "medium" && Yt(y), wi(A, o, f, t), ys(o, n.clientWidth, n.clientHeight);
5044
+ }), y !== "medium" && Yt(y), wi(A, r, f, t), ys(r, n.clientWidth, n.clientHeight);
5046
5045
  const Ce = new v.Box3().setFromObject(A), pt = Ce.getBoundingSphere(new v.Sphere()), ht = pt.radius > 0 ? pt.radius : 1;
5047
5046
  d.mesh.position.y = Ce.min.y, d.setScale(ht), e.emit("loading", { progress: 1 }), e.emit("loaded", { parts: S, materials: B }), D = null, L = null, (k = performance == null ? void 0 : performance.mark) == null || k.call(performance, "3d-viewer:load-end"), G();
5048
5047
  } catch (H) {
@@ -5175,7 +5174,7 @@ function Vs(n, t = {}) {
5175
5174
  C,
5176
5175
  F,
5177
5176
  R,
5178
- o,
5177
+ r,
5179
5178
  f,
5180
5179
  T,
5181
5180
  P
@@ -5188,7 +5187,7 @@ function Vs(n, t = {}) {
5188
5187
  dt,
5189
5188
  mt,
5190
5189
  Ve,
5191
- o,
5190
+ r,
5192
5191
  f,
5193
5192
  {
5194
5193
  setMaterialColor: En,
@@ -5204,13 +5203,13 @@ function Vs(n, t = {}) {
5204
5203
  );
5205
5204
  return D = I.metalColor, L = I.stoneColor, G(), _;
5206
5205
  }
5207
- t.initialState && (Nn(t.initialState), u.initialPosition.copy(o.position), u.initialTarget.copy(f.target));
5206
+ t.initialState && (Nn(t.initialState), u.initialPosition.copy(r.position), u.initialTarget.copy(f.target));
5208
5207
  function Yi(I, E) {
5209
5208
  return e.on(I, E);
5210
5209
  }
5211
5210
  function Xi() {
5212
5211
  var I, E;
5213
- M !== null && (clearTimeout(M), M = null), V == null || V.abort(), ne !== 0 && typeof cancelAnimationFrame < "u" && (cancelAnimationFrame(ne), ne = 0), typeof document < "u" && document.removeEventListener("visibilitychange", se), (I = f.removeEventListener) == null || I.call(f, "change", ce), (E = x.removeEventListener) == null || E.call(x, "webglcontextrestored", b), ct.clearCache(), d.dispose(), Dn.dispose(), u.dispose(), A && (r.remove(A), ln(A), A = null), m == null || m.dispose(), p == null || p.dispose(), s(), a.dispose(), e.clear();
5212
+ M !== null && (clearTimeout(M), M = null), V == null || V.abort(), ne !== 0 && typeof cancelAnimationFrame < "u" && (cancelAnimationFrame(ne), ne = 0), typeof document < "u" && document.removeEventListener("visibilitychange", se), (I = f.removeEventListener) == null || I.call(f, "change", ce), (E = x.removeEventListener) == null || E.call(x, "webglcontextrestored", b), ct.clearCache(), d.dispose(), Dn.dispose(), u.dispose(), A && (o.remove(A), ln(A), A = null), m == null || m.dispose(), p == null || p.dispose(), s(), a.dispose(), e.clear();
5214
5213
  }
5215
5214
  function Ki(I) {
5216
5215
  return I !== void 0 && (f.autoRotateSpeed = I), f.autoRotate = !f.autoRotate, f.autoRotate && G(), f.autoRotate;
@@ -5228,14 +5227,14 @@ function Vs(n, t = {}) {
5228
5227
  u.resetCamera(), G();
5229
5228
  }
5230
5229
  function eo() {
5231
- A && (wi(A, o, f, t), G());
5230
+ A && (wi(A, r, f, t), G());
5232
5231
  }
5233
5232
  function to(I, E) {
5234
- o.position.set(I[0], I[1], I[2]), f.target.set(E[0], E[1], E[2]), f.update(), G();
5233
+ r.position.set(I[0], I[1], I[2]), f.target.set(E[0], E[1], E[2]), f.update(), G();
5235
5234
  }
5236
5235
  async function no(I) {
5237
5236
  const E = (I == null ? void 0 : I.format) ?? "image/png", N = (I == null ? void 0 : I.quality) ?? 0.95;
5238
- return c.render(r, o), c.domElement.toDataURL(E, N);
5237
+ return c.render(o, r), c.domElement.toDataURL(E, N);
5239
5238
  }
5240
5239
  function io(I) {
5241
5240
  a.setQuality(I);
@@ -5244,7 +5243,7 @@ function Vs(n, t = {}) {
5244
5243
  d.setVisible(I), G();
5245
5244
  }
5246
5245
  function ro() {
5247
- V == null || V.abort(), A && (r.remove(A), ln(A), A = null), S = [], R = {}, B = [], T = {}, P = {}, D = null, L = null, d.mesh.position.y = 0, d.setScale(1), G();
5246
+ V == null || V.abort(), A && (o.remove(A), ln(A), A = null), S = [], R = {}, B = [], T = {}, P = {}, D = null, L = null, d.mesh.position.y = 0, d.setScale(1), G();
5248
5247
  }
5249
5248
  function Yt(I) {
5250
5249
  const E = w(I);
@@ -5303,7 +5302,7 @@ function Vs(n, t = {}) {
5303
5302
  setDiamondQuality: Yt,
5304
5303
  requestRender: G
5305
5304
  };
5306
- return typeof window < "u" && (Ne.__scene = r, Ne.__getCurrentModel = () => A), Ne;
5305
+ return typeof window < "u" && (Ne.__scene = o, Ne.__getCurrentModel = () => A), Ne;
5307
5306
  }
5308
5307
  const Gs = "1.0.0";
5309
5308
  export {