u-space 0.0.30 → 0.0.32

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.
Files changed (37) hide show
  1. package/dist/getTransferables-C97JPUVf.cjs +1 -0
  2. package/dist/getTransferables-DrzSmiCR.js +43 -0
  3. package/dist/index.cjs +3 -3
  4. package/dist/index.js +1549 -1026
  5. package/dist/modelDecodeProtocol-D1Apm9iG.cjs +1 -0
  6. package/dist/modelDecodeProtocol-wDB7ksYw.js +56 -0
  7. package/dist/plugins/u-manager/index.cjs +1 -1
  8. package/dist/plugins/u-manager/index.js +73 -53
  9. package/dist/src/loaders/ModelDecodeWorkerClient.d.ts +31 -0
  10. package/dist/src/loaders/ModelLoaderManager.d.ts +15 -2
  11. package/dist/src/loaders/buildDecodedGltfModel.d.ts +4 -0
  12. package/dist/src/loaders/index.d.ts +1 -0
  13. package/dist/src/objects/Model.d.ts +1 -0
  14. package/dist/src/worker/decodeGltfModel.d.ts +10 -0
  15. package/dist/src/worker/getTransferables.d.ts +1 -0
  16. package/dist/src/worker/index.d.ts +1 -0
  17. package/dist/src/worker/installWorkerImageLoader.d.ts +3 -0
  18. package/dist/src/worker/model-decoder.d.ts +13 -0
  19. package/dist/src/worker/modelDecodeProtocol.d.ts +205 -0
  20. package/dist/src/worker/workerImageUtils.d.ts +8 -0
  21. package/dist/worker/index.cjs +1 -1
  22. package/dist/worker/index.js +8 -6
  23. package/dist/worker/model-decoder.cjs +1 -0
  24. package/dist/worker/model-decoder.js +339 -0
  25. package/dist/worker/runtime.cjs +1 -1
  26. package/dist/worker/runtime.js +202 -208
  27. package/dist/workerImageUtils-lmOMyTQN.cjs +1 -0
  28. package/dist/workerImageUtils-mQD3TQ1N.js +105 -0
  29. package/docs/api-effects.md +66 -2
  30. package/docs/api-viewer.md +45 -1
  31. package/docs/changelog.md +26 -0
  32. package/docs/examples-guide.md +31 -11
  33. package/docs/getting-started.md +97 -93
  34. package/docs/index.md +2 -2
  35. package/docs/mcp.md +16 -3
  36. package/docs/release.md +5 -3
  37. package/package.json +9 -1
package/dist/index.js CHANGED
@@ -1,22 +1,23 @@
1
- import { g as Et } from "./Viewer-Cs_y7IiH.js";
2
- import { C as Qi, a as qi, I as Yi, b as Vi, O as Ji, R as Zi, c as er, V as tr, e as sr } from "./Viewer-Cs_y7IiH.js";
3
- import { EventDispatcher as qt, Vector2 as z, Box2 as Yt, Matrix4 as L, Vector3 as C, Scene as Vt, Color as A, AmbientLight as Jt, DirectionalLight as Pe, PointLight as Ne, SpotLight as ze, HemisphereLight as De, DirectionalLightHelper as Zt, PointLightHelper as es, SpotLightHelper as ts, HemisphereLightHelper as ss, MeshStandardNodeMaterial as K, Loader as ns, LoaderUtils as G, FileLoader as _t, TextureLoader as Ct, Group as H, SRGBColorSpace as Ot, RepeatWrapping as Re, BufferGeometry as Q, BufferAttribute as je, Mesh as P, FrontSide as is, BackSide as rs, DoubleSide as as, REVISION as ke, CubeTextureLoader as os, EquirectangularReflectionMapping as cs, Sprite as ls, AnimationMixer as hs, LoopRepeat as us, LoopOnce as ds, Box3 as $, SphereGeometry as ps, TubeGeometry as ms, LineCurve3 as fs, CatmullRomCurve3 as gs, SpriteNodeMaterial as ys, CanvasTexture as bs, ShapeGeometry as ws, Shape as At, ExtrudeGeometry as xs, PlaneGeometry as Ms, CircleGeometry as Is, Quaternion as Ss, BoxGeometry as vs, MeshBasicNodeMaterial as Bs, ClippingGroup as Es, Plane as _s, PlaneHelper as Cs, LineBasicMaterial as me, Line as fe, Object3D as Os, Sphere as ne, Float32BufferAttribute as As, SkinnedMesh as Ts, DataTexture as Ls, RGBAFormat as Ps, FloatType as Ns, NearestFilter as Ue, Texture as zs, Frustum as Ds, InstancedBufferAttribute as We, DynamicDrawUsage as Be, InstancedMesh as Rs, StorageInstancedBufferAttribute as js } from "three/webgpu";
4
- import { GLTFLoader as Tt } from "three/addons/loaders/GLTFLoader.js";
5
- import { FBXLoader as ks } from "three/addons/loaders/FBXLoader.js";
6
- import { OBJLoader as Us } from "three/addons/loaders/OBJLoader.js";
7
- import { STLLoader as Ws } from "three/addons/loaders/STLLoader.js";
8
- import { DRACOLoader as Hs } from "three/addons/loaders/DRACOLoader.js";
9
- import { KTX2Loader as Fs } from "three/addons/loaders/KTX2Loader.js";
10
- import { MeshoptDecoder as He } from "three/addons/libs/meshopt_decoder.module.js";
11
- import { HDRLoader as Gs } from "three/addons/loaders/HDRLoader.js";
12
- import { clone as Le } from "three/addons/utils/SkeletonUtils.js";
13
- import { color as V, uv as Fe, time as ge, pow as ye, sin as Ce, mix as be, mx_noise_float as Ge, uniform as ae, add as $s, vec4 as Ks, Fn as Lt, userData as U, materialColor as xe, select as F, materialOpacity as Oe, vec3 as Xs, attribute as Qs, int as $e, textureSize as qs, textureLoad as Ke, ivec2 as Ys, instancedBufferAttribute as Xe, float as Vs } from "three/tsl";
14
- import { outline as Js } from "three/addons/tsl/display/OutlineNode.js";
15
- import { Easing as x, Tween as Zs } from "three/addons/libs/tween.module.js";
16
- import { mergeGeometries as en } from "three/addons/utils/BufferGeometryUtils.js";
17
- import { CSS2DObject as ir } from "three/addons/renderers/CSS2DRenderer.js";
18
- import { CSS3DObject as ar, CSS3DSprite as or } from "three/addons/renderers/CSS3DRenderer.js";
19
- class Ci extends qt {
1
+ import { g as jt } from "./Viewer-Cs_y7IiH.js";
2
+ import { C as vi, a as Si, I as Ii, b as Ei, O as Ci, R as Ai, c as Oi, V as Bi, e as _i } from "./Viewer-Cs_y7IiH.js";
3
+ import { EventDispatcher as hs, Vector2 as j, Box2 as ds, Matrix4 as R, Vector3 as D, Scene as us, Color as P, AmbientLight as ps, DirectionalLight as Fe, PointLight as He, SpotLight as $e, HemisphereLight as Ge, DirectionalLightHelper as fs, PointLightHelper as ms, SpotLightHelper as gs, HemisphereLightHelper as ys, MeshStandardNodeMaterial as q, Loader as bs, LoaderUtils as he, FileLoader as Wt, TextureLoader as Ft, Group as W, SRGBColorSpace as Se, RepeatWrapping as Ie, BufferGeometry as G, BufferAttribute as Pe, Mesh as k, FrontSide as ws, BackSide as xs, DoubleSide as Ht, InterleavedBufferAttribute as Ke, MeshStandardMaterial as Ms, LinearSRGBColorSpace as qe, InterleavedBuffer as vs, Texture as $t, NearestFilter as Ee, LinearFilter as Ve, LinearMipmapLinearFilter as Ss, NearestMipmapLinearFilter as Is, LinearMipmapNearestFilter as Es, NearestMipmapNearestFilter as Cs, MirroredRepeatWrapping as Xe, ClampToEdgeWrapping as Ye, NoColorSpace as fe, REVISION as Qe, LoadingManager as As, CubeTextureLoader as Os, EquirectangularReflectionMapping as Bs, Sprite as _s, AnimationMixer as Ts, LoopRepeat as Ls, LoopOnce as Ns, Box3 as K, SphereGeometry as Ds, TubeGeometry as Ps, LineCurve3 as Rs, CatmullRomCurve3 as ks, SpriteNodeMaterial as zs, CanvasTexture as Us, ShapeGeometry as js, Shape as Gt, ExtrudeGeometry as Ws, PlaneGeometry as Fs, CircleGeometry as Hs, Quaternion as $s, BoxGeometry as Gs, MeshBasicNodeMaterial as Ks, ClippingGroup as qs, Plane as Vs, PlaneHelper as Xs, LineBasicMaterial as ye, Line as be, Object3D as Ys, Sphere as ne, Float32BufferAttribute as Qs, SkinnedMesh as Js, DataTexture as Zs, RGBAFormat as en, FloatType as tn, Frustum as sn, InstancedBufferAttribute as Je, DynamicDrawUsage as Te, InstancedMesh as nn, StorageInstancedBufferAttribute as rn } from "three/webgpu";
4
+ import { GLTFLoader as Re } from "three/addons/loaders/GLTFLoader.js";
5
+ import { FBXLoader as Ze } from "three/addons/loaders/FBXLoader.js";
6
+ import { OBJLoader as an } from "three/addons/loaders/OBJLoader.js";
7
+ import { STLLoader as on } from "three/addons/loaders/STLLoader.js";
8
+ import { DRACOLoader as cn } from "three/addons/loaders/DRACOLoader.js";
9
+ import { KTX2Loader as ln } from "three/addons/loaders/KTX2Loader.js";
10
+ import { MeshoptDecoder as Le } from "three/addons/libs/meshopt_decoder.module.js";
11
+ import { M as et, v as hn, U as Kt } from "./modelDecodeProtocol-wDB7ksYw.js";
12
+ import { HDRLoader as dn } from "three/addons/loaders/HDRLoader.js";
13
+ import { clone as We } from "three/addons/utils/SkeletonUtils.js";
14
+ import { color as Y, uv as tt, time as we, pow as xe, sin as ke, mix as Me, mx_noise_float as st, uniform as ae, add as un, vec4 as pn, Fn as qt, userData as F, materialColor as Ce, select as $, materialOpacity as ze, vec3 as fn, attribute as mn, int as nt, textureSize as gn, textureLoad as rt, ivec2 as yn, instancedBufferAttribute as it, float as bn } from "three/tsl";
15
+ import { outline as wn } from "three/addons/tsl/display/OutlineNode.js";
16
+ import { Easing as T, Tween as xn } from "three/addons/libs/tween.module.js";
17
+ import { mergeGeometries as Mn } from "three/addons/utils/BufferGeometryUtils.js";
18
+ import { CSS2DObject as Li } from "three/addons/renderers/CSS2DRenderer.js";
19
+ import { CSS3DObject as Di, CSS3DSprite as Pi } from "three/addons/renderers/CSS3DRenderer.js";
20
+ class si extends hs {
20
21
  scene;
21
22
  camera;
22
23
  domElement;
@@ -26,8 +27,8 @@ class Ci extends qt {
26
27
  // Box selection state
27
28
  _boxSelectionEnabled = !1;
28
29
  _isSelecting = !1;
29
- _startPoint = new z();
30
- _endPoint = new z();
30
+ _startPoint = new j();
31
+ _endPoint = new j();
31
32
  _selectionBox = null;
32
33
  _deep = !0;
33
34
  /**
@@ -126,33 +127,33 @@ class Ci extends qt {
126
127
  this._selectionBox.style.left = `${e}px`, this._selectionBox.style.top = `${t}px`, this._selectionBox.style.width = `${s}px`, this._selectionBox.style.height = `${n}px`;
127
128
  }
128
129
  _getObjectsInBox() {
129
- const e = this._container.getBoundingClientRect(), t = e.width, s = e.height, n = new z(
130
+ const e = this._container.getBoundingClientRect(), t = e.width, s = e.height, n = new j(
130
131
  this._startPoint.x / t * 2 - 1,
131
132
  -(this._startPoint.y / s) * 2 + 1
132
- ), i = new z(
133
+ ), r = new j(
133
134
  this._endPoint.x / t * 2 - 1,
134
135
  -(this._endPoint.y / s) * 2 + 1
135
- ), a = new Yt(
136
- new z(Math.min(n.x, i.x), Math.min(n.y, i.y)),
137
- new z(Math.max(n.x, i.x), Math.max(n.y, i.y))
138
- ), o = this.targetObjects || this.scene.children, c = [], l = new L();
136
+ ), a = new ds(
137
+ new j(Math.min(n.x, r.x), Math.min(n.y, r.y)),
138
+ new j(Math.max(n.x, r.x), Math.max(n.y, r.y))
139
+ ), o = this.targetObjects || this.scene.children, c = [], l = new R();
139
140
  l.multiplyMatrices(this.camera.projectionMatrix, this.camera.matrixWorldInverse);
140
- const h = (u) => {
141
- if (!u.visible) return;
142
- const d = new C();
143
- if (d.setFromMatrixPosition(u.matrixWorld), d.applyMatrix4(l), d.z > -1 && d.z < 1 && a.containsPoint(new z(d.x, d.y)) && c.push(u), this._deep)
144
- for (const p of u.children)
141
+ const h = (d) => {
142
+ if (!d.visible) return;
143
+ const u = new D();
144
+ if (u.setFromMatrixPosition(d.matrixWorld), u.applyMatrix4(l), u.z > -1 && u.z < 1 && a.containsPoint(new j(u.x, u.y)) && c.push(d), this._deep)
145
+ for (const p of d.children)
145
146
  h(p);
146
147
  };
147
- for (const u of o)
148
- h(u);
148
+ for (const d of o)
149
+ h(d);
149
150
  return c;
150
151
  }
151
152
  dispose() {
152
153
  this.disableBoxSelection(), this._selected.clear();
153
154
  }
154
155
  }
155
- class Oi {
156
+ class ni {
156
157
  scenes = /* @__PURE__ */ new Map();
157
158
  _activeSceneKey = null;
158
159
  /**
@@ -165,8 +166,8 @@ class Oi {
165
166
  * Create and register a new scene.
166
167
  */
167
168
  create(e, t = {}) {
168
- const s = new Vt();
169
- return t.background !== void 0 && (s.background = new A(t.background)), this.scenes.set(e, s), s;
169
+ const s = new us();
170
+ return t.background !== void 0 && (s.background = new P(t.background)), this.scenes.set(e, s), s;
170
171
  }
171
172
  /**
172
173
  * Get a scene by key.
@@ -205,7 +206,7 @@ class Oi {
205
206
  const t = this.scenes.get(e);
206
207
  if (!t) return null;
207
208
  let s = null;
208
- return t.background instanceof A && (s = `#${t.background.getHexString()}`), {
209
+ return t.background instanceof P && (s = `#${t.background.getHexString()}`), {
209
210
  name: t.name || e,
210
211
  background: s,
211
212
  environmentRotation: {
@@ -226,7 +227,7 @@ class Oi {
226
227
  return this.scenes.size;
227
228
  }
228
229
  }
229
- class Ai {
230
+ class ri {
230
231
  scene;
231
232
  lights = /* @__PURE__ */ new Map();
232
233
  helpers = /* @__PURE__ */ new Map();
@@ -234,33 +235,33 @@ class Ai {
234
235
  this.scene = e;
235
236
  }
236
237
  addAmbient(e, t = {}) {
237
- const { color: s = 16777215, intensity: n = 0.5 } = t, i = new Jt(s, n);
238
- return i.name = e, this._register(e, i), i;
238
+ const { color: s = 16777215, intensity: n = 0.5 } = t, r = new ps(s, n);
239
+ return r.name = e, this._register(e, r), r;
239
240
  }
240
241
  addDirectional(e, t = {}) {
241
- const { color: s = 16777215, intensity: n = 1, position: i = { x: 5, y: 10, z: 5 }, castShadow: a = !1, shadowMapSize: o = 1024 } = t, c = new Pe(s, n);
242
- return c.position.set(i.x, i.y, i.z), c.castShadow = a, a && c.shadow.mapSize.setScalar(o), c.name = e, this._register(e, c), c;
242
+ const { color: s = 16777215, intensity: n = 1, position: r = { x: 5, y: 10, z: 5 }, castShadow: a = !1, shadowMapSize: o = 1024 } = t, c = new Fe(s, n);
243
+ return c.position.set(r.x, r.y, r.z), c.castShadow = a, a && c.shadow.mapSize.setScalar(o), c.name = e, this._register(e, c), c;
243
244
  }
244
245
  addPoint(e, t = {}) {
245
- const { color: s = 16777215, intensity: n = 1, distance: i = 0, decay: a = 2, position: o = { x: 0, y: 5, z: 0 }, castShadow: c = !1 } = t, l = new Ne(s, n, i, a);
246
+ const { color: s = 16777215, intensity: n = 1, distance: r = 0, decay: a = 2, position: o = { x: 0, y: 5, z: 0 }, castShadow: c = !1 } = t, l = new He(s, n, r, a);
246
247
  return l.position.set(o.x, o.y, o.z), l.castShadow = c, l.name = e, this._register(e, l), l;
247
248
  }
248
249
  addSpot(e, t = {}) {
249
250
  const {
250
251
  color: s = 16777215,
251
252
  intensity: n = 1,
252
- distance: i = 0,
253
+ distance: r = 0,
253
254
  angle: a = Math.PI / 6,
254
255
  penumbra: o = 0.1,
255
256
  decay: c = 2,
256
257
  position: l = { x: 0, y: 10, z: 0 },
257
258
  target: h,
258
- castShadow: u = !1
259
- } = t, d = new ze(s, n, i, a, o, c);
260
- return d.position.set(l.x, l.y, l.z), h && d.target.position.set(h.x, h.y, h.z), d.castShadow = u, d.name = e, this._register(e, d), d;
259
+ castShadow: d = !1
260
+ } = t, u = new $e(s, n, r, a, o, c);
261
+ return u.position.set(l.x, l.y, l.z), h && u.target.position.set(h.x, h.y, h.z), u.castShadow = d, u.name = e, this._register(e, u), u;
261
262
  }
262
263
  addHemisphere(e, t = {}) {
263
- const { skyColor: s = 8900331, groundColor: n = 3549447, intensity: i = 0.6 } = t, a = new De(s, n, i);
264
+ const { skyColor: s = 8900331, groundColor: n = 3549447, intensity: r = 0.6 } = t, a = new Ge(s, n, r);
264
265
  return a.name = e, this._register(e, a), a;
265
266
  }
266
267
  /**
@@ -311,7 +312,7 @@ class Ai {
311
312
  const t = this.lights.get(e);
312
313
  if (!t) return;
313
314
  let s = null;
314
- t instanceof Pe ? s = new Zt(t, 1) : t instanceof Ne ? s = new es(t, 0.5) : t instanceof ze ? s = new ts(t) : t instanceof De && (s = new ss(t, 1)), s && (this.scene.add(s), this.helpers.set(e, s));
315
+ t instanceof Fe ? s = new fs(t, 1) : t instanceof He ? s = new ms(t, 0.5) : t instanceof $e ? s = new gs(t) : t instanceof Ge && (s = new ys(t, 1)), s && (this.scene.add(s), this.helpers.set(e, s));
315
316
  }
316
317
  /**
317
318
  * Hide (remove) the helper for a light.
@@ -342,113 +343,113 @@ class Ai {
342
343
  this.removeAll(), this.hideAllHelpers();
343
344
  }
344
345
  }
345
- class tn extends Tt {
346
+ class at extends Re {
346
347
  constructor(e) {
347
348
  super(e);
348
349
  }
349
350
  parse(e, t, s, n) {
350
- if (sn(e.slice(0, 8)) === "SBMG----") {
351
- const a = nn(e.slice(8));
351
+ if (vn(e.slice(0, 8)) === "SBMG----") {
352
+ const a = Sn(e.slice(8));
352
353
  return super.parse(a, t, s, n);
353
354
  } else
354
355
  return super.parse(e, t, s, n);
355
356
  }
356
357
  }
357
- function sn(r) {
358
- return new TextDecoder().decode(new Uint8Array(r));
358
+ function vn(i) {
359
+ return new TextDecoder().decode(new Uint8Array(i));
359
360
  }
360
- function nn(r) {
361
- const e = new DataView(r);
361
+ function Sn(i) {
362
+ const e = new DataView(i);
362
363
  for (let t = 0; t < e.byteLength; t++) {
363
364
  const s = e.getUint8(t), n = (s >> 4 & 15) + (s << 4 & 240);
364
365
  e.setUint8(t, n);
365
366
  }
366
367
  return e.buffer;
367
368
  }
368
- const rn = 8, an = 130, Qe = 66, on = "SBK-----", cn = "SBM-----", Pt = new TextDecoder(), ln = new TextEncoder();
369
- function hn(r) {
370
- let e = rn;
371
- const t = new Uint8Array(r, 0, e);
372
- if (Pt.decode(t) !== on)
373
- return r;
374
- e += an;
375
- const n = new Uint8Array(r, 0, e);
369
+ const In = 8, En = 130, ot = 66, Cn = "SBK-----", An = "SBM-----", Vt = new TextDecoder(), On = new TextEncoder();
370
+ function Bn(i) {
371
+ let e = In;
372
+ const t = new Uint8Array(i, 0, e);
373
+ if (Vt.decode(t) !== Cn)
374
+ return i;
375
+ e += En;
376
+ const n = new Uint8Array(i, 0, e);
376
377
  if (n[40] === 1) {
377
- const a = ln.encode(cn), o = new Uint8Array([n[41]]), c = un(n), l = dn(c);
378
- let h = Qe % l.length;
379
- const u = e + Qe, d = new Uint8Array(r, u), p = new Uint8Array(d.length);
380
- for (let b = 0; b < d.length; b++)
381
- p[b] = d[b] ^ l[h], h = (h + 1) % l.length;
382
- const m = new Uint8Array(a.length + o.length + p.length);
383
- return m.set(a), m.set(o, a.length), m.set(p, a.length + o.length), m.buffer;
378
+ const a = On.encode(An), o = new Uint8Array([n[41]]), c = _n(n), l = Tn(c);
379
+ let h = ot % l.length;
380
+ const d = e + ot, u = new Uint8Array(i, d), p = new Uint8Array(u.length);
381
+ for (let I = 0; I < u.length; I++)
382
+ p[I] = u[I] ^ l[h], h = (h + 1) % l.length;
383
+ const x = new Uint8Array(a.length + o.length + p.length);
384
+ return x.set(a), x.set(o, a.length), x.set(p, a.length + o.length), x.buffer;
384
385
  }
385
386
  }
386
- function un(r) {
387
+ function _n(i) {
387
388
  const e = new Uint8Array(128);
388
- return e.set(r.slice(42, 74), 0), e.set(r.slice(74, 138), 32), e.set(r.slice(8, 40), 96), e;
389
+ return e.set(i.slice(42, 74), 0), e.set(i.slice(74, 138), 32), e.set(i.slice(8, 40), 96), e;
389
390
  }
390
- function dn(r) {
391
+ function Tn(i) {
391
392
  const e = new Uint8Array(64);
392
- return e.set(r.slice(0, 8), 0), e.set(r.slice(24, 32), 8), e.set(r.slice(40, 56), 16), e.set(r.slice(64, 88), 32), e.set(r.slice(96, 104), 56), e;
393
+ return e.set(i.slice(0, 8), 0), e.set(i.slice(24, 32), 8), e.set(i.slice(40, 56), 16), e.set(i.slice(64, 88), 32), e.set(i.slice(96, 104), 56), e;
393
394
  }
394
- const pn = (r, e, t) => {
395
- const s = r.buffer.slice(t, t + e);
396
- let n = Pt.decode(s);
395
+ const Ln = (i, e, t) => {
396
+ const s = i.buffer.slice(t, t + e);
397
+ let n = Vt.decode(s);
397
398
  return n = n.replace("\\", "/"), n.startsWith("Maps/") || (n = `Maps/${n}`), n;
398
- }, mn = (r, e, t) => {
399
- const [s, n, i, a, o] = e, c = t || a < 1;
400
- return new K({
401
- name: r,
402
- color: new A(s, n, i),
399
+ }, Nn = (i, e, t) => {
400
+ const [s, n, r, a, o] = e, c = t || a < 1;
401
+ return new q({
402
+ name: i,
403
+ color: new P(s, n, r),
403
404
  opacity: a,
404
405
  transparent: c,
405
406
  alphaTest: 0.01,
406
407
  side: o
407
408
  });
408
- }, fn = (r) => r?.toLowerCase().endsWith(".png") ?? !1;
409
- class gn {
409
+ }, Dn = (i) => i?.toLowerCase().endsWith(".png") ?? !1;
410
+ class Pn {
410
411
  data;
411
412
  options;
412
413
  textureLoader;
413
414
  littleEndian = !0;
414
415
  materials = /* @__PURE__ */ new Map();
415
416
  constructor(e, t) {
416
- this.data = e, this.options = t, this.textureLoader = new Ct(t.manager), this.textureLoader.setCrossOrigin(t.crossOrigin), this.textureLoader.setRequestHeader(t.requestHeader);
417
+ this.data = e, this.options = t, this.textureLoader = new Ft(t.manager), this.textureLoader.setCrossOrigin(t.crossOrigin), this.textureLoader.setRequestHeader(t.requestHeader);
417
418
  }
418
419
  parse(e, t) {
419
420
  let s = this.data;
420
- const n = hn(this.data);
421
+ const n = Bn(this.data);
421
422
  n && (s = n);
422
- const i = new DataView(s);
423
+ const r = new DataView(s);
423
424
  let a = 8;
424
- const o = i.getUint8(a);
425
- a += 1, o === 1 ? this._parseV2(i, a, e) : o === 2 ? this._parseV2(i, a, e) : o === 3 ? this._parseV3(i, a, e) : t?.(new Error(`SBMLoader: Unsupported SBM version: ${o}`));
425
+ const o = r.getUint8(a);
426
+ a += 1, o === 1 ? this._parseV2(r, a, e) : o === 2 ? this._parseV2(r, a, e) : o === 3 ? this._parseV3(r, a, e) : t?.(new Error(`SBMLoader: Unsupported SBM version: ${o}`));
426
427
  }
427
428
  _parseV2(e, t, s) {
428
- const n = new H(), i = e.getUint16(t, this.littleEndian);
429
+ const n = new W(), r = e.getUint16(t, this.littleEndian);
429
430
  t += 2;
430
431
  const a = e.getUint16(t, this.littleEndian);
431
432
  t += 2;
432
- for (let o = 0; o < i; ++o) {
433
+ for (let o = 0; o < r; ++o) {
433
434
  const c = e.getUint16(t, this.littleEndian).toString();
434
435
  t += 2, t += 4, t += 4, t += 4, t += 4;
435
436
  const l = e.getFloat32(t, this.littleEndian);
436
437
  t += 4;
437
438
  const h = e.getFloat32(t, this.littleEndian);
438
439
  t += 4;
439
- const u = e.getFloat32(t, this.littleEndian);
440
- t += 4;
441
440
  const d = e.getFloat32(t, this.littleEndian);
441
+ t += 4;
442
+ const u = e.getFloat32(t, this.littleEndian);
442
443
  t += 4, t += 4, t += 4, t += 4, t += 4;
443
444
  let p = e.getUint8(t);
444
- t += 1, p === 0 ? p = is : p === 1 ? p = rs : p === 2 && (p = as);
445
- const m = e.getUint16(t, this.littleEndian);
445
+ t += 1, p === 0 ? p = ws : p === 1 ? p = xs : p === 2 && (p = Ht);
446
+ const x = e.getUint16(t, this.littleEndian);
446
447
  t += 2;
447
- const b = m > 0 ? pn(e, m, t) : "";
448
- if (t += m, !this.materials.has(c)) {
449
- const w = mn(c, [l, h, u, d, p], fn(b));
450
- this.materials.set(c, w), b && this.options.path && this.textureLoader.load(G.resolveURL(b, this.options.path), (g) => {
451
- g.colorSpace = Ot, g.wrapS = Re, g.wrapT = Re, g.flipY = !1, g.anisotropy = 16, w.map = g;
448
+ const I = x > 0 ? Ln(e, x, t) : "";
449
+ if (t += x, !this.materials.has(c)) {
450
+ const C = Nn(c, [l, h, d, u, p], Dn(I));
451
+ this.materials.set(c, C), I && this.options.path && this.textureLoader.load(he.resolveURL(I, this.options.path), (y) => {
452
+ y.colorSpace = Se, y.wrapS = Ie, y.wrapT = Ie, y.flipY = !1, y.anisotropy = 16, C.map = y;
452
453
  });
453
454
  }
454
455
  }
@@ -457,76 +458,76 @@ class gn {
457
458
  t += 2;
458
459
  const l = e.getUint16(t, this.littleEndian).toString();
459
460
  t += 2;
460
- const h = [], u = [], d = [], p = [], m = e.getUint16(t, this.littleEndian);
461
- if (t += 2, m > 0)
462
- for (let y = 0; y < m; y++) {
463
- const _ = new C();
464
- _.setX(e.getFloat32(t, this.littleEndian)), t += 4, _.setY(e.getFloat32(t, this.littleEndian)), t += 4, _.setZ(e.getFloat32(t, this.littleEndian)), t += 4, h.push(_);
461
+ const h = [], d = [], u = [], p = [], x = e.getUint16(t, this.littleEndian);
462
+ if (t += 2, x > 0)
463
+ for (let b = 0; b < x; b++) {
464
+ const S = new D();
465
+ S.setX(e.getFloat32(t, this.littleEndian)), t += 4, S.setY(e.getFloat32(t, this.littleEndian)), t += 4, S.setZ(e.getFloat32(t, this.littleEndian)), t += 4, h.push(S);
465
466
  }
466
- const b = e.getUint16(t, this.littleEndian);
467
- if (t += 2, b > 0)
468
- for (let y = 0; y < b; y++)
467
+ const I = e.getUint16(t, this.littleEndian);
468
+ if (t += 2, I > 0)
469
+ for (let b = 0; b < I; b++)
469
470
  t += 4, t += 4, t += 4;
470
- const S = e.getUint16(t, this.littleEndian);
471
- if (t += 2, S > 0)
472
- for (let y = 0; y < S; y++) {
473
- const _ = new z();
474
- _.setX(e.getFloat32(t, this.littleEndian)), t += 4, _.setY(e.getFloat32(t, this.littleEndian)), t += 4, u.push(_);
471
+ const _ = e.getUint16(t, this.littleEndian);
472
+ if (t += 2, _ > 0)
473
+ for (let b = 0; b < _; b++) {
474
+ const S = new j();
475
+ S.setX(e.getFloat32(t, this.littleEndian)), t += 4, S.setY(e.getFloat32(t, this.littleEndian)), t += 4, d.push(S);
475
476
  }
476
- const w = e.getUint16(t, this.littleEndian);
477
- if (t += 2, w > 0)
478
- for (let y = 0; y < w; y++) {
479
- const _ = e.getUint16(t, this.littleEndian);
477
+ const C = e.getUint16(t, this.littleEndian);
478
+ if (t += 2, C > 0)
479
+ for (let b = 0; b < C; b++) {
480
+ const S = e.getUint16(t, this.littleEndian);
480
481
  t += 2;
481
- const k = e.getUint16(t, this.littleEndian);
482
+ const A = e.getUint16(t, this.littleEndian);
482
483
  t += 2;
483
- const N = e.getUint16(t, this.littleEndian);
484
+ const v = e.getUint16(t, this.littleEndian);
484
485
  t += 2;
485
- const D = [_, k, N];
486
- d.push(D), u.length > 0 && p.push([u[D[0]], u[D[1]], u[D[2]]]);
486
+ const E = [S, A, v];
487
+ u.push(E), d.length > 0 && p.push([d[E[0]], d[E[1]], d[E[2]]]);
487
488
  }
488
- const g = [], I = [];
489
- for (let y = 0; y < d.length; y++) {
490
- const _ = d[y], k = h[_[0]], N = h[_[1]], D = h[_[2]];
491
- g.push(...k.toArray(), ...N.toArray(), ...D.toArray());
492
- let Y = new z(), R = new z(), f = new z();
493
- const E = p[y];
494
- E !== void 0 && (Y = E[0], R = E[1], f = E[2]), I.push(...Y.toArray(), ...R.toArray(), ...f.toArray());
489
+ const y = [], w = [];
490
+ for (let b = 0; b < u.length; b++) {
491
+ const S = u[b], A = h[S[0]], v = h[S[1]], E = h[S[2]];
492
+ y.push(...A.toArray(), ...v.toArray(), ...E.toArray());
493
+ let z = new j(), N = new j(), f = new j();
494
+ const L = p[b];
495
+ L !== void 0 && (z = L[0], N = L[1], f = L[2]), w.push(...z.toArray(), ...N.toArray(), ...f.toArray());
495
496
  }
496
- const B = new Float32Array(g), O = new Float32Array(I), T = new Q();
497
- if (B.length > 0 && T.setAttribute("position", new je(B, 3)), O.length > 0 && T.setAttribute("uv", new je(O, 2)), T.computeVertexNormals(), this.materials.has(l)) {
498
- const y = new P(T, this.materials.get(l));
499
- y.name = c, y.castShadow = !0, y.receiveShadow = !0, n.add(y);
497
+ const g = new Float32Array(y), m = new Float32Array(w), M = new G();
498
+ if (g.length > 0 && M.setAttribute("position", new Pe(g, 3)), m.length > 0 && M.setAttribute("uv", new Pe(m, 2)), M.computeVertexNormals(), this.materials.has(l)) {
499
+ const b = new k(M, this.materials.get(l));
500
+ b.name = c, b.castShadow = !0, b.receiveShadow = !0, n.add(b);
500
501
  }
501
502
  }
502
503
  s(n);
503
504
  }
504
505
  _parseV3(e, t, s) {
505
- const n = new H();
506
+ const n = new W();
506
507
  console.warn("SBMLoader: SBM version 3 is not supported yet."), s(n);
507
508
  }
508
509
  }
509
- class yn extends ns {
510
+ class ct extends bs {
510
511
  load(e, t, s, n) {
511
- let i;
512
+ let r;
512
513
  if (this.resourcePath !== "")
513
- i = this.resourcePath;
514
+ r = this.resourcePath;
514
515
  else if (this.path !== "") {
515
- const c = G.extractUrlBase(e);
516
- i = G.resolveURL(c, this.path);
516
+ const c = he.extractUrlBase(e);
517
+ r = he.resolveURL(c, this.path);
517
518
  } else
518
- i = G.extractUrlBase(e);
519
+ r = he.extractUrlBase(e);
519
520
  this.manager.itemStart(e);
520
521
  const a = (c) => {
521
522
  n ? n(c) : console.error(c), this.manager.itemError(e), this.manager.itemEnd(e);
522
- }, o = new _t(this.manager);
523
+ }, o = new Wt(this.manager);
523
524
  o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(
524
525
  e,
525
526
  (c) => {
526
527
  try {
527
528
  this.parse(
528
529
  c,
529
- i,
530
+ r,
530
531
  (l) => {
531
532
  t(l), this.manager.itemEnd(e);
532
533
  },
@@ -541,12 +542,12 @@ class yn extends ns {
541
542
  );
542
543
  }
543
544
  parse(e, t, s, n) {
544
- const i = new TextDecoder().decode(e.slice(0, 8));
545
- if (i !== "SBK-----" && i !== "SBM-----") {
546
- n?.(new Error(`SBMLoader: Invalid SBM format: ${i}`));
545
+ const r = new TextDecoder().decode(e.slice(0, 8));
546
+ if (r !== "SBK-----" && r !== "SBM-----") {
547
+ n?.(new Error(`SBMLoader: Invalid SBM format: ${r}`));
547
548
  return;
548
549
  }
549
- new gn(e, {
550
+ new Pn(e, {
550
551
  path: t,
551
552
  crossOrigin: this.crossOrigin,
552
553
  requestHeader: this.requestHeader,
@@ -558,17 +559,427 @@ class yn extends ns {
558
559
  this.parse(
559
560
  e,
560
561
  t,
561
- (i) => {
562
- s(i);
562
+ (r) => {
563
+ s(r);
563
564
  },
564
- (i) => {
565
- n(i);
565
+ (r) => {
566
+ n(r);
566
567
  }
567
568
  );
568
569
  });
569
570
  }
570
571
  }
571
- const bn = [
572
+ const Rn = {
573
+ 5120: Int8Array,
574
+ 5121: Uint8Array,
575
+ 5122: Int16Array,
576
+ 5123: Uint16Array,
577
+ 5125: Uint32Array,
578
+ 5126: Float32Array
579
+ }, kn = {
580
+ SCALAR: 1,
581
+ VEC2: 2,
582
+ VEC3: 3,
583
+ VEC4: 4,
584
+ MAT2: 4,
585
+ MAT3: 9,
586
+ MAT4: 16
587
+ }, zn = {
588
+ POSITION: "position",
589
+ NORMAL: "normal",
590
+ TANGENT: "tangent",
591
+ TEXCOORD_0: "uv",
592
+ TEXCOORD_1: "uv1",
593
+ TEXCOORD_2: "uv2",
594
+ TEXCOORD_3: "uv3",
595
+ COLOR_0: "color"
596
+ };
597
+ function oe(i, e) {
598
+ e && typeof e == "object" && !Array.isArray(e) && Object.assign(i.userData, e);
599
+ }
600
+ function Un(i) {
601
+ if (i.protocolVersion !== et)
602
+ throw new Error(
603
+ `Unsupported model decode protocol ${i.protocolVersion}; expected ${et}.`
604
+ );
605
+ const { document: e, buffers: t, images: s } = i;
606
+ hn(e);
607
+ const n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = (w) => {
608
+ const g = n.get(w);
609
+ if (g) return g;
610
+ const m = e.accessors?.[w];
611
+ if (!m || m.bufferView === void 0)
612
+ throw new Error(`Decoded glTF references missing accessor ${w}.`);
613
+ const M = e.bufferViews?.[m.bufferView];
614
+ if (!M) throw new Error(`Decoded glTF references missing bufferView ${m.bufferView}.`);
615
+ const b = t[M.buffer];
616
+ if (!b) throw new Error(`Decoded glTF references missing buffer ${M.buffer}.`);
617
+ const S = Rn[m.componentType], A = kn[m.type];
618
+ if (!S || !A)
619
+ throw new Error(`Unsupported decoded glTF accessor type ${m.componentType}/${m.type}.`);
620
+ const v = S.BYTES_PER_ELEMENT, E = M.byteOffset ?? 0, z = m.byteOffset ?? 0;
621
+ let N;
622
+ const f = A * v;
623
+ if (M.byteStride && M.byteStride !== f) {
624
+ if (M.byteStride % v !== 0 || z % v !== 0)
625
+ throw new Error(`Decoded glTF accessor ${w} has an invalid interleaved alignment.`);
626
+ const L = Math.floor(z / M.byteStride), O = [
627
+ m.bufferView,
628
+ m.componentType,
629
+ L,
630
+ m.count
631
+ ].join(":");
632
+ let B = r.get(O);
633
+ if (!B) {
634
+ const U = new S(
635
+ b,
636
+ E + L * M.byteStride,
637
+ m.count * M.byteStride / v
638
+ );
639
+ B = new vs(U, M.byteStride / v), r.set(O, B);
640
+ }
641
+ N = new Ke(
642
+ B,
643
+ A,
644
+ z % M.byteStride / v,
645
+ m.normalized ?? !1
646
+ );
647
+ } else {
648
+ const L = new S(
649
+ b,
650
+ E + z,
651
+ m.count * A
652
+ );
653
+ N = new Pe(L, A, m.normalized ?? !1);
654
+ }
655
+ return N.name = m.name ?? "", n.set(w, N), N;
656
+ }, h = (w, g, m) => {
657
+ const M = `${w}:${g}:${m}`, b = c.get(M);
658
+ if (b) return b;
659
+ const S = e.textures?.[w];
660
+ if (!S || S.source === void 0)
661
+ throw new Error(`Decoded glTF references missing texture ${w}.`);
662
+ const A = s[S.source];
663
+ if (!A) throw new Error(`Decoded glTF references missing image ${S.source}.`);
664
+ const v = S.sampler === void 0 ? void 0 : e.samplers?.[S.sampler], E = new $t(A);
665
+ return E.name = S.name ?? e.images?.[S.source]?.name ?? "", E.flipY = !1, E.colorSpace = g, E.channel = m, E.magFilter = v?.magFilter === 9728 ? Ee : Ve, E.minFilter = (() => {
666
+ switch (v?.minFilter) {
667
+ case 9728:
668
+ return Ee;
669
+ case 9729:
670
+ return Ve;
671
+ case 9984:
672
+ return Cs;
673
+ case 9985:
674
+ return Es;
675
+ case 9986:
676
+ return Is;
677
+ default:
678
+ return Ss;
679
+ }
680
+ })(), E.wrapS = (() => {
681
+ switch (v?.wrapS) {
682
+ case 33071:
683
+ return Ye;
684
+ case 33648:
685
+ return Xe;
686
+ default:
687
+ return Ie;
688
+ }
689
+ })(), E.wrapT = (() => {
690
+ switch (v?.wrapT) {
691
+ case 33071:
692
+ return Ye;
693
+ case 33648:
694
+ return Xe;
695
+ default:
696
+ return Ie;
697
+ }
698
+ })(), E.needsUpdate = !0, c.set(M, E), E;
699
+ }, d = (w, g, m, M) => {
700
+ m && (w[g] = h(m.index, M, m.texCoord ?? 0));
701
+ }, u = (w, g, m, M) => {
702
+ const b = [
703
+ w ?? "default",
704
+ g ? "derivative-tangents" : "",
705
+ m ? "vertex-colors" : "",
706
+ M ? "flat-shading" : ""
707
+ ].join(":"), S = o.get(b);
708
+ if (S) return S;
709
+ const A = w === void 0 ? void 0 : e.materials?.[w];
710
+ if (w !== void 0 && !A)
711
+ throw new Error(`Decoded glTF references missing material ${w}.`);
712
+ const v = A ?? {}, E = v.pbrMetallicRoughness ?? {}, z = E.baseColorFactor ?? [1, 1, 1, 1], N = v.alphaMode ?? "OPAQUE", f = new Ms({
713
+ color: new P().setRGB(
714
+ z[0] ?? 1,
715
+ z[1] ?? 1,
716
+ z[2] ?? 1,
717
+ qe
718
+ ),
719
+ opacity: z[3] ?? 1,
720
+ metalness: E.metallicFactor ?? 1,
721
+ roughness: E.roughnessFactor ?? 1,
722
+ transparent: N === "BLEND",
723
+ depthWrite: N !== "BLEND",
724
+ alphaTest: N === "MASK" ? v.alphaCutoff ?? 0.5 : 0
725
+ });
726
+ return v.doubleSided && (f.side = Ht), f.vertexColors = m, f.flatShading = M, f.name = v.name ?? "", d(f, "map", E.baseColorTexture, Se), d(f, "metalnessMap", E.metallicRoughnessTexture, fe), d(f, "roughnessMap", E.metallicRoughnessTexture, fe), d(f, "normalMap", v.normalTexture, fe), d(f, "aoMap", v.occlusionTexture, fe), d(f, "emissiveMap", v.emissiveTexture, Se), v.normalTexture?.scale !== void 0 && (f.normalScale = new j(
727
+ v.normalTexture.scale,
728
+ v.normalTexture.scale
729
+ )), g && (f.normalScale.y *= -1), v.occlusionTexture?.strength !== void 0 && (f.aoMapIntensity = v.occlusionTexture.strength), v.emissiveFactor && f.emissive.setRGB(
730
+ v.emissiveFactor[0] ?? 0,
731
+ v.emissiveFactor[1] ?? 0,
732
+ v.emissiveFactor[2] ?? 0,
733
+ qe
734
+ ), oe(f, v.extras), o.set(b, f), f;
735
+ }, p = (w, g) => {
736
+ const m = `${w}:${g}`, M = a.get(m);
737
+ if (M) return M;
738
+ const b = e.meshes?.[w]?.primitives[g];
739
+ if (!b) throw new Error(`Decoded glTF references missing primitive ${m}.`);
740
+ const S = new G();
741
+ for (const [A, v] of Object.entries(b.attributes)) {
742
+ const E = zn[A] ?? A.toLowerCase();
743
+ S.setAttribute(E, l(v));
744
+ }
745
+ if (b.indices !== void 0) {
746
+ const A = l(b.indices);
747
+ if (A instanceof Ke)
748
+ throw new Error(`Decoded glTF index accessor ${b.indices} cannot be interleaved.`);
749
+ S.setIndex(A);
750
+ }
751
+ return a.set(m, S), S;
752
+ }, x = (w) => {
753
+ const g = e.meshes?.[w];
754
+ if (!g) throw new Error(`Decoded glTF references missing mesh ${w}.`);
755
+ const m = g.primitives.map((b, S) => {
756
+ const A = new k(
757
+ p(w, S),
758
+ u(
759
+ b.material,
760
+ b.attributes.TANGENT === void 0,
761
+ b.attributes.COLOR_0 !== void 0,
762
+ b.attributes.NORMAL === void 0
763
+ )
764
+ );
765
+ return A.name = g.name ?? "", A;
766
+ });
767
+ if (m.length === 1)
768
+ return oe(m[0], g.extras), m[0];
769
+ const M = new W();
770
+ return M.name = g.name ?? "", M.add(...m), oe(M, g.extras), M;
771
+ }, I = (w) => {
772
+ const g = e.nodes?.[w];
773
+ if (!g) throw new Error(`Decoded glTF references missing node ${w}.`);
774
+ const m = g.mesh === void 0 ? new W() : x(g.mesh);
775
+ m.name = g.name ?? m.name, g.matrix ? new R().fromArray(g.matrix).decompose(m.position, m.quaternion, m.scale) : (g.translation && m.position.fromArray(g.translation), g.rotation && m.quaternion.fromArray(g.rotation), g.scale && m.scale.fromArray(g.scale)), oe(m, g.extras);
776
+ for (const M of g.children ?? [])
777
+ m.add(I(M));
778
+ return m;
779
+ }, _ = e.scene ?? 0, C = e.scenes?.[_];
780
+ if (!C) throw new Error(`Decoded glTF references missing scene ${_}.`);
781
+ const y = new W();
782
+ y.name = C.name ?? "", oe(y, C.extras);
783
+ for (const w of C.nodes ?? []) y.add(I(w));
784
+ return y.animations = [], y;
785
+ }
786
+ const jn = 256;
787
+ function Wn(i) {
788
+ return i instanceof Error ? { message: i.message, name: i.name, stack: i.stack } : { message: String(i) };
789
+ }
790
+ function Fn(i) {
791
+ const e = new Error(i.message);
792
+ return e.name = i.name ?? "Error", e.stack = i.stack, e;
793
+ }
794
+ class ve extends Error {
795
+ name = "ModelDecodeWorkerUnavailableError";
796
+ constructor(e, t) {
797
+ super(e, t);
798
+ }
799
+ }
800
+ function Hn(i, e, t = jn) {
801
+ if (i.images.length !== i.imageKeys.length)
802
+ throw new Error("Decoded model image identities do not match its image payload.");
803
+ const s = [];
804
+ for (let n = 0; n < i.images.length; n++) {
805
+ const r = i.imageKeys[n], a = i.images[n], o = e.get(r);
806
+ if (o)
807
+ e.delete(r), e.set(r, o), o !== a && a.close(), i.images[n] = o;
808
+ else
809
+ for (e.set(r, a), s.push(r); e.size > Math.max(0, t); ) {
810
+ const c = e.keys().next().value;
811
+ if (c === void 0) break;
812
+ e.delete(c);
813
+ }
814
+ }
815
+ return s;
816
+ }
817
+ class $n {
818
+ worker;
819
+ #s;
820
+ #a = 1;
821
+ #t = /* @__PURE__ */ new Map();
822
+ #e = /* @__PURE__ */ new Map();
823
+ #r = !1;
824
+ constructor(e, t = {}) {
825
+ this.worker = e, this.#s = t.onFatal, e.addEventListener("message", this.#o), e.addEventListener("error", this.#l), e.addEventListener("messageerror", this.#d);
826
+ }
827
+ get disposed() {
828
+ return this.#r;
829
+ }
830
+ supports(e) {
831
+ const t = e.split(/[?#]/, 1)[0].split(".").pop()?.toLowerCase();
832
+ return t === "sbmx" || t === "gltf" || t === "glb";
833
+ }
834
+ async loadAsync(e, t = {}) {
835
+ if (this.#r)
836
+ throw new ve("Model decode Worker is unavailable.");
837
+ const s = this.#a++, { signal: n, loadingManager: r, ...a } = t;
838
+ if (n?.aborted) throw n.reason ?? new DOMException("Aborted", "AbortError");
839
+ const o = await new Promise((l, h) => {
840
+ const d = {
841
+ resolve: l,
842
+ reject: h,
843
+ manager: r,
844
+ rootUrl: e,
845
+ resources: /* @__PURE__ */ new Map()
846
+ };
847
+ if (r?.itemStart(e), n) {
848
+ const u = () => {
849
+ this.#t.delete(s), this.#h(d, n.reason ?? new DOMException("Aborted", "AbortError")), h(n.reason ?? new DOMException("Aborted", "AbortError"));
850
+ try {
851
+ this.#n({ type: "cancel", id: s });
852
+ } catch {
853
+ }
854
+ };
855
+ d.cleanup = () => n.removeEventListener("abort", u), n.addEventListener("abort", u, { once: !0 });
856
+ }
857
+ this.#t.set(s, d);
858
+ try {
859
+ this.#n({ type: "decode", id: s, url: e, options: a });
860
+ } catch (u) {
861
+ this.#t.delete(s), d.cleanup?.();
862
+ const p = u instanceof Error ? u : new Error(String(u));
863
+ this.#h(d, p), h(p);
864
+ }
865
+ }), c = [];
866
+ try {
867
+ return c.push(...Hn(o, this.#e)), Un(o);
868
+ } catch (l) {
869
+ const h = /* @__PURE__ */ new Set();
870
+ for (const d of c) {
871
+ const u = o.imageKeys.indexOf(d), p = this.#e.get(d) ?? o.images[u];
872
+ this.#e.get(d) === p && this.#e.delete(d), p && !h.has(p) && (p.close(), h.add(p));
873
+ }
874
+ throw l;
875
+ } finally {
876
+ try {
877
+ this.#n({ type: "ack", id: s });
878
+ } catch {
879
+ }
880
+ }
881
+ }
882
+ dispose() {
883
+ if (!this.#r) {
884
+ this.#r = !0;
885
+ try {
886
+ this.#n({ type: "dispose" });
887
+ } catch {
888
+ }
889
+ this.#i(), this.worker.terminate(), this.#p(new ve("Model decode Worker was disposed.")), this.#e.clear();
890
+ }
891
+ }
892
+ #n(e) {
893
+ this.worker.postMessage(e);
894
+ }
895
+ #o = (e) => {
896
+ const t = e.data;
897
+ if (t.type === "disposed") return;
898
+ if (t.type === "resolve-resource") {
899
+ this.#c(t.id, t.resourceId, t.url);
900
+ return;
901
+ }
902
+ if (t.type === "resource-complete") {
903
+ const n = this.#t.get(t.id), r = n?.resources.get(t.resourceId);
904
+ n && r !== void 0 && (n.resources.delete(t.resourceId), t.ok || n.manager?.itemError(r), n.manager?.itemEnd(r));
905
+ return;
906
+ }
907
+ const s = this.#t.get(t.id);
908
+ if (!s) {
909
+ if (t.type === "decoded") {
910
+ t.packet.images.forEach((n) => n.close());
911
+ try {
912
+ this.#n({ type: "ack", id: t.id });
913
+ } catch {
914
+ }
915
+ }
916
+ return;
917
+ }
918
+ if (this.#t.delete(t.id), s.cleanup?.(), t.type === "decoded")
919
+ this.#h(s), s.resolve(t.packet);
920
+ else if (t.type === "unsupported")
921
+ this.#h(s, void 0, !1), s.reject(new Kt(t.reason));
922
+ else {
923
+ const n = Fn(t.error);
924
+ this.#h(s, n), s.reject(n);
925
+ }
926
+ };
927
+ #c(e, t, s) {
928
+ const n = this.#t.get(e);
929
+ if (!n) {
930
+ try {
931
+ this.#n({
932
+ type: "resource-resolved",
933
+ id: e,
934
+ resourceId: t,
935
+ error: { message: "The model decode request is no longer active.", name: "AbortError" }
936
+ });
937
+ } catch {
938
+ }
939
+ return;
940
+ }
941
+ let r;
942
+ try {
943
+ r = n.manager?.resolveURL(s) ?? s, n.manager?.itemStart(r), n.manager && n.resources.set(t, r), this.#n({ type: "resource-resolved", id: e, resourceId: t, url: r });
944
+ } catch (a) {
945
+ r !== void 0 && n.resources.delete(t) && (n.manager?.itemError(r), n.manager?.itemEnd(r));
946
+ try {
947
+ this.#n({ type: "resource-resolved", id: e, resourceId: t, error: Wn(a) });
948
+ } catch (o) {
949
+ this.#u(o instanceof Error ? o : new Error(String(o)));
950
+ }
951
+ }
952
+ }
953
+ #l = (e) => {
954
+ this.#u(e.error instanceof Error ? e.error : new Error(e.message));
955
+ };
956
+ #d = () => {
957
+ this.#u(new Error("Failed to deserialize a model decode Worker response."));
958
+ };
959
+ #u(e) {
960
+ if (this.#r) return;
961
+ this.#r = !0, this.#i(), this.worker.terminate();
962
+ const t = new ve(
963
+ `Model decode Worker failed: ${e.message}`,
964
+ { cause: e }
965
+ );
966
+ this.#p(t), this.#e.clear(), this.#s?.(t);
967
+ }
968
+ #i() {
969
+ this.worker.removeEventListener("message", this.#o), this.worker.removeEventListener("error", this.#l), this.worker.removeEventListener("messageerror", this.#d);
970
+ }
971
+ #h(e, t, s = t !== void 0) {
972
+ for (const n of e.resources.values())
973
+ t && e.manager?.itemError(n), e.manager?.itemEnd(n);
974
+ e.resources.clear(), s && e.manager?.itemError(e.rootUrl), e.manager?.itemEnd(e.rootUrl);
975
+ }
976
+ #p(e) {
977
+ for (const t of this.#t.values())
978
+ t.cleanup?.(), this.#h(t, e), t.reject(e);
979
+ this.#t.clear();
980
+ }
981
+ }
982
+ const Gn = [
572
983
  "map",
573
984
  "alphaMap",
574
985
  "aoMap",
@@ -595,36 +1006,59 @@ const bn = [
595
1006
  "thicknessMap",
596
1007
  "transmissionMap"
597
1008
  ];
598
- function oe(r) {
599
- return r.traverse((e) => {
600
- if (!(e instanceof P)) return;
1009
+ function ce(i) {
1010
+ return i.traverse((e) => {
1011
+ if (!(e instanceof k)) return;
601
1012
  const t = Array.isArray(e.material) ? e.material : [e.material];
602
1013
  for (const s of t) {
603
1014
  if (!s) continue;
604
1015
  let n = !1;
605
- for (const i of bn) {
606
- const a = s[i];
607
- a?.isTexture && a.image == null && (a.dispose(), s[i] = null, n = !0);
1016
+ for (const r of Gn) {
1017
+ const a = s[r];
1018
+ a?.isTexture && a.image == null && (a.dispose(), s[r] = null, n = !0);
608
1019
  }
609
1020
  n && (s.needsUpdate = !0);
610
1021
  }
611
- }), r;
1022
+ }), i;
612
1023
  }
613
- class X {
1024
+ class V {
614
1025
  static CACHE_NAME = "u-space-model-loader-cache";
615
- static fileLoader = new _t().setResponseType("arraybuffer");
616
- static dracoLoader = new Hs().setDecoderPath(
617
- `https://cdn.jsdelivr.net/npm/three@0.${ke}.0/examples/jsm/libs/draco/`
1026
+ static fileLoader = new Wt().setResponseType("arraybuffer");
1027
+ static dracoLoader = new cn().setDecoderPath(
1028
+ `https://cdn.jsdelivr.net/npm/three@0.${Qe}.0/examples/jsm/libs/draco/`
618
1029
  );
619
- static ktx2Loader = new Fs().setTranscoderPath(
620
- `https://cdn.jsdelivr.net/npm/three@0.${ke}.0/examples/jsm/libs/basis/`
1030
+ static ktx2Loader = new ln().setTranscoderPath(
1031
+ `https://cdn.jsdelivr.net/npm/three@0.${Qe}.0/examples/jsm/libs/basis/`
621
1032
  );
622
- static gltfLoader = new Tt().setDRACOLoader(X.dracoLoader).setKTX2Loader(X.ktx2Loader).setMeshoptDecoder(He);
623
- static sbmxLoader = new tn().setDRACOLoader(X.dracoLoader).setKTX2Loader(X.ktx2Loader).setMeshoptDecoder(He);
624
- static sbmLoader = new yn();
625
- static fbxLoader = new ks();
626
- static objLoader = new Us();
627
- static stlLoader = new Ws();
1033
+ static gltfLoader = new Re().setDRACOLoader(V.dracoLoader).setKTX2Loader(V.ktx2Loader).setMeshoptDecoder(Le);
1034
+ static sbmxLoader = new at().setDRACOLoader(V.dracoLoader).setKTX2Loader(V.ktx2Loader).setMeshoptDecoder(Le);
1035
+ static sbmLoader = new ct();
1036
+ static fbxLoader = new Ze();
1037
+ static objLoader = new an();
1038
+ static stlLoader = new on();
1039
+ static decodeWorkerClient = null;
1040
+ /**
1041
+ * Routes supported static glTF/GLB/SBMX models through a dedicated decoder
1042
+ * Worker. ModelLoaderManager owns the supplied Worker and terminates it when
1043
+ * replaced or cleared. The returned disposer only clears this specific
1044
+ * Worker, so a late owner cleanup cannot terminate a newer replacement.
1045
+ */
1046
+ static setDecodeWorker(e) {
1047
+ const t = this.decodeWorkerClient;
1048
+ if (this.decodeWorkerClient = null, t?.dispose(), !e) return () => {
1049
+ };
1050
+ let s;
1051
+ return s = new $n(e, {
1052
+ onFatal: () => {
1053
+ this.decodeWorkerClient === s && (this.decodeWorkerClient = null);
1054
+ }
1055
+ }), this.decodeWorkerClient = s, () => {
1056
+ this.decodeWorkerClient === s && (this.decodeWorkerClient = null, s.dispose());
1057
+ };
1058
+ }
1059
+ static get decodeWorkerEnabled() {
1060
+ return this.decodeWorkerClient !== null && !this.decodeWorkerClient.disposed;
1061
+ }
628
1062
  static setLoadingManager(e) {
629
1063
  this.fileLoader.manager = e, this.dracoLoader.manager = e, this.ktx2Loader.manager = e, this.gltfLoader.manager = e, this.sbmxLoader.manager = e, this.sbmLoader.manager = e, this.fbxLoader.manager = e, this.objLoader.manager = e, this.stlLoader.manager = e;
630
1064
  }
@@ -647,48 +1081,124 @@ class X {
647
1081
  this.ktx2Loader.setTranscoderPath(e);
648
1082
  }
649
1083
  static async loadAsync(e, t = { persistent: !0 }) {
650
- const s = e.split(".").pop()?.split("?")[0].toLowerCase();
651
- let n;
652
- switch (t.persistent && typeof caches < "u" ? n = await this.getPersistentData(e) : n = await this.fileLoader.loadAsync(e), s) {
653
- case "gltf":
654
- case "glb":
655
- const i = await this.gltfLoader.parseAsync(n, G.extractUrlBase(e));
656
- return i.scene.animations = i.animations, oe(i.scene);
657
- case "sbmx":
658
- const a = await this.sbmxLoader.parseAsync(n, G.extractUrlBase(e));
659
- return a.scene.animations = a.animations, oe(a.scene);
660
- case "sbm":
661
- const o = await this.sbmLoader.parseAsync(n, G.extractUrlBase(e));
662
- return oe(o);
663
- case "fbx":
664
- const c = this.fbxLoader.parse(n, G.extractUrlBase(e));
665
- return oe(c);
666
- case "obj":
667
- const l = new TextDecoder().decode(n), h = this.objLoader.parse(l);
668
- return oe(h);
669
- case "stl":
670
- const u = this.stlLoader.parse(n);
671
- return new P(u, new K());
672
- default:
673
- throw new Error(`Unsupported model format: ${s}`);
1084
+ const s = e.split(/[?#]/, 1)[0].split(".").pop()?.toLowerCase(), n = t.persistent ?? !0, r = t.signal;
1085
+ this.throwIfAborted(r);
1086
+ const a = this.decodeWorkerClient;
1087
+ if (a?.supports(e)) {
1088
+ const h = this.fileLoader.manager.resolveURL(e), d = typeof location > "u" ? e : new URL(e, location.href).href, u = typeof location > "u" ? h : new URL(h, location.href).href;
1089
+ try {
1090
+ return await a.loadAsync(u, {
1091
+ persistent: n,
1092
+ headers: this.fileLoader.requestHeader,
1093
+ credentials: this.fileLoader.withCredentials ? "include" : "same-origin",
1094
+ resourceBaseUrl: d,
1095
+ signal: r,
1096
+ loadingManager: this.fileLoader.manager
1097
+ });
1098
+ } catch (p) {
1099
+ if (this.throwIfAborted(r), !(p instanceof Kt) && !(p instanceof ve)) throw p;
1100
+ console.info(`[ModelLoaderManager] Decode Worker fallback for ${e}: ${p.message}`);
1101
+ }
1102
+ }
1103
+ const o = await this.loadSourceBuffer(e, n, r);
1104
+ this.throwIfAborted(r);
1105
+ const c = he.extractUrlBase(e), l = this.createParseLoadingManager(r);
1106
+ try {
1107
+ switch (s) {
1108
+ case "gltf":
1109
+ case "glb": {
1110
+ const d = await this.configureGltfLoader(new Re(l.manager)).parseAsync(o, c);
1111
+ return this.throwIfAborted(r), d.scene.animations = d.animations, ce(d.scene);
1112
+ }
1113
+ case "sbmx": {
1114
+ const d = await this.configureGltfLoader(new at(l.manager)).parseAsync(o, c);
1115
+ return this.throwIfAborted(r), d.scene.animations = d.animations, ce(d.scene);
1116
+ }
1117
+ case "sbm": {
1118
+ const d = await new ct(l.manager).setCrossOrigin(this.sbmLoader.crossOrigin).setRequestHeader(this.sbmLoader.requestHeader).setWithCredentials(this.sbmLoader.withCredentials).parseAsync(o, c);
1119
+ return this.throwIfAborted(r), ce(d);
1120
+ }
1121
+ case "fbx": {
1122
+ const d = new Ze(l.manager).setCrossOrigin(this.fbxLoader.crossOrigin).setRequestHeader(this.fbxLoader.requestHeader).setWithCredentials(this.fbxLoader.withCredentials).parse(o, c);
1123
+ return this.throwIfAborted(r), ce(d);
1124
+ }
1125
+ case "obj": {
1126
+ const h = new TextDecoder().decode(o), d = this.objLoader.parse(h);
1127
+ return this.throwIfAborted(r), ce(d);
1128
+ }
1129
+ case "stl": {
1130
+ const h = this.stlLoader.parse(o);
1131
+ return this.throwIfAborted(r), new k(h, new q());
1132
+ }
1133
+ default:
1134
+ throw new Error(`Unsupported model format: ${s}`);
1135
+ }
1136
+ } finally {
1137
+ l.cleanup();
674
1138
  }
675
1139
  }
676
- static async getPersistentData(e) {
1140
+ static configureGltfLoader(e) {
1141
+ return e.setDRACOLoader(this.dracoLoader).setKTX2Loader(this.ktx2Loader).setMeshoptDecoder(Le).setCrossOrigin(this.gltfLoader.crossOrigin).setRequestHeader(this.gltfLoader.requestHeader).setWithCredentials(this.gltfLoader.withCredentials), e;
1142
+ }
1143
+ static createParseLoadingManager(e) {
1144
+ this.throwIfAborted(e);
1145
+ const t = this.fileLoader.manager, s = new As();
1146
+ s.setURLModifier((r) => t.resolveURL(r)), s.itemStart = (r) => t.itemStart(r), s.itemEnd = (r) => t.itemEnd(r), s.itemError = (r) => t.itemError(r);
1147
+ const n = () => s.abort();
1148
+ return e?.addEventListener("abort", n, { once: !0 }), {
1149
+ manager: s,
1150
+ cleanup: () => e?.removeEventListener("abort", n)
1151
+ };
1152
+ }
1153
+ static async loadSourceBuffer(e, t, s) {
1154
+ this.throwIfAborted(s);
1155
+ const n = this.fileLoader.manager, r = n.resolveURL(e);
1156
+ n.itemStart(r);
677
1157
  try {
678
- const t = await caches.open(this.CACHE_NAME), s = await t.match(e);
679
- if (s)
680
- return await s.arrayBuffer();
681
- const n = await this.fileLoader.loadAsync(e), i = new Response(n);
682
- return await t.put(e, i), n;
683
- } catch (t) {
684
- return console.warn(`[LoaderManager] Failed to use Cache API for ${e}:`, t), await this.fileLoader.loadAsync(e);
1158
+ let a;
1159
+ if (t && typeof caches < "u")
1160
+ try {
1161
+ a = await caches.open(this.CACHE_NAME);
1162
+ const d = await a.match(r);
1163
+ if (this.throwIfAborted(s), d) {
1164
+ const u = await d.arrayBuffer();
1165
+ return this.throwIfAborted(s), u;
1166
+ }
1167
+ } catch (d) {
1168
+ this.throwIfAborted(s), console.warn(`[ModelLoaderManager] Failed to read Cache Storage for ${r}:`, d);
1169
+ }
1170
+ const o = n.abortController.signal, c = s && typeof AbortSignal.any == "function" ? AbortSignal.any([s, o]) : s ?? o, l = await fetch(r, {
1171
+ headers: this.fileLoader.requestHeader,
1172
+ credentials: this.fileLoader.withCredentials ? "include" : "same-origin",
1173
+ signal: c
1174
+ });
1175
+ if (!l.ok)
1176
+ throw new Error(
1177
+ `Failed to load model ${r}: ${l.status} ${l.statusText}`
1178
+ );
1179
+ const h = await l.arrayBuffer();
1180
+ if (this.throwIfAborted(s), a)
1181
+ try {
1182
+ await a.put(r, new Response(h.slice(0)));
1183
+ } catch (d) {
1184
+ this.throwIfAborted(s), console.warn(`[ModelLoaderManager] Failed to write Cache Storage for ${r}:`, d);
1185
+ }
1186
+ return h;
1187
+ } catch (a) {
1188
+ throw n.itemError(r), a;
1189
+ } finally {
1190
+ n.itemEnd(r);
685
1191
  }
686
1192
  }
1193
+ static throwIfAborted(e) {
1194
+ if (e?.aborted)
1195
+ throw e.reason ?? new DOMException("Aborted", "AbortError");
1196
+ }
687
1197
  }
688
- class Ti {
689
- static textureLoader = new Ct();
690
- static hdrLoader = new Gs();
691
- static cubeTextureLoader = new os();
1198
+ class ii {
1199
+ static textureLoader = new Ft();
1200
+ static hdrLoader = new dn();
1201
+ static cubeTextureLoader = new Os();
692
1202
  static setLoadingManager(e) {
693
1203
  this.textureLoader.manager = e, this.hdrLoader.manager = e, this.cubeTextureLoader.manager = e;
694
1204
  }
@@ -697,13 +1207,13 @@ class Ti {
697
1207
  }
698
1208
  static async loadAsyncHDR(e) {
699
1209
  const t = await this.hdrLoader.loadAsync(e);
700
- return t.mapping = cs, t;
1210
+ return t.mapping = Bs, t;
701
1211
  }
702
1212
  static async loadAsyncCubeTexture(e, t) {
703
1213
  return this.cubeTextureLoader.setPath(e), await this.cubeTextureLoader.loadAsync(t);
704
1214
  }
705
1215
  }
706
- class q extends P {
1216
+ class X extends k {
707
1217
  isBaseMesh = !0;
708
1218
  type = "BaseMesh";
709
1219
  castShadow = !0;
@@ -716,7 +1226,7 @@ class q extends P {
716
1226
  return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
717
1227
  }
718
1228
  }
719
- class ue extends H {
1229
+ class pe extends W {
720
1230
  isBaseGroup = !0;
721
1231
  type = "BaseGroup";
722
1232
  ignoreInvisibleWhenRaycast = !0;
@@ -727,7 +1237,7 @@ class ue extends H {
727
1237
  return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
728
1238
  }
729
1239
  }
730
- class wn extends ls {
1240
+ class Kn extends _s {
731
1241
  isBaseSprite = !0;
732
1242
  type = "BaseSprite";
733
1243
  ignoreInvisibleWhenRaycast = !0;
@@ -738,7 +1248,7 @@ class wn extends ls {
738
1248
  return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
739
1249
  }
740
1250
  }
741
- class we extends ue {
1251
+ class te extends pe {
742
1252
  isModel = !0;
743
1253
  type = "Model";
744
1254
  static memoryCache = /* @__PURE__ */ new Map();
@@ -749,24 +1259,34 @@ class we extends ue {
749
1259
  super();
750
1260
  }
751
1261
  async loadAsync(e) {
752
- const { url: t, cache: s = !0, persistent: n = !0 } = e;
1262
+ const { url: t, cache: s = !0, persistent: n = !0, signal: r } = e;
753
1263
  try {
754
- let i;
755
- s ? we.memoryCache.has(t) ? i = we.memoryCache.get(t) : (i = X.loadAsync(t, { persistent: n }), we.memoryCache.set(t, i)) : i = X.loadAsync(t, { persistent: n });
756
- const a = await i, o = Le(a);
757
- return this.add(o), o.animations && o.animations.length > 0 && (this.animations = o.animations, this.mixer = new hs(o)), o;
758
- } catch (i) {
759
- return console.error(`[Model] Failed to load model from ${t}:`, i), null;
1264
+ let a;
1265
+ if (s && !r)
1266
+ if (te.memoryCache.has(t))
1267
+ a = te.memoryCache.get(t);
1268
+ else {
1269
+ const h = V.loadAsync(t, { persistent: n, signal: r }).catch((d) => {
1270
+ throw te.memoryCache.get(t) === h && te.memoryCache.delete(t), d;
1271
+ });
1272
+ te.memoryCache.set(t, h), a = h;
1273
+ }
1274
+ else
1275
+ a = V.loadAsync(t, { persistent: n, signal: r });
1276
+ const o = await a, c = We(o);
1277
+ return this.add(c), c.animations && c.animations.length > 0 && (this.animations = c.animations, this.mixer = new Ts(c)), c;
1278
+ } catch (a) {
1279
+ return console.error(`[Model] Failed to load model from ${t}:`, a), null;
760
1280
  }
761
1281
  }
762
1282
  playAnimation(e, t = {}) {
763
1283
  if (!this.mixer || this.animations.length === 0) return null;
764
- const { loop: s = !0, repetitions: n = 1 / 0, timeScale: i = 1, clampWhenFinished: a = !1 } = t;
1284
+ const { loop: s = !0, repetitions: n = 1 / 0, timeScale: r = 1, clampWhenFinished: a = !1 } = t;
765
1285
  let o;
766
1286
  if (e === void 0 ? o = this.animations[0] : typeof e == "number" ? o = this.animations[e] : o = this.animations.find((l) => l.name === e), !o)
767
1287
  return console.warn(`[Model] Animation not found: ${e}`), null;
768
1288
  let c = this.actions.get(o.name);
769
- return c || (c = this.mixer.clipAction(o), this.actions.set(o.name, c)), c.setLoop(s ? us : ds, n), c.clampWhenFinished = a, c.timeScale = i, c.reset().play(), c;
1289
+ return c || (c = this.mixer.clipAction(o), this.actions.set(o.name, c)), c.setLoop(s ? Ls : Ns, n), c.clampWhenFinished = a, c.timeScale = r, c.reset().play(), c;
770
1290
  }
771
1291
  playAllAnimations(e = {}) {
772
1292
  return this.animations.map((t, s) => this.playAnimation(s, e)).filter((t) => t !== null);
@@ -787,13 +1307,13 @@ class we extends ue {
787
1307
  * Get the axis-aligned bounding box of this model.
788
1308
  */
789
1309
  getBoundingBox() {
790
- return new $().setFromObject(this);
1310
+ return new K().setFromObject(this);
791
1311
  }
792
1312
  /**
793
1313
  * Get the center point of this model's bounding box.
794
1314
  */
795
1315
  getCenter() {
796
- const e = new C();
1316
+ const e = new D();
797
1317
  return this.getBoundingBox().getCenter(e), e;
798
1318
  }
799
1319
  /**
@@ -801,21 +1321,21 @@ class we extends ue {
801
1321
  */
802
1322
  setMaterial(e) {
803
1323
  this.traverse((t) => {
804
- t instanceof P && (t.material = e);
1324
+ t instanceof k && (t.material = e);
805
1325
  });
806
1326
  }
807
1327
  static clearMemoryCache() {
808
1328
  this.memoryCache.clear();
809
1329
  }
810
1330
  static async clearPersistentCache() {
811
- typeof caches < "u" && await caches.delete("u-space-loader-cache");
1331
+ typeof caches < "u" && await caches.delete("u-space-model-loader-cache");
812
1332
  }
813
1333
  }
814
- class xn extends q {
1334
+ class qn extends X {
815
1335
  isSphereMesh = !0;
816
1336
  type = "SphereMesh";
817
1337
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
818
- super(), this.geometry = new ps(
1338
+ super(), this.geometry = new Ds(
819
1339
  e?.radius,
820
1340
  e?.widthSegments,
821
1341
  e?.heightSegments,
@@ -823,23 +1343,23 @@ class xn extends q {
823
1343
  e?.phiLength,
824
1344
  e?.thetaStart,
825
1345
  e?.thetaLength
826
- ), this.material = new K(t);
1346
+ ), this.material = new q(t);
827
1347
  }
828
1348
  }
829
- class qe extends q {
1349
+ class lt extends X {
830
1350
  isTubeMesh = !0;
831
1351
  type = "TubeMesh";
832
1352
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
833
- super(), this.geometry = new ms(
1353
+ super(), this.geometry = new Ps(
834
1354
  e?.path,
835
1355
  e?.tubularSegments,
836
1356
  e?.radius,
837
1357
  e?.radialSegments,
838
1358
  e?.closed
839
- ), this.material = new K(t);
1359
+ ), this.material = new q(t);
840
1360
  }
841
1361
  }
842
- class Li extends ue {
1362
+ class ai extends pe {
843
1363
  isTopology = !0;
844
1364
  type = "Topology";
845
1365
  // Visuals
@@ -885,12 +1405,12 @@ class Li extends ue {
885
1405
  * @param bidirectional If true, adds the reverse edge as well. Default true.
886
1406
  */
887
1407
  addEdge(e, t, s, n = !0) {
888
- const i = this.nodes.get(e), a = this.nodes.get(t);
889
- if (!i || !a) {
1408
+ const r = this.nodes.get(e), a = this.nodes.get(t);
1409
+ if (!r || !a) {
890
1410
  console.error(`[Topology] Cannot add edge. One or both nodes not found: ${e}, ${t}`);
891
1411
  return;
892
1412
  }
893
- const o = s ?? i.distanceTo(a);
1413
+ const o = s ?? r.distanceTo(a);
894
1414
  this.getNeighbors(e)?.set(t, o), n && this.getNeighbors(t)?.set(e, o);
895
1415
  }
896
1416
  /**
@@ -908,24 +1428,24 @@ class Li extends ue {
908
1428
  getShortestPath(e, t) {
909
1429
  if (!this.nodes.has(e) || !this.nodes.has(t))
910
1430
  return console.warn("[Topology] Start or End node not found."), [];
911
- const s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
1431
+ const s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
912
1432
  for (const [c] of this.nodes)
913
- s.set(c, 1 / 0), n.set(c, null), i.add(c);
914
- for (s.set(e, 0); i.size > 0; ) {
1433
+ s.set(c, 1 / 0), n.set(c, null), r.add(c);
1434
+ for (s.set(e, 0); r.size > 0; ) {
915
1435
  let c = null, l = 1 / 0;
916
- for (const u of i) {
917
- const d = s.get(u);
918
- d < l && (l = d, c = u);
1436
+ for (const d of r) {
1437
+ const u = s.get(d);
1438
+ u < l && (l = u, c = d);
919
1439
  }
920
1440
  if (c === null || c === t || l === 1 / 0)
921
1441
  break;
922
- i.delete(c);
1442
+ r.delete(c);
923
1443
  const h = this.adjacencyMap?.get(c);
924
1444
  if (h)
925
- for (const [u, d] of h) {
926
- if (!i.has(u)) continue;
927
- const p = s.get(c) + d;
928
- p < s.get(u) && (s.set(u, p), n.set(u, c));
1445
+ for (const [d, u] of h) {
1446
+ if (!r.has(d)) continue;
1447
+ const p = s.get(c) + u;
1448
+ p < s.get(d) && (s.set(d, p), n.set(d, c));
929
1449
  }
930
1450
  }
931
1451
  const a = [];
@@ -942,8 +1462,8 @@ class Li extends ue {
942
1462
  * Renders the entire topology graph structure using TubeGeometry and Spheres.
943
1463
  */
944
1464
  renderGraph() {
945
- this.clearGraph(), this.graphGroup = new H();
946
- const e = new xn({
1465
+ this.clearGraph(), this.graphGroup = new W();
1466
+ const e = new qn({
947
1467
  geometryParameters: {
948
1468
  radius: this.parameters.nodeRadius,
949
1469
  widthSegments: 16,
@@ -954,18 +1474,18 @@ class Li extends ue {
954
1474
  }
955
1475
  });
956
1476
  this.nodes.forEach((s, n) => {
957
- const i = e.clone();
958
- i.position.copy(s), Object.assign(i.userData, { id: n, type: "node" }), this.graphGroup.add(i);
1477
+ const r = e.clone();
1478
+ r.position.copy(s), Object.assign(r.userData, { id: n, type: "node" }), this.graphGroup.add(r);
959
1479
  });
960
1480
  const t = /* @__PURE__ */ new Set();
961
1481
  this.adjacencyMap.forEach((s, n) => {
962
- s.forEach((i, a) => {
1482
+ s.forEach((r, a) => {
963
1483
  const o = [n, a].sort().join("-");
964
1484
  if (t.has(o)) return;
965
1485
  t.add(o);
966
1486
  const c = this.nodes.get(n), l = this.nodes.get(a);
967
1487
  if (c && l) {
968
- const h = new fs(c, l), u = new qe({
1488
+ const h = new Rs(c, l), d = new lt({
969
1489
  geometryParameters: {
970
1490
  path: h,
971
1491
  tubularSegments: 1,
@@ -977,14 +1497,14 @@ class Li extends ue {
977
1497
  color: this.parameters.edgeColor
978
1498
  }
979
1499
  });
980
- Object.assign(u.userData, { from: n, to: a, weight: i, type: "edge" }), this.graphGroup.add(u);
1500
+ Object.assign(d.userData, { from: n, to: a, weight: r, type: "edge" }), this.graphGroup.add(d);
981
1501
  }
982
1502
  });
983
1503
  }), this.add(this.graphGroup);
984
1504
  }
985
1505
  clearGraph() {
986
1506
  this.graphGroup && (this.remove(this.graphGroup), this.graphGroup.traverse((e) => {
987
- e instanceof P && (e.geometry.dispose(), e.material.dispose());
1507
+ e instanceof k && (e.geometry.dispose(), e.material.dispose());
988
1508
  }), this.graphGroup = null);
989
1509
  }
990
1510
  /**
@@ -992,7 +1512,7 @@ class Li extends ue {
992
1512
  */
993
1513
  renderPath(e, t = this.parameters.pathColor) {
994
1514
  if (e.length < 2) return;
995
- const s = new gs(e, !1, "catmullrom", 0), n = new qe({
1515
+ const s = new ks(e, !1, "catmullrom", 0), n = new lt({
996
1516
  geometryParameters: {
997
1517
  path: s,
998
1518
  tubularSegments: e.length * 10,
@@ -1013,14 +1533,14 @@ class Li extends ue {
1013
1533
  /** Export nodes and edges as a JSON-serializable object. */
1014
1534
  exportData() {
1015
1535
  const e = {};
1016
- this.nodes.forEach((n, i) => {
1017
- e[i] = { x: n.x, y: n.y, z: n.z };
1536
+ this.nodes.forEach((n, r) => {
1537
+ e[r] = { x: n.x, y: n.y, z: n.z };
1018
1538
  });
1019
1539
  const t = [], s = /* @__PURE__ */ new Set();
1020
- return this.adjacencyMap.forEach((n, i) => {
1540
+ return this.adjacencyMap.forEach((n, r) => {
1021
1541
  n.forEach((a, o) => {
1022
- const c = [i, o].sort().join("-");
1023
- s.has(c) || (s.add(c), t.push({ from: i, to: o, weight: a }));
1542
+ const c = [r, o].sort().join("-");
1543
+ s.has(c) || (s.add(c), t.push({ from: r, to: o, weight: a }));
1024
1544
  });
1025
1545
  }), { nodes: e, edges: t };
1026
1546
  }
@@ -1030,7 +1550,7 @@ class Li extends ue {
1030
1550
  */
1031
1551
  importData(e) {
1032
1552
  this.clearGraph(), this.clearPaths(), this.nodes.clear(), this.adjacencyMap.clear(), Object.entries(e.nodes).forEach(([t, s]) => {
1033
- this.addNode(t, new C(s.x, s.y, s.z));
1553
+ this.addNode(t, new D(s.x, s.y, s.z));
1034
1554
  }), e.edges.forEach(({ from: t, to: s, weight: n }) => {
1035
1555
  this.addEdge(t, s, n);
1036
1556
  }), this.renderGraph();
@@ -1042,7 +1562,7 @@ class Li extends ue {
1042
1562
  return this.adjacencyMap.get(e);
1043
1563
  }
1044
1564
  }
1045
- class Pi extends wn {
1565
+ class oi extends Kn {
1046
1566
  isPoi = !0;
1047
1567
  type = "Poi";
1048
1568
  parameters = {
@@ -1061,7 +1581,7 @@ class Pi extends wn {
1061
1581
  _canvas = document.createElement("canvas");
1062
1582
  _lastParametersJSON = "";
1063
1583
  constructor(e = {}) {
1064
- super(new ys()), Object.assign(this.parameters, e), this.updateAsync();
1584
+ super(new zs()), Object.assign(this.parameters, e), this.updateAsync();
1065
1585
  }
1066
1586
  /**
1067
1587
  * Update the POI with new parameters
@@ -1075,35 +1595,35 @@ class Pi extends wn {
1075
1595
  const s = this._canvas, n = s.getContext("2d");
1076
1596
  if (!n) return;
1077
1597
  n.font = `${this.parameters.fontSize}px ${this.parameters.fontFamily}`;
1078
- let i = null;
1079
- this.parameters.img && (i = await this._loadImage(this.parameters.img));
1080
- const { text: a, fontSize: o, color: c, iconSize: l, padding: h, backgroundColor: u, borderRadius: d, textPosition: p, scaleFactor: m } = this.parameters, b = n.measureText(a), S = a ? b.width : 0, w = a ? o : 0;
1081
- let g = 0, I = 0, B = 0, O = 0, T = 0, y = 0;
1082
- const _ = !!i, k = !!a;
1083
- if (_ && k)
1598
+ let r = null;
1599
+ this.parameters.img && (r = await this._loadImage(this.parameters.img));
1600
+ const { text: a, fontSize: o, color: c, iconSize: l, padding: h, backgroundColor: d, borderRadius: u, textPosition: p, scaleFactor: x } = this.parameters, I = n.measureText(a), _ = a ? I.width : 0, C = a ? o : 0;
1601
+ let y = 0, w = 0, g = 0, m = 0, M = 0, b = 0;
1602
+ const S = !!r, A = !!a;
1603
+ if (S && A)
1084
1604
  switch (p) {
1085
1605
  case "top":
1086
- g = Math.max(l, S), I = l + h + w, T = (g - S) / 2, y = w / 2, B = (g - l) / 2, O = w + h;
1606
+ y = Math.max(l, _), w = l + h + C, M = (y - _) / 2, b = C / 2, g = (y - l) / 2, m = C + h;
1087
1607
  break;
1088
1608
  case "bottom":
1089
- g = Math.max(l, S), I = l + h + w, B = (g - l) / 2, O = 0, T = (g - S) / 2, y = l + h + w / 2;
1609
+ y = Math.max(l, _), w = l + h + C, g = (y - l) / 2, m = 0, M = (y - _) / 2, b = l + h + C / 2;
1090
1610
  break;
1091
1611
  case "left":
1092
- g = l + h + S, I = Math.max(l, w), T = 0, y = I / 2, B = S + h, O = (I - l) / 2;
1612
+ y = l + h + _, w = Math.max(l, C), M = 0, b = w / 2, g = _ + h, m = (w - l) / 2;
1093
1613
  break;
1094
1614
  default:
1095
- g = l + h + S, I = Math.max(l, w), B = 0, O = (I - l) / 2, T = l + h, y = I / 2;
1615
+ y = l + h + _, w = Math.max(l, C), g = 0, m = (w - l) / 2, M = l + h, b = w / 2;
1096
1616
  break;
1097
1617
  }
1098
- else _ ? (g = l, I = l, B = 0, O = 0) : k && (g = S, I = w, T = 0, y = w / 2);
1099
- const N = g + h * 2, D = I + h * 2;
1100
- if (s.width = N, s.height = D, n.font = `${o}px ${this.parameters.fontFamily}`, u && (n.fillStyle = u, this._drawRoundedRect(n, 0, 0, N, D, d), n.fill()), _ && n.drawImage(i, B + h, O + h, l, l), k) {
1618
+ else S ? (y = l, w = l, g = 0, m = 0) : A && (y = _, w = C, M = 0, b = C / 2);
1619
+ const v = y + h * 2, E = w + h * 2;
1620
+ if (s.width = v, s.height = E, n.font = `${o}px ${this.parameters.fontFamily}`, d && (n.fillStyle = d, this._drawRoundedRect(n, 0, 0, v, E, u), n.fill()), S && n.drawImage(r, g + h, m + h, l, l), A) {
1101
1621
  n.fillStyle = c;
1102
- const f = n.measureText(a), E = f.actualBoundingBoxAscent + f.actualBoundingBoxDescent, M = f.actualBoundingBoxAscent - E / 2;
1103
- n.textBaseline = "alphabetic", n.fillText(a, T + h, y + h + M);
1622
+ const f = n.measureText(a), L = f.actualBoundingBoxAscent + f.actualBoundingBoxDescent, O = f.actualBoundingBoxAscent - L / 2;
1623
+ n.textBaseline = "alphabetic", n.fillText(a, M + h, b + h + O);
1104
1624
  }
1105
- const Y = this.material.map, R = new bs(s);
1106
- R.colorSpace = Ot, this.material.map = R, Y?.dispose(), this.scale.set(N * m, D * m, 1);
1625
+ const z = this.material.map, N = new Us(s);
1626
+ N.colorSpace = Se, this.material.map = N, z?.dispose(), this.scale.set(v * x, E * x, 1);
1107
1627
  }
1108
1628
  _loadImage(e) {
1109
1629
  return new Promise((t, s) => {
@@ -1114,256 +1634,256 @@ class Pi extends wn {
1114
1634
  t(e);
1115
1635
  });
1116
1636
  }
1117
- _drawRoundedRect(e, t, s, n, i, a) {
1118
- e.beginPath(), e.moveTo(t + a, s), e.lineTo(t + n - a, s), e.quadraticCurveTo(t + n, s, t + n, s + a), e.lineTo(t + n, s + i - a), e.quadraticCurveTo(t + n, s + i, t + n - a, s + i), e.lineTo(t + a, s + i), e.quadraticCurveTo(t, s + i, t, s + i - a), e.lineTo(t, s + a), e.quadraticCurveTo(t, s, t + a, s), e.closePath();
1637
+ _drawRoundedRect(e, t, s, n, r, a) {
1638
+ e.beginPath(), e.moveTo(t + a, s), e.lineTo(t + n - a, s), e.quadraticCurveTo(t + n, s, t + n, s + a), e.lineTo(t + n, s + r - a), e.quadraticCurveTo(t + n, s + r, t + n - a, s + r), e.lineTo(t + a, s + r), e.quadraticCurveTo(t, s + r, t, s + r - a), e.lineTo(t, s + a), e.quadraticCurveTo(t, s, t + a, s), e.closePath();
1119
1639
  }
1120
1640
  dispose() {
1121
1641
  this.material.map?.dispose(), this.material.dispose();
1122
1642
  }
1123
1643
  }
1124
- class Nt extends q {
1644
+ class Xt extends X {
1125
1645
  isShapeMesh = !0;
1126
1646
  type = "ShapeMesh";
1127
1647
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
1128
- super(), this.geometry = new ws(e?.shape, e?.curveSegments), this.material = new K(t), this.geometry.rotateX(-Math.PI / 2);
1648
+ super(), this.geometry = new js(e?.shape, e?.curveSegments), this.material = new q(t), this.geometry.rotateX(-Math.PI / 2);
1129
1649
  }
1130
1650
  static createFromPoints(e, t = {}) {
1131
- return new Nt({
1651
+ return new Xt({
1132
1652
  ...t,
1133
1653
  geometryParameters: {
1134
1654
  ...t.geometryParameters,
1135
- shape: new At(e.map((s) => new z(s.x, -s.z)))
1655
+ shape: new Gt(e.map((s) => new j(s.x, -s.z)))
1136
1656
  }
1137
1657
  });
1138
1658
  }
1139
1659
  }
1140
- class zt extends q {
1660
+ class Yt extends X {
1141
1661
  isExtrudeMesh = !0;
1142
1662
  type = "ExtrudeMesh";
1143
1663
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
1144
- super(), this.geometry = new xs(e?.shape, e?.options), this.material = new K(t), this.geometry.rotateX(-Math.PI / 2);
1664
+ super(), this.geometry = new Ws(e?.shape, e?.options), this.material = new q(t), this.geometry.rotateX(-Math.PI / 2);
1145
1665
  }
1146
1666
  static createFromPoints(e, t = {}) {
1147
- return e && e.length === 0 && (e = void 0), new zt({
1667
+ return e && e.length === 0 && (e = void 0), new Yt({
1148
1668
  ...t,
1149
1669
  geometryParameters: {
1150
1670
  ...t.geometryParameters,
1151
- shape: new At(e?.map((s) => new z(s.x, -s.z)))
1671
+ shape: new Gt(e?.map((s) => new j(s.x, -s.z)))
1152
1672
  }
1153
1673
  });
1154
1674
  }
1155
1675
  }
1156
- class Ni extends q {
1676
+ class ci extends X {
1157
1677
  isPlaneMesh = !0;
1158
1678
  type = "PlaneMesh";
1159
1679
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
1160
- super(), this.geometry = new Ms(
1680
+ super(), this.geometry = new Fs(
1161
1681
  e?.width,
1162
1682
  e?.height,
1163
1683
  e?.widthSegments,
1164
1684
  e?.heightSegments
1165
- ), this.material = new K(t);
1685
+ ), this.material = new q(t);
1166
1686
  }
1167
1687
  }
1168
- class zi extends q {
1688
+ class li extends X {
1169
1689
  isCircleMesh = !0;
1170
1690
  type = "CircleMesh";
1171
1691
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
1172
1692
  super(
1173
- new Is(
1693
+ new Hs(
1174
1694
  e?.radius,
1175
1695
  e?.segments,
1176
1696
  e?.thetaStart,
1177
1697
  e?.thetaLength
1178
1698
  ),
1179
- new K(t)
1699
+ new q(t)
1180
1700
  ), this.geometry.rotateX(-Math.PI / 2);
1181
1701
  }
1182
1702
  }
1183
- class J {
1703
+ class Q {
1184
1704
  static traverseMeshes(e, t) {
1185
1705
  e.traverse((s) => {
1186
- s instanceof P && t(s);
1706
+ s instanceof k && t(s);
1187
1707
  });
1188
1708
  }
1189
1709
  }
1190
- const Mn = 3, In = 1, Sn = 0, vn = 2, Bn = 1e-3, Ye = new C(), Z = new C(), En = new Ss();
1191
- function Ve(r) {
1192
- return r.isInstanceObject === !0;
1710
+ const Vn = 3, Xn = 1, Yn = 0, Qn = 2, Jn = 1e-3, ht = new D(), J = new D(), Zn = new $s();
1711
+ function dt(i) {
1712
+ return i.isInstanceObject === !0;
1193
1713
  }
1194
- function Je(r) {
1714
+ function ut(i) {
1195
1715
  let e = !1;
1196
- return r.traverse((t) => {
1716
+ return i.traverse((t) => {
1197
1717
  if (e) return;
1198
1718
  const s = t;
1199
1719
  e = s.isMesh === !0 || s.isSprite === !0;
1200
1720
  }), e;
1201
1721
  }
1202
- function _n(r) {
1203
- let e = r;
1722
+ function er(i) {
1723
+ let e = i;
1204
1724
  for (; e; ) {
1205
1725
  if (!e.visible) return !1;
1206
1726
  e = e.parent;
1207
1727
  }
1208
1728
  return !0;
1209
1729
  }
1210
- function Ze(r) {
1211
- return r === void 0 || !Number.isFinite(r) || r <= 0 ? vn : r;
1730
+ function pt(i) {
1731
+ return i === void 0 || !Number.isFinite(i) || i <= 0 ? Qn : i;
1212
1732
  }
1213
- class Di {
1733
+ class hi {
1214
1734
  static flow(e = {}) {
1215
- const { baseColor: t = 16777215, flowColor: s = 65280, speed: n = 1, scale: i = 3, intensity: a = 4 } = e, o = V(new A(t)), c = V(new A(s)), l = Fe().x.mul(i).sub(ge.mul(n)), h = ye(Ce(l).add(1).mul(0.5), a);
1216
- return be(o, c, h);
1735
+ const { baseColor: t = 16777215, flowColor: s = 65280, speed: n = 1, scale: r = 3, intensity: a = 4 } = e, o = Y(new P(t)), c = Y(new P(s)), l = tt().x.mul(r).sub(we.mul(n)), h = xe(ke(l).add(1).mul(0.5), a);
1736
+ return Me(o, c, h);
1217
1737
  }
1218
1738
  static breathe(e = {}) {
1219
- const { baseColor: t = 16777215, breathColor: s = 65280, speed: n = 1, intensity: i = 2 } = e, a = V(new A(t)), o = V(new A(s)), c = Ce(ge.mul(n)).add(1).mul(0.5), l = ye(c, i);
1220
- return be(a, o, l);
1739
+ const { baseColor: t = 16777215, breathColor: s = 65280, speed: n = 1, intensity: r = 2 } = e, a = Y(new P(t)), o = Y(new P(s)), c = ke(we.mul(n)).add(1).mul(0.5), l = xe(c, r);
1740
+ return Me(a, o, l);
1221
1741
  }
1222
1742
  static fluid(e = {}) {
1223
1743
  const {
1224
1744
  baseColor: t = 16777215,
1225
1745
  flowColor: s = 255,
1226
1746
  speed: n = 1,
1227
- scale: i = 1,
1747
+ scale: r = 1,
1228
1748
  intensity: a = 1,
1229
1749
  distortion: o = 0.5
1230
- } = e, c = V(new A(t)), l = V(new A(s)), h = Fe().mul(i), u = ge.mul(n), d = Ge(h.add(u), 1, 0), p = h.add(d.mul(o)), m = Ge(p, 1, 0).add(1).mul(0.5), b = ye(m, a);
1231
- return be(c, l, b);
1750
+ } = e, c = Y(new P(t)), l = Y(new P(s)), h = tt().mul(r), d = we.mul(n), u = st(h.add(d), 1, 0), p = h.add(u.mul(o)), x = st(p, 1, 0).add(1).mul(0.5), I = xe(x, a);
1751
+ return Me(c, l, I);
1232
1752
  }
1233
1753
  static outline(e = {}) {
1234
1754
  let t = [...e.selectedObjects ?? []];
1235
- const s = [], n = /* @__PURE__ */ new Map(), i = new $();
1236
- let a = null, o = null, c = null, l = null, h = null, u = e.instanceBoundsProxy ?? !0, d = e.instanceBoundsPadding ?? 0, p = e.instanceBoundsMinSize ?? Bn, m = Ze(e.downSampleRatio);
1237
- const b = ae(e.edgeStrength ?? Mn), S = ae(e.edgeThickness ?? In), w = ae(e.edgeGlow ?? Sn), g = ae(new A(e.visibleEdgeColor ?? 16777215)), I = ae(new A(e.hiddenEdgeColor ?? 5125686)), B = () => (l ??= new vs(1, 1, 1), l), O = () => (h || (h = new Bs({ color: 16777215 }), h.colorWrite = !1, h.depthWrite = !1, h.name = "u-space.outline.instanceBoundsProxy"), h), T = (f) => {
1238
- const { source: E, mesh: M } = f, v = E.getInstanceBoundingBox?.(i, !0);
1239
- if (!v || v.isEmpty() || !_n(E)) {
1240
- M.visible = !1;
1755
+ const s = [], n = /* @__PURE__ */ new Map(), r = new K();
1756
+ let a = null, o = null, c = null, l = null, h = null, d = e.instanceBoundsProxy ?? !0, u = e.instanceBoundsPadding ?? 0, p = e.instanceBoundsMinSize ?? Jn, x = pt(e.downSampleRatio);
1757
+ const I = ae(e.edgeStrength ?? Vn), _ = ae(e.edgeThickness ?? Xn), C = ae(e.edgeGlow ?? Yn), y = ae(new P(e.visibleEdgeColor ?? 16777215)), w = ae(new P(e.hiddenEdgeColor ?? 5125686)), g = () => (l ??= new Gs(1, 1, 1), l), m = () => (h || (h = new Ks({ color: 16777215 }), h.colorWrite = !1, h.depthWrite = !1, h.name = "u-space.outline.instanceBoundsProxy"), h), M = (f) => {
1758
+ const { source: L, mesh: O } = f, B = L.getInstanceBoundingBox?.(r, !0);
1759
+ if (!B || B.isEmpty() || !er(L)) {
1760
+ O.visible = !1;
1241
1761
  return;
1242
1762
  }
1243
- v.getCenter(Ye), v.getSize(Z);
1244
- const j = Math.max(0, d), re = Math.max(0, p);
1245
- Z.set(
1246
- Math.max(Z.x + j * 2, re),
1247
- Math.max(Z.y + j * 2, re),
1248
- Math.max(Z.z + j * 2, re)
1249
- ), M.visible = !0, M.layers.mask = E.layers.mask, M.matrix.compose(Ye, En, Z), M.matrixWorldNeedsUpdate = !0;
1250
- }, y = (f) => {
1763
+ B.getCenter(ht), B.getSize(J);
1764
+ const U = Math.max(0, u), ie = Math.max(0, p);
1765
+ J.set(
1766
+ Math.max(J.x + U * 2, ie),
1767
+ Math.max(J.y + U * 2, ie),
1768
+ Math.max(J.z + U * 2, ie)
1769
+ ), O.visible = !0, O.layers.mask = L.layers.mask, O.matrix.compose(ht, Zn, J), O.matrixWorldNeedsUpdate = !0;
1770
+ }, b = (f) => {
1251
1771
  f.unsubscribe?.(), f.mesh.removeFromParent();
1252
- }, _ = (f, E) => {
1253
- let M = n.get(f);
1254
- if (!M) {
1255
- const v = new P(B(), O());
1256
- v.name = `u-space.outline.instanceBoundsProxy:${f.uuid}`, v.matrixAutoUpdate = !1, v.castShadow = !1, v.receiveShadow = !1, v.frustumCulled = !1, v.raycast = () => {
1257
- }, v.userData.instanceObject = f, M = {
1772
+ }, S = (f, L) => {
1773
+ let O = n.get(f);
1774
+ if (!O) {
1775
+ const B = new k(g(), m());
1776
+ B.name = `u-space.outline.instanceBoundsProxy:${f.uuid}`, B.matrixAutoUpdate = !1, B.castShadow = !1, B.receiveShadow = !1, B.frustumCulled = !1, B.raycast = () => {
1777
+ }, B.userData.instanceObject = f, O = {
1258
1778
  source: f,
1259
- mesh: v,
1260
- unsubscribe: f.onInstanceRenderDirty?.(() => T(M)) ?? null
1261
- }, n.set(f, M);
1779
+ mesh: B,
1780
+ unsubscribe: f.onInstanceRenderDirty?.(() => M(O)) ?? null
1781
+ }, n.set(f, O);
1262
1782
  }
1263
- return M.mesh.parent !== E && (M.mesh.removeFromParent(), E.add(M.mesh)), T(M), M.mesh.visible ? M.mesh : null;
1264
- }, k = (f, E) => {
1265
- const M = f.getInstanceRenderObject?.();
1266
- return M && Je(M) ? M : Je(f) ? f : u && f.getInstanceBoundingBox ? _(f, E) : null;
1267
- }, N = (f) => {
1268
- const E = /* @__PURE__ */ new Set(), M = /* @__PURE__ */ new Set();
1269
- for (const v of t) {
1270
- const j = Ve(v) ? k(v, f) : v;
1271
- j && (E.add(j), Ve(v) && n.get(v)?.mesh === j && M.add(v));
1783
+ return O.mesh.parent !== L && (O.mesh.removeFromParent(), L.add(O.mesh)), M(O), O.mesh.visible ? O.mesh : null;
1784
+ }, A = (f, L) => {
1785
+ const O = f.getInstanceRenderObject?.();
1786
+ return O && ut(O) ? O : ut(f) ? f : d && f.getInstanceBoundingBox ? S(f, L) : null;
1787
+ }, v = (f) => {
1788
+ const L = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set();
1789
+ for (const B of t) {
1790
+ const U = dt(B) ? A(B, f) : B;
1791
+ U && (L.add(U), dt(B) && n.get(B)?.mesh === U && O.add(B));
1272
1792
  }
1273
- n.forEach((v, j) => {
1274
- M.has(j) || (y(v), n.delete(j));
1275
- }), s.length = 0, E.forEach((v) => s.push(v));
1276
- }, D = () => {
1793
+ n.forEach((B, U) => {
1794
+ O.has(U) || (b(B), n.delete(U));
1795
+ }), s.length = 0, L.forEach((B) => s.push(B));
1796
+ }, E = () => {
1277
1797
  a?.dispose(), a = null;
1278
- }, Y = (f, E) => {
1279
- if (a && o === f && c === E)
1280
- return a.downSampleRatio = m, a;
1281
- D(), o = f, c = E, a = Js(f, E, {
1798
+ }, z = (f, L) => {
1799
+ if (a && o === f && c === L)
1800
+ return a.downSampleRatio = x, a;
1801
+ E(), o = f, c = L, a = wn(f, L, {
1282
1802
  selectedObjects: s,
1283
- edgeThickness: S,
1284
- edgeGlow: w,
1285
- downSampleRatio: m
1803
+ edgeThickness: _,
1804
+ edgeGlow: C,
1805
+ downSampleRatio: x
1286
1806
  });
1287
- const M = a.updateBefore.bind(a);
1288
- return a.updateBefore = (v) => (N(f), M(v)), a;
1289
- }, R = ((f, E) => {
1290
- const M = f.scene, v = f.camera;
1291
- N(M);
1292
- const j = Y(M, v), re = j.visibleEdge.mul(g).add(j.hiddenEdge.mul(I)).mul(b);
1293
- return $s(E, Ks(re, 0));
1807
+ const O = a.updateBefore.bind(a);
1808
+ return a.updateBefore = (B) => (v(f), O(B)), a;
1809
+ }, N = ((f, L) => {
1810
+ const O = f.scene, B = f.camera;
1811
+ v(O);
1812
+ const U = z(O, B), ie = U.visibleEdge.mul(y).add(U.hiddenEdge.mul(w)).mul(I);
1813
+ return un(L, pn(ie, 0));
1294
1814
  });
1295
- return Object.defineProperties(R, {
1815
+ return Object.defineProperties(N, {
1296
1816
  outlineNode: {
1297
1817
  get: () => a
1298
1818
  },
1299
1819
  selectedObjects: {
1300
1820
  get: () => t
1301
1821
  }
1302
- }), R.setSelectedObjects = (f) => (t = [...f], o && N(o), R), R.update = (f) => (f.edgeStrength !== void 0 && (b.value = f.edgeStrength), f.edgeThickness !== void 0 && (S.value = f.edgeThickness), f.edgeGlow !== void 0 && (w.value = f.edgeGlow), f.visibleEdgeColor !== void 0 && g.value.set(f.visibleEdgeColor), f.hiddenEdgeColor !== void 0 && I.value.set(f.hiddenEdgeColor), f.instanceBoundsProxy !== void 0 && (u = f.instanceBoundsProxy), f.instanceBoundsPadding !== void 0 && (d = f.instanceBoundsPadding), f.instanceBoundsMinSize !== void 0 && (p = f.instanceBoundsMinSize), f.downSampleRatio !== void 0 && (m = Ze(f.downSampleRatio), a && (a.downSampleRatio = m)), o && N(o), R), R.dispose = () => {
1303
- D(), n.forEach(y), n.clear(), l?.dispose(), h?.dispose(), l = null, h = null, t = [], s.length = 0, o = null, c = null;
1304
- }, R;
1822
+ }), N.setSelectedObjects = (f) => (t = [...f], o && v(o), N), N.update = (f) => (f.edgeStrength !== void 0 && (I.value = f.edgeStrength), f.edgeThickness !== void 0 && (_.value = f.edgeThickness), f.edgeGlow !== void 0 && (C.value = f.edgeGlow), f.visibleEdgeColor !== void 0 && y.value.set(f.visibleEdgeColor), f.hiddenEdgeColor !== void 0 && w.value.set(f.hiddenEdgeColor), f.instanceBoundsProxy !== void 0 && (d = f.instanceBoundsProxy), f.instanceBoundsPadding !== void 0 && (u = f.instanceBoundsPadding), f.instanceBoundsMinSize !== void 0 && (p = f.instanceBoundsMinSize), f.downSampleRatio !== void 0 && (x = pt(f.downSampleRatio), a && (a.downSampleRatio = x)), o && v(o), N), N.dispose = () => {
1823
+ E(), n.forEach(b), n.clear(), l?.dispose(), h?.dispose(), l = null, h = null, t = [], s.length = 0, o = null, c = null;
1824
+ }, N;
1305
1825
  }
1306
1826
  }
1307
- function Ri(r) {
1827
+ function di(i) {
1308
1828
  }
1309
- const ie = "uSpaceHighlight", he = `${ie}/enabled`, Dt = `${ie}/opacity`, Rt = `${ie}/color`, jt = `${ie}/overwrite`, kt = `${ie}/multiplyOpacity`, Me = `${ie}/instancedOriginalOpacity`, ve = "uSpaceBreathe", Ie = `${ve}/enabled`, Ut = `${ve}/color`, Wt = `${ve}/speed`, Ht = `${ve}/intensity`, Se = /* @__PURE__ */ new WeakMap(), Cn = Lt(() => {
1310
- const r = U(he, "uint"), e = U(Rt, "uint"), t = U(jt, "uint"), s = st(e), n = xe.mul(s), i = F(t.greaterThan(0), s, n), a = F(r.greaterThan(0), i, xe), o = U(Ie, "uint"), c = U(Ut, "uint"), l = U(Wt, "float"), h = U(Ht, "float"), u = st(c), d = Ce(ge.mul(l)).add(1).mul(0.5), p = ye(d, h), m = be(a, u, p);
1311
- return F(o.greaterThan(0), m, a);
1312
- })(), On = Lt(() => {
1313
- const r = U(he, "uint"), e = U(Dt, "float"), t = U(kt, "uint"), s = F(t.greaterThan(0), Oe.mul(e), e);
1314
- return F(r.greaterThan(0), s, Oe);
1829
+ const re = "uSpaceHighlight", ue = `${re}/enabled`, Qt = `${re}/opacity`, Jt = `${re}/color`, Zt = `${re}/overwrite`, es = `${re}/multiplyOpacity`, Ae = `${re}/instancedOriginalOpacity`, _e = "uSpaceBreathe", Oe = `${_e}/enabled`, ts = `${_e}/color`, ss = `${_e}/speed`, ns = `${_e}/intensity`, Be = /* @__PURE__ */ new WeakMap(), tr = qt(() => {
1830
+ const i = F(ue, "uint"), e = F(Jt, "uint"), t = F(Zt, "uint"), s = gt(e), n = Ce.mul(s), r = $(t.greaterThan(0), s, n), a = $(i.greaterThan(0), r, Ce), o = F(Oe, "uint"), c = F(ts, "uint"), l = F(ss, "float"), h = F(ns, "float"), d = gt(c), u = ke(we.mul(l)).add(1).mul(0.5), p = xe(u, h), x = Me(a, d, p);
1831
+ return $(o.greaterThan(0), x, a);
1832
+ })(), sr = qt(() => {
1833
+ const i = F(ue, "uint"), e = F(Qt, "float"), t = F(es, "uint"), s = $(t.greaterThan(0), ze.mul(e), e);
1834
+ return $(i.greaterThan(0), s, ze);
1315
1835
  })();
1316
- function le(r) {
1317
- return Array.isArray(r.material) ? r.material : [r.material];
1836
+ function de(i) {
1837
+ return Array.isArray(i.material) ? i.material : [i.material];
1318
1838
  }
1319
- function et(r) {
1320
- le(r).forEach((t) => {
1839
+ function ft(i) {
1840
+ de(i).forEach((t) => {
1321
1841
  if (!t) return;
1322
- let s = Se.get(t);
1842
+ let s = Be.get(t);
1323
1843
  s || (s = {
1324
1844
  colorNode: t.colorNode,
1325
1845
  opacityNode: t.opacityNode,
1326
1846
  transparent: t.transparent,
1327
1847
  depthWrite: t.depthWrite,
1328
1848
  activeMeshes: /* @__PURE__ */ new Set()
1329
- }, Se.set(t, s)), s.activeMeshes.add(r), t.transparent = !0, t.colorNode = Cn, t.opacityNode = On, t.needsUpdate = !0;
1849
+ }, Be.set(t, s)), s.activeMeshes.add(i), t.transparent = !0, t.colorNode = tr, t.opacityNode = sr, t.needsUpdate = !0;
1330
1850
  });
1331
1851
  }
1332
- function tt(r) {
1333
- const e = r.userData[he], t = r.userData[Ie];
1852
+ function mt(i) {
1853
+ const e = i.userData[ue], t = i.userData[Oe];
1334
1854
  if (e || t) return;
1335
- le(r).forEach((n) => {
1855
+ de(i).forEach((n) => {
1336
1856
  if (!n) return;
1337
- const i = Se.get(n);
1338
- i && (i.activeMeshes.delete(r), !(i.activeMeshes.size > 0) && (n.colorNode = i.colorNode, n.opacityNode = i.opacityNode, n.transparent = i.transparent, n.depthWrite = i.depthWrite, n.needsUpdate = !0, Se.delete(n)));
1857
+ const r = Be.get(n);
1858
+ r && (r.activeMeshes.delete(i), !(r.activeMeshes.size > 0) && (n.colorNode = r.colorNode, n.opacityNode = r.opacityNode, n.transparent = r.transparent, n.depthWrite = r.depthWrite, n.needsUpdate = !0, Be.delete(n)));
1339
1859
  });
1340
1860
  }
1341
- function An(r, e, t, s) {
1342
- const n = r, i = n.setInstanceHighlight;
1343
- if (i)
1344
- return i.call(r, e, t, s), !0;
1861
+ function nr(i, e, t, s) {
1862
+ const n = i, r = n.setInstanceHighlight;
1863
+ if (r)
1864
+ return r.call(i, e, t, s), !0;
1345
1865
  const a = n.setInstanceColor, o = n.setInstanceOpacity, c = n.getInstanceOpacity, l = n.getInstanceColor, h = n.hasInstanceColor;
1346
- return !a || !o ? !1 : (r.userData[Me] === void 0 && (r.userData[Me] = {
1347
- hasColor: h?.call(r) ?? !1,
1348
- color: l?.call(r, new A()).getHex() ?? 16777215,
1349
- opacity: c?.call(r) ?? 1
1350
- }), a.call(r, e), o.call(r, t), !0);
1351
- }
1352
- function Tn(r) {
1353
- const e = r, t = e.clearInstanceHighlight;
1866
+ return !a || !o ? !1 : (i.userData[Ae] === void 0 && (i.userData[Ae] = {
1867
+ hasColor: h?.call(i) ?? !1,
1868
+ color: l?.call(i, new P()).getHex() ?? 16777215,
1869
+ opacity: c?.call(i) ?? 1
1870
+ }), a.call(i, e), o.call(i, t), !0);
1871
+ }
1872
+ function rr(i) {
1873
+ const e = i, t = e.clearInstanceHighlight;
1354
1874
  if (t)
1355
- return t.call(r), !0;
1356
- const s = e.resetInstanceColor, n = e.setInstanceColor, i = e.setInstanceOpacity;
1357
- if (!s || !i) return !1;
1358
- const a = r.userData[Me];
1359
- return a && (a.hasColor && n ? n.call(r, a.color) : s.call(r), i.call(r, a.opacity), Reflect.deleteProperty(r.userData, Me)), !0;
1875
+ return t.call(i), !0;
1876
+ const s = e.resetInstanceColor, n = e.setInstanceColor, r = e.setInstanceOpacity;
1877
+ if (!s || !r) return !1;
1878
+ const a = i.userData[Ae];
1879
+ return a && (a.hasColor && n ? n.call(i, a.color) : s.call(i), r.call(i, a.opacity), Reflect.deleteProperty(i.userData, Ae)), !0;
1360
1880
  }
1361
1881
  class se {
1362
1882
  static highlightColor(e, t = {}) {
1363
- const s = Array.isArray(e) ? e : [e], { opacity: n = 0.5, color: i = 16711680, overwrite: a = !1, depthWrite: o, multiplyOpacity: c = !1 } = t, l = new A(i).getHex();
1883
+ const s = Array.isArray(e) ? e : [e], { opacity: n = 0.5, color: r = 16711680, overwrite: a = !1, depthWrite: o, multiplyOpacity: c = !1 } = t, l = new P(r).getHex();
1364
1884
  for (const h of s)
1365
- An(h, i, n, a) || J.traverseMeshes(h, (u) => {
1366
- u.userData[he] = 1, u.userData[Dt] = n, u.userData[Rt] = l, u.userData[jt] = a ? 1 : 0, u.userData[kt] = c ? 1 : 0, et(u), o !== void 0 && le(u).forEach((p) => {
1885
+ nr(h, r, n, a) || Q.traverseMeshes(h, (d) => {
1886
+ d.userData[ue] = 1, d.userData[Qt] = n, d.userData[Jt] = l, d.userData[Zt] = a ? 1 : 0, d.userData[es] = c ? 1 : 0, ft(d), o !== void 0 && de(d).forEach((p) => {
1367
1887
  p && (p.depthWrite = o);
1368
1888
  });
1369
1889
  });
@@ -1371,8 +1891,8 @@ class se {
1371
1891
  static removeHighlightColor(e) {
1372
1892
  const t = Array.isArray(e) ? e : [e];
1373
1893
  for (const s of t)
1374
- Tn(s) || J.traverseMeshes(s, (n) => {
1375
- n.userData[he] = 0, tt(n);
1894
+ rr(s) || Q.traverseMeshes(s, (n) => {
1895
+ n.userData[ue] = 0, mt(n);
1376
1896
  });
1377
1897
  }
1378
1898
  static breatheColor(e, t = {}) {
@@ -1384,17 +1904,17 @@ class se {
1384
1904
  },
1385
1905
  t
1386
1906
  );
1387
- n.color = new A(n.color).getHex();
1388
- for (const i of s)
1389
- J.traverseMeshes(i, (a) => {
1390
- a.userData[Ie] = 1, a.userData[Ut] = n.color, a.userData[Wt] = n.speed, a.userData[Ht] = n.intensity, et(a);
1907
+ n.color = new P(n.color).getHex();
1908
+ for (const r of s)
1909
+ Q.traverseMeshes(r, (a) => {
1910
+ a.userData[Oe] = 1, a.userData[ts] = n.color, a.userData[ss] = n.speed, a.userData[ns] = n.intensity, ft(a);
1391
1911
  });
1392
1912
  }
1393
1913
  static removeBreatheColor(e) {
1394
1914
  const t = Array.isArray(e) ? e : [e];
1395
1915
  for (const s of t)
1396
- J.traverseMeshes(s, (n) => {
1397
- n.userData[Ie] = 0, tt(n);
1916
+ Q.traverseMeshes(s, (n) => {
1917
+ n.userData[Oe] = 0, mt(n);
1398
1918
  });
1399
1919
  }
1400
1920
  /**
@@ -1403,8 +1923,8 @@ class se {
1403
1923
  static wireframe(e, t = !0) {
1404
1924
  const s = Array.isArray(e) ? e : [e];
1405
1925
  for (const n of s)
1406
- J.traverseMeshes(n, (i) => {
1407
- le(i).forEach((a) => {
1926
+ Q.traverseMeshes(n, (r) => {
1927
+ de(r).forEach((a) => {
1408
1928
  if (!a) return;
1409
1929
  const o = a;
1410
1930
  o.wireframe = t, o.needsUpdate = !0;
@@ -1434,17 +1954,17 @@ class se {
1434
1954
  return se._fade(e, 1, 0, s);
1435
1955
  }
1436
1956
  static _fade(e, t, s, n) {
1437
- const i = Array.isArray(e) ? e : [e], a = /* @__PURE__ */ new Map();
1438
- for (const o of i)
1439
- J.traverseMeshes(o, (c) => {
1440
- le(c).forEach((l) => {
1957
+ const r = Array.isArray(e) ? e : [e], a = /* @__PURE__ */ new Map();
1958
+ for (const o of r)
1959
+ Q.traverseMeshes(o, (c) => {
1960
+ de(c).forEach((l) => {
1441
1961
  if (!l || a.has(l)) return;
1442
- const h = l.opacity, u = l.transparent, d = s >= 1 ? h : s;
1962
+ const h = l.opacity, d = l.transparent, u = s >= 1 ? h : s;
1443
1963
  a.set(l, {
1444
1964
  material: l,
1445
- targetOpacity: d,
1965
+ targetOpacity: u,
1446
1966
  originalOpacity: h,
1447
- originalTransparent: u
1967
+ originalTransparent: d
1448
1968
  }), l.transparent = !0, l.opacity = t, l.needsUpdate = !0;
1449
1969
  });
1450
1970
  });
@@ -1452,19 +1972,19 @@ class se {
1452
1972
  const c = performance.now();
1453
1973
  let l = 0;
1454
1974
  const h = () => {
1455
- const u = performance.now() - c, d = Math.min(u / n, 1);
1456
- if (!i[0].parent) {
1975
+ const d = performance.now() - c, u = Math.min(d / n, 1);
1976
+ if (!r[0].parent) {
1457
1977
  cancelAnimationFrame(l), o();
1458
1978
  return;
1459
1979
  }
1460
- for (const { material: m, targetOpacity: b } of a.values())
1461
- m.opacity = t + (b - t) * d, m.needsUpdate = !0;
1462
- if (d < 1)
1980
+ for (const { material: x, targetOpacity: I } of a.values())
1981
+ x.opacity = t + (I - t) * u, x.needsUpdate = !0;
1982
+ if (u < 1)
1463
1983
  l = requestAnimationFrame(h);
1464
1984
  else {
1465
1985
  if (s >= 1)
1466
- for (const { material: m, originalOpacity: b, originalTransparent: S } of a.values())
1467
- m.opacity = b, m.transparent = S, m.needsUpdate = !0;
1986
+ for (const { material: x, originalOpacity: I, originalTransparent: _ } of a.values())
1987
+ x.opacity = I, x.transparent = _, x.needsUpdate = !0;
1468
1988
  o();
1469
1989
  }
1470
1990
  };
@@ -1472,11 +1992,11 @@ class se {
1472
1992
  });
1473
1993
  }
1474
1994
  }
1475
- const st = (r) => {
1476
- const e = r.shiftRight(16).bitAnd(255).toFloat().div(255), t = r.shiftRight(8).bitAnd(255).toFloat().div(255), s = r.bitAnd(255).toFloat().div(255);
1477
- return Xs(e, t, s);
1995
+ const gt = (i) => {
1996
+ const e = i.shiftRight(16).bitAnd(255).toFloat().div(255), t = i.shiftRight(8).bitAnd(255).toFloat().div(255), s = i.bitAnd(255).toFloat().div(255);
1997
+ return fn(e, t, s);
1478
1998
  };
1479
- class Ln extends Zs {
1999
+ class ir extends xn {
1480
2000
  viewer;
1481
2001
  constructor(e, t) {
1482
2002
  super(t), this.viewer = e;
@@ -1486,7 +2006,7 @@ class Ln extends Zs {
1486
2006
  this.viewer.invalidate(), t || this.viewer.removeEventListener("afterControlsUpdate", this._update);
1487
2007
  };
1488
2008
  easingByMode(e) {
1489
- const t = Pn[e];
2009
+ const t = ar[e];
1490
2010
  return super.easing(t);
1491
2011
  }
1492
2012
  start(e, t) {
@@ -1496,54 +2016,54 @@ class Ln extends Zs {
1496
2016
  return this.viewer.removeEventListener("afterControlsUpdate", this._update), super.stop();
1497
2017
  }
1498
2018
  }
1499
- function ji(r, e, t, s = {}, n, i) {
2019
+ function ui(i, e, t, s = {}, n, r) {
1500
2020
  return new Promise((a, o) => {
1501
- const { duration: c = 1e3, delay: l = 0, repeat: h = !1, mode: u = "Linear.None", yoyo: d = !1 } = s, p = new Ln(r, e).to(t, c).easingByMode(u).delay(l).onUpdate((m) => {
1502
- n?.(m, p);
2021
+ const { duration: c = 1e3, delay: l = 0, repeat: h = !1, mode: d = "Linear.None", yoyo: u = !1 } = s, p = new ir(i, e).to(t, c).easingByMode(d).delay(l).onUpdate((x) => {
2022
+ n?.(x, p);
1503
2023
  }).onComplete(() => {
1504
2024
  a();
1505
2025
  }).onStop(() => {
1506
2026
  o("animation stop");
1507
2027
  }).onStart(() => {
1508
- i?.(p);
2028
+ r?.(p);
1509
2029
  });
1510
- typeof h == "number" ? p.repeat(h) : typeof h == "boolean" && h && p.repeat(1 / 0), d && p.repeatDelay(20), p.yoyo(d), p.start();
2030
+ typeof h == "number" ? p.repeat(h) : typeof h == "boolean" && h && p.repeat(1 / 0), u && p.repeatDelay(20), p.yoyo(u), p.start();
1511
2031
  });
1512
2032
  }
1513
- const Pn = {
1514
- "Linear.None": x.Linear.None,
1515
- "Quadratic.In": x.Quadratic.In,
1516
- "Quadratic.Out": x.Quadratic.Out,
1517
- "Quadratic.InOut": x.Quadratic.InOut,
1518
- "Cubic.In": x.Cubic.In,
1519
- "Cubic.Out": x.Cubic.Out,
1520
- "Cubic.InOut": x.Cubic.InOut,
1521
- "Quartic.In": x.Quartic.In,
1522
- "Quartic.Out": x.Quartic.Out,
1523
- "Quartic.InOut": x.Quartic.InOut,
1524
- "Quintic.In": x.Quintic.In,
1525
- "Quintic.Out": x.Quintic.Out,
1526
- "Quintic.InOut": x.Quintic.InOut,
1527
- "Sinusoidal.In": x.Sinusoidal.In,
1528
- "Sinusoidal.Out": x.Sinusoidal.Out,
1529
- "Sinusoidal.InOut": x.Sinusoidal.InOut,
1530
- "Exponential.In": x.Exponential.In,
1531
- "Exponential.Out": x.Exponential.Out,
1532
- "Exponential.InOut": x.Exponential.InOut,
1533
- "Circular.In": x.Circular.In,
1534
- "Circular.Out": x.Circular.Out,
1535
- "Circular.InOut": x.Circular.InOut,
1536
- "Elastic.In": x.Elastic.In,
1537
- "Elastic.Out": x.Elastic.Out,
1538
- "Elastic.InOut": x.Elastic.InOut,
1539
- "Back.In": x.Back.In,
1540
- "Back.Out": x.Back.Out,
1541
- "Back.InOut": x.Back.InOut,
1542
- "Bounce.In": x.Bounce.In,
1543
- "Bounce.Out": x.Bounce.Out,
1544
- "Bounce.InOut": x.Bounce.InOut
2033
+ const ar = {
2034
+ "Linear.None": T.Linear.None,
2035
+ "Quadratic.In": T.Quadratic.In,
2036
+ "Quadratic.Out": T.Quadratic.Out,
2037
+ "Quadratic.InOut": T.Quadratic.InOut,
2038
+ "Cubic.In": T.Cubic.In,
2039
+ "Cubic.Out": T.Cubic.Out,
2040
+ "Cubic.InOut": T.Cubic.InOut,
2041
+ "Quartic.In": T.Quartic.In,
2042
+ "Quartic.Out": T.Quartic.Out,
2043
+ "Quartic.InOut": T.Quartic.InOut,
2044
+ "Quintic.In": T.Quintic.In,
2045
+ "Quintic.Out": T.Quintic.Out,
2046
+ "Quintic.InOut": T.Quintic.InOut,
2047
+ "Sinusoidal.In": T.Sinusoidal.In,
2048
+ "Sinusoidal.Out": T.Sinusoidal.Out,
2049
+ "Sinusoidal.InOut": T.Sinusoidal.InOut,
2050
+ "Exponential.In": T.Exponential.In,
2051
+ "Exponential.Out": T.Exponential.Out,
2052
+ "Exponential.InOut": T.Exponential.InOut,
2053
+ "Circular.In": T.Circular.In,
2054
+ "Circular.Out": T.Circular.Out,
2055
+ "Circular.InOut": T.Circular.InOut,
2056
+ "Elastic.In": T.Elastic.In,
2057
+ "Elastic.Out": T.Elastic.Out,
2058
+ "Elastic.InOut": T.Elastic.InOut,
2059
+ "Back.In": T.Back.In,
2060
+ "Back.Out": T.Back.Out,
2061
+ "Back.InOut": T.Back.InOut,
2062
+ "Bounce.In": T.Bounce.In,
2063
+ "Bounce.Out": T.Bounce.Out,
2064
+ "Bounce.InOut": T.Bounce.InOut
1545
2065
  };
1546
- class ki {
2066
+ class pi {
1547
2067
  scene;
1548
2068
  planes = /* @__PURE__ */ new Map();
1549
2069
  helpers = /* @__PURE__ */ new Map();
@@ -1552,7 +2072,7 @@ class ki {
1552
2072
  */
1553
2073
  group;
1554
2074
  constructor(e) {
1555
- this.scene = e, this.group = new Es(), this.group.name = "__clippingToolGroup", this.scene.add(this.group);
2075
+ this.scene = e, this.group = new qs(), this.group.name = "__clippingToolGroup", this.scene.add(this.group);
1556
2076
  }
1557
2077
  /**
1558
2078
  * Move all current scene children (except the clipping group itself) into the ClippingGroup,
@@ -1590,18 +2110,18 @@ class ki {
1590
2110
  const {
1591
2111
  normal: s = { x: 0, y: -1, z: 0 },
1592
2112
  constant: n = 0,
1593
- showHelper: i = !1,
2113
+ showHelper: r = !1,
1594
2114
  helperSize: a = 5,
1595
2115
  helperColor: o = 16711680
1596
- } = t, c = new _s(new C(s.x, s.y, s.z), n);
1597
- return this.planes.set(e, c), this._syncPlanes(), i && this.showHelper(e, a, o), c;
2116
+ } = t, c = new Vs(new D(s.x, s.y, s.z), n);
2117
+ return this.planes.set(e, c), this._syncPlanes(), r && this.showHelper(e, a, o), c;
1598
2118
  }
1599
2119
  /**
1600
2120
  * Add six clipping planes that form a box around a Box3.
1601
2121
  * Returns the six plane ids: `${id}_+x`, `${id}_-x`, etc.
1602
2122
  */
1603
2123
  addBox(e, t, s = {}) {
1604
- const { showHelpers: n = !1, helperColor: i = 16711680 } = s, a = t.min, o = t.max, c = [
2124
+ const { showHelpers: n = !1, helperColor: r = 16711680 } = s, a = t.min, o = t.max, c = [
1605
2125
  { suffix: "+x", normal: { x: -1, y: 0, z: 0 }, constant: o.x },
1606
2126
  { suffix: "-x", normal: { x: 1, y: 0, z: 0 }, constant: -a.x },
1607
2127
  { suffix: "+y", normal: { x: 0, y: -1, z: 0 }, constant: o.y },
@@ -1610,8 +2130,8 @@ class ki {
1610
2130
  { suffix: "-z", normal: { x: 0, y: 0, z: 1 }, constant: -a.z }
1611
2131
  ], l = [];
1612
2132
  for (const h of c) {
1613
- const u = `${e}_${h.suffix}`;
1614
- this.addPlane(u, { normal: h.normal, constant: h.constant, showHelper: n, helperColor: i }), l.push(u);
2133
+ const d = `${e}_${h.suffix}`;
2134
+ this.addPlane(d, { normal: h.normal, constant: h.constant, showHelper: n, helperColor: r }), l.push(d);
1615
2135
  }
1616
2136
  return l;
1617
2137
  }
@@ -1619,8 +2139,8 @@ class ki {
1619
2139
  * Add a clipping box from an object's bounding box with optional padding.
1620
2140
  */
1621
2141
  addBoxFromObject(e, t, s = 0, n = {}) {
1622
- const i = new $().setFromObject(t);
1623
- return i.expandByScalar(s), this.addBox(e, i, n);
2142
+ const r = new K().setFromObject(t);
2143
+ return r.expandByScalar(s), this.addBox(e, r, n);
1624
2144
  }
1625
2145
  /**
1626
2146
  * Update a plane's constant (distance from origin).
@@ -1659,8 +2179,8 @@ class ki {
1659
2179
  this.hideHelper(e);
1660
2180
  const n = this.planes.get(e);
1661
2181
  if (!n) return;
1662
- const i = new Cs(n, t, new A(s).getHex());
1663
- i.name = e, this.helpers.set(e, i), this.scene.add(i);
2182
+ const r = new Xs(n, t, new P(s).getHex());
2183
+ r.name = e, this.helpers.set(e, r), this.scene.add(r);
1664
2184
  }
1665
2185
  /**
1666
2186
  * Hide a plane helper.
@@ -1685,7 +2205,7 @@ class ki {
1685
2205
  this.detach(), this.removeAll(), this.scene.remove(this.group);
1686
2206
  }
1687
2207
  }
1688
- class Ui {
2208
+ class fi {
1689
2209
  scene;
1690
2210
  measurements = /* @__PURE__ */ new Map();
1691
2211
  _idCounter = 0;
@@ -1696,16 +2216,16 @@ class Ui {
1696
2216
  * Measure distance between two points.
1697
2217
  */
1698
2218
  measureDistance(e, t, s = {}) {
1699
- const { lineColor: n = 16776960 } = s, i = new C(e.x, e.y, e.z), a = new C(t.x, t.y, t.z), o = i.distanceTo(a), c = `measure_dist_${this._idCounter++}`, l = new H();
2219
+ const { lineColor: n = 16776960 } = s, r = new D(e.x, e.y, e.z), a = new D(t.x, t.y, t.z), o = r.distanceTo(a), c = `measure_dist_${this._idCounter++}`, l = new W();
1700
2220
  l.name = c;
1701
- const h = new Q().setFromPoints([i, a]), u = new me({ color: n }), d = new fe(h, u);
1702
- l.add(d), this.scene.add(l);
2221
+ const h = new G().setFromPoints([r, a]), d = new ye({ color: n }), u = new be(h, d);
2222
+ l.add(u), this.scene.add(l);
1703
2223
  const p = {
1704
2224
  id: c,
1705
2225
  type: "distance",
1706
2226
  value: o,
1707
2227
  unit: "m",
1708
- points: [i, a],
2228
+ points: [r, a],
1709
2229
  object: l
1710
2230
  };
1711
2231
  return this.measurements.set(c, p), p;
@@ -1717,37 +2237,37 @@ class Ui {
1717
2237
  const { lineColor: s = 65280 } = t;
1718
2238
  if (e.length < 3)
1719
2239
  throw new Error("MeasureTool.measureArea requires at least 3 points");
1720
- const n = e.map((p) => new C(p.x, p.y, p.z)), i = this._calculatePolygonArea(n), a = `measure_area_${this._idCounter++}`, o = new H();
2240
+ const n = e.map((p) => new D(p.x, p.y, p.z)), r = this._calculatePolygonArea(n), a = `measure_area_${this._idCounter++}`, o = new W();
1721
2241
  o.name = a;
1722
- const c = [...n, n[0]], l = new Q().setFromPoints(c), h = new me({ color: s }), u = new fe(l, h);
1723
- o.add(u), this.scene.add(o);
1724
- const d = {
2242
+ const c = [...n, n[0]], l = new G().setFromPoints(c), h = new ye({ color: s }), d = new be(l, h);
2243
+ o.add(d), this.scene.add(o);
2244
+ const u = {
1725
2245
  id: a,
1726
2246
  type: "area",
1727
- value: i,
2247
+ value: r,
1728
2248
  unit: "m²",
1729
2249
  points: n,
1730
2250
  object: o
1731
2251
  };
1732
- return this.measurements.set(a, d), d;
2252
+ return this.measurements.set(a, u), u;
1733
2253
  }
1734
2254
  /**
1735
2255
  * Measure the angle between three points (vertex at the middle point).
1736
2256
  */
1737
2257
  measureAngle(e, t, s, n = {}) {
1738
- const { lineColor: i = 16746496 } = n, a = new C(e.x, e.y, e.z), o = new C(t.x, t.y, t.z), c = new C(s.x, s.y, s.z), l = a.clone().sub(o).normalize(), h = c.clone().sub(o).normalize(), d = Math.acos(Math.max(-1, Math.min(1, l.dot(h)))) * 180 / Math.PI, p = `measure_angle_${this._idCounter++}`, m = new H();
1739
- m.name = p;
1740
- const b = new Q().setFromPoints([a, o, c]), S = new me({ color: i }), w = new fe(b, S);
1741
- m.add(w), this.scene.add(m);
1742
- const g = {
2258
+ const { lineColor: r = 16746496 } = n, a = new D(e.x, e.y, e.z), o = new D(t.x, t.y, t.z), c = new D(s.x, s.y, s.z), l = a.clone().sub(o).normalize(), h = c.clone().sub(o).normalize(), u = Math.acos(Math.max(-1, Math.min(1, l.dot(h)))) * 180 / Math.PI, p = `measure_angle_${this._idCounter++}`, x = new W();
2259
+ x.name = p;
2260
+ const I = new G().setFromPoints([a, o, c]), _ = new ye({ color: r }), C = new be(I, _);
2261
+ x.add(C), this.scene.add(x);
2262
+ const y = {
1743
2263
  id: p,
1744
2264
  type: "angle",
1745
- value: d,
2265
+ value: u,
1746
2266
  unit: "°",
1747
2267
  points: [a, o, c],
1748
- object: m
2268
+ object: x
1749
2269
  };
1750
- return this.measurements.set(p, g), g;
2270
+ return this.measurements.set(p, y), y;
1751
2271
  }
1752
2272
  /**
1753
2273
  * Get a measurement result by id.
@@ -1782,15 +2302,15 @@ class Ui {
1782
2302
  * Calculate polygon area using cross product method (Newell's method).
1783
2303
  */
1784
2304
  _calculatePolygonArea(e) {
1785
- const t = e.length, s = new C();
1786
- for (let i = 0; i < t; i++) {
1787
- const a = e[i], o = e[(i + 1) % t], c = new C().crossVectors(a, o);
2305
+ const t = e.length, s = new D();
2306
+ for (let r = 0; r < t; r++) {
2307
+ const a = e[r], o = e[(r + 1) % t], c = new D().crossVectors(a, o);
1788
2308
  s.add(c);
1789
2309
  }
1790
- const n = new C();
2310
+ const n = new D();
1791
2311
  if (t >= 3) {
1792
- const i = e[1].clone().sub(e[0]), a = e[2].clone().sub(e[0]);
1793
- n.crossVectors(i, a).normalize();
2312
+ const r = e[1].clone().sub(e[0]), a = e[2].clone().sub(e[0]);
2313
+ n.crossVectors(r, a).normalize();
1794
2314
  }
1795
2315
  return Math.abs(s.dot(n)) / 2;
1796
2316
  }
@@ -1798,7 +2318,7 @@ class Ui {
1798
2318
  this.removeAll();
1799
2319
  }
1800
2320
  }
1801
- class Wi {
2321
+ class mi {
1802
2322
  scene;
1803
2323
  annotations = /* @__PURE__ */ new Map();
1804
2324
  _idCounter = 0;
@@ -1818,12 +2338,12 @@ class Wi {
1818
2338
  */
1819
2339
  add(e, t) {
1820
2340
  this.annotations.has(e) && this.remove(e);
1821
- const s = new H();
2341
+ const s = new W();
1822
2342
  s.name = `annotation_${e}`;
1823
- const n = new C(t.position.x, t.position.y, t.position.z);
2343
+ const n = new D(t.position.x, t.position.y, t.position.z);
1824
2344
  s.position.copy(n);
1825
- const i = document.createElement("div");
1826
- if (i.innerHTML = t.content, i.style.cssText = `
2345
+ const r = document.createElement("div");
2346
+ if (r.innerHTML = t.content, r.style.cssText = `
1827
2347
  padding: 4px 8px;
1828
2348
  background: rgba(0, 0, 0, 0.75);
1829
2349
  color: #fff;
@@ -1834,19 +2354,19 @@ class Wi {
1834
2354
  `, t.labelStyle)
1835
2355
  for (const l of Object.keys(t.labelStyle)) {
1836
2356
  const h = t.labelStyle[l];
1837
- h !== void 0 && (i.style[l] = h);
2357
+ h !== void 0 && (r.style[l] = h);
1838
2358
  }
1839
2359
  let a = null;
1840
2360
  const o = t.labelOffset || { x: 0, y: 2, z: 0 };
1841
2361
  if (t.showLeaderLine !== !1) {
1842
- const { lineColor: l = 16777215 } = t, h = new Q().setFromPoints([
1843
- new C(0, 0, 0),
1844
- new C(o.x, o.y, o.z)
1845
- ]), u = new me({ color: l });
1846
- a = new fe(h, u), s.add(a);
2362
+ const { lineColor: l = 16777215 } = t, h = new G().setFromPoints([
2363
+ new D(0, 0, 0),
2364
+ new D(o.x, o.y, o.z)
2365
+ ]), d = new ye({ color: l });
2366
+ a = new be(h, d), s.add(a);
1847
2367
  }
1848
2368
  if (this._createCSSObject) {
1849
- const l = this._createCSSObject(i);
2369
+ const l = this._createCSSObject(r);
1850
2370
  l.position.set(o.x, o.y, o.z), s.add(l);
1851
2371
  }
1852
2372
  this.scene.add(s);
@@ -1854,7 +2374,7 @@ class Wi {
1854
2374
  id: e,
1855
2375
  options: t,
1856
2376
  group: s,
1857
- labelElement: i,
2377
+ labelElement: r,
1858
2378
  line: a
1859
2379
  };
1860
2380
  return this.annotations.set(e, c), c;
@@ -1951,80 +2471,80 @@ class Wi {
1951
2471
  this.removeAll();
1952
2472
  }
1953
2473
  }
1954
- const nt = new L(), Nn = 1e-6, zn = 1e-6, it = "uSpaceInstanceOriginalMaterialState", rt = 0, Ee = 1, Dn = 2;
1955
- function Rn(r) {
1956
- let e = r;
2474
+ const yt = new R(), or = 1e-6, cr = 1e-6, bt = "uSpaceInstanceOriginalMaterialState", wt = 0, Ne = 1, lr = 2;
2475
+ function hr(i) {
2476
+ let e = i;
1957
2477
  for (; e; ) {
1958
2478
  if (!e.visible) return !1;
1959
2479
  e = e.parent;
1960
2480
  }
1961
2481
  return !0;
1962
2482
  }
1963
- function jn(r, e) {
1964
- const t = r.elements, s = e.elements;
2483
+ function dr(i, e) {
2484
+ const t = i.elements, s = e.elements;
1965
2485
  for (let n = 0; n < 16; n++)
1966
- if (Math.abs(t[n] - s[n]) > Nn) return !1;
2486
+ if (Math.abs(t[n] - s[n]) > or) return !1;
1967
2487
  return !0;
1968
2488
  }
1969
- function Ft(r) {
1970
- const e = r.material;
2489
+ function rs(i) {
2490
+ const e = i.material;
1971
2491
  return Array.isArray(e) ? e : [e];
1972
2492
  }
1973
- function Gt(r) {
1974
- const e = r.userData, t = e[it];
2493
+ function is(i) {
2494
+ const e = i.userData, t = e[bt];
1975
2495
  if (t) return t;
1976
2496
  const s = {
1977
- transparent: r.transparent,
1978
- opacity: r.opacity
2497
+ transparent: i.transparent,
2498
+ opacity: i.opacity
1979
2499
  };
1980
- return e[it] = s, s;
2500
+ return e[bt] = s, s;
1981
2501
  }
1982
- function kn(r, e) {
1983
- r.traverse((t) => {
2502
+ function ur(i, e) {
2503
+ i.traverse((t) => {
1984
2504
  const s = t;
1985
- s.isMesh && Ft(s).forEach((n) => {
2505
+ s.isMesh && rs(s).forEach((n) => {
1986
2506
  if (!n) return;
1987
- const i = n, a = Gt(i), o = a.opacity * e;
1988
- i.transparent = a.transparent || o < 1, i.opacity = o, i.needsUpdate = !0;
2507
+ const r = n, a = is(r), o = a.opacity * e;
2508
+ r.transparent = a.transparent || o < 1, r.opacity = o, r.needsUpdate = !0;
1989
2509
  });
1990
2510
  });
1991
2511
  }
1992
- function Un(r) {
1993
- r.traverse((e) => {
2512
+ function pr(i) {
2513
+ i.traverse((e) => {
1994
2514
  const t = e;
1995
- t.isMesh && Ft(t).forEach((s) => {
2515
+ t.isMesh && rs(t).forEach((s) => {
1996
2516
  if (!s) return;
1997
- const n = s, i = Gt(n);
1998
- n.transparent = i.transparent, n.opacity = i.opacity, n.needsUpdate = !0;
2517
+ const n = s, r = is(n);
2518
+ n.transparent = r.transparent, n.opacity = r.opacity, n.needsUpdate = !0;
1999
2519
  });
2000
2520
  });
2001
2521
  }
2002
- class Hi extends ue {
2522
+ class gi extends pe {
2003
2523
  isInstanceObject = !0;
2004
2524
  type = "InstanceObject";
2005
2525
  instanceId = "";
2006
2526
  instanceKind = "";
2007
2527
  instanceName = "";
2008
- geometry = new Q();
2528
+ geometry = new G();
2009
2529
  boundingBox = null;
2010
2530
  boundingSphere = null;
2011
- #t = {
2531
+ #s = {
2012
2532
  color: null,
2013
- colorMode: rt,
2533
+ colorMode: wt,
2014
2534
  opacity: 1
2015
2535
  };
2016
2536
  #a = null;
2017
- #s = null;
2537
+ #t = null;
2018
2538
  #e = null;
2019
- #n = null;
2020
- #i = /* @__PURE__ */ new Set();
2021
- #o = new L();
2539
+ #r = null;
2540
+ #n = /* @__PURE__ */ new Set();
2541
+ #o = new R();
2022
2542
  #c = !1;
2023
2543
  #l = !0;
2024
- #h = !1;
2025
- #d;
2544
+ #d = !1;
2545
+ #u;
2026
2546
  constructor(e = {}) {
2027
- super(), this.#d = e.boundsName ?? "InstanceBounds";
2547
+ super(), this.#u = e.boundsName ?? "InstanceBounds";
2028
2548
  }
2029
2549
  setInstanceIdentity(e) {
2030
2550
  let t = !1;
@@ -2044,33 +2564,33 @@ class Hi extends ue {
2044
2564
  }
2045
2565
  setInstanceBounds(e) {
2046
2566
  if (e.isEmpty()) return this;
2047
- this.#s && this.remove(this.#s);
2048
- const t = new Q();
2567
+ this.#t && this.remove(this.#t);
2568
+ const t = new G();
2049
2569
  t.boundingBox = e.clone();
2050
- const s = new Os();
2051
- return s.name = this.#d, s.visible = !1, s.geometry = t, s.raycast = () => {
2052
- }, this.#s = s, this.add(s), this.#p(), this.markInstanceRenderDirty(), this;
2570
+ const s = new Ys();
2571
+ return s.name = this.#u, s.visible = !1, s.geometry = t, s.raycast = () => {
2572
+ }, this.#t = s, this.add(s), this.#h(), this.markInstanceRenderDirty(), this;
2053
2573
  }
2054
2574
  setInstanceRenderObject(e) {
2055
- return this.#e && this.#e !== e && this.#e.parent === this && this.remove(this.#e), this.#e = e, e && e.parent !== this && this.add(e), this.#u(), this.#p(), this.markInstanceRenderDirty(), this;
2575
+ return this.#e && this.#e !== e && this.#e.parent === this && this.remove(this.#e), this.#e = e, e && e.parent !== this && this.add(e), this.#f(), this.#h(), this.markInstanceRenderDirty(), this;
2056
2576
  }
2057
2577
  getInstanceRenderObject() {
2058
2578
  return this.#e;
2059
2579
  }
2060
2580
  setInstanceMaterializer(e) {
2061
- return this.#n = e, this;
2581
+ return this.#r = e, this;
2062
2582
  }
2063
2583
  hasInstanceMaterializer(e) {
2064
- return this.#n === e;
2584
+ return this.#r === e;
2065
2585
  }
2066
2586
  clearInstanceMaterializer(e) {
2067
- return (e === void 0 || this.#n === e) && (this.#n = null), this;
2587
+ return (e === void 0 || this.#r === e) && (this.#r = null), this;
2068
2588
  }
2069
2589
  materialize() {
2070
- return this.#n?.() ?? this.#e ?? null;
2590
+ return this.#r?.() ?? this.#e ?? null;
2071
2591
  }
2072
2592
  computeBoundingBox() {
2073
- this.boundingBox === null && (this.boundingBox = new $()), this.getInstanceBoundingBox(this.boundingBox, !1);
2593
+ this.boundingBox === null && (this.boundingBox = new K()), this.getInstanceBoundingBox(this.boundingBox, !1);
2074
2594
  }
2075
2595
  computeBoundingSphere() {
2076
2596
  if (this.boundingSphere === null && (this.boundingSphere = new ne()), this.boundingBox === null && this.computeBoundingBox(), !this.boundingBox || this.boundingBox.isEmpty()) {
@@ -2079,167 +2599,167 @@ class Hi extends ue {
2079
2599
  }
2080
2600
  this.boundingBox.getBoundingSphere(this.boundingSphere);
2081
2601
  }
2082
- getInstanceBoundingBox(e = new $(), t = !1) {
2083
- const s = this.#s?.geometry?.boundingBox;
2084
- return s ? (e.copy(s), t && (this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld)), e) : this.#e ? (e.setFromObject(this.#e), t || (this.updateWorldMatrix(!0, !1), nt.copy(this.matrixWorld).invert(), e.applyMatrix4(nt)), e) : e.makeEmpty();
2602
+ getInstanceBoundingBox(e = new K(), t = !1) {
2603
+ const s = this.#t?.geometry?.boundingBox;
2604
+ return s ? (e.copy(s), t && (this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld)), e) : this.#e ? (e.setFromObject(this.#e), t || (this.updateWorldMatrix(!0, !1), yt.copy(this.matrixWorld).invert(), e.applyMatrix4(yt)), e) : e.makeEmpty();
2085
2605
  }
2086
2606
  setInstanceVisible(e) {
2087
2607
  return this.visible === e ? this : (this.visible = e, this.markInstanceRenderDirty(), this);
2088
2608
  }
2089
2609
  setInstanceColor(e) {
2090
- return this.#t.color = new A(e), this.#t.colorMode = Ee, this.#u(), this.markInstanceRenderDirty(), this;
2610
+ return this.#s.color = new P(e), this.#s.colorMode = Ne, this.#f(), this.markInstanceRenderDirty(), this;
2091
2611
  }
2092
2612
  resetInstanceColor() {
2093
- return this.#t.color === null ? this : (this.#t.color = null, this.#t.colorMode = rt, this.#u(), this.markInstanceRenderDirty(), this);
2613
+ return this.#s.color === null ? this : (this.#s.color = null, this.#s.colorMode = wt, this.#f(), this.markInstanceRenderDirty(), this);
2094
2614
  }
2095
2615
  setInstanceOpacity(e) {
2096
2616
  const t = Math.max(0, Math.min(1, e));
2097
- return Math.abs(this.#t.opacity - t) <= zn ? this : (this.#t.opacity = t, this.#u(), this.markInstanceRenderDirty(), this);
2617
+ return Math.abs(this.#s.opacity - t) <= cr ? this : (this.#s.opacity = t, this.#f(), this.markInstanceRenderDirty(), this);
2098
2618
  }
2099
- getInstanceColor(e = new A()) {
2100
- const t = this.#m();
2619
+ getInstanceColor(e = new P()) {
2620
+ const t = this.#p();
2101
2621
  return t.color ? e.copy(t.color) : e.setRGB(1, 1, 1);
2102
2622
  }
2103
2623
  hasInstanceColor() {
2104
- return this.#m().color !== null;
2624
+ return this.#p().color !== null;
2105
2625
  }
2106
2626
  getInstanceOpacity() {
2107
- return this.#m().opacity;
2627
+ return this.#p().opacity;
2108
2628
  }
2109
2629
  setInstanceHighlight(e, t, s = !1) {
2110
2630
  return this.#a = {
2111
- color: new A(e),
2112
- colorMode: s ? Ee : Dn,
2631
+ color: new P(e),
2632
+ colorMode: s ? Ne : lr,
2113
2633
  opacity: Math.max(0, Math.min(1, t))
2114
- }, this.#u(), this.markInstanceRenderDirty(), this;
2634
+ }, this.#f(), this.markInstanceRenderDirty(), this;
2115
2635
  }
2116
2636
  clearInstanceHighlight() {
2117
- return this.#a === null ? this : (this.#a = null, this.#u(), this.markInstanceRenderDirty(), this);
2637
+ return this.#a === null ? this : (this.#a = null, this.#f(), this.markInstanceRenderDirty(), this);
2118
2638
  }
2119
2639
  getInstanceColorMode() {
2120
- return this.#m().colorMode;
2640
+ return this.#p().colorMode;
2121
2641
  }
2122
2642
  onInstanceRenderDirty(e) {
2123
- return this.#i.add(e), () => this.#i.delete(e);
2643
+ return this.#n.add(e), () => this.#n.delete(e);
2124
2644
  }
2125
2645
  markInstanceRenderDirty() {
2126
- return this.#i.forEach((e) => e()), this;
2646
+ return this.#n.forEach((e) => e()), this;
2127
2647
  }
2128
2648
  updateMatrixWorld(e) {
2129
- super.updateMatrixWorld(e), this.#r();
2649
+ super.updateMatrixWorld(e), this.#i();
2130
2650
  }
2131
2651
  updateWorldMatrix(e, t) {
2132
- super.updateWorldMatrix(e, t), this.#r();
2652
+ super.updateWorldMatrix(e, t), this.#i();
2133
2653
  }
2134
- #r() {
2135
- const e = Rn(this);
2136
- (!this.#c || !jn(this.matrixWorld, this.#o) || !this.#h || e !== this.#l) && (this.#c = !0, this.#h = !0, this.#o.copy(this.matrixWorld), this.#l = e, this.markInstanceRenderDirty());
2654
+ #i() {
2655
+ const e = hr(this);
2656
+ (!this.#c || !dr(this.matrixWorld, this.#o) || !this.#d || e !== this.#l) && (this.#c = !0, this.#d = !0, this.#o.copy(this.matrixWorld), this.#l = e, this.markInstanceRenderDirty());
2137
2657
  }
2138
- #p() {
2658
+ #h() {
2139
2659
  this.boundingBox = null, this.boundingSphere = null;
2140
2660
  }
2141
- #m() {
2142
- return this.#a ?? this.#t;
2661
+ #p() {
2662
+ return this.#a ?? this.#s;
2143
2663
  }
2144
- #u() {
2664
+ #f() {
2145
2665
  if (!this.#e) return;
2146
- const e = this.#m();
2666
+ const e = this.#p();
2147
2667
  if (e.color) {
2148
- Un(this.#e), se.highlightColor(this.#e, {
2668
+ pr(this.#e), se.highlightColor(this.#e, {
2149
2669
  color: e.color,
2150
2670
  opacity: e.opacity,
2151
- overwrite: e.colorMode === Ee,
2671
+ overwrite: e.colorMode === Ne,
2152
2672
  multiplyOpacity: !0
2153
2673
  });
2154
2674
  return;
2155
2675
  }
2156
- se.removeHighlightColor(this.#e), kn(this.#e, e.opacity);
2676
+ se.removeHighlightColor(this.#e), ur(this.#e, e.opacity);
2157
2677
  }
2158
2678
  }
2159
- function Fi(r) {
2160
- return r.isInstanceObject === !0;
2679
+ function yi(i) {
2680
+ return i.isInstanceObject === !0;
2161
2681
  }
2162
- const Wn = /* @__PURE__ */ new Set([
2682
+ const fr = /* @__PURE__ */ new Set([
2163
2683
  "MeshBasicMaterial",
2164
2684
  "MeshLambertMaterial",
2165
2685
  "MeshPhongMaterial",
2166
2686
  "MeshStandardMaterial",
2167
2687
  "MeshPhysicalMaterial"
2168
- ]), at = /* @__PURE__ */ new WeakMap();
2169
- let Hn = 1;
2170
- const ot = new L(), ce = new L(), ct = new L();
2171
- function Fn(r, e, t = 1e-6) {
2172
- const s = r.elements, n = e.elements;
2173
- for (let i = 0; i < 16; i++)
2174
- if (Math.abs(s[i] - n[i]) > t) return !1;
2688
+ ]), xt = /* @__PURE__ */ new WeakMap();
2689
+ let mr = 1;
2690
+ const Mt = new R(), le = new R(), vt = new R();
2691
+ function gr(i, e, t = 1e-6) {
2692
+ const s = i.elements, n = e.elements;
2693
+ for (let r = 0; r < 16; r++)
2694
+ if (Math.abs(s[r] - n[r]) > t) return !1;
2175
2695
  return !0;
2176
2696
  }
2177
- function $t(r) {
2178
- let e = r;
2697
+ function as(i) {
2698
+ let e = i;
2179
2699
  for (; e; ) {
2180
2700
  if (!e.visible) return !1;
2181
2701
  e = e.parent;
2182
2702
  }
2183
2703
  return !0;
2184
2704
  }
2185
- function Gn(r) {
2186
- const e = r.source.data;
2705
+ function yr(i) {
2706
+ const e = i.source.data;
2187
2707
  if (!e || typeof e != "object" && typeof e != "function")
2188
- return `texture:${r.uuid}`;
2189
- let t = at.get(e);
2190
- return t === void 0 && (t = Hn++, at.set(e, t)), `source:${t}`;
2708
+ return `texture:${i.uuid}`;
2709
+ let t = xt.get(e);
2710
+ return t === void 0 && (t = mr++, xt.set(e, t)), `source:${t}`;
2191
2711
  }
2192
- function $n(r) {
2712
+ function br(i) {
2193
2713
  return JSON.stringify([
2194
- Gn(r),
2195
- r.mapping,
2196
- r.channel,
2197
- r.wrapS,
2198
- r.wrapT,
2199
- r.magFilter,
2200
- r.minFilter,
2201
- r.anisotropy,
2202
- r.format,
2203
- r.internalFormat,
2204
- r.type,
2205
- r.offset.toArray(),
2206
- r.repeat.toArray(),
2207
- r.center.toArray(),
2208
- r.rotation,
2209
- r.matrixAutoUpdate,
2210
- r.matrix.toArray(),
2211
- r.generateMipmaps,
2212
- r.premultiplyAlpha,
2213
- r.flipY,
2214
- r.unpackAlignment,
2215
- r.colorSpace,
2216
- "compareFunction" in r ? r.compareFunction : null
2714
+ yr(i),
2715
+ i.mapping,
2716
+ i.channel,
2717
+ i.wrapS,
2718
+ i.wrapT,
2719
+ i.magFilter,
2720
+ i.minFilter,
2721
+ i.anisotropy,
2722
+ i.format,
2723
+ i.internalFormat,
2724
+ i.type,
2725
+ i.offset.toArray(),
2726
+ i.repeat.toArray(),
2727
+ i.center.toArray(),
2728
+ i.rotation,
2729
+ i.matrixAutoUpdate,
2730
+ i.matrix.toArray(),
2731
+ i.generateMipmaps,
2732
+ i.premultiplyAlpha,
2733
+ i.flipY,
2734
+ i.unpackAlignment,
2735
+ i.colorSpace,
2736
+ "compareFunction" in i ? i.compareFunction : null
2217
2737
  ]);
2218
2738
  }
2219
- function Ae(r) {
2220
- if (Array.isArray(r)) return r.map(Ae);
2221
- if (!r || typeof r != "object") return r;
2222
- const e = r;
2739
+ function Ue(i) {
2740
+ if (Array.isArray(i)) return i.map(Ue);
2741
+ if (!i || typeof i != "object") return i;
2742
+ const e = i;
2223
2743
  return Object.fromEntries(
2224
- Object.keys(e).sort().map((t) => [t, Ae(e[t])])
2744
+ Object.keys(e).sort().map((t) => [t, Ue(e[t])])
2225
2745
  );
2226
2746
  }
2227
- function Te(r, e) {
2228
- if (Array.isArray(r)) return r.map((s) => Te(s, e));
2229
- if (!r || typeof r != "object")
2230
- return typeof r == "string" ? e.get(r) ?? r : r;
2231
- const t = r;
2747
+ function je(i, e) {
2748
+ if (Array.isArray(i)) return i.map((s) => je(s, e));
2749
+ if (!i || typeof i != "object")
2750
+ return typeof i == "string" ? e.get(i) ?? i : i;
2751
+ const t = i;
2232
2752
  return Object.fromEntries(
2233
- Object.keys(t).filter((s) => s !== "metadata" && s !== "uuid" && s !== "name").sort().map((s) => [s, Te(t[s], e)])
2753
+ Object.keys(t).filter((s) => s !== "metadata" && s !== "uuid" && s !== "name").sort().map((s) => [s, je(t[s], e)])
2234
2754
  );
2235
2755
  }
2236
- function Kn(r) {
2237
- if (!Wn.has(r.type) || r.transparent || r.opacity < 0.999 || r.visible === !1) return null;
2238
- const e = r;
2239
- if (Object.keys(e).some((i) => i.endsWith("Node") && e[i] != null) || Object.hasOwn(r, "onBeforeCompile")) return null;
2756
+ function wr(i) {
2757
+ if (!fr.has(i.type) || i.transparent || i.opacity < 0.999 || i.visible === !1) return null;
2758
+ const e = i;
2759
+ if (Object.keys(e).some((r) => r.endsWith("Node") && e[r] != null) || Object.hasOwn(i, "onBeforeCompile")) return null;
2240
2760
  const t = /* @__PURE__ */ new Map();
2241
- Object.values(e).forEach((i) => {
2242
- i instanceof zs && t.set(i.uuid, $n(i));
2761
+ Object.values(e).forEach((r) => {
2762
+ r instanceof $t && t.set(r.uuid, br(r));
2243
2763
  });
2244
2764
  const s = {
2245
2765
  geometries: {},
@@ -2250,26 +2770,26 @@ function Kn(r) {
2250
2770
  skeletons: {},
2251
2771
  animations: {},
2252
2772
  nodes: {}
2253
- }, n = r.toJSON(s);
2254
- return JSON.stringify(Ae(Te(n, t)));
2773
+ }, n = i.toJSON(s);
2774
+ return JSON.stringify(Ue(je(n, t)));
2255
2775
  }
2256
- function Xn(r) {
2257
- if (Object.keys(r.morphAttributes).length > 0 || r.drawRange.start !== 0 || r.drawRange.count !== 1 / 0) return null;
2258
- const e = Object.entries(r.attributes).sort(([t], [s]) => t.localeCompare(s)).map(([t, s]) => "isInterleavedBufferAttribute" in s ? null : [t, s.itemSize, s.normalized, s.array.constructor.name, s.gpuType]);
2776
+ function xr(i) {
2777
+ if (Object.keys(i.morphAttributes).length > 0 || i.drawRange.start !== 0 || i.drawRange.count !== 1 / 0) return null;
2778
+ const e = Object.entries(i.attributes).sort(([t], [s]) => t.localeCompare(s)).map(([t, s]) => "isInterleavedBufferAttribute" in s ? null : [t, s.itemSize, s.normalized, s.array.constructor.name, s.gpuType]);
2259
2779
  return e.some((t) => t === null) ? null : JSON.stringify([
2260
- r.index?.array.constructor.name ?? "non-indexed",
2780
+ i.index?.array.constructor.name ?? "non-indexed",
2261
2781
  e
2262
2782
  ]);
2263
2783
  }
2264
- function Qn(r, e) {
2265
- const t = [], s = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), i = !e && (r.animations.length > 0 || r.mixer !== null);
2266
- return i && n.add("animation"), r.updateWorldMatrix(!0, !0), ot.copy(r.matrixWorld).invert(), r.traverseVisible((a) => {
2267
- if (!(a instanceof P)) return;
2268
- if (i) {
2784
+ function Mr(i, e) {
2785
+ const t = [], s = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = !e && (i.animations.length > 0 || i.mixer !== null);
2786
+ return r && n.add("animation"), i.updateWorldMatrix(!0, !0), Mt.copy(i.matrixWorld).invert(), i.traverseVisible((a) => {
2787
+ if (!(a instanceof k)) return;
2788
+ if (r) {
2269
2789
  s.add(a);
2270
2790
  return;
2271
2791
  }
2272
- if (a instanceof Ts) {
2792
+ if (a instanceof Js) {
2273
2793
  s.add(a), n.add("skinned");
2274
2794
  return;
2275
2795
  }
@@ -2281,7 +2801,7 @@ function Qn(r, e) {
2281
2801
  s.add(a), n.add("material-array");
2282
2802
  return;
2283
2803
  }
2284
- const o = Kn(a.material), c = Xn(a.geometry);
2804
+ const o = wr(a.material), c = xr(a.geometry);
2285
2805
  if (!o) {
2286
2806
  s.add(a), n.add(a.material.transparent || a.material.opacity < 0.999 ? "transparent" : `material:${a.material.type}`);
2287
2807
  return;
@@ -2296,7 +2816,7 @@ function Qn(r, e) {
2296
2816
  }
2297
2817
  t.push({
2298
2818
  mesh: a,
2299
- localMatrix: ot.clone().multiply(a.matrixWorld),
2819
+ localMatrix: Mt.clone().multiply(a.matrixWorld),
2300
2820
  materialKey: o,
2301
2821
  geometryKey: c
2302
2822
  });
@@ -2306,63 +2826,63 @@ function Qn(r, e) {
2306
2826
  fallbackReasons: n
2307
2827
  };
2308
2828
  }
2309
- function qn(r, e) {
2310
- const t = Le(r), s = [], n = [];
2311
- return r.traverse((i) => {
2312
- i instanceof P && s.push(i);
2313
- }), t.traverse((i) => {
2314
- i instanceof P && n.push(i);
2315
- }), s.forEach((i, a) => {
2316
- e.has(i) && n[a] && (n[a].visible = !1);
2829
+ function vr(i, e) {
2830
+ const t = We(i), s = [], n = [];
2831
+ return i.traverse((r) => {
2832
+ r instanceof k && s.push(r);
2833
+ }), t.traverse((r) => {
2834
+ r instanceof k && n.push(r);
2835
+ }), s.forEach((r, a) => {
2836
+ e.has(r) && n[a] && (n[a].visible = !1);
2317
2837
  }), t;
2318
2838
  }
2319
- function Yn(r) {
2320
- const e = Le(r), t = /* @__PURE__ */ new Map(), s = (n) => {
2321
- let i = t.get(n);
2322
- return i || (i = n.clone(), t.set(n, i)), i;
2839
+ function Sr(i) {
2840
+ const e = We(i), t = /* @__PURE__ */ new Map(), s = (n) => {
2841
+ let r = t.get(n);
2842
+ return r || (r = n.clone(), t.set(n, r)), r;
2323
2843
  };
2324
2844
  return e.traverse((n) => {
2325
- n instanceof P && (n.material = Array.isArray(n.material) ? n.material.map(s) : s(n.material));
2845
+ n instanceof k && (n.material = Array.isArray(n.material) ? n.material.map(s) : s(n.material));
2326
2846
  }), e;
2327
2847
  }
2328
- function Vn(r) {
2329
- return Math.max(1, Math.ceil(Math.sqrt(Math.max(1, r))));
2848
+ function Ir(i) {
2849
+ return Math.max(1, Math.ceil(Math.sqrt(Math.max(1, i))));
2330
2850
  }
2331
- function Jn(r) {
2332
- const e = new Ls(new Float32Array(r * r * 4), r, r, Ps, Ns);
2333
- return e.magFilter = Ue, e.minFilter = Ue, e.generateMipmaps = !1, e.needsUpdate = !0, e;
2851
+ function Er(i) {
2852
+ const e = new Zs(new Float32Array(i * i * 4), i, i, en, tn);
2853
+ return e.magFilter = Ee, e.minFilter = Ee, e.generateMipmaps = !1, e.needsUpdate = !0, e;
2334
2854
  }
2335
- function Zn(r, e) {
2336
- const t = r.clone(), s = Qs("batchObjectIndex", "float").toInt(), n = $e(qs(Ke(e), $e(0)).x).toConst(), i = s.mod(n).toConst(), a = s.div(n).toConst(), o = Ke(e, Ys(i, a)), c = t.colorNode ?? xe, l = F(o.a.greaterThan(1.5), c.mul(o.rgb), o.rgb);
2337
- return t.colorNode = F(o.a.greaterThan(0.5), l, c), t.maskNode = o.a.greaterThan(-0.5), t.needsUpdate = !0, t;
2855
+ function Cr(i, e) {
2856
+ const t = i.clone(), s = mn("batchObjectIndex", "float").toInt(), n = nt(gn(rt(e), nt(0)).x).toConst(), r = s.mod(n).toConst(), a = s.div(n).toConst(), o = rt(e, yn(r, a)), c = t.colorNode ?? Ce, l = $(o.a.greaterThan(1.5), c.mul(o.rgb), o.rgb);
2857
+ return t.colorNode = $(o.a.greaterThan(0.5), l, c), t.maskNode = o.a.greaterThan(-0.5), t.needsUpdate = !0, t;
2338
2858
  }
2339
- function lt(r) {
2340
- let e = 0, t = r.parent;
2859
+ function St(i) {
2860
+ let e = 0, t = i.parent;
2341
2861
  for (; t; )
2342
2862
  e++, t = t.parent;
2343
2863
  return e;
2344
2864
  }
2345
- class ei extends q {
2865
+ class Ar extends X {
2346
2866
  objectIndices;
2347
2867
  states;
2348
- #t;
2868
+ #s;
2349
2869
  constructor(e, t, s, n) {
2350
2870
  super(e, t), this.objectIndices = s, this.states = n, this.userData.editableGeometryBatch = !0;
2351
2871
  }
2352
2872
  raycast(e, t) {
2353
2873
  if (this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0)
2354
2874
  return !1;
2355
- this.#t === void 0 && (this.#t = Et(this.geometry));
2875
+ this.#s === void 0 && (this.#s = jt(this.geometry));
2356
2876
  const s = [];
2357
- this.#t ? this.#t.raycastObject3D(this, e, s) : super.raycast(e, s), s.forEach((n) => {
2358
- const i = n.faceIndex;
2359
- if (i == null) return;
2360
- const a = i * 3, o = this.geometry.index?.getX(a) ?? a, c = this.objectIndices[o], l = c === void 0 ? void 0 : this.states[c], h = l?.instance;
2361
- !l || l.materialized || !h || !$t(h) || h.getInstanceOpacity() <= 1e-3 || (n.object = h, n.batchObjectIndex = c, t.push(n));
2877
+ this.#s ? this.#s.raycastObject3D(this, e, s) : super.raycast(e, s), s.forEach((n) => {
2878
+ const r = n.faceIndex;
2879
+ if (r == null) return;
2880
+ const a = r * 3, o = this.geometry.index?.getX(a) ?? a, c = this.objectIndices[o], l = c === void 0 ? void 0 : this.states[c], h = l?.instance;
2881
+ !l || l.materialized || !h || !as(h) || h.getInstanceOpacity() <= 1e-3 || (n.object = h, n.batchObjectIndex = c, t.push(n));
2362
2882
  });
2363
2883
  }
2364
2884
  }
2365
- class Gi extends ue {
2885
+ class bi extends pe {
2366
2886
  isEditableGeometryBatchLayer = !0;
2367
2887
  type = "EditableGeometryBatchLayer";
2368
2888
  options;
@@ -2376,16 +2896,16 @@ class Gi extends ue {
2376
2896
  unsupportedInstances: 0,
2377
2897
  unsupportedByReason: {}
2378
2898
  };
2379
- #t = [];
2380
- #a = /* @__PURE__ */ new Set();
2381
2899
  #s = [];
2900
+ #a = /* @__PURE__ */ new Set();
2901
+ #t = [];
2382
2902
  #e = /* @__PURE__ */ new Map();
2383
- #n = /* @__PURE__ */ new Set();
2384
- #i = null;
2385
- #o = new L();
2903
+ #r = /* @__PURE__ */ new Set();
2904
+ #n = null;
2905
+ #o = new R();
2386
2906
  #c = !1;
2387
2907
  #l = !1;
2388
- #h = !1;
2908
+ #d = !1;
2389
2909
  constructor(e = {}) {
2390
2910
  super(), this.name = "EditableGeometryBatches", this.options = {
2391
2911
  maxVerticesPerBatch: e.maxVerticesPerBatch ?? 15e5,
@@ -2396,228 +2916,228 @@ class Gi extends ue {
2396
2916
  addSource(e) {
2397
2917
  if (this.#l) throw new Error("EditableGeometryBatchLayer has been disposed.");
2398
2918
  if (this.#c) throw new Error("EditableGeometryBatchLayer has already been built.");
2399
- const { key: t, template: s, instances: n } = e, i = /* @__PURE__ */ new Set();
2919
+ const { key: t, template: s, instances: n } = e, r = /* @__PURE__ */ new Set();
2400
2920
  n.forEach((l) => {
2401
- if (i.has(l) || this.#a.has(l))
2921
+ if (r.has(l) || this.#a.has(l))
2402
2922
  throw new Error(
2403
2923
  "EditableGeometryBatchLayer cannot batch the same InstanceObject more than once."
2404
2924
  );
2405
- i.add(l);
2925
+ r.add(l);
2406
2926
  });
2407
- const { meshes: a, fallbackMeshes: o, fallbackReasons: c } = Qn(
2927
+ const { meshes: a, fallbackMeshes: o, fallbackReasons: c } = Mr(
2408
2928
  s,
2409
2929
  this.options.freezeAnimations
2410
2930
  );
2411
- return i.forEach((l) => this.#a.add(l)), this.#t.push({
2931
+ return r.forEach((l) => this.#a.add(l)), this.#s.push({
2412
2932
  key: t,
2413
2933
  template: s,
2414
2934
  instances: [...n],
2415
2935
  meshes: a,
2416
2936
  fallbackMeshes: o,
2417
2937
  fallbackReasons: c,
2418
- bounds: new $().setFromObject(s)
2938
+ bounds: new K().setFromObject(s)
2419
2939
  }), a.length > 0;
2420
2940
  }
2421
2941
  build() {
2422
2942
  if (this.#l) throw new Error("EditableGeometryBatchLayer has been disposed.");
2423
2943
  if (this.#c) throw new Error("EditableGeometryBatchLayer.build() can only be called once.");
2424
2944
  this.#c = !0, this.updateWorldMatrix(!0, !1), this.#o.copy(this.matrixWorld).invert();
2425
- const e = [], t = /* @__PURE__ */ new Map(), s = (i, a, o, c) => {
2945
+ const e = [], t = /* @__PURE__ */ new Map(), s = (r, a, o, c) => {
2426
2946
  if (o.length === 0) return;
2427
2947
  const l = c.size > 0 ? [...c] : ["unknown"];
2428
- e.push({ key: i.key, template: a, instances: o, reasons: l }), l.forEach((h) => {
2948
+ e.push({ key: r.key, template: a, instances: o, reasons: l }), l.forEach((h) => {
2429
2949
  this.stats.unsupportedByReason[h] = (this.stats.unsupportedByReason[h] ?? 0) + o.length;
2430
2950
  });
2431
2951
  };
2432
- this.#t.forEach((i) => {
2952
+ this.#s.forEach((r) => {
2433
2953
  const a = [], o = [];
2434
- i.instances.forEach((l) => {
2435
- l.updateWorldMatrix(!0, !1), ce.multiplyMatrices(this.#o, l.matrixWorld), ce.determinant() <= 0 ? o.push(l) : a.push({ instance: l, matrix: ce.clone() });
2954
+ r.instances.forEach((l) => {
2955
+ l.updateWorldMatrix(!0, !1), le.multiplyMatrices(this.#o, l.matrixWorld), le.determinant() <= 0 ? o.push(l) : a.push({ instance: l, matrix: le.clone() });
2436
2956
  });
2437
- const c = i.fallbackReasons.size > 0 ? i.fallbackReasons : /* @__PURE__ */ new Set(["unknown"]);
2438
- if (i.meshes.length === 0) {
2957
+ const c = r.fallbackReasons.size > 0 ? r.fallbackReasons : /* @__PURE__ */ new Set(["unknown"]);
2958
+ if (r.meshes.length === 0) {
2439
2959
  s(
2440
- i,
2441
- i.template,
2960
+ r,
2961
+ r.template,
2442
2962
  a.map(({ instance: l }) => l),
2443
2963
  c
2444
2964
  ), s(
2445
- i,
2446
- i.template,
2965
+ r,
2966
+ r.template,
2447
2967
  o,
2448
2968
  /* @__PURE__ */ new Set([...c, "negative-scale"])
2449
2969
  );
2450
2970
  return;
2451
2971
  }
2452
- i.fallbackMeshes.size > 0 && s(
2453
- i,
2454
- qn(
2455
- i.template,
2456
- new Set(i.meshes.map(({ mesh: l }) => l))
2972
+ r.fallbackMeshes.size > 0 && s(
2973
+ r,
2974
+ vr(
2975
+ r.template,
2976
+ new Set(r.meshes.map(({ mesh: l }) => l))
2457
2977
  ),
2458
2978
  a.map(({ instance: l }) => l),
2459
2979
  c
2460
2980
  ), s(
2461
- i,
2462
- i.template,
2981
+ r,
2982
+ r.template,
2463
2983
  o,
2464
- /* @__PURE__ */ new Set([...i.fallbackReasons, "negative-scale"])
2984
+ /* @__PURE__ */ new Set([...r.fallbackReasons, "negative-scale"])
2465
2985
  ), a.forEach(({ instance: l, matrix: h }) => {
2466
- const u = this.#s.length, d = () => this.materialize(l), p = {
2986
+ const d = this.#t.length, u = () => this.materialize(l), p = {
2467
2987
  instance: l,
2468
- template: i.template,
2988
+ template: r.template,
2469
2989
  initialMatrix: h,
2470
- objectIndex: u,
2990
+ objectIndex: d,
2471
2991
  materialized: !1,
2472
- materializer: d,
2992
+ materializer: u,
2473
2993
  unsubscribe: () => {
2474
2994
  }
2475
2995
  };
2476
- p.unsubscribe = l.onInstanceRenderDirty(() => this.#p(p)), this.#s.push(p), this.#e.set(l, p), l.setInstanceBounds(i.bounds), l.setInstanceMaterializer(d), this.#n.add(p), i.meshes.forEach(({ mesh: m, localMatrix: b, materialKey: S, geometryKey: w }) => {
2477
- ct.multiplyMatrices(h, b);
2478
- const g = m.geometry.clone().applyMatrix4(ct), I = g.getAttribute("position");
2479
- g.setAttribute(
2996
+ p.unsubscribe = l.onInstanceRenderDirty(() => this.#h(p)), this.#t.push(p), this.#e.set(l, p), l.setInstanceBounds(r.bounds), l.setInstanceMaterializer(u), this.#r.add(p), r.meshes.forEach(({ mesh: x, localMatrix: I, materialKey: _, geometryKey: C }) => {
2997
+ vt.multiplyMatrices(h, I);
2998
+ const y = x.geometry.clone().applyMatrix4(vt), w = y.getAttribute("position");
2999
+ y.setAttribute(
2480
3000
  "batchObjectIndex",
2481
- new As(new Float32Array(I.count).fill(u), 1)
3001
+ new Qs(new Float32Array(w.count).fill(d), 1)
2482
3002
  );
2483
- const B = JSON.stringify([
2484
- S,
2485
- w,
2486
- m.castShadow,
2487
- m.receiveShadow,
2488
- m.renderOrder
2489
- ]), O = t.get(B), T = {
2490
- geometry: g,
2491
- material: m.material,
2492
- castShadow: m.castShadow,
2493
- receiveShadow: m.receiveShadow,
2494
- renderOrder: m.renderOrder,
2495
- objectIndices: new Array(I.count).fill(u)
3003
+ const g = JSON.stringify([
3004
+ _,
3005
+ C,
3006
+ x.castShadow,
3007
+ x.receiveShadow,
3008
+ x.renderOrder
3009
+ ]), m = t.get(g), M = {
3010
+ geometry: y,
3011
+ material: x.material,
3012
+ castShadow: x.castShadow,
3013
+ receiveShadow: x.receiveShadow,
3014
+ renderOrder: x.renderOrder,
3015
+ objectIndices: new Array(w.count).fill(d)
2496
3016
  };
2497
- O ? O.push(T) : t.set(B, [T]), this.stats.sourceMeshes++, this.stats.vertices += I.count, this.stats.indices += g.index?.count ?? I.count;
3017
+ m ? m.push(M) : t.set(g, [M]), this.stats.sourceMeshes++, this.stats.vertices += w.count, this.stats.indices += y.index?.count ?? w.count;
2498
3018
  });
2499
3019
  });
2500
- }), this.stats.instances = this.#s.length, this.stats.unsupportedInstances = e.reduce((i, a) => i + a.instances.length, 0);
2501
- const n = Vn(this.#s.length);
2502
- return this.#i = Jn(n), this.#r(), t.forEach((i) => this.#d(i)), this.stats.batches = this.children.length, this.stats.drawCallsSaved = Math.max(0, this.stats.sourceMeshes - this.stats.batches), this.children.forEach((i) => {
2503
- i instanceof P && (i.onBeforeRender = () => this.#r());
3020
+ }), this.stats.instances = this.#t.length, this.stats.unsupportedInstances = e.reduce((r, a) => r + a.instances.length, 0);
3021
+ const n = Ir(this.#t.length);
3022
+ return this.#n = Er(n), this.#i(), t.forEach((r) => this.#u(r)), this.stats.batches = this.children.length, this.stats.drawCallsSaved = Math.max(0, this.stats.sourceMeshes - this.stats.batches), this.children.forEach((r) => {
3023
+ r instanceof k && (r.onBeforeRender = () => this.#i());
2504
3024
  }), { stats: { ...this.stats }, unsupported: e };
2505
3025
  }
2506
3026
  materialize(e) {
2507
3027
  const t = this.#e.get(e);
2508
3028
  if (!t || t.materialized) return e.getInstanceRenderObject();
2509
- const s = Yn(t.template);
2510
- return s.position.set(0, 0, 0), s.quaternion.identity(), s.scale.set(1, 1, 1), s.matrix.identity(), t.materialized = !0, e.setInstanceRenderObject(s), s.updateWorldMatrix(!0, !0), this.#n.add(t), this.dispatchEvent({ type: "materialize", instance: e, object: s }), s;
3029
+ const s = Sr(t.template);
3030
+ return s.position.set(0, 0, 0), s.quaternion.identity(), s.scale.set(1, 1, 1), s.matrix.identity(), t.materialized = !0, e.setInstanceRenderObject(s), s.updateWorldMatrix(!0, !0), this.#r.add(t), this.dispatchEvent({ type: "materialize", instance: e, object: s }), s;
2511
3031
  }
2512
- #d(e) {
3032
+ #u(e) {
2513
3033
  const t = [];
2514
- let s = [], n = 0, i = 0;
3034
+ let s = [], n = 0, r = 0;
2515
3035
  e.forEach((a) => {
2516
3036
  const o = a.geometry.getAttribute("position").count, c = a.geometry.index?.count ?? o;
2517
- s.length > 0 && (n + o > this.options.maxVerticesPerBatch || i + c > this.options.maxIndicesPerBatch) && (t.push(s), s = [], n = 0, i = 0), s.push(a), n += o, i += c;
3037
+ s.length > 0 && (n + o > this.options.maxVerticesPerBatch || r + c > this.options.maxIndicesPerBatch) && (t.push(s), s = [], n = 0, r = 0), s.push(a), n += o, r += c;
2518
3038
  }), s.length > 0 && t.push(s), t.forEach((a) => {
2519
- const o = en(a.map((d) => d.geometry), !1);
2520
- if (a.forEach((d) => d.geometry.dispose()), !o || !this.#i) return;
3039
+ const o = Mn(a.map((u) => u.geometry), !1);
3040
+ if (a.forEach((u) => u.geometry.dispose()), !o || !this.#n) return;
2521
3041
  o.computeBoundingBox(), o.computeBoundingSphere();
2522
- const c = a[0], l = a.flatMap((d) => d.objectIndices), h = Zn(c.material, this.#i), u = new ei(
3042
+ const c = a[0], l = a.flatMap((u) => u.objectIndices), h = Cr(c.material, this.#n), d = new Ar(
2523
3043
  o,
2524
3044
  h,
2525
3045
  l,
2526
- this.#s
3046
+ this.#t
2527
3047
  );
2528
- u.name = `EditableGeometryBatch:${this.children.length}`, u.castShadow = c.castShadow, u.receiveShadow = c.receiveShadow, u.renderOrder = c.renderOrder, u.matrixAutoUpdate = !1, this.add(u);
3048
+ d.name = `EditableGeometryBatch:${this.children.length}`, d.castShadow = c.castShadow, d.receiveShadow = c.receiveShadow, d.renderOrder = c.renderOrder, d.matrixAutoUpdate = !1, this.add(d);
2529
3049
  });
2530
3050
  }
2531
- #r() {
2532
- if (!(!this.#i || this.#n.size === 0 || this.#h)) {
2533
- this.#h = !0;
3051
+ #i() {
3052
+ if (!(!this.#n || this.#r.size === 0 || this.#d)) {
3053
+ this.#d = !0;
2534
3054
  try {
2535
3055
  this.updateWorldMatrix(!0, !1), this.#o.copy(this.matrixWorld).invert();
2536
- const e = this.#i.image.data;
2537
- [...this.#n].sort((t, s) => lt(t.instance) - lt(s.instance)).forEach((t) => {
3056
+ const e = this.#n.image.data;
3057
+ [...this.#r].sort((t, s) => St(t.instance) - St(s.instance)).forEach((t) => {
2538
3058
  const { instance: s, objectIndex: n } = t;
2539
- s.updateWorldMatrix(!0, !1), ce.multiplyMatrices(this.#o, s.matrixWorld), !t.materialized && s.getInstanceRenderObject() !== null && !s.hasInstanceMaterializer(t.materializer) && (t.materialized = !0), !t.materialized && !Fn(ce, t.initialMatrix) && this.materialize(s), !t.materialized && s.getInstanceOpacity() < 0.999 && this.materialize(s);
2540
- const i = n * 4, a = !t.materialized && $t(s) && s.getInstanceOpacity() > 1e-3, o = s.getInstanceColor();
2541
- e[i] = o.r, e[i + 1] = o.g, e[i + 2] = o.b, e[i + 3] = a ? s.getInstanceColorMode() : -1, this.#n.delete(t);
2542
- }), this.#i.needsUpdate = !0;
3059
+ s.updateWorldMatrix(!0, !1), le.multiplyMatrices(this.#o, s.matrixWorld), !t.materialized && s.getInstanceRenderObject() !== null && !s.hasInstanceMaterializer(t.materializer) && (t.materialized = !0), !t.materialized && !gr(le, t.initialMatrix) && this.materialize(s), !t.materialized && s.getInstanceOpacity() < 0.999 && this.materialize(s);
3060
+ const r = n * 4, a = !t.materialized && as(s) && s.getInstanceOpacity() > 1e-3, o = s.getInstanceColor();
3061
+ e[r] = o.r, e[r + 1] = o.g, e[r + 2] = o.b, e[r + 3] = a ? s.getInstanceColorMode() : -1, this.#r.delete(t);
3062
+ }), this.#n.needsUpdate = !0;
2543
3063
  } finally {
2544
- this.#h = !1;
3064
+ this.#d = !1;
2545
3065
  }
2546
- this.#n.size > 0 && this.#r();
3066
+ this.#r.size > 0 && this.#i();
2547
3067
  }
2548
3068
  }
2549
- #p(e) {
2550
- this.#n.add(e), this.#r();
3069
+ #h(e) {
3070
+ this.#r.add(e), this.#i();
2551
3071
  }
2552
3072
  dispose() {
2553
- this.#l || (this.#l = !0, this.#s.forEach((e) => {
3073
+ this.#l || (this.#l = !0, this.#t.forEach((e) => {
2554
3074
  e.unsubscribe(), e.instance.clearInstanceMaterializer(e.materializer);
2555
- }), this.#s.length = 0, this.#e.clear(), this.#a.clear(), this.#n.clear(), this.#t.length = 0, this.#i?.dispose(), this.#i = null, this.traverse((e) => {
2556
- if (!(e instanceof P)) return;
3075
+ }), this.#t.length = 0, this.#e.clear(), this.#a.clear(), this.#r.clear(), this.#s.length = 0, this.#n?.dispose(), this.#n = null, this.traverse((e) => {
3076
+ if (!(e instanceof k)) return;
2557
3077
  e.geometry.dispose(), (Array.isArray(e.material) ? e.material : [e.material]).forEach((s) => s.dispose());
2558
3078
  }), this.clear());
2559
3079
  }
2560
3080
  }
2561
- const ht = new L(), de = new L(), ut = new L(), dt = new L(), pt = new $(), mt = new ne(), ft = new ne(), ti = new Ds(), ee = new A(), gt = new z(), yt = new C(), bt = new L(), wt = new L(), xt = new ne(), pe = [], Kt = 1e-6, W = 1e-6, Xt = 0.999, si = 0, Mt = 1;
2562
- function ni(r, e, t) {
2563
- const s = r.elements;
3081
+ const It = new R(), me = new R(), Et = new R(), Ct = new R(), At = new K(), Ot = new ne(), Bt = new ne(), Or = new sn(), Z = new P(), _t = new j(), Tt = new D(), Lt = new R(), Nt = new R(), Dt = new ne(), ge = [], os = 1e-6, H = 1e-6, cs = 0.999, Br = 0, Pt = 1;
3082
+ function _r(i, e, t) {
3083
+ const s = i.elements;
2564
3084
  for (let n = 0; n < 16; n++)
2565
- if (Math.abs(s[n] - e[t + n]) > Kt) return !1;
3085
+ if (Math.abs(s[n] - e[t + n]) > os) return !1;
2566
3086
  return !0;
2567
3087
  }
2568
- function ii(r, e, t, s) {
2569
- return Math.abs(r.r - t[s]) <= W && Math.abs(r.g - t[s + 1]) <= W && Math.abs(r.b - t[s + 2]) <= W && Math.abs(e - t[s + 3]) <= W;
3088
+ function Tr(i, e, t, s) {
3089
+ return Math.abs(i.r - t[s]) <= H && Math.abs(i.g - t[s + 1]) <= H && Math.abs(i.b - t[s + 2]) <= H && Math.abs(e - t[s + 3]) <= H;
2570
3090
  }
2571
- function It(r, e) {
2572
- const t = r.elements, s = e.elements;
3091
+ function Rt(i, e) {
3092
+ const t = i.elements, s = e.elements;
2573
3093
  for (let n = 0; n < 16; n++)
2574
- if (Math.abs(t[n] - s[n]) > Kt) return !1;
3094
+ if (Math.abs(t[n] - s[n]) > os) return !1;
2575
3095
  return !0;
2576
3096
  }
2577
- function _e(r) {
2578
- let e = r;
3097
+ function De(i) {
3098
+ let e = i;
2579
3099
  for (; e; ) {
2580
3100
  if (!e.visible) return !1;
2581
3101
  e = e.parent;
2582
3102
  }
2583
3103
  return !0;
2584
3104
  }
2585
- function ri(r) {
2586
- const e = r.geometry.morphAttributes;
3105
+ function Lr(i) {
3106
+ const e = i.geometry.morphAttributes;
2587
3107
  return Object.values(e).some((t) => t?.length);
2588
3108
  }
2589
- function ai(r) {
2590
- const e = r.material;
3109
+ function Nr(i) {
3110
+ const e = i.material;
2591
3111
  if (!Array.isArray(e)) return !0;
2592
3112
  if (e.length === 0 || !e.every(Boolean)) return !1;
2593
- const t = r.geometry.groups;
3113
+ const t = i.geometry.groups;
2594
3114
  return t.length === 0 ? !1 : t.every((s) => {
2595
3115
  const n = s.materialIndex ?? 0;
2596
3116
  return Number.isInteger(s.start) && s.start >= 0 && Number.isInteger(s.count) && s.count > 0 && Number.isInteger(n) && n >= 0 && n < e.length;
2597
3117
  });
2598
3118
  }
2599
- function oi(r) {
2600
- return !r.isSkinnedMesh && !ri(r) && ai(r);
3119
+ function Dr(i) {
3120
+ return !i.isSkinnedMesh && !Lr(i) && Nr(i);
2601
3121
  }
2602
- function St(r) {
2603
- return Array.isArray(r) ? r : [r];
3122
+ function kt(i) {
3123
+ return Array.isArray(i) ? i : [i];
2604
3124
  }
2605
- function Qt(r) {
2606
- return r.transparent || r.opacity < Xt;
3125
+ function ls(i) {
3126
+ return i.transparent || i.opacity < cs;
2607
3127
  }
2608
- function vt(r, e, t) {
2609
- const s = r.clone(), n = Xe(e, "vec4", 4, 0), i = Xe(t, "float", 1, 0), a = s.colorNode ?? xe, o = s.opacityNode ? Vs(s.opacityNode) : Oe, c = F(n.a.greaterThan(1.5), a.mul(n.rgb), n.rgb);
2610
- return s.colorNode = F(n.a.greaterThan(0.5), c, a), s.opacityNode = o.mul(i), s.transparent = Qt(r), s.needsUpdate = !0, s;
3128
+ function zt(i, e, t) {
3129
+ const s = i.clone(), n = it(e, "vec4", 4, 0), r = it(t, "float", 1, 0), a = s.colorNode ?? Ce, o = s.opacityNode ? bn(s.opacityNode) : ze, c = $(n.a.greaterThan(1.5), a.mul(n.rgb), n.rgb);
3130
+ return s.colorNode = $(n.a.greaterThan(0.5), c, a), s.opacityNode = o.mul(r), s.transparent = ls(i), s.needsUpdate = !0, s;
2611
3131
  }
2612
- function ci(r, e, t) {
2613
- return Array.isArray(r) ? r.map((s) => vt(s, e, t)) : vt(r, e, t);
3132
+ function Pr(i, e, t) {
3133
+ return Array.isArray(i) ? i.map((s) => zt(s, e, t)) : zt(i, e, t);
2614
3134
  }
2615
- function li(r) {
2616
- const e = [], t = new L();
3135
+ function Rr(i) {
3136
+ const e = [], t = new R();
2617
3137
  let s = !1;
2618
- return r.updateWorldMatrix(!0, !0), t.copy(r.matrixWorld).invert(), r.traverse((n) => {
2619
- if (!s && !(!(n instanceof P) || !n.visible)) {
2620
- if (!oi(n)) {
3138
+ return i.updateWorldMatrix(!0, !0), t.copy(i.matrixWorld).invert(), i.traverse((n) => {
3139
+ if (!s && !(!(n instanceof k) || !n.visible)) {
3140
+ if (!Dr(n)) {
2621
3141
  s = !0;
2622
3142
  return;
2623
3143
  }
@@ -2628,48 +3148,48 @@ function li(r) {
2628
3148
  }
2629
3149
  }), s ? [] : e;
2630
3150
  }
2631
- function hi(r) {
2632
- const e = new $();
2633
- return r.forEach(({ mesh: t, localMatrix: s }) => {
3151
+ function kr(i) {
3152
+ const e = new K();
3153
+ return i.forEach(({ mesh: t, localMatrix: s }) => {
2634
3154
  const n = t.geometry;
2635
- n.boundingBox || n.computeBoundingBox(), n.boundingBox && (pt.copy(n.boundingBox).applyMatrix4(s), e.union(pt));
3155
+ n.boundingBox || n.computeBoundingBox(), n.boundingBox && (At.copy(n.boundingBox).applyMatrix4(s), e.union(At));
2636
3156
  }), e;
2637
3157
  }
2638
- function te(r) {
2639
- const e = r;
3158
+ function ee(i) {
3159
+ const e = i;
2640
3160
  "needsUpdate" in e && (e.needsUpdate = !0);
2641
3161
  }
2642
- function Bt(r, e = Mt) {
2643
- let t = Math.max(Mt, e);
2644
- for (; t < r; )
3162
+ function Ut(i, e = Pt) {
3163
+ let t = Math.max(Pt, e);
3164
+ for (; t < i; )
2645
3165
  t *= 2;
2646
3166
  return t;
2647
3167
  }
2648
- function ui(r) {
2649
- return r !== null && typeof r == "object" && Symbol.iterator in r;
3168
+ function zr(i) {
3169
+ return i !== null && typeof i == "object" && Symbol.iterator in i;
2650
3170
  }
2651
- class $i extends ue {
3171
+ class wi extends pe {
2652
3172
  isModelInstancedLayer = !0;
2653
3173
  type = "ModelInstancedLayer";
2654
- #t = [];
3174
+ #s = [];
2655
3175
  #a = /* @__PURE__ */ new Map();
2656
- #s = /* @__PURE__ */ new Map();
3176
+ #t = /* @__PURE__ */ new Map();
2657
3177
  #e = /* @__PURE__ */ new Map();
2658
- #n = !0;
2659
- #i = !1;
3178
+ #r = !0;
3179
+ #n = !1;
2660
3180
  #o = !0;
2661
- #c = si;
3181
+ #c = Br;
2662
3182
  #l;
2663
- #h;
3183
+ #d;
2664
3184
  constructor(e = {}) {
2665
- super(), this.name = e.name ?? "ModelInstances", this.#l = e.instanceKind ?? "", this.#h = e.getHitUserData ?? (() => ({}));
3185
+ super(), this.name = e.name ?? "ModelInstances", this.#l = e.instanceKind ?? "", this.#d = e.getHitUserData ?? (() => ({}));
2666
3186
  }
2667
3187
  get instanceKind() {
2668
3188
  return this.#l;
2669
3189
  }
2670
3190
  getInstances() {
2671
3191
  const e = [];
2672
- return this.#r((t) => e.push(t)), e;
3192
+ return this.#i((t) => e.push(t)), e;
2673
3193
  }
2674
3194
  getInstanceById(e) {
2675
3195
  return this.#w(), this.#e.get(e);
@@ -2679,124 +3199,124 @@ class $i extends ue {
2679
3199
  }
2680
3200
  getInstanceCulling() {
2681
3201
  return {
2682
- enabled: this.#i,
3202
+ enabled: this.#n,
2683
3203
  frustum: this.#o,
2684
3204
  minScreenRadius: this.#c
2685
3205
  };
2686
3206
  }
2687
3207
  setInstanceCulling(e = {}) {
2688
3208
  let t = !1;
2689
- if (e.enabled !== void 0 && this.#i !== e.enabled && (this.#i = e.enabled, t = !0), e.frustum !== void 0 && this.#o !== e.frustum && (this.#o = e.frustum, t = !0), e.minScreenRadius !== void 0) {
3209
+ if (e.enabled !== void 0 && this.#n !== e.enabled && (this.#n = e.enabled, t = !0), e.frustum !== void 0 && this.#o !== e.frustum && (this.#o = e.frustum, t = !0), e.minScreenRadius !== void 0) {
2690
3210
  const s = Math.max(0, e.minScreenRadius);
2691
- Math.abs(this.#c - s) > W && (this.#c = s, t = !0);
3211
+ Math.abs(this.#c - s) > H && (this.#c = s, t = !0);
2692
3212
  }
2693
- return t && this.#t.forEach((s) => this.#v(s)), this;
3213
+ return t && this.#s.forEach((s) => this.#I(s)), this;
2694
3214
  }
2695
3215
  setInstanceVisible(e) {
2696
- return this.visible !== e && (this.visible = e), this.#r((t) => {
3216
+ return this.visible !== e && (this.visible = e), this.#i((t) => {
2697
3217
  t.setInstanceVisible(e);
2698
3218
  }), this;
2699
3219
  }
2700
3220
  setInstanceColor(e) {
2701
- return this.#r((t) => {
3221
+ return this.#i((t) => {
2702
3222
  t.setInstanceColor(e);
2703
3223
  }), this;
2704
3224
  }
2705
3225
  resetInstanceColor() {
2706
- return this.#r((e) => {
3226
+ return this.#i((e) => {
2707
3227
  e.resetInstanceColor();
2708
3228
  }), this;
2709
3229
  }
2710
3230
  setInstanceOpacity(e) {
2711
- return this.#r((t) => {
3231
+ return this.#i((t) => {
2712
3232
  t.setInstanceOpacity(e);
2713
3233
  }), this;
2714
3234
  }
2715
3235
  setInstanceHighlight(e, t, s = !1) {
2716
- return this.#r((n) => {
3236
+ return this.#i((n) => {
2717
3237
  n.setInstanceHighlight(e, t, s);
2718
3238
  }), this;
2719
3239
  }
2720
3240
  clearInstanceHighlight() {
2721
- return this.#r((e) => {
3241
+ return this.#i((e) => {
2722
3242
  e.clearInstanceHighlight();
2723
3243
  }), this;
2724
3244
  }
2725
3245
  reserveBatch(e, t, s) {
2726
3246
  const n = Math.floor(s);
2727
- return n <= 0 ? !1 : this.#d(e, t, n) !== null;
3247
+ return n <= 0 ? !1 : this.#u(e, t, n) !== null;
2728
3248
  }
2729
3249
  addInstance(e, t, s) {
2730
3250
  return this.addInstances(e, t, [s]);
2731
3251
  }
2732
3252
  addInstances(e, t, s) {
2733
3253
  if (s.length === 0) return !1;
2734
- const n = this.#a.has(e), i = this.#d(e, t, s.length);
2735
- if (!i) return !1;
3254
+ const n = this.#a.has(e), r = this.#u(e, t, s.length);
3255
+ if (!r) return !1;
2736
3256
  const a = [], o = /* @__PURE__ */ new Set();
2737
3257
  return s.forEach((c) => {
2738
- o.has(c) || (o.add(c), this.#s.get(c) === i) || a.push(c);
2739
- }), a.length === 0 ? !0 : this.#E(a) ? (a.forEach((c) => {
2740
- const l = this.#s.get(c);
2741
- l && l !== i && this.#I(l, c);
2742
- }), this.#M(i, i.instances.length + a.length), a.forEach((c) => {
2743
- c.setInstanceBounds(i.templateBounds), i.instances.push(c), this.#s.set(c, i), i.unsubscribeByInstance.set(
3258
+ o.has(c) || (o.add(c), this.#t.get(c) === r) || a.push(c);
3259
+ }), a.length === 0 ? !0 : this.#C(a) ? (a.forEach((c) => {
3260
+ const l = this.#t.get(c);
3261
+ l && l !== r && this.#v(l, c);
3262
+ }), this.#M(r, r.instances.length + a.length), a.forEach((c) => {
3263
+ c.setInstanceBounds(r.templateBounds), r.instances.push(c), this.#t.set(c, r), r.unsubscribeByInstance.set(
2744
3264
  c,
2745
3265
  c.onInstanceRenderDirty(() => {
2746
- this.#g(), this.#y(i);
3266
+ this.#g(), this.#y(r);
2747
3267
  })
2748
3268
  );
2749
- }), this.#g(), this.#b(i), this.#y(i), !0) : (!n && i.instances.length === 0 && this.#f(i), !1);
3269
+ }), this.#g(), this.#b(r), this.#y(r), !0) : (!n && r.instances.length === 0 && this.#m(r), !1);
2750
3270
  }
2751
3271
  removeInstance(e) {
2752
3272
  return this.removeInstances([e]) > 0;
2753
3273
  }
2754
3274
  removeInstances(e) {
2755
- const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), n = typeof e == "string" || !ui(e) ? [e] : e;
3275
+ const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), n = typeof e == "string" || !zr(e) ? [e] : e;
2756
3276
  for (const a of n)
2757
- typeof a == "string" ? t.add(a) : this.#s.has(a) && s.add(a);
3277
+ typeof a == "string" ? t.add(a) : this.#t.has(a) && s.add(a);
2758
3278
  t.size > 0 && (this.#w(), t.forEach((a) => {
2759
3279
  const o = this.#e.get(a);
2760
3280
  o && s.add(o);
2761
3281
  }));
2762
- let i = 0;
3282
+ let r = 0;
2763
3283
  return s.forEach((a) => {
2764
- const o = this.#s.get(a);
2765
- o && this.#I(o, a) && i++;
2766
- }), i;
3284
+ const o = this.#t.get(a);
3285
+ o && this.#v(o, a) && r++;
3286
+ }), r;
2767
3287
  }
2768
3288
  removeBatch(e) {
2769
3289
  const t = this.#a.get(e);
2770
- return t ? (this.#f(t), !0) : !1;
3290
+ return t ? (this.#m(t), !0) : !1;
2771
3291
  }
2772
3292
  clearBatches() {
2773
- return [...this.#a.values()].forEach((e) => this.#f(e)), this;
3293
+ return [...this.#a.values()].forEach((e) => this.#m(e)), this;
2774
3294
  }
2775
- #d(e, t, s) {
3295
+ #u(e, t, s) {
2776
3296
  const n = this.#a.get(e);
2777
3297
  if (n)
2778
3298
  return this.#M(n, s), n;
2779
3299
  if (t.animations?.length) return null;
2780
- const i = li(t);
2781
- if (i.length === 0) return null;
2782
- const a = hi(i), o = new H();
3300
+ const r = Rr(t);
3301
+ if (r.length === 0) return null;
3302
+ const a = kr(r), o = new W();
2783
3303
  o.name = e, this.add(o);
2784
3304
  const c = {
2785
3305
  url: e,
2786
3306
  batch: o,
2787
- templateMeshes: i,
3307
+ templateMeshes: r,
2788
3308
  templateBounds: a,
2789
3309
  records: [],
2790
3310
  instances: [],
2791
3311
  unsubscribeByInstance: /* @__PURE__ */ new Map(),
2792
- capacity: Bt(s)
3312
+ capacity: Ut(s)
2793
3313
  };
2794
- return i.forEach(({ mesh: l, localMatrix: h }, u) => {
2795
- const d = this.#p(c, l, h, u);
2796
- c.records.push(d), this.#t.push(d);
3314
+ return r.forEach(({ mesh: l, localMatrix: h }, d) => {
3315
+ const u = this.#h(c, l, h, d);
3316
+ c.records.push(u), this.#s.push(u);
2797
3317
  }), this.#a.set(e, c), this.#b(c), c;
2798
3318
  }
2799
- #r(e) {
3319
+ #i(e) {
2800
3320
  const t = /* @__PURE__ */ new Set();
2801
3321
  this.#a.forEach((s) => {
2802
3322
  s.instances.forEach((n) => {
@@ -2804,91 +3324,91 @@ class $i extends ue {
2804
3324
  });
2805
3325
  });
2806
3326
  }
2807
- #p(e, t, s, n) {
2808
- const i = new We(new Float32Array(e.capacity * 4), 4), a = new We(new Float32Array(e.capacity).fill(1), 1);
2809
- i.setUsage(Be), a.setUsage(Be);
2810
- const o = ci(
3327
+ #h(e, t, s, n) {
3328
+ const r = new Je(new Float32Array(e.capacity * 4), 4), a = new Je(new Float32Array(e.capacity).fill(1), 1);
3329
+ r.setUsage(Te), a.setUsage(Te);
3330
+ const o = Pr(
2811
3331
  t.material,
2812
- i,
3332
+ r,
2813
3333
  a
2814
- ), c = St(o), l = St(t.material).some(
2815
- Qt
2816
- ), h = new Rs(t.geometry, o, e.capacity);
2817
- h.instanceMatrix = new js(e.capacity, 16), h.count = 0, h.name = t.name || `${e.url}#${n}`, h.castShadow = t.castShadow, h.receiveShadow = t.receiveShadow, h.frustumCulled = !0, h.matrixAutoUpdate = !1, h.instanceMatrix.setUsage(Be), h.userData.url = e.url;
2818
- const u = new P(t.geometry, o);
2819
- u.matrixAutoUpdate = !1;
2820
- const d = {
3334
+ ), c = kt(o), l = kt(t.material).some(
3335
+ ls
3336
+ ), h = new nn(t.geometry, o, e.capacity);
3337
+ h.instanceMatrix = new rn(e.capacity, 16), h.count = 0, h.name = t.name || `${e.url}#${n}`, h.castShadow = t.castShadow, h.receiveShadow = t.receiveShadow, h.frustumCulled = !0, h.matrixAutoUpdate = !1, h.instanceMatrix.setUsage(Te), h.userData.url = e.url;
3338
+ const d = new k(t.geometry, o);
3339
+ d.matrixAutoUpdate = !1;
3340
+ const u = {
2821
3341
  batchRecord: e,
2822
3342
  mesh: h,
2823
3343
  boundsTree: void 0,
2824
- raycastMesh: u,
3344
+ raycastMesh: d,
2825
3345
  localMatrix: s.clone(),
2826
3346
  fullBoundingSphere: new ne(),
2827
3347
  materials: c,
2828
3348
  hasSourceTransparency: l,
2829
- colorAttribute: i,
3349
+ colorAttribute: r,
2830
3350
  opacityAttribute: a,
2831
3351
  renderedInstances: [],
2832
3352
  visibleInstances: [],
2833
- lastCameraMatrixWorldInverse: new L(),
2834
- lastCameraProjectionMatrix: new L(),
3353
+ lastCameraMatrixWorldInverse: new R(),
3354
+ lastCameraProjectionMatrix: new R(),
2835
3355
  lastViewportHeight: 0,
2836
3356
  hasLastCameraState: !1,
2837
3357
  dirty: !0
2838
3358
  };
2839
- h.userData.getInstanceObjectByRenderIndex = (m) => d.renderedInstances[m], h.userData.raycastAcceleration = "lazy";
3359
+ h.userData.getInstanceObjectByRenderIndex = (x) => u.renderedInstances[x], h.userData.raycastAcceleration = "lazy";
2840
3360
  const p = h.raycast.bind(h);
2841
- return h.raycast = (m, b) => {
2842
- if (this.#B(d), !this.#m(d, m)) return;
2843
- d.boundsTree === void 0 && (d.boundsTree = Et(d.mesh.geometry), d.mesh.userData.raycastAcceleration = d.boundsTree ? "three-mesh-bvh" : "default");
2844
- const S = b.length;
2845
- d.boundsTree ? this.#u(d, m, b) : p(m, b);
2846
- for (let w = S; w < b.length; ) {
2847
- const g = b[w], I = g.instanceId;
2848
- if (I === void 0) {
2849
- w++;
3361
+ return h.raycast = (x, I) => {
3362
+ if (this.#E(u), !this.#p(u, x)) return;
3363
+ u.boundsTree === void 0 && (u.boundsTree = jt(u.mesh.geometry), u.mesh.userData.raycastAcceleration = u.boundsTree ? "three-mesh-bvh" : "default");
3364
+ const _ = I.length;
3365
+ u.boundsTree ? this.#f(u, x, I) : p(x, I);
3366
+ for (let C = _; C < I.length; ) {
3367
+ const y = I[C], w = y.instanceId;
3368
+ if (w === void 0) {
3369
+ C++;
2850
3370
  continue;
2851
3371
  }
2852
- const B = d.renderedInstances[I];
2853
- if (!B || !_e(B)) {
2854
- b.splice(w, 1);
3372
+ const g = u.renderedInstances[w];
3373
+ if (!g || !De(g)) {
3374
+ I.splice(C, 1);
2855
3375
  continue;
2856
3376
  }
2857
- g.object = B, g.instanceObject = B, g.instanceObjectId = B.instanceId, g.instanceKind = B.instanceKind || this.#l, g.instanceName = B.instanceName, g.instanceIndex = I, Object.assign(g, this.#h(B, I)), w++;
3377
+ y.object = g, y.instanceObject = g, y.instanceObjectId = g.instanceId, y.instanceKind = g.instanceKind || this.#l, y.instanceName = g.instanceName, y.instanceIndex = w, Object.assign(y, this.#d(g, w)), C++;
2858
3378
  }
2859
- }, h.onBeforeRender = (m, b, S) => this.#B(d, m, S), e.batch.add(h), d;
3379
+ }, h.onBeforeRender = (x, I, _) => this.#E(u, x, _), e.batch.add(h), u;
2860
3380
  }
2861
- #m(e, t) {
3381
+ #p(e, t) {
2862
3382
  const { mesh: s } = e;
2863
- return s.count === 0 ? !1 : (s.boundingSphere === null && s.computeBoundingSphere(), s.boundingSphere ? (xt.copy(s.boundingSphere).applyMatrix4(s.matrixWorld), t.ray.intersectsSphere(xt)) : !0);
3383
+ return s.count === 0 ? !1 : (s.boundingSphere === null && s.computeBoundingSphere(), s.boundingSphere ? (Dt.copy(s.boundingSphere).applyMatrix4(s.matrixWorld), t.ray.intersectsSphere(Dt)) : !0);
2864
3384
  }
2865
- #u(e, t, s) {
2866
- const { mesh: n, boundsTree: i, raycastMesh: a } = e;
2867
- if (!(!i || n.count === 0)) {
3385
+ #f(e, t, s) {
3386
+ const { mesh: n, boundsTree: r, raycastMesh: a } = e;
3387
+ if (!(!r || n.count === 0)) {
2868
3388
  a.geometry = n.geometry, a.material = n.material;
2869
3389
  for (let o = 0; o < n.count; o++)
2870
- n.getMatrixAt(o, bt), wt.multiplyMatrices(n.matrixWorld, bt), a.matrixWorld.copy(wt), pe.length = 0, i.raycastObject3D(a, t, pe), pe.forEach((c) => {
3390
+ n.getMatrixAt(o, Lt), Nt.multiplyMatrices(n.matrixWorld, Lt), a.matrixWorld.copy(Nt), ge.length = 0, r.raycastObject3D(a, t, ge), ge.forEach((c) => {
2871
3391
  c.instanceId = o, c.object = n, s.push(c);
2872
- }), pe.length = 0;
3392
+ }), ge.length = 0;
2873
3393
  }
2874
3394
  }
2875
3395
  #M(e, t) {
2876
3396
  if (t <= e.capacity) return;
2877
- e.capacity = Bt(t, e.capacity);
3397
+ e.capacity = Ut(t, e.capacity);
2878
3398
  const s = new Set(e.records);
2879
- s.forEach((n) => this.#S(n)), this.#t = this.#t.filter((n) => !s.has(n)), e.records = e.templateMeshes.map(({ mesh: n, localMatrix: i }, a) => {
2880
- const o = this.#p(e, n, i, a);
2881
- return this.#t.push(o), o;
3399
+ s.forEach((n) => this.#S(n)), this.#s = this.#s.filter((n) => !s.has(n)), e.records = e.templateMeshes.map(({ mesh: n, localMatrix: r }, a) => {
3400
+ const o = this.#h(e, n, r, a);
3401
+ return this.#s.push(o), o;
2882
3402
  }), this.#y(e);
2883
3403
  }
2884
- #I(e, t) {
3404
+ #v(e, t) {
2885
3405
  const s = e.instances.indexOf(t);
2886
- return s === -1 ? !1 : (e.instances.splice(s, 1), e.records.forEach((n) => n.visibleInstances.splice(s, 1)), this.#s.delete(t), this.#g(), e.unsubscribeByInstance.get(t)?.(), e.unsubscribeByInstance.delete(t), e.instances.length === 0 ? (this.#f(e), !0) : (this.#b(e), this.#y(e), !0));
3406
+ return s === -1 ? !1 : (e.instances.splice(s, 1), e.records.forEach((n) => n.visibleInstances.splice(s, 1)), this.#t.delete(t), this.#g(), e.unsubscribeByInstance.get(t)?.(), e.unsubscribeByInstance.delete(t), e.instances.length === 0 ? (this.#m(e), !0) : (this.#b(e), this.#y(e), !0));
2887
3407
  }
2888
- #f(e) {
2889
- e.unsubscribeByInstance.forEach((s) => s()), e.instances.forEach((s) => this.#s.delete(s)), e.unsubscribeByInstance.clear(), e.instances.length = 0, this.#g();
3408
+ #m(e) {
3409
+ e.unsubscribeByInstance.forEach((s) => s()), e.instances.forEach((s) => this.#t.delete(s)), e.unsubscribeByInstance.clear(), e.instances.length = 0, this.#g();
2890
3410
  const t = new Set(e.records);
2891
- t.forEach((s) => this.#S(s)), this.#t = this.#t.filter((s) => !t.has(s)), e.records.length = 0, e.templateMeshes.length = 0, this.#a.delete(e.url), this.remove(e.batch);
3411
+ t.forEach((s) => this.#S(s)), this.#s = this.#s.filter((s) => !t.has(s)), e.records.length = 0, e.templateMeshes.length = 0, this.#a.delete(e.url), this.remove(e.batch);
2892
3412
  }
2893
3413
  #S(e) {
2894
3414
  e.batchRecord.batch.remove(e.mesh), e.mesh.dispose(), e.materials.forEach((t) => t.dispose());
@@ -2903,27 +3423,27 @@ class $i extends ue {
2903
3423
  delete t.mesh.userData.instances;
2904
3424
  });
2905
3425
  }
2906
- #E(e) {
3426
+ #C(e) {
2907
3427
  const t = new Set(e), s = /* @__PURE__ */ new Map();
2908
- for (const i of e) {
2909
- const { instanceId: a } = i;
3428
+ for (const r of e) {
3429
+ const { instanceId: a } = r;
2910
3430
  if (!a) continue;
2911
3431
  const o = s.get(a);
2912
- if (o && o !== i) return !1;
2913
- s.set(a, i);
3432
+ if (o && o !== r) return !1;
3433
+ s.set(a, r);
2914
3434
  }
2915
3435
  let n = !0;
2916
- return s.forEach((i, a) => {
2917
- n && this.#r((o) => {
3436
+ return s.forEach((r, a) => {
3437
+ n && this.#i((o) => {
2918
3438
  !n || t.has(o) || o.instanceId === a && (n = !1);
2919
3439
  });
2920
3440
  }), n;
2921
3441
  }
2922
3442
  #w() {
2923
- if (!this.#n) return;
3443
+ if (!this.#r) return;
2924
3444
  this.#e.clear();
2925
3445
  const e = /* @__PURE__ */ new Set();
2926
- this.#r((t) => {
3446
+ this.#i((t) => {
2927
3447
  const { instanceId: s } = t;
2928
3448
  if (!s || e.has(s)) return;
2929
3449
  const n = this.#e.get(s);
@@ -2932,128 +3452,131 @@ class $i extends ue {
2932
3452
  return;
2933
3453
  }
2934
3454
  this.#e.set(s, t);
2935
- }), this.#n = !1;
3455
+ }), this.#r = !1;
2936
3456
  }
2937
3457
  #g() {
2938
- this.#n = !0;
3458
+ this.#r = !0;
2939
3459
  }
2940
3460
  #y(e) {
2941
- e.records.forEach((t) => this.#v(t));
3461
+ e.records.forEach((t) => this.#I(t));
2942
3462
  }
2943
- #v(e) {
2944
- e.dirty = !0, e.hasLastCameraState = !1, e.mesh.visible = !0, e.mesh.frustumCulled = !1, te(e.batchRecord.batch);
3463
+ #I(e) {
3464
+ e.dirty = !0, e.hasLastCameraState = !1, e.mesh.visible = !0, e.mesh.frustumCulled = !1, ee(e.batchRecord.batch);
2945
3465
  }
2946
- #B(e, t, s) {
2947
- const n = this.#C(t), i = this.#O(e, s, n);
2948
- !e.dirty && !this.#_(e) && !i || this.#P(e, s, n);
3466
+ #E(e, t, s) {
3467
+ const n = this.#O(t), r = this.#B(e, s, n);
3468
+ !e.dirty && !this.#A(e) && !r || this.#N(e, s, n);
2949
3469
  }
2950
- #_(e) {
3470
+ #A(e) {
2951
3471
  const { instances: t } = e.batchRecord;
2952
3472
  for (let s = 0; s < t.length; s++)
2953
- if (e.visibleInstances[s] !== _e(t[s]))
2954
- return e.dirty = !0, te(e.batchRecord.batch), !0;
3473
+ if (e.visibleInstances[s] !== De(t[s]))
3474
+ return e.dirty = !0, ee(e.batchRecord.batch), !0;
2955
3475
  return !1;
2956
3476
  }
2957
- #C(e) {
2958
- return e?.getDrawingBufferSize ? (e.getDrawingBufferSize(gt), gt.y) : 0;
3477
+ #O(e) {
3478
+ return e?.getDrawingBufferSize ? (e.getDrawingBufferSize(_t), _t.y) : 0;
2959
3479
  }
2960
- #O(e, t, s) {
2961
- return this.#x(t, s) ? e.hasLastCameraState ? !It(e.lastCameraMatrixWorldInverse, t.matrixWorldInverse) || !It(e.lastCameraProjectionMatrix, t.projectionMatrix) || Math.abs(e.lastViewportHeight - s) > W : !0 : !1;
3480
+ #B(e, t, s) {
3481
+ return this.#x(t, s) ? e.hasLastCameraState ? !Rt(e.lastCameraMatrixWorldInverse, t.matrixWorldInverse) || !Rt(e.lastCameraProjectionMatrix, t.projectionMatrix) || Math.abs(e.lastViewportHeight - s) > H : !0 : !1;
2962
3482
  }
2963
3483
  #x(e, t) {
2964
- return this.#i && e !== void 0 && (this.#o || this.#c > 0 && t > 0);
3484
+ return this.#n && e !== void 0 && (this.#o || this.#c > 0 && t > 0);
2965
3485
  }
2966
- #A(e, t) {
3486
+ #_(e, t) {
2967
3487
  if (!this.#x(e, t)) return null;
2968
3488
  let s = null;
2969
- return this.#o && (dt.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse), s = ti.setFromProjectionMatrix(dt)), { camera: e, frustum: s, viewportHeight: t };
3489
+ return this.#o && (Ct.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse), s = Or.setFromProjectionMatrix(Ct)), { camera: e, frustum: s, viewportHeight: t };
2970
3490
  }
2971
3491
  #T(e, t) {
2972
3492
  return t ? t.frustum && !t.frustum.intersectsSphere(e) ? !1 : this.#c <= 0 || t.viewportHeight <= 0 ? !0 : this.#L(e, t.camera, t.viewportHeight) >= this.#c : !0;
2973
3493
  }
2974
3494
  #L(e, t, s) {
2975
3495
  const n = Math.abs(t.projectionMatrix.elements[5]);
2976
- if (n <= W) return 1 / 0;
3496
+ if (n <= H) return 1 / 0;
2977
3497
  if (t.isOrthographicCamera)
2978
3498
  return e.radius * n * s * 0.5;
2979
- yt.copy(e.center).applyMatrix4(t.matrixWorldInverse);
2980
- const i = -yt.z;
2981
- return i <= W ? 1 / 0 : e.radius * n * s * 0.5 / i;
2982
- }
2983
- #P(e, t, s = 0) {
2984
- this.updateWorldMatrix(!0, !1), ht.copy(this.matrixWorld).invert();
2985
- const n = e.mesh.instanceMatrix.array, i = e.colorAttribute.array, a = e.opacityAttribute.array, o = e.mesh.geometry;
2986
- let c = !1, l = !1, h = !1, u = 0, d = 0, p = !1;
2987
- const m = e.mesh.count, b = this.#A(t, s);
2988
- o.boundingSphere || o.computeBoundingSphere(), e.fullBoundingSphere.makeEmpty(), e.renderedInstances.length = 0, e.batchRecord.instances.forEach((g, I) => {
2989
- const B = _e(g);
2990
- e.visibleInstances[I] = B, g.updateWorldMatrix(!0, !1), de.multiplyMatrices(ht, g.matrixWorld).multiply(e.localMatrix);
2991
- const O = g.getInstanceOpacity();
2992
- if (!(B && O > W) || (d++, o.boundingSphere && (mt.copy(o.boundingSphere).applyMatrix4(de), e.fullBoundingSphere.union(mt), b && (ut.multiplyMatrices(g.matrixWorld, e.localMatrix), ft.copy(o.boundingSphere).applyMatrix4(ut), !this.#T(ft, b)))))
3499
+ Tt.copy(e.center).applyMatrix4(t.matrixWorldInverse);
3500
+ const r = -Tt.z;
3501
+ return r <= H ? 1 / 0 : e.radius * n * s * 0.5 / r;
3502
+ }
3503
+ #N(e, t, s = 0) {
3504
+ this.updateWorldMatrix(!0, !1), It.copy(this.matrixWorld).invert();
3505
+ const n = e.mesh.instanceMatrix.array, r = e.colorAttribute.array, a = e.opacityAttribute.array, o = e.mesh.geometry;
3506
+ let c = !1, l = !1, h = !1, d = 0, u = 0, p = !1;
3507
+ const x = e.mesh.count, I = this.#_(t, s);
3508
+ o.boundingSphere || o.computeBoundingSphere(), e.fullBoundingSphere.makeEmpty(), e.renderedInstances.length = 0, e.batchRecord.instances.forEach((y, w) => {
3509
+ const g = De(y);
3510
+ e.visibleInstances[w] = g, y.updateWorldMatrix(!0, !1), me.multiplyMatrices(It, y.matrixWorld).multiply(e.localMatrix);
3511
+ const m = y.getInstanceOpacity();
3512
+ if (!(g && m > H) || (u++, o.boundingSphere && (Ot.copy(o.boundingSphere).applyMatrix4(me), e.fullBoundingSphere.union(Ot), I && (Et.multiplyMatrices(y.matrixWorld, e.localMatrix), Bt.copy(o.boundingSphere).applyMatrix4(Et), !this.#T(Bt, I)))))
2993
3513
  return;
2994
- const y = u, _ = y * 16;
2995
- ni(de, n, _) || (e.mesh.setMatrixAt(y, de), c = !0), ee.copy(g.getInstanceColor(ee));
2996
- const k = g.getInstanceColorMode(), N = y * 4;
2997
- ii(ee, k, i, N) || (e.colorAttribute.setXYZW(y, ee.r, ee.g, ee.b, k), l = !0), O < Xt && (p = !0), Math.abs(O - a[y]) > W && (e.opacityAttribute.setX(y, O), h = !0), e.renderedInstances[y] = g, u++;
2998
- }), e.mesh.count = u, m !== u && (c = !0, l = !0, h = !0, te(e.batchRecord.batch));
2999
- const S = d > 0;
3000
- e.mesh.visible !== S && (e.mesh.visible = S, te(e.batchRecord.batch)), e.mesh.frustumCulled !== !0 && (e.mesh.frustumCulled = !0, te(e.batchRecord.batch)), c && (e.mesh.instanceMatrix.needsUpdate = !0), l && (e.colorAttribute.needsUpdate = !0), h && (e.opacityAttribute.needsUpdate = !0), e.mesh.boundingSphere === null && (e.mesh.boundingSphere = new ne()), e.mesh.boundingSphere.copy(e.fullBoundingSphere);
3001
- const w = e.hasSourceTransparency || p;
3002
- e.materials.forEach((g) => {
3003
- g.transparent !== w && (g.transparent = w, g.needsUpdate = !0, te(e.batchRecord.batch));
3514
+ const b = d, S = b * 16;
3515
+ _r(me, n, S) || (e.mesh.setMatrixAt(b, me), c = !0), Z.copy(y.getInstanceColor(Z));
3516
+ const A = y.getInstanceColorMode(), v = b * 4;
3517
+ Tr(Z, A, r, v) || (e.colorAttribute.setXYZW(b, Z.r, Z.g, Z.b, A), l = !0), m < cs && (p = !0), Math.abs(m - a[b]) > H && (e.opacityAttribute.setX(b, m), h = !0), e.renderedInstances[b] = y, d++;
3518
+ }), e.mesh.count = d, x !== d && (c = !0, l = !0, h = !0, ee(e.batchRecord.batch));
3519
+ const _ = u > 0;
3520
+ e.mesh.visible !== _ && (e.mesh.visible = _, ee(e.batchRecord.batch)), e.mesh.frustumCulled !== !0 && (e.mesh.frustumCulled = !0, ee(e.batchRecord.batch)), c && (e.mesh.instanceMatrix.needsUpdate = !0), l && (e.colorAttribute.needsUpdate = !0), h && (e.opacityAttribute.needsUpdate = !0), e.mesh.boundingSphere === null && (e.mesh.boundingSphere = new ne()), e.mesh.boundingSphere.copy(e.fullBoundingSphere);
3521
+ const C = e.hasSourceTransparency || p;
3522
+ e.materials.forEach((y) => {
3523
+ y.transparent !== C && (y.transparent = C, y.needsUpdate = !0, ee(e.batchRecord.batch));
3004
3524
  }), t && this.#x(t, s) ? (e.lastCameraMatrixWorldInverse.copy(t.matrixWorldInverse), e.lastCameraProjectionMatrix.copy(t.projectionMatrix), e.lastViewportHeight = s, e.hasLastCameraState = !0) : e.hasLastCameraState = !1, e.dirty = !1;
3005
3525
  }
3006
3526
  }
3007
- const di = "0.0.30";
3008
- typeof window < "u" && (window.__USPACE__ = { version: di });
3527
+ const Ur = "0.0.32";
3528
+ typeof window < "u" && (window.__USPACE__ = { version: Ur });
3009
3529
  export {
3010
- Wi as AnnotationManager,
3011
- ue as BaseGroup,
3012
- q as BaseMesh,
3013
- wn as BaseSprite,
3014
- ir as CSS2DObject,
3015
- ar as CSS3DObject,
3016
- or as CSS3DSprite,
3017
- Qi as CSSRenderer,
3018
- qi as CameraControls,
3019
- zi as CircleMesh,
3020
- ki as ClippingTool,
3021
- Gi as EditableGeometryBatchLayer,
3022
- zt as ExtrudeMesh,
3023
- rt as INSTANCE_COLOR_MODE_NONE,
3024
- Ee as INSTANCE_COLOR_MODE_OVERRIDE,
3025
- Dn as INSTANCE_COLOR_MODE_TINT,
3026
- Hi as InstanceObject,
3027
- Yi as InteractionEvent,
3028
- Vi as InteractionManager,
3029
- Ai as LightManager,
3530
+ mi as AnnotationManager,
3531
+ pe as BaseGroup,
3532
+ X as BaseMesh,
3533
+ Kn as BaseSprite,
3534
+ Li as CSS2DObject,
3535
+ Di as CSS3DObject,
3536
+ Pi as CSS3DSprite,
3537
+ vi as CSSRenderer,
3538
+ Si as CameraControls,
3539
+ li as CircleMesh,
3540
+ pi as ClippingTool,
3541
+ bi as EditableGeometryBatchLayer,
3542
+ Yt as ExtrudeMesh,
3543
+ wt as INSTANCE_COLOR_MODE_NONE,
3544
+ Ne as INSTANCE_COLOR_MODE_OVERRIDE,
3545
+ lr as INSTANCE_COLOR_MODE_TINT,
3546
+ gi as InstanceObject,
3547
+ Ii as InteractionEvent,
3548
+ Ei as InteractionManager,
3549
+ ri as LightManager,
3030
3550
  se as MaterialEffects,
3031
- Ui as MeasureTool,
3032
- we as Model,
3033
- $i as ModelInstancedLayer,
3034
- X as ModelLoaderManager,
3035
- Ji as ObjectManager,
3036
- J as ObjectUtils,
3037
- Ni as PlaneMesh,
3038
- Pi as Poi,
3039
- Zi as RenderPipeline,
3040
- er as RoomEnvironment,
3041
- yn as SBMLoader,
3042
- tn as SBMXLoader,
3043
- Oi as SceneManager,
3044
- Ci as Selection,
3045
- Nt as ShapeMesh,
3046
- xn as SphereMesh,
3047
- Di as TSLEffects,
3048
- Ti as TextureLoaderManager,
3049
- Li as Topology,
3050
- qe as TubeMesh,
3051
- Ln as Tween,
3052
- tr as Viewer,
3053
- sr as enableMeshBVHRaycast,
3054
- Et as getGeometryBoundsTree,
3055
- Fi as isInstanceObject,
3056
- Ri as reinterpretType,
3057
- ji as tweenAnimation,
3058
- di as version
3551
+ fi as MeasureTool,
3552
+ te as Model,
3553
+ $n as ModelDecodeWorkerClient,
3554
+ ve as ModelDecodeWorkerUnavailableError,
3555
+ wi as ModelInstancedLayer,
3556
+ V as ModelLoaderManager,
3557
+ Ci as ObjectManager,
3558
+ Q as ObjectUtils,
3559
+ ci as PlaneMesh,
3560
+ oi as Poi,
3561
+ Ai as RenderPipeline,
3562
+ Oi as RoomEnvironment,
3563
+ ct as SBMLoader,
3564
+ at as SBMXLoader,
3565
+ ni as SceneManager,
3566
+ si as Selection,
3567
+ Xt as ShapeMesh,
3568
+ qn as SphereMesh,
3569
+ hi as TSLEffects,
3570
+ ii as TextureLoaderManager,
3571
+ ai as Topology,
3572
+ lt as TubeMesh,
3573
+ ir as Tween,
3574
+ Bi as Viewer,
3575
+ _i as enableMeshBVHRaycast,
3576
+ jt as getGeometryBoundsTree,
3577
+ yi as isInstanceObject,
3578
+ di as reinterpretType,
3579
+ Hn as reuseDecodedImageContent,
3580
+ ui as tweenAnimation,
3581
+ Ur as version
3059
3582
  };