u-space 0.0.29 → 0.0.30

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 (72) hide show
  1. package/README.md +9 -0
  2. package/dist/Viewer-BKNV67Jj.cjs +1 -0
  3. package/dist/Viewer-Cs_y7IiH.js +1256 -0
  4. package/dist/index.cjs +3 -3
  5. package/dist/index.js +1718 -1503
  6. package/dist/plugins/atmosphere/AgxToneMapping.d.ts +1 -1
  7. package/dist/plugins/atmosphere/index.cjs +1 -1
  8. package/dist/plugins/atmosphere/index.js +4 -4
  9. package/dist/plugins/curve-movement/index.cjs +1 -1
  10. package/dist/plugins/curve-movement/index.js +1 -1
  11. package/dist/plugins/fire/index.cjs +1 -1
  12. package/dist/plugins/fire/index.js +5 -5
  13. package/dist/plugins/object-controls/index.cjs +1 -1
  14. package/dist/plugins/object-controls/index.js +4 -4
  15. package/dist/plugins/tiles/index.cjs +1 -1
  16. package/dist/plugins/tiles/index.js +5 -5
  17. package/dist/plugins/u-manager/index.cjs +48 -48
  18. package/dist/plugins/u-manager/index.d.ts +1 -1
  19. package/dist/plugins/u-manager/index.js +8126 -8660
  20. package/dist/plugins/u-manager/loaders/SceneEditableBatchLayer.d.ts +17 -0
  21. package/dist/plugins/u-manager/loaders/SceneInstancedLayer.d.ts +3 -3
  22. package/dist/plugins/u-manager/loaders/SceneLoader.d.ts +11 -3
  23. package/dist/plugins/u-manager/semantics/objects/BuildingGroup.d.ts +4 -5
  24. package/dist/plugins/u-manager/semantics/objects/FacilityInstancedLayer.d.ts +4 -4
  25. package/dist/plugins/u-manager/semantics/objects/FloorMesh.d.ts +20 -22
  26. package/dist/plugins/u-manager/semantics/objects/SemanticGroup.d.ts +2 -3
  27. package/dist/protocol-C-OMPz15.js +10 -0
  28. package/dist/protocol-IUAzx0lk.cjs +1 -0
  29. package/dist/src/batches/EditableGeometryBatchLayer.d.ts +50 -0
  30. package/dist/src/batches/ModelInstancedLayer.d.ts +42 -0
  31. package/dist/src/batches/index.d.ts +2 -0
  32. package/dist/src/effects/TSLEffects.d.ts +24 -1
  33. package/dist/src/index.d.ts +2 -0
  34. package/dist/src/instances/InstanceObject.d.ts +57 -0
  35. package/dist/src/instances/index.d.ts +1 -0
  36. package/dist/src/interactions/MeshBVHRaycast.d.ts +9 -0
  37. package/dist/src/interactions/index.d.ts +1 -0
  38. package/dist/src/viewers/RenderPipeline.d.ts +37 -0
  39. package/dist/src/viewers/ReversedDepthSSGICompat.d.ts +10 -0
  40. package/dist/src/viewers/ReversedDepthSSRCompat.d.ts +20 -0
  41. package/dist/src/viewers/Viewer.d.ts +3 -1
  42. package/dist/src/viewers/renderInvalidation.d.ts +2 -0
  43. package/dist/src/worker/FrameTimingWindow.d.ts +16 -0
  44. package/dist/src/worker/OffscreenViewerHost.d.ts +20 -0
  45. package/dist/src/worker/WorkerDomTarget.d.ts +44 -0
  46. package/dist/src/worker/createWorkerViewer.d.ts +18 -0
  47. package/dist/src/worker/index.d.ts +2 -0
  48. package/dist/src/worker/installWorkerImageLoader.d.ts +5 -0
  49. package/dist/src/worker/protocol.d.ts +102 -0
  50. package/dist/src/worker/runtime.d.ts +2 -0
  51. package/dist/worker/index.cjs +1 -0
  52. package/dist/worker/index.js +224 -0
  53. package/dist/worker/runtime.cjs +1 -0
  54. package/dist/worker/runtime.js +418 -0
  55. package/docs/api-batches.md +112 -0
  56. package/docs/api-effects.md +2 -2
  57. package/docs/api-interactions.md +8 -0
  58. package/docs/api-managers.md +1 -1
  59. package/docs/api-objects.md +207 -0
  60. package/docs/api-plugin-u-manager.md +193 -102
  61. package/docs/api-render-pipeline.md +103 -5
  62. package/docs/api-viewer.md +188 -1
  63. package/docs/changelog.md +53 -12
  64. package/docs/examples-guide.md +98 -20
  65. package/docs/getting-started.md +1 -1
  66. package/docs/index.md +11 -4
  67. package/docs/mcp.md +28 -14
  68. package/docs/release.md +95 -0
  69. package/package.json +27 -4
  70. package/dist/plugins/u-manager/instances/SemanticInstanceObject.d.ts +0 -51
  71. package/dist/plugins/u-manager/instances/SemanticModelInstancedLayer.d.ts +0 -42
  72. package/dist/plugins/u-manager/instances/index.d.ts +0 -2
package/dist/index.js CHANGED
@@ -1,211 +1,22 @@
1
- import { Raycaster as De, Vector2 as C, EventDispatcher as ke, Box2 as at, Matrix4 as je, Vector3 as v, Box3 as V, Scene as Ue, Color as T, AmbientLight as ct, DirectionalLight as we, PointLight as ve, SpotLight as be, HemisphereLight as xe, DirectionalLightHelper as ht, PointLightHelper as lt, SpotLightHelper as dt, HemisphereLightHelper as pt, RenderPipeline as ut, PerspectiveCamera as se, Sphere as fe, Spherical as M, Quaternion as mt, Vector4 as ft, MathUtils as gt, PMREMGenerator as yt, OrthographicCamera as ne, TimestampQuery as Z, Cache as wt, Timer as vt, WebGPURenderer as bt, PCFShadowMap as xt, AgXToneMapping as St, Fog as Ct, FogExp2 as Tt, MeshStandardNodeMaterial as L, Loader as Mt, LoaderUtils as R, FileLoader as He, TextureLoader as Fe, Group as I, SRGBColorSpace as Ge, RepeatWrapping as Se, BufferGeometry as Q, BufferAttribute as Ce, Mesh as k, FrontSide as _t, BackSide as Et, DoubleSide as Pt, REVISION as Te, CubeTextureLoader as Ot, EquirectangularReflectionMapping as At, Sprite as Bt, AnimationMixer as Rt, LoopRepeat as It, LoopOnce as Lt, SphereGeometry as zt, TubeGeometry as Nt, LineCurve3 as Dt, CatmullRomCurve3 as kt, SpriteNodeMaterial as jt, CanvasTexture as Ut, ShapeGeometry as Ht, Shape as $e, ExtrudeGeometry as Ft, PlaneGeometry as Gt, CircleGeometry as $t, ClippingGroup as Wt, Plane as Kt, PlaneHelper as Qt, LineBasicMaterial as ie, Line as re } from "three/webgpu";
2
- import { pass as ge, mrt as qt, output as Xt, add as Me, blendColor as Yt, emissive as Vt, normalView as Jt, velocity as Zt, color as H, uv as _e, time as oe, pow as ae, sin as ye, mix as ce, mx_noise_float as Ee, Fn as We, userData as O, materialColor as Pe, select as q, materialOpacity as Oe, vec3 as es } from "three/tsl";
3
- import { bloom as ts } from "three/addons/tsl/display/BloomNode.js";
4
- import { ssgi as ss } from "three/addons/tsl/display/SSGINode.js";
5
- import { traa as ns } from "three/addons/tsl/display/TRAANode.js";
6
- import Ke from "camera-controls";
7
- import { RoomEnvironment as is } from "three/addons/environments/RoomEnvironment.js";
8
- import { ViewHelper as rs } from "three/addons/helpers/ViewHelper.js";
9
- import { CSS2DRenderer as os, CSS2DObject as as } from "three/addons/renderers/CSS2DRenderer.js";
10
- import { CSS2DObject as $n } from "three/addons/renderers/CSS2DRenderer.js";
11
- import { CSS3DRenderer as cs, CSS3DSprite as hs, CSS3DObject as ls } from "three/addons/renderers/CSS3DRenderer.js";
12
- import { CSS3DObject as Kn, CSS3DSprite as Qn } from "three/addons/renderers/CSS3DRenderer.js";
13
- import { GLTFLoader as Qe } from "three/addons/loaders/GLTFLoader.js";
14
- import { FBXLoader as ds } from "three/addons/loaders/FBXLoader.js";
15
- import { OBJLoader as ps } from "three/addons/loaders/OBJLoader.js";
16
- import { STLLoader as us } from "three/addons/loaders/STLLoader.js";
17
- import { DRACOLoader as ms } from "three/addons/loaders/DRACOLoader.js";
18
- import { KTX2Loader as fs } from "three/addons/loaders/KTX2Loader.js";
19
- import { MeshoptDecoder as Ae } from "three/addons/libs/meshopt_decoder.module.js";
20
- import { HDRLoader as gs } from "three/addons/loaders/HDRLoader.js";
21
- import { clone as ys } from "three/addons/utils/SkeletonUtils.js";
22
- import { Easing as f, Tween as ws } from "three/addons/libs/tween.module.js";
23
- class vs {
24
- /** The type of event (e.g., 'click', 'pointerdown'). */
25
- type;
26
- /** The original 3D object that triggered the event. */
27
- target;
28
- /** The current 3D object during the bubbling phase. */
29
- currentTarget;
30
- /** The intersection data from raycasting, or null if not applicable. */
31
- intersect;
32
- /** The original DOM event, or undefined if not applicable. */
33
- originalEvent;
34
- _propagationStopped = !1;
35
- constructor(e) {
36
- this.type = e.type, this.target = e.target, this.currentTarget = e.target, this.intersect = e.intersect, this.originalEvent = e.originalEvent;
37
- }
38
- /**
39
- * Stops the event from bubbling up the parent chain.
40
- */
41
- stopPropagation() {
42
- this._propagationStopped = !0;
43
- }
44
- /**
45
- * Returns true if `stopPropagation()` has been called.
46
- */
47
- get propagationStopped() {
48
- return this._propagationStopped;
49
- }
50
- }
51
- class bs {
52
- domElement;
53
- scene;
54
- camera;
55
- raycaster = new De();
56
- pointer = new C();
57
- hoveredObject = null;
58
- pointerDownTime = 0;
59
- pointerDownPos = new C();
60
- clickTimer = null;
61
- longPressThreshold = 500;
62
- moveThreshold = 0.01;
63
- /**
64
- * The objects to check for intersections. default to all children of the scene (including nested).
65
- */
66
- targetObjects;
67
- /**
68
- * Whether to enable pointer move events (pointermove, pointerenter, pointerleave).
69
- * Disabled by default for performance optimization.
70
- */
71
- pointerMoveEventsEnabled = !1;
72
- /**
73
- * Whether interaction is enabled globally.
74
- */
75
- _enabled = !0;
76
- /**
77
- * Objects excluded from raycasting (via addIgnore or setInteractable(false)).
78
- */
79
- _excludeSet = /* @__PURE__ */ new Set();
80
- constructor(e, t, s) {
81
- this.domElement = e, this.scene = t, this.camera = s, this.raycaster.params.Points.threshold = 0.1, this.raycaster.params.Line.threshold = 0.1, this.targetObjects = this.scene.children, this._bindEvents();
82
- }
83
- /**
84
- * Updates the camera reference (useful when switching cameras).
85
- */
86
- setCamera(e) {
87
- this.camera = e;
88
- }
89
- /**
90
- * Enable all interactions.
91
- */
92
- enable() {
93
- this._enabled = !0;
94
- }
95
- /**
96
- * Disable all interactions.
97
- */
98
- disable() {
99
- this._enabled = !1;
100
- }
101
- /**
102
- * Set whether a specific object is interactable.
103
- * When set to false, the object and its children are excluded from raycasting.
104
- */
105
- setInteractable(e, t) {
106
- t ? this._excludeSet.delete(e) : this._excludeSet.add(e);
107
- }
108
- /**
109
- * Add an object to the exclude list (will not receive any events).
110
- * Alias for `setInteractable(object, false)`.
111
- */
112
- addIgnore(e) {
113
- this._excludeSet.add(e);
114
- }
115
- /**
116
- * Remove an object from the exclude list.
117
- * Alias for `setInteractable(object, true)`.
118
- */
119
- removeIgnore(e) {
120
- this._excludeSet.delete(e);
121
- }
122
- _bindEvents() {
123
- this.domElement.addEventListener("click", this._onClick), this.domElement.addEventListener("dblclick", this._onDblClick), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointerup", this._onPointerUp), this.domElement.addEventListener("pointermove", this._onPointerMove);
124
- }
125
- _updatePointer(e) {
126
- const t = this.domElement.getBoundingClientRect();
127
- this.pointer.x = (e.clientX - t.left) / t.width * 2 - 1, this.pointer.y = -((e.clientY - t.top) / t.height) * 2 + 1;
128
- }
129
- _getIntersects() {
130
- this.raycaster.setFromCamera(this.pointer, this.camera);
131
- const e = this.raycaster.intersectObjects(this.targetObjects, !0);
132
- return this._excludeSet.size > 0 ? e.filter((t) => {
133
- let s = t.object;
134
- for (; s; ) {
135
- if (this._excludeSet.has(s))
136
- return !1;
137
- s = s.parent;
138
- }
139
- return !0;
140
- }) : e;
141
- }
142
- /**
143
- * Dispatches an event to the target object and bubbles up the parent chain.
144
- */
145
- _dispatchToTarget(e, t, s, n) {
146
- const i = new vs({
147
- type: e,
148
- target: t,
149
- intersect: s,
150
- originalEvent: n
151
- });
152
- let r = t;
153
- for (; r && !i.propagationStopped; )
154
- i.currentTarget = r, r.dispatchEvent({ type: e, event: i }), r = r.parent;
155
- }
156
- /**
157
- * Handles a DOM event by raycasting and dispatching to the first intersected object.
158
- */
159
- _handleEvent(e, t) {
160
- if (!this._enabled) return;
161
- this._updatePointer(t);
162
- const s = this._getIntersects();
163
- if (s.length === 0) return;
164
- const n = s[0];
165
- this._dispatchToTarget(e, n.object, n, t);
166
- }
167
- _onClick = (e) => {
168
- const t = Date.now() - this.pointerDownTime, s = this.pointer.distanceTo(this.pointerDownPos);
169
- if (!(t > this.longPressThreshold || s > this.moveThreshold)) {
170
- if (this.clickTimer) {
171
- clearTimeout(this.clickTimer), this.clickTimer = null;
172
- return;
173
- }
174
- this.clickTimer = setTimeout(() => {
175
- this._handleEvent("click", e), this.clickTimer = null;
176
- }, 200);
177
- }
178
- };
179
- _onDblClick = (e) => {
180
- this.clickTimer && (clearTimeout(this.clickTimer), this.clickTimer = null), this._handleEvent("dblclick", e);
181
- };
182
- _onContextMenu = (e) => {
183
- e.preventDefault();
184
- };
185
- _onPointerDown = (e) => {
186
- this.pointerDownTime = Date.now(), this._updatePointer(e), this.pointerDownPos.copy(this.pointer), this._handleEvent("pointerdown", e);
187
- };
188
- _onPointerUp = (e) => {
189
- if (this._updatePointer(e), e.button === 2) {
190
- const t = Date.now() - this.pointerDownTime, s = this.pointer.distanceTo(this.pointerDownPos);
191
- t <= this.longPressThreshold && s <= this.moveThreshold && this._handleEvent("rightclick", e);
192
- }
193
- this._handleEvent("pointerup", e);
194
- };
195
- _onPointerMove = (e) => {
196
- if (!this._enabled || !this.pointerMoveEventsEnabled) return;
197
- this._updatePointer(e);
198
- const t = this._getIntersects(), s = t.length > 0 ? t[0].object : null, n = t.length > 0 ? t[0] : null;
199
- this.hoveredObject !== s && (this.hoveredObject && this._dispatchToTarget("pointerleave", this.hoveredObject, null, e), this.hoveredObject = s, s && n && this._dispatchToTarget("pointerenter", s, n, e)), s && n && this._dispatchToTarget("pointermove", s, n, e);
200
- };
201
- /**
202
- * Cleans up event listeners.
203
- */
204
- dispose() {
205
- this.domElement.removeEventListener("click", this._onClick), this.domElement.removeEventListener("dblclick", this._onDblClick), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.clickTimer && (clearTimeout(this.clickTimer), this.clickTimer = null), this.hoveredObject = null, this._excludeSet.clear();
206
- }
207
- }
208
- class En extends ke {
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 {
209
20
  scene;
210
21
  camera;
211
22
  domElement;
@@ -215,8 +26,8 @@ class En extends ke {
215
26
  // Box selection state
216
27
  _boxSelectionEnabled = !1;
217
28
  _isSelecting = !1;
218
- _startPoint = new C();
219
- _endPoint = new C();
29
+ _startPoint = new z();
30
+ _endPoint = new z();
220
31
  _selectionBox = null;
221
32
  _deep = !0;
222
33
  /**
@@ -315,226 +126,33 @@ class En extends ke {
315
126
  this._selectionBox.style.left = `${e}px`, this._selectionBox.style.top = `${t}px`, this._selectionBox.style.width = `${s}px`, this._selectionBox.style.height = `${n}px`;
316
127
  }
317
128
  _getObjectsInBox() {
318
- const e = this._container.getBoundingClientRect(), t = e.width, s = e.height, n = new C(
129
+ const e = this._container.getBoundingClientRect(), t = e.width, s = e.height, n = new z(
319
130
  this._startPoint.x / t * 2 - 1,
320
131
  -(this._startPoint.y / s) * 2 + 1
321
- ), i = new C(
132
+ ), i = new z(
322
133
  this._endPoint.x / t * 2 - 1,
323
134
  -(this._endPoint.y / s) * 2 + 1
324
- ), r = new at(
325
- new C(Math.min(n.x, i.x), Math.min(n.y, i.y)),
326
- new C(Math.max(n.x, i.x), Math.max(n.y, i.y))
327
- ), o = this.targetObjects || this.scene.children, a = [], c = new je();
328
- c.multiplyMatrices(this.camera.projectionMatrix, this.camera.matrixWorldInverse);
329
- const l = (d) => {
330
- if (!d.visible) return;
331
- const p = new v();
332
- if (p.setFromMatrixPosition(d.matrixWorld), p.applyMatrix4(c), p.z > -1 && p.z < 1 && r.containsPoint(new C(p.x, p.y)) && a.push(d), this._deep)
333
- for (const u of d.children)
334
- l(u);
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();
139
+ 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)
145
+ h(p);
335
146
  };
336
- for (const d of o)
337
- l(d);
338
- return a;
147
+ for (const u of o)
148
+ h(u);
149
+ return c;
339
150
  }
340
151
  dispose() {
341
152
  this.disableBoxSelection(), this._selected.clear();
342
153
  }
343
154
  }
344
- function ee(h, e) {
345
- const t = h;
346
- if (t.setSemanticVisible) {
347
- t.setSemanticVisible(e);
348
- return;
349
- }
350
- h.visible = e, t.markSemanticRenderDirty?.();
351
- }
352
- class xs {
353
- idMap = /* @__PURE__ */ new Map();
354
- nameMap = /* @__PURE__ */ new Map();
355
- typeMap = /* @__PURE__ */ new Map();
356
- objectIds = /* @__PURE__ */ new Map();
357
- allObjects = /* @__PURE__ */ new Set();
358
- /**
359
- * Add an object with a custom id.
360
- * One object can have multiple ids.
361
- */
362
- add(e, t) {
363
- if (this.idMap.has(e)) {
364
- console.warn(`ObjectManager: Object with id ${e} already exists.`);
365
- return;
366
- }
367
- this.idMap.set(e, t), this.allObjects.add(t), this.objectIds.has(t) || this.objectIds.set(t, /* @__PURE__ */ new Set()), this.objectIds.get(t).add(e), t.name && (this.nameMap.has(t.name) || this.nameMap.set(t.name, /* @__PURE__ */ new Set()), this.nameMap.get(t.name).add(t)), t.type && (this.typeMap.has(t.type) || this.typeMap.set(t.type, /* @__PURE__ */ new Set()), this.typeMap.get(t.type).add(t));
368
- }
369
- /**
370
- * Get an object by its custom id.
371
- */
372
- getById(e) {
373
- return this.idMap.get(e);
374
- }
375
- /**
376
- * Get all objects with a given name.
377
- */
378
- getByName(e) {
379
- return this.nameMap.get(e) || /* @__PURE__ */ new Set();
380
- }
381
- /**
382
- * Get all objects with a given type.
383
- */
384
- getByType(e) {
385
- return this.typeMap.get(e) || /* @__PURE__ */ new Set();
386
- }
387
- /**
388
- * Get all ids associated with an object.
389
- */
390
- getObjectIds(e) {
391
- return this.objectIds.get(e) || /* @__PURE__ */ new Set();
392
- }
393
- /**
394
- * Remove an object and all its associated ids.
395
- */
396
- remove(e) {
397
- const t = this.objectIds.get(e);
398
- if (t) {
399
- for (const s of t)
400
- this.idMap.delete(s);
401
- this.objectIds.delete(e);
402
- }
403
- if (e.name && this.nameMap.has(e.name)) {
404
- const s = this.nameMap.get(e.name);
405
- s.delete(e), s.size === 0 && this.nameMap.delete(e.name);
406
- }
407
- if (e.type && this.typeMap.has(e.type)) {
408
- const s = this.typeMap.get(e.type);
409
- s.delete(e), s.size === 0 && this.typeMap.delete(e.type);
410
- }
411
- this.allObjects.delete(e);
412
- }
413
- /**
414
- * Remove an object by its id.
415
- */
416
- removeById(e) {
417
- const t = this.idMap.get(e);
418
- t && this.remove(t);
419
- }
420
- /**
421
- * Remove all objects with a given name.
422
- */
423
- removeByName(e) {
424
- const t = this.getByName(e);
425
- for (const s of t)
426
- this.remove(s);
427
- }
428
- /**
429
- * Remove all objects with a given type.
430
- */
431
- removeByType(e) {
432
- const t = this.getByType(e);
433
- for (const s of t)
434
- this.remove(s);
435
- }
436
- /**
437
- * Clear all cached objects.
438
- */
439
- clear() {
440
- this.idMap.clear(), this.nameMap.clear(), this.typeMap.clear(), this.objectIds.clear(), this.allObjects.clear();
441
- }
442
- /**
443
- * Get all cached objects as a Set.
444
- */
445
- getAll() {
446
- return this.allObjects;
447
- }
448
- /**
449
- * Get the number of unique cached objects.
450
- */
451
- get size() {
452
- return this.allObjects.size;
453
- }
454
- /**
455
- * Show an object by id.
456
- */
457
- show(e) {
458
- const t = this.idMap.get(e);
459
- t && ee(t, !0);
460
- }
461
- /**
462
- * Hide an object by id.
463
- */
464
- hide(e) {
465
- const t = this.idMap.get(e);
466
- t && ee(t, !1);
467
- }
468
- /**
469
- * Show only the specified objects, hide all others.
470
- */
471
- isolate(e) {
472
- const t = new Set(e);
473
- for (const s of this.allObjects) {
474
- const n = this.objectIds.get(s) ?? /* @__PURE__ */ new Set();
475
- ee(s, [...n].some((i) => t.has(i)));
476
- }
477
- }
478
- /**
479
- * Set the opacity of an object's materials.
480
- */
481
- setOpacity(e, t) {
482
- const s = this.idMap.get(e);
483
- if (!s) return;
484
- const n = s;
485
- if (n.setSemanticOpacity) {
486
- n.setSemanticOpacity(t);
487
- return;
488
- }
489
- s.traverse((i) => {
490
- if (!i.isMesh) return;
491
- const r = i.material;
492
- if (!r) return;
493
- const o = Array.isArray(r) ? r : [r];
494
- for (const a of o)
495
- a.transparent = t < 1, a.opacity = t, a.needsUpdate = !0;
496
- });
497
- }
498
- /**
499
- * Get the bounding box of an object by id, or all objects if no id provided.
500
- */
501
- getBoundingBox(e) {
502
- const t = new V();
503
- if (e) {
504
- const s = this.idMap.get(e);
505
- s && t.setFromObject(s);
506
- } else
507
- for (const s of this.allObjects)
508
- t.expandByObject(s);
509
- return t;
510
- }
511
- /**
512
- * Iterate over all managed objects.
513
- */
514
- forEach(e) {
515
- for (const t of this.allObjects) {
516
- const s = this.objectIds.get(t) || /* @__PURE__ */ new Set();
517
- e(t, s);
518
- }
519
- }
520
- /**
521
- * Filter objects by a predicate.
522
- */
523
- filter(e) {
524
- const t = [];
525
- for (const s of this.allObjects)
526
- e(s) && t.push(s);
527
- return t;
528
- }
529
- /**
530
- * Show all managed objects.
531
- */
532
- showAll() {
533
- for (const e of this.allObjects)
534
- ee(e, !0);
535
- }
536
- }
537
- class Pn {
155
+ class Oi {
538
156
  scenes = /* @__PURE__ */ new Map();
539
157
  _activeSceneKey = null;
540
158
  /**
@@ -547,8 +165,8 @@ class Pn {
547
165
  * Create and register a new scene.
548
166
  */
549
167
  create(e, t = {}) {
550
- const s = new Ue();
551
- return t.background !== void 0 && (s.background = new T(t.background)), this.scenes.set(e, s), s;
168
+ const s = new Vt();
169
+ return t.background !== void 0 && (s.background = new A(t.background)), this.scenes.set(e, s), s;
552
170
  }
553
171
  /**
554
172
  * Get a scene by key.
@@ -587,7 +205,7 @@ class Pn {
587
205
  const t = this.scenes.get(e);
588
206
  if (!t) return null;
589
207
  let s = null;
590
- return t.background instanceof T && (s = `#${t.background.getHexString()}`), {
208
+ return t.background instanceof A && (s = `#${t.background.getHexString()}`), {
591
209
  name: t.name || e,
592
210
  background: s,
593
211
  environmentRotation: {
@@ -608,7 +226,7 @@ class Pn {
608
226
  return this.scenes.size;
609
227
  }
610
228
  }
611
- class On {
229
+ class Ai {
612
230
  scene;
613
231
  lights = /* @__PURE__ */ new Map();
614
232
  helpers = /* @__PURE__ */ new Map();
@@ -616,34 +234,34 @@ class On {
616
234
  this.scene = e;
617
235
  }
618
236
  addAmbient(e, t = {}) {
619
- const { color: s = 16777215, intensity: n = 0.5 } = t, i = new ct(s, n);
237
+ const { color: s = 16777215, intensity: n = 0.5 } = t, i = new Jt(s, n);
620
238
  return i.name = e, this._register(e, i), i;
621
239
  }
622
240
  addDirectional(e, t = {}) {
623
- const { color: s = 16777215, intensity: n = 1, position: i = { x: 5, y: 10, z: 5 }, castShadow: r = !1, shadowMapSize: o = 1024 } = t, a = new we(s, n);
624
- return a.position.set(i.x, i.y, i.z), a.castShadow = r, r && a.shadow.mapSize.setScalar(o), a.name = e, this._register(e, a), a;
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;
625
243
  }
626
244
  addPoint(e, t = {}) {
627
- const { color: s = 16777215, intensity: n = 1, distance: i = 0, decay: r = 2, position: o = { x: 0, y: 5, z: 0 }, castShadow: a = !1 } = t, c = new ve(s, n, i, r);
628
- return c.position.set(o.x, o.y, o.z), c.castShadow = a, c.name = e, this._register(e, c), c;
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
+ return l.position.set(o.x, o.y, o.z), l.castShadow = c, l.name = e, this._register(e, l), l;
629
247
  }
630
248
  addSpot(e, t = {}) {
631
249
  const {
632
250
  color: s = 16777215,
633
251
  intensity: n = 1,
634
252
  distance: i = 0,
635
- angle: r = Math.PI / 6,
253
+ angle: a = Math.PI / 6,
636
254
  penumbra: o = 0.1,
637
- decay: a = 2,
638
- position: c = { x: 0, y: 10, z: 0 },
639
- target: l,
640
- castShadow: d = !1
641
- } = t, p = new be(s, n, i, r, o, a);
642
- return p.position.set(c.x, c.y, c.z), l && p.target.position.set(l.x, l.y, l.z), p.castShadow = d, p.name = e, this._register(e, p), p;
255
+ decay: c = 2,
256
+ position: l = { x: 0, y: 10, z: 0 },
257
+ 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;
643
261
  }
644
262
  addHemisphere(e, t = {}) {
645
- const { skyColor: s = 8900331, groundColor: n = 3549447, intensity: i = 0.6 } = t, r = new xe(s, n, i);
646
- return r.name = e, this._register(e, r), r;
263
+ const { skyColor: s = 8900331, groundColor: n = 3549447, intensity: i = 0.6 } = t, a = new De(s, n, i);
264
+ return a.name = e, this._register(e, a), a;
647
265
  }
648
266
  /**
649
267
  * Apply a lighting preset to the scene.
@@ -680,808 +298,246 @@ class On {
680
298
  /**
681
299
  * Remove all lights managed by this manager.
682
300
  */
683
- removeAll() {
684
- const e = Array.from(this.lights.keys());
685
- for (const t of e)
686
- this.remove(t);
687
- }
688
- /**
689
- * Show a visual helper for a light.
690
- */
691
- showHelper(e) {
692
- if (this.helpers.has(e)) return;
693
- const t = this.lights.get(e);
694
- if (!t) return;
695
- let s = null;
696
- t instanceof we ? s = new ht(t, 1) : t instanceof ve ? s = new lt(t, 0.5) : t instanceof be ? s = new dt(t) : t instanceof xe && (s = new pt(t, 1)), s && (this.scene.add(s), this.helpers.set(e, s));
697
- }
698
- /**
699
- * Hide (remove) the helper for a light.
700
- */
701
- hideHelper(e) {
702
- const t = this.helpers.get(e);
703
- t && (this.scene.remove(t), this.helpers.delete(e));
704
- }
705
- /**
706
- * Show helpers for all lights.
707
- */
708
- showAllHelpers() {
709
- for (const [e] of this.lights)
710
- this.showHelper(e);
711
- }
712
- /**
713
- * Hide all helpers.
714
- */
715
- hideAllHelpers() {
716
- const e = Array.from(this.helpers.keys());
717
- for (const t of e)
718
- this.hideHelper(t);
719
- }
720
- _register(e, t) {
721
- this.lights.has(e) && this.remove(e), this.lights.set(e, t), this.scene.add(t);
722
- }
723
- dispose() {
724
- this.removeAll(), this.hideAllHelpers();
725
- }
726
- }
727
- class Ss extends ut {
728
- scene;
729
- camera;
730
- scenePass;
731
- needsUpdateOutputNode;
732
- #t;
733
- #e;
734
- #s = !1;
735
- #r = { strength: 1, radius: 0, threshold: 0 };
736
- #n = null;
737
- #o = !1;
738
- #a = {
739
- sliceCount: 1,
740
- stepCount: 12,
741
- aoIntensity: 1,
742
- giIntensity: 10,
743
- radius: 12,
744
- thickness: 1
745
- };
746
- #p = null;
747
- #h = !1;
748
- #l = null;
749
- #u = null;
750
- #d;
751
- #c;
752
- #m = !1;
753
- #f = !0;
754
- constructor(...e) {
755
- const [t, s, n] = e;
756
- super(t), this.scene = s, this.camera = n, this.scenePass = ge(s, n), this.needsUpdateOutputNode = !0, this.#t = /* @__PURE__ */ new Set(), this.#e = [], this.#d = /* @__PURE__ */ new Set(), this.#c = /* @__PURE__ */ new Map(), this.#g();
757
- }
758
- /** @deprecated Use `scenePass` instead */
759
- get currentOutputNode() {
760
- return this.scenePass;
761
- }
762
- addOverlayPass(e) {
763
- this.#t.add(e), this.needsUpdateOutputNode = !0;
764
- }
765
- removeOverlayPass(e) {
766
- this.#t.delete(e), this.needsUpdateOutputNode = !0;
767
- }
768
- setCamera(e) {
769
- this.camera = e, this.#i();
770
- }
771
- /** @deprecated Use `setOutputComposer` instead */
772
- setCurrentOutputNode(e) {
773
- this.setOutputComposer(() => e);
774
- }
775
- /** @deprecated Use `setOutputComposer(null)` instead */
776
- resetCurrentOutputNode() {
777
- this.setOutputComposer(null);
778
- }
779
- setOutputComposer(e) {
780
- this.#u = e, this.needsUpdateOutputNode = !0;
781
- }
782
- addOutputEffect(e) {
783
- return this.#d.add(e), this.needsUpdateOutputNode = !0, this;
784
- }
785
- removeOutputEffect(e) {
786
- return this.#d.delete(e), this.needsUpdateOutputNode = !0, this;
787
- }
788
- addMRTChannel(e, t) {
789
- return this.#c.get(e) === t ? this : (this.#c.set(e, t), this.#i(), this);
790
- }
791
- removeMRTChannel(e) {
792
- return this.#c.delete(e) && this.#i(), this;
793
- }
794
- enableBloom(e) {
795
- e && Object.assign(this.#r, e), this.#s = !0, this.#i();
796
- }
797
- disableBloom() {
798
- this.#s = !1, this.#n = null, this.#i();
799
- }
800
- updateBloom(e) {
801
- Object.assign(this.#r, e), this.#s && (this.needsUpdateOutputNode = !0);
802
- }
803
- enableSSGI(e) {
804
- e && Object.assign(this.#a, e), this.#o = !0, this.#i();
805
- }
806
- disableSSGI() {
807
- this.#o = !1, this.#p = null, this.#i();
808
- }
809
- updateSSGI(e) {
810
- if (Object.assign(this.#a, e), this.#p) {
811
- const t = this.#p;
812
- e.sliceCount !== void 0 && (t.sliceCount.value = e.sliceCount), e.stepCount !== void 0 && (t.stepCount.value = e.stepCount), e.aoIntensity !== void 0 && (t.aoIntensity.value = e.aoIntensity), e.giIntensity !== void 0 && (t.giIntensity.value = e.giIntensity), e.radius !== void 0 && (t.radius.value = e.radius), e.thickness !== void 0 && (t.thickness.value = e.thickness);
813
- }
814
- }
815
- enableTRAA() {
816
- this.#h = !0, this.#i();
817
- }
818
- disableTRAA() {
819
- this.#h = !1, this.#l = null, this.#i();
820
- }
821
- #i() {
822
- const e = this.scenePass;
823
- this.scenePass = ge(this.scene, this.camera), this.#g(), this.needsUpdateOutputNode = !0, e.dispose();
824
- }
825
- #g() {
826
- if (this.#s || this.#o || this.#h || this.#c.size > 0) {
827
- const t = { output: Xt };
828
- this.#c.forEach((s, n) => {
829
- n !== "output" && (t[n] = s);
830
- }), this.#s && (t.emissive = Vt), this.#o && (t.normal = Jt), this.#h && (t.velocity = Zt), this.scenePass.setMRT(qt(t));
831
- }
832
- }
833
- #y() {
834
- for (const e of this.#e)
835
- e.dispose();
836
- this.#e = [];
837
- }
838
- #w() {
839
- let e = this.scenePass.getTextureNode();
840
- if (this.#o)
841
- if (!(this.camera instanceof se))
842
- console.warn("RenderPipeline: SSGI requires a PerspectiveCamera, skipping.");
843
- else {
844
- const t = this.scenePass.getTextureNode(), s = this.scenePass.getTextureNode("depth"), n = this.scenePass.getTextureNode("normal"), i = ss(t, s, n, this.camera);
845
- i.sliceCount.value = this.#a.sliceCount, i.stepCount.value = this.#a.stepCount, i.aoIntensity.value = this.#a.aoIntensity, i.giIntensity.value = this.#a.giIntensity, i.radius.value = this.#a.radius, i.thickness.value = this.#a.thickness, this.#p = i, e = Me(e, i), this.#e.push(i);
846
- }
847
- if (this.#s) {
848
- const t = this.scenePass.getTextureNode("emissive");
849
- this.#n = ts(
850
- t,
851
- this.#r.strength,
852
- this.#r.radius,
853
- this.#r.threshold
854
- ), e = Me(e, this.#n), this.#e.push(this.#n);
855
- }
856
- return e;
857
- }
858
- #v(e) {
859
- e ? (this.#m || (this.#f = this.outputColorTransform), this.outputColorTransform = !1) : this.#m && (this.outputColorTransform = this.#f), this.#m = e;
860
- }
861
- #b() {
862
- this.#y();
863
- let e, t = !1, s = !1;
864
- const n = this.#u !== null;
865
- if (n ? e = this.#u(this.scenePass) : this.#s || this.#o ? e = this.#w() : e = this.#d.size > 0 ? this.scenePass.getTextureNode() : this.scenePass, n || this.#d.forEach((i) => {
866
- t ||= i.includesTemporalAntialias === !0, s ||= i.includesOutputTransform === !0, e = i(this.scenePass, e);
867
- }), this.#v(s), this.#h && !t) {
868
- const i = this.scenePass.getTextureNode("depth"), r = this.scenePass.getTextureNode("velocity");
869
- this.#l = ns(e, i, r, this.camera), this.#e.push(this.#l), e = this.#l;
870
- } else
871
- this.#l = null;
872
- this.#t.size > 0 && this.#t.forEach((i) => {
873
- const r = Yt(e, i);
874
- this.#e.push(r), e = r;
875
- }), this.outputNode = e, this.needsUpdate = !0;
876
- }
877
- render() {
878
- this.needsUpdateOutputNode && (this.#b(), this.needsUpdateOutputNode = !1), super.render();
879
- }
880
- dispose() {
881
- this.#y(), this.scenePass.dispose(), super.dispose();
882
- }
883
- }
884
- const Cs = {
885
- Vector2: C,
886
- Vector3: v,
887
- Vector4: ft,
888
- Quaternion: mt,
889
- Matrix4: je,
890
- Spherical: M,
891
- Box3: V,
892
- Sphere: fe,
893
- Raycaster: De
894
- };
895
- Ke.install({ THREE: Cs });
896
- class Ts extends Ke {
897
- constructor(...e) {
898
- super(...e), this.minDistance = 0.2, this.smoothTime = 0.2, this.dollySpeed = 0.2;
899
- }
900
- /**
901
- * Set absolute angle for azimuth to avoid spinning
902
- */
903
- absoluteRotations() {
904
- this.azimuthAngle = _s(this.azimuthAngle, 0);
905
- }
906
- async flyToBox(e, t = {}) {
907
- if (e.isEmpty())
908
- return console.warn("CameraControls.flyToBox: The provided Box3 is empty."), !1;
909
- this.absoluteRotations();
910
- const { viewpoint: s = "frontTop", enableTransition: n = !0, padding: i = 0.1, cover: r = !1 } = t;
911
- if (s !== "current") {
912
- const o = s.toUpperCase(), a = Be[o] ?? Be.FRONTTOP, c = a.theta, l = a.phi;
913
- if (await this.rotateTo(c, l, n), Ms.has(o))
914
- await this.fitToBox(e, n, {
915
- paddingLeft: i,
916
- paddingRight: i,
917
- paddingTop: i,
918
- paddingBottom: i,
919
- cover: r
920
- });
921
- else {
922
- const d = new fe();
923
- e.getBoundingSphere(d), d.radius += i, await this.fitToSphere(d, n);
924
- }
925
- } else {
926
- const o = new fe();
927
- e.getBoundingSphere(o), o.radius += i, await this.fitToSphere(o, n);
928
- }
929
- return !0;
930
- }
931
- async flyToObject(e, t = {}) {
932
- const s = new V().setFromObject(e);
933
- return this.flyToBox(s, t);
934
- }
935
- /**
936
- * Fly camera to a specific position and look-at target.
937
- */
938
- async flyTo(e, t, s = {}) {
939
- const { enableTransition: n = !0 } = s;
940
- return this.absoluteRotations(), this.setLookAt(e.x, e.y, e.z, t.x, t.y, t.z, n);
941
- }
942
- /**
943
- * Get the current camera viewpoint data (position, target, zoom).
944
- */
945
- getCameraViewpoint() {
946
- const e = new v(), t = new v();
947
- return this.getPosition(e), this.getTarget(t), {
948
- position: { x: e.x, y: e.y, z: e.z },
949
- target: { x: t.x, y: t.y, z: t.z },
950
- zoom: this.camera.zoom
951
- };
952
- }
953
- /**
954
- * Lock camera controls (disable all user interaction).
955
- */
956
- lock() {
957
- this.enabled = !1;
958
- }
959
- /**
960
- * Unlock camera controls (re-enable user interaction).
961
- */
962
- unlock() {
963
- this.enabled = !0;
964
- }
965
- /**
966
- * Switch between 2D top-down and 3D perspective views.
967
- */
968
- async setViewMode(e, t = !0) {
969
- if (e === "2d") {
970
- const s = new v();
971
- this.getTarget(s), await this.rotateTo(0, 0, t), this.minPolarAngle = 0, this.maxPolarAngle = 0;
972
- } else
973
- this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, await this.rotateTo(0, Math.PI / 4, t);
974
- }
975
- async setCameraViewpoint(e, t = !0) {
976
- const { position: s, target: n, zoom: i = this.camera.zoom } = e;
977
- return Promise.all([
978
- this.zoomTo(i, t),
979
- this.setLookAt(s.x, s.y, s.z, n.x, n.y, n.z, t)
980
- ]);
981
- }
982
- }
983
- const Be = {
984
- LEFT: new M(0, Math.PI / 2, -Math.PI / 2),
985
- RIGHT: new M(0, Math.PI / 2, Math.PI / 2),
986
- FRONT: new M(0, Math.PI / 2, 0),
987
- BACK: new M(0, Math.PI / 2, Math.PI),
988
- TOP: new M(0, 0, 0),
989
- BOTTOM: new M(0, Math.PI, 0),
990
- FRONTTOP: new M(0, Math.PI / 4, 0),
991
- BACKTOP: new M(0, Math.PI / 4, Math.PI),
992
- LEFTTOP: new M(0, Math.PI / 4, -Math.PI / 2),
993
- RIGHTTOP: new M(0, Math.PI / 4, Math.PI / 2),
994
- LEFTFRONTTOP: new M(0, Math.PI / 4, -Math.PI / 4),
995
- RIGHTFRONTTOP: new M(0, Math.PI / 4, Math.PI / 4),
996
- LEFTBACKTOP: new M(0, Math.PI / 4, -Math.PI / 4 * 3),
997
- RIGHTBACKTOP: new M(0, Math.PI / 4, Math.PI / 4 * 3)
998
- }, Ms = /* @__PURE__ */ new Set(["LEFT", "RIGHT", "FRONT", "BACK", "TOP", "BOTTOM"]);
999
- function _s(h, e) {
1000
- const t = h - e;
1001
- return gt.euclideanModulo(t + Math.PI, Math.PI * 2) - Math.PI;
1002
- }
1003
- class Es {
1004
- environment = new is();
1005
- renderer;
1006
- pmremGenerator;
1007
- envMap = null;
1008
- constructor(e) {
1009
- this.renderer = e, this.pmremGenerator = new yt(e);
1010
- }
1011
- update() {
1012
- this.envMap || (this.envMap = this.pmremGenerator.fromScene(this.environment).texture);
1013
- }
1014
- dispose() {
1015
- this.pmremGenerator.dispose(), this.envMap?.dispose();
1016
- }
1017
- }
1018
- const te = 128;
1019
- class Ps extends rs {
1020
- viewer;
1021
- overlayPass;
1022
- constructor(e) {
1023
- super(e.camera, e.el), this.viewer = e;
1024
- const t = new ne(-2, 2, 2, -2, 0, 4);
1025
- t.position.set(0, 0, 2), this.overlayPass = ge(this, t), this.setLabels("x", "y", "z");
1026
- }
1027
- _update = () => {
1028
- this.quaternion.copy(this.viewer.camera.quaternion).invert();
1029
- const e = this.location;
1030
- let t, s;
1031
- e.left !== null ? t = e.left : t = this.viewer.el.offsetWidth - te - e.right, e.top !== null ? s = e.top : s = this.viewer.el.offsetHeight - te - e.bottom, this.overlayPass.setViewport(t, s, te, te);
1032
- };
1033
- enable() {
1034
- return this.viewer.renderPipeline.addOverlayPass(this.overlayPass), this.viewer.addEventListener("beforeRender", this._update), this.viewer.render(), this;
1035
- }
1036
- disable() {
1037
- return this.viewer.renderPipeline.removeOverlayPass(this.overlayPass), this.viewer.removeEventListener("beforeRender", this._update), this.viewer.render(), this;
1038
- }
1039
- }
1040
- const qe = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;overflow:hidden;", Os = qe + "z-index:0;", As = qe + "z-index:1;";
1041
- class Bs {
1042
- el;
1043
- css2dRenderer = null;
1044
- css3dRenderer = null;
1045
- constructor(e) {
1046
- this.el = e, getComputedStyle(e).position === "static" && (e.style.position = "relative");
1047
- }
1048
- initCSS2DRenderer() {
1049
- const e = new os();
1050
- return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = As, this.el.appendChild(e.domElement), this.css2dRenderer = e, e;
1051
- }
1052
- initCSS3DRenderer() {
1053
- const e = new cs();
1054
- return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = Os, this.el.appendChild(e.domElement), this.css3dRenderer = e, e;
1055
- }
1056
- createCSS2DObject(e) {
1057
- return this.css2dRenderer || this.initCSS2DRenderer(), new as(e);
1058
- }
1059
- createCSS25DObject(e) {
1060
- return this.css3dRenderer || this.initCSS3DRenderer(), new hs(e);
1061
- }
1062
- createCSS3DObject(e) {
1063
- return this.css3dRenderer || this.initCSS3DRenderer(), new ls(e);
1064
- }
1065
- render(e, t) {
1066
- this.css2dRenderer && this.css2dRenderer.render(e, t), this.css3dRenderer && this.css3dRenderer.render(e, t);
1067
- }
1068
- resize(e, t) {
1069
- this.css2dRenderer && this.css2dRenderer.setSize(e, t), this.css3dRenderer && this.css3dRenderer.setSize(e, t);
1070
- }
1071
- dispose() {
1072
- this.css2dRenderer && (this.el.removeChild(this.css2dRenderer.domElement), this.css2dRenderer = null), this.css3dRenderer && (this.el.removeChild(this.css3dRenderer.domElement), this.css3dRenderer = null);
1073
- }
1074
- }
1075
- const Rs = "timestamp-query";
1076
- class Is {
1077
- el;
1078
- renderer;
1079
- container;
1080
- drawCallsText;
1081
- frameCallsText;
1082
- trianglesText;
1083
- pointsText;
1084
- linesText;
1085
- timestampText;
1086
- _enabled = !1;
1087
- #t = !1;
1088
- constructor(e, t) {
1089
- this.el = e, this.renderer = t;
1090
- const s = document.createElement("div");
1091
- s.style.position = "absolute", s.style.left = "12px", s.style.bottom = "12px", s.style.fontSize = "12px", s.style.color = "#fff", s.style.pointerEvents = "none", this.container = s;
1092
- function n(r, o = !0) {
1093
- const a = document.createElement("span");
1094
- return o && (a.style.marginLeft = "6px"), a.innerText = r, a;
1095
- }
1096
- function i() {
1097
- return document.createElement("br");
1098
- }
1099
- this.drawCallsText = n("0"), this.frameCallsText = n("0"), this.trianglesText = n("0"), this.linesText = n("0"), this.pointsText = n("0"), this.timestampText = n("0"), this.container.appendChild(n("draw calls", !1)), this.container.appendChild(this.drawCallsText), this.container.appendChild(i()), this.container.appendChild(n("frame calls", !1)), this.container.appendChild(this.frameCallsText), this.container.appendChild(i()), this.container.appendChild(n("triangles", !1)), this.container.appendChild(this.trianglesText), this.container.appendChild(i()), this.container.appendChild(n("points", !1)), this.container.appendChild(this.pointsText), this.container.appendChild(i()), this.container.appendChild(n("lines", !1)), this.container.appendChild(this.linesText), this.container.appendChild(i()), this.container.appendChild(n("timestamp", !1)), this.container.appendChild(this.timestampText), this.container.appendChild(i());
1100
- }
1101
- update() {
1102
- if (this._enabled) {
1103
- const { render: e } = this.renderer.info;
1104
- if (this.drawCallsText.innerText = e.drawCalls.toString(), this.frameCallsText.innerText = e.frameCalls.toString(), this.trianglesText.innerText = e.triangles.toString(), this.pointsText.innerText = e.points.toString(), this.linesText.innerText = e.lines.toString(), !this.#t) {
1105
- this.timestampText.innerText = "0";
1106
- return;
1107
- }
1108
- this.#n(Z.RENDER).then((t) => {
1109
- this._enabled && (this.timestampText.innerText = t?.toFixed(2) ?? "0");
1110
- }), this.#n(Z.COMPUTE);
1111
- }
1112
- }
1113
- enable() {
1114
- this._enabled = !0, this.#r(!0), this.el.appendChild(this.container);
1115
- }
1116
- disable() {
1117
- this._enabled = !1, this.#r(!1), this.#o(), this.container.remove();
1118
- }
1119
- dispose() {
1120
- this.disable();
1121
- }
1122
- #e() {
1123
- return this.renderer.backend;
1124
- }
1125
- #s() {
1126
- try {
1127
- return this.renderer.hasFeature(Rs);
1128
- } catch {
1129
- return !0;
1130
- }
1131
- }
1132
- #r(e) {
1133
- const t = this.#e();
1134
- if (!t) {
1135
- this.#t = !1;
1136
- return;
1137
- }
1138
- t.trackTimestamp = e && this.#s(), this.#t = t.trackTimestamp === !0;
1139
- }
1140
- #n(e) {
1141
- const t = this.#e()?.timestampQueryPool?.[e];
1142
- return t?.resolveQueriesAsync ? Promise.resolve(t.resolveQueriesAsync()).catch(() => {
1143
- }) : Promise.resolve(void 0);
1144
- }
1145
- #o() {
1146
- this.#n(Z.RENDER), this.#n(Z.COMPUTE);
1147
- }
1148
- }
1149
- wt.enabled = !0;
1150
- class An extends ke {
1151
- el;
1152
- renderer;
1153
- scene;
1154
- camera;
1155
- info;
1156
- controls;
1157
- renderPipeline;
1158
- timer;
1159
- roomEnvironment;
1160
- interactionManager;
1161
- objectManager;
1162
- viewerHelper;
1163
- cssRenderer;
1164
- frameCount = 1;
1165
- frameloop = "demand";
1166
- constructor({ el: e, rendererOptions: t }) {
1167
- super(), this.el = e, this.renderer = this._initRenderer(t), this.scene = this.createScene(), this.camera = this.createPerspectiveCamera(), this.info = new Is(this.el, this.renderer), this.controls = new Ts(this.camera, this.renderer.domElement), this.renderPipeline = new Ss(this.renderer, this.scene, this.camera), this.timer = new vt(), this.roomEnvironment = new Es(this.renderer), this.interactionManager = new bs(this.renderer.domElement, this.scene, this.camera), this.objectManager = new xs(), this.viewerHelper = new Ps(this), this.cssRenderer = new Bs(this.el), window.addEventListener("resize", this.onWindowResize);
1168
- }
1169
- onWindowResize = () => {
1170
- const e = this.el.clientWidth, t = this.el.clientHeight;
1171
- this.camera instanceof se ? (this.camera.aspect = e / t, this.camera.updateProjectionMatrix()) : this.camera instanceof ne && (this.camera.left = -e / 2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = -t / 2, this.camera.updateProjectionMatrix()), this.renderer.setSize(e, t), this.cssRenderer.resize(e, t), this.render();
1172
- };
1173
- async init() {
1174
- await this.renderer.init(), this.roomEnvironment.update(), this.scene.environment = this.roomEnvironment.envMap;
1175
- }
1176
- setCamera(e) {
1177
- this.camera = e, this.controls.camera = e, this.interactionManager.setCamera(e), this.renderPipeline.setCamera(e), this.onWindowResize(), this.dispatchEvent({ type: "cameraChange", camera: e });
1178
- }
1179
- setCameraByType(e) {
1180
- e === "perspective" && !(this.camera instanceof se) ? this.setCamera(this.createPerspectiveCamera()) : e === "orthographic" && !(this.camera instanceof ne) && this.setCamera(this.createOrthographicCamera());
1181
- }
1182
- render(e = 1) {
1183
- return this.frameCount += e, new Promise((t) => {
1184
- const s = () => {
1185
- this.removeEventListener("afterRender", s), t();
1186
- };
1187
- this.addEventListener("afterRender", s);
1188
- });
1189
- }
1190
- animate = (e) => {
1191
- this.timer.update(e);
1192
- const t = this.timer.getDelta();
1193
- this.dispatchEvent({ type: "beforeControlsUpdate", time: e, delta: t });
1194
- let s = this.controls.update(t);
1195
- this.dispatchEvent({ type: "afterControlsUpdate", time: e, delta: t }), this.frameCount > 0 && (this.frameCount--, s = !0), this.frameloop === "always" && (s = !0), s && (this.dispatchEvent({ type: "beforeRender", time: e, delta: t }), this.renderer.info.reset(), this.renderPipeline.render(), this.cssRenderer.render(this.scene, this.camera), this.info.update(), this.dispatchEvent({ type: "afterRender", time: e, delta: t }));
1196
- };
1197
- _initRenderer(e) {
1198
- const t = new bt({
1199
- reversedDepthBuffer: !0,
1200
- antialias: !1,
1201
- depth: !1,
1202
- trackTimestamp: !1,
1203
- ...e
1204
- });
1205
- return t.setSize(this.el.clientWidth, this.el.clientHeight), t.shadowMap.enabled = !0, t.shadowMap.type = xt, t.toneMapping = St, t.toneMappingExposure = 1, t.info.autoReset = !1, t.setPixelRatio(Math.min(window.devicePixelRatio, 1.5)), t.setAnimationLoop(this.animate), this.el.appendChild(t.domElement), t;
1206
- }
1207
- createScene() {
1208
- const e = new Ue();
1209
- return e.background = new T(0), e;
1210
- }
1211
- createPerspectiveCamera() {
1212
- const e = new se(50, this.el.clientWidth / this.el.clientHeight, 0.1, 1e5);
1213
- return e.position.setScalar(5), e;
1214
- }
1215
- createOrthographicCamera() {
1216
- const e = new ne(
1217
- -this.el.clientWidth / 2,
1218
- this.el.clientWidth / 2,
1219
- this.el.clientHeight / 2,
1220
- -this.el.clientHeight / 2,
1221
- 0.1,
1222
- 1e5
1223
- );
1224
- return e.position.setScalar(5), e;
1225
- }
1226
- /**
1227
- * Manually trigger a resize update.
1228
- */
1229
- resize(e, t) {
1230
- e !== void 0 && t !== void 0 && (this.el.style.width = `${e}px`, this.el.style.height = `${t}px`), this.onWindowResize();
1231
- }
1232
- /**
1233
- * Capture a screenshot of the current render.
1234
- */
1235
- async screenshot(e = {}) {
1236
- const { type: t = "image/png", quality: s = 1 } = e, n = this.el.clientWidth, i = this.el.clientHeight, r = e.width && e.height;
1237
- r && this.renderer.setSize(e.width, e.height), await this.render();
1238
- const o = this.renderer.domElement.toDataURL(t, s);
1239
- return r && (this.renderer.setSize(n, i), this.onWindowResize()), o;
1240
- }
1241
- /**
1242
- * Set the scene background color, texture, or null.
1243
- */
1244
- setBackground(e) {
1245
- e === null ? this.scene.background = null : e instanceof T || typeof e == "number" || typeof e == "string" ? this.scene.background = new T(e) : this.scene.background = e, this.render();
1246
- }
1247
- /**
1248
- * Set the scene environment map for reflections / IBL.
1249
- */
1250
- setEnvironment(e) {
1251
- this.scene.environment = e, this.render();
1252
- }
1253
- /**
1254
- * Enable shadow rendering.
1255
- */
1256
- enableShadow() {
1257
- this.renderer.shadowMap.enabled = !0, this.render();
301
+ removeAll() {
302
+ const e = Array.from(this.lights.keys());
303
+ for (const t of e)
304
+ this.remove(t);
1258
305
  }
1259
306
  /**
1260
- * Disable shadow rendering.
307
+ * Show a visual helper for a light.
1261
308
  */
1262
- disableShadow() {
1263
- this.renderer.shadowMap.enabled = !1, this.render();
309
+ showHelper(e) {
310
+ if (this.helpers.has(e)) return;
311
+ const t = this.lights.get(e);
312
+ if (!t) return;
313
+ 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));
1264
315
  }
1265
316
  /**
1266
- * Enable linear fog.
317
+ * Hide (remove) the helper for a light.
1267
318
  */
1268
- enableFog(e = {}) {
1269
- const { color: t = 13421772, near: s = 10, far: n = 100 } = e;
1270
- this.scene.fog = new Ct(t, s, n), this.render();
319
+ hideHelper(e) {
320
+ const t = this.helpers.get(e);
321
+ t && (this.scene.remove(t), this.helpers.delete(e));
1271
322
  }
1272
323
  /**
1273
- * Enable exponential fog.
324
+ * Show helpers for all lights.
1274
325
  */
1275
- enableFogExp2(e = {}) {
1276
- const { color: t = 13421772, density: s = 0.01 } = e;
1277
- this.scene.fog = new Tt(t, s), this.render();
326
+ showAllHelpers() {
327
+ for (const [e] of this.lights)
328
+ this.showHelper(e);
1278
329
  }
1279
330
  /**
1280
- * Disable fog.
331
+ * Hide all helpers.
1281
332
  */
1282
- disableFog() {
1283
- this.scene.fog = null, this.render();
333
+ hideAllHelpers() {
334
+ const e = Array.from(this.helpers.keys());
335
+ for (const t of e)
336
+ this.hideHelper(t);
337
+ }
338
+ _register(e, t) {
339
+ this.lights.has(e) && this.remove(e), this.lights.set(e, t), this.scene.add(t);
1284
340
  }
1285
341
  dispose() {
1286
- this.el.removeChild(this.renderer.domElement), window.removeEventListener("resize", this.onWindowResize), this.info.dispose(), this.interactionManager.dispose(), this.roomEnvironment.dispose(), this.cssRenderer.dispose(), this.renderPipeline.dispose(), this.renderer.dispose();
342
+ this.removeAll(), this.hideAllHelpers();
1287
343
  }
1288
344
  }
1289
- class Ls extends Qe {
345
+ class tn extends Tt {
1290
346
  constructor(e) {
1291
347
  super(e);
1292
348
  }
1293
349
  parse(e, t, s, n) {
1294
- if (zs(e.slice(0, 8)) === "SBMG----") {
1295
- const r = Ns(e.slice(8));
1296
- return super.parse(r, t, s, n);
350
+ if (sn(e.slice(0, 8)) === "SBMG----") {
351
+ const a = nn(e.slice(8));
352
+ return super.parse(a, t, s, n);
1297
353
  } else
1298
354
  return super.parse(e, t, s, n);
1299
355
  }
1300
356
  }
1301
- function zs(h) {
1302
- return new TextDecoder().decode(new Uint8Array(h));
357
+ function sn(r) {
358
+ return new TextDecoder().decode(new Uint8Array(r));
1303
359
  }
1304
- function Ns(h) {
1305
- const e = new DataView(h);
360
+ function nn(r) {
361
+ const e = new DataView(r);
1306
362
  for (let t = 0; t < e.byteLength; t++) {
1307
363
  const s = e.getUint8(t), n = (s >> 4 & 15) + (s << 4 & 240);
1308
364
  e.setUint8(t, n);
1309
365
  }
1310
366
  return e.buffer;
1311
367
  }
1312
- const Ds = 8, ks = 130, Re = 66, js = "SBK-----", Us = "SBM-----", Xe = new TextDecoder(), Hs = new TextEncoder();
1313
- function Fs(h) {
1314
- let e = Ds;
1315
- const t = new Uint8Array(h, 0, e);
1316
- if (Xe.decode(t) !== js)
1317
- return h;
1318
- e += ks;
1319
- const n = new Uint8Array(h, 0, e);
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);
1320
376
  if (n[40] === 1) {
1321
- const r = Hs.encode(Us), o = new Uint8Array([n[41]]), a = Gs(n), c = $s(a);
1322
- let l = Re % c.length;
1323
- const d = e + Re, p = new Uint8Array(h, d), u = new Uint8Array(p.length);
1324
- for (let w = 0; w < p.length; w++)
1325
- u[w] = p[w] ^ c[l], l = (l + 1) % c.length;
1326
- const m = new Uint8Array(r.length + o.length + u.length);
1327
- return m.set(r), m.set(o, r.length), m.set(u, r.length + o.length), m.buffer;
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;
1328
384
  }
1329
385
  }
1330
- function Gs(h) {
386
+ function un(r) {
1331
387
  const e = new Uint8Array(128);
1332
- return e.set(h.slice(42, 74), 0), e.set(h.slice(74, 138), 32), e.set(h.slice(8, 40), 96), e;
388
+ return e.set(r.slice(42, 74), 0), e.set(r.slice(74, 138), 32), e.set(r.slice(8, 40), 96), e;
1333
389
  }
1334
- function $s(h) {
390
+ function dn(r) {
1335
391
  const e = new Uint8Array(64);
1336
- return e.set(h.slice(0, 8), 0), e.set(h.slice(24, 32), 8), e.set(h.slice(40, 56), 16), e.set(h.slice(64, 88), 32), e.set(h.slice(96, 104), 56), e;
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;
1337
393
  }
1338
- const Ws = (h, e, t) => {
1339
- const s = h.buffer.slice(t, t + e);
1340
- let n = Xe.decode(s);
394
+ const pn = (r, e, t) => {
395
+ const s = r.buffer.slice(t, t + e);
396
+ let n = Pt.decode(s);
1341
397
  return n = n.replace("\\", "/"), n.startsWith("Maps/") || (n = `Maps/${n}`), n;
1342
- }, Ks = (h, e, t) => {
1343
- const [s, n, i, r, o] = e, a = t || r < 1;
1344
- return new L({
1345
- name: h,
1346
- color: new T(s, n, i),
1347
- opacity: r,
1348
- transparent: a,
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),
403
+ opacity: a,
404
+ transparent: c,
1349
405
  alphaTest: 0.01,
1350
406
  side: o
1351
407
  });
1352
- }, Qs = (h) => h?.toLowerCase().endsWith(".png") ?? !1;
1353
- class qs {
408
+ }, fn = (r) => r?.toLowerCase().endsWith(".png") ?? !1;
409
+ class gn {
1354
410
  data;
1355
411
  options;
1356
412
  textureLoader;
1357
413
  littleEndian = !0;
1358
414
  materials = /* @__PURE__ */ new Map();
1359
415
  constructor(e, t) {
1360
- this.data = e, this.options = t, this.textureLoader = new Fe(t.manager), this.textureLoader.setCrossOrigin(t.crossOrigin), this.textureLoader.setRequestHeader(t.requestHeader);
416
+ this.data = e, this.options = t, this.textureLoader = new Ct(t.manager), this.textureLoader.setCrossOrigin(t.crossOrigin), this.textureLoader.setRequestHeader(t.requestHeader);
1361
417
  }
1362
418
  parse(e, t) {
1363
419
  let s = this.data;
1364
- const n = Fs(this.data);
420
+ const n = hn(this.data);
1365
421
  n && (s = n);
1366
422
  const i = new DataView(s);
1367
- let r = 8;
1368
- const o = i.getUint8(r);
1369
- r += 1, o === 1 ? this._parseV2(i, r, e) : o === 2 ? this._parseV2(i, r, e) : o === 3 ? this._parseV3(i, r, e) : t?.(new Error(`SBMLoader: Unsupported SBM version: ${o}`));
423
+ 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}`));
1370
426
  }
1371
427
  _parseV2(e, t, s) {
1372
- const n = new I(), i = e.getUint16(t, this.littleEndian);
428
+ const n = new H(), i = e.getUint16(t, this.littleEndian);
1373
429
  t += 2;
1374
- const r = e.getUint16(t, this.littleEndian);
430
+ const a = e.getUint16(t, this.littleEndian);
1375
431
  t += 2;
1376
432
  for (let o = 0; o < i; ++o) {
1377
- const a = e.getUint16(t, this.littleEndian).toString();
433
+ const c = e.getUint16(t, this.littleEndian).toString();
1378
434
  t += 2, t += 4, t += 4, t += 4, t += 4;
1379
- const c = e.getFloat32(t, this.littleEndian);
1380
- t += 4;
1381
435
  const l = e.getFloat32(t, this.littleEndian);
1382
436
  t += 4;
1383
- const d = e.getFloat32(t, this.littleEndian);
437
+ const h = e.getFloat32(t, this.littleEndian);
438
+ t += 4;
439
+ const u = e.getFloat32(t, this.littleEndian);
1384
440
  t += 4;
1385
- const p = e.getFloat32(t, this.littleEndian);
441
+ const d = e.getFloat32(t, this.littleEndian);
1386
442
  t += 4, t += 4, t += 4, t += 4, t += 4;
1387
- let u = e.getUint8(t);
1388
- t += 1, u === 0 ? u = _t : u === 1 ? u = Et : u === 2 && (u = Pt);
443
+ let p = e.getUint8(t);
444
+ t += 1, p === 0 ? p = is : p === 1 ? p = rs : p === 2 && (p = as);
1389
445
  const m = e.getUint16(t, this.littleEndian);
1390
446
  t += 2;
1391
- const w = m > 0 ? Ws(e, m, t) : "";
1392
- if (t += m, !this.materials.has(a)) {
1393
- const x = Ks(a, [c, l, d, p, u], Qs(w));
1394
- this.materials.set(a, x), w && this.options.path && this.textureLoader.load(R.resolveURL(w, this.options.path), (y) => {
1395
- y.colorSpace = Ge, y.wrapS = Se, y.wrapT = Se, y.flipY = !1, y.anisotropy = 16, x.map = y;
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;
1396
452
  });
1397
453
  }
1398
454
  }
1399
- for (let o = 0; o < r; ++o) {
1400
- const a = e.getUint16(t, this.littleEndian).toString();
1401
- t += 2;
455
+ for (let o = 0; o < a; ++o) {
1402
456
  const c = e.getUint16(t, this.littleEndian).toString();
1403
457
  t += 2;
1404
- const l = [], d = [], p = [], u = [], m = e.getUint16(t, this.littleEndian);
458
+ const l = e.getUint16(t, this.littleEndian).toString();
459
+ t += 2;
460
+ const h = [], u = [], d = [], p = [], m = e.getUint16(t, this.littleEndian);
1405
461
  if (t += 2, m > 0)
1406
- for (let g = 0; g < m; g++) {
1407
- const b = new v();
1408
- b.setX(e.getFloat32(t, this.littleEndian)), t += 4, b.setY(e.getFloat32(t, this.littleEndian)), t += 4, b.setZ(e.getFloat32(t, this.littleEndian)), t += 4, l.push(b);
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(_);
1409
465
  }
1410
- const w = e.getUint16(t, this.littleEndian);
1411
- if (t += 2, w > 0)
1412
- for (let g = 0; g < w; g++)
466
+ const b = e.getUint16(t, this.littleEndian);
467
+ if (t += 2, b > 0)
468
+ for (let y = 0; y < b; y++)
1413
469
  t += 4, t += 4, t += 4;
1414
470
  const S = e.getUint16(t, this.littleEndian);
1415
471
  if (t += 2, S > 0)
1416
- for (let g = 0; g < S; g++) {
1417
- const b = new C();
1418
- b.setX(e.getFloat32(t, this.littleEndian)), t += 4, b.setY(e.getFloat32(t, this.littleEndian)), t += 4, d.push(b);
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(_);
1419
475
  }
1420
- const x = e.getUint16(t, this.littleEndian);
1421
- if (t += 2, x > 0)
1422
- for (let g = 0; g < x; g++) {
1423
- const b = e.getUint16(t, this.littleEndian);
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);
1424
480
  t += 2;
1425
- const z = e.getUint16(t, this.littleEndian);
481
+ const k = e.getUint16(t, this.littleEndian);
1426
482
  t += 2;
1427
483
  const N = e.getUint16(t, this.littleEndian);
1428
484
  t += 2;
1429
- const P = [b, z, N];
1430
- p.push(P), d.length > 0 && u.push([d[P[0]], d[P[1]], d[P[2]]]);
485
+ const D = [_, k, N];
486
+ d.push(D), u.length > 0 && p.push([u[D[0]], u[D[1]], u[D[2]]]);
1431
487
  }
1432
- const y = [], _ = [];
1433
- for (let g = 0; g < p.length; g++) {
1434
- const b = p[g], z = l[b[0]], N = l[b[1]], P = l[b[2]];
1435
- y.push(...z.toArray(), ...N.toArray(), ...P.toArray());
1436
- let J = new C(), W = new C(), j = new C();
1437
- const U = u[g];
1438
- U !== void 0 && (J = U[0], W = U[1], j = U[2]), _.push(...J.toArray(), ...W.toArray(), ...j.toArray());
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());
1439
495
  }
1440
- const A = new Float32Array(y), B = new Float32Array(_), E = new Q();
1441
- if (A.length > 0 && E.setAttribute("position", new Ce(A, 3)), B.length > 0 && E.setAttribute("uv", new Ce(B, 2)), E.computeVertexNormals(), this.materials.has(c)) {
1442
- const g = new k(E, this.materials.get(c));
1443
- g.name = a, g.castShadow = !0, g.receiveShadow = !0, n.add(g);
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);
1444
500
  }
1445
501
  }
1446
502
  s(n);
1447
503
  }
1448
504
  _parseV3(e, t, s) {
1449
- const n = new I();
505
+ const n = new H();
1450
506
  console.warn("SBMLoader: SBM version 3 is not supported yet."), s(n);
1451
507
  }
1452
508
  }
1453
- class Xs extends Mt {
509
+ class yn extends ns {
1454
510
  load(e, t, s, n) {
1455
511
  let i;
1456
512
  if (this.resourcePath !== "")
1457
513
  i = this.resourcePath;
1458
514
  else if (this.path !== "") {
1459
- const a = R.extractUrlBase(e);
1460
- i = R.resolveURL(a, this.path);
515
+ const c = G.extractUrlBase(e);
516
+ i = G.resolveURL(c, this.path);
1461
517
  } else
1462
- i = R.extractUrlBase(e);
518
+ i = G.extractUrlBase(e);
1463
519
  this.manager.itemStart(e);
1464
- const r = (a) => {
1465
- n ? n(a) : console.error(a), this.manager.itemError(e), this.manager.itemEnd(e);
1466
- }, o = new He(this.manager);
520
+ const a = (c) => {
521
+ n ? n(c) : console.error(c), this.manager.itemError(e), this.manager.itemEnd(e);
522
+ }, o = new _t(this.manager);
1467
523
  o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(
1468
524
  e,
1469
- (a) => {
525
+ (c) => {
1470
526
  try {
1471
527
  this.parse(
1472
- a,
528
+ c,
1473
529
  i,
1474
- (c) => {
1475
- t(c), this.manager.itemEnd(e);
530
+ (l) => {
531
+ t(l), this.manager.itemEnd(e);
1476
532
  },
1477
- r
533
+ a
1478
534
  );
1479
- } catch (c) {
1480
- r(c);
535
+ } catch (l) {
536
+ a(l);
1481
537
  }
1482
538
  },
1483
539
  s,
1484
- r
540
+ a
1485
541
  );
1486
542
  }
1487
543
  parse(e, t, s, n) {
@@ -1490,7 +546,7 @@ class Xs extends Mt {
1490
546
  n?.(new Error(`SBMLoader: Invalid SBM format: ${i}`));
1491
547
  return;
1492
548
  }
1493
- new qs(e, {
549
+ new gn(e, {
1494
550
  path: t,
1495
551
  crossOrigin: this.crossOrigin,
1496
552
  requestHeader: this.requestHeader,
@@ -1512,7 +568,7 @@ class Xs extends Mt {
1512
568
  });
1513
569
  }
1514
570
  }
1515
- const Ys = [
571
+ const bn = [
1516
572
  "map",
1517
573
  "alphaMap",
1518
574
  "aoMap",
@@ -1539,36 +595,36 @@ const Ys = [
1539
595
  "thicknessMap",
1540
596
  "transmissionMap"
1541
597
  ];
1542
- function K(h) {
1543
- return h.traverse((e) => {
1544
- if (!(e instanceof k)) return;
598
+ function oe(r) {
599
+ return r.traverse((e) => {
600
+ if (!(e instanceof P)) return;
1545
601
  const t = Array.isArray(e.material) ? e.material : [e.material];
1546
602
  for (const s of t) {
1547
603
  if (!s) continue;
1548
604
  let n = !1;
1549
- for (const i of Ys) {
1550
- const r = s[i];
1551
- r?.isTexture && r.image == null && (r.dispose(), s[i] = null, n = !0);
605
+ for (const i of bn) {
606
+ const a = s[i];
607
+ a?.isTexture && a.image == null && (a.dispose(), s[i] = null, n = !0);
1552
608
  }
1553
609
  n && (s.needsUpdate = !0);
1554
610
  }
1555
- }), h;
611
+ }), r;
1556
612
  }
1557
- class D {
613
+ class X {
1558
614
  static CACHE_NAME = "u-space-model-loader-cache";
1559
- static fileLoader = new He().setResponseType("arraybuffer");
1560
- static dracoLoader = new ms().setDecoderPath(
1561
- `https://cdn.jsdelivr.net/npm/three@0.${Te}.0/examples/jsm/libs/draco/`
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/`
1562
618
  );
1563
- static ktx2Loader = new fs().setTranscoderPath(
1564
- `https://cdn.jsdelivr.net/npm/three@0.${Te}.0/examples/jsm/libs/basis/`
619
+ static ktx2Loader = new Fs().setTranscoderPath(
620
+ `https://cdn.jsdelivr.net/npm/three@0.${ke}.0/examples/jsm/libs/basis/`
1565
621
  );
1566
- static gltfLoader = new Qe().setDRACOLoader(D.dracoLoader).setKTX2Loader(D.ktx2Loader).setMeshoptDecoder(Ae);
1567
- static sbmxLoader = new Ls().setDRACOLoader(D.dracoLoader).setKTX2Loader(D.ktx2Loader).setMeshoptDecoder(Ae);
1568
- static sbmLoader = new Xs();
1569
- static fbxLoader = new ds();
1570
- static objLoader = new ps();
1571
- static stlLoader = new us();
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();
1572
628
  static setLoadingManager(e) {
1573
629
  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;
1574
630
  }
@@ -1596,23 +652,23 @@ class D {
1596
652
  switch (t.persistent && typeof caches < "u" ? n = await this.getPersistentData(e) : n = await this.fileLoader.loadAsync(e), s) {
1597
653
  case "gltf":
1598
654
  case "glb":
1599
- const i = await this.gltfLoader.parseAsync(n, R.extractUrlBase(e));
1600
- return i.scene.animations = i.animations, K(i.scene);
655
+ const i = await this.gltfLoader.parseAsync(n, G.extractUrlBase(e));
656
+ return i.scene.animations = i.animations, oe(i.scene);
1601
657
  case "sbmx":
1602
- const r = await this.sbmxLoader.parseAsync(n, R.extractUrlBase(e));
1603
- return r.scene.animations = r.animations, K(r.scene);
658
+ const a = await this.sbmxLoader.parseAsync(n, G.extractUrlBase(e));
659
+ return a.scene.animations = a.animations, oe(a.scene);
1604
660
  case "sbm":
1605
- const o = await this.sbmLoader.parseAsync(n, R.extractUrlBase(e));
1606
- return K(o);
661
+ const o = await this.sbmLoader.parseAsync(n, G.extractUrlBase(e));
662
+ return oe(o);
1607
663
  case "fbx":
1608
- const a = this.fbxLoader.parse(n, R.extractUrlBase(e));
1609
- return K(a);
664
+ const c = this.fbxLoader.parse(n, G.extractUrlBase(e));
665
+ return oe(c);
1610
666
  case "obj":
1611
- const c = new TextDecoder().decode(n), l = this.objLoader.parse(c);
1612
- return K(l);
667
+ const l = new TextDecoder().decode(n), h = this.objLoader.parse(l);
668
+ return oe(h);
1613
669
  case "stl":
1614
- const d = this.stlLoader.parse(n);
1615
- return new k(d, new L());
670
+ const u = this.stlLoader.parse(n);
671
+ return new P(u, new K());
1616
672
  default:
1617
673
  throw new Error(`Unsupported model format: ${s}`);
1618
674
  }
@@ -1629,10 +685,10 @@ class D {
1629
685
  }
1630
686
  }
1631
687
  }
1632
- class Bn {
1633
- static textureLoader = new Fe();
1634
- static hdrLoader = new gs();
1635
- static cubeTextureLoader = new Ot();
688
+ class Ti {
689
+ static textureLoader = new Ct();
690
+ static hdrLoader = new Gs();
691
+ static cubeTextureLoader = new os();
1636
692
  static setLoadingManager(e) {
1637
693
  this.textureLoader.manager = e, this.hdrLoader.manager = e, this.cubeTextureLoader.manager = e;
1638
694
  }
@@ -1641,13 +697,13 @@ class Bn {
1641
697
  }
1642
698
  static async loadAsyncHDR(e) {
1643
699
  const t = await this.hdrLoader.loadAsync(e);
1644
- return t.mapping = At, t;
700
+ return t.mapping = cs, t;
1645
701
  }
1646
702
  static async loadAsyncCubeTexture(e, t) {
1647
703
  return this.cubeTextureLoader.setPath(e), await this.cubeTextureLoader.loadAsync(t);
1648
704
  }
1649
705
  }
1650
- class G extends k {
706
+ class q extends P {
1651
707
  isBaseMesh = !0;
1652
708
  type = "BaseMesh";
1653
709
  castShadow = !0;
@@ -1660,7 +716,7 @@ class G extends k {
1660
716
  return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
1661
717
  }
1662
718
  }
1663
- class Ye extends I {
719
+ class ue extends H {
1664
720
  isBaseGroup = !0;
1665
721
  type = "BaseGroup";
1666
722
  ignoreInvisibleWhenRaycast = !0;
@@ -1671,7 +727,7 @@ class Ye extends I {
1671
727
  return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
1672
728
  }
1673
729
  }
1674
- class Vs extends Bt {
730
+ class wn extends ls {
1675
731
  isBaseSprite = !0;
1676
732
  type = "BaseSprite";
1677
733
  ignoreInvisibleWhenRaycast = !0;
@@ -1682,7 +738,7 @@ class Vs extends Bt {
1682
738
  return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
1683
739
  }
1684
740
  }
1685
- class he extends Ye {
741
+ class we extends ue {
1686
742
  isModel = !0;
1687
743
  type = "Model";
1688
744
  static memoryCache = /* @__PURE__ */ new Map();
@@ -1696,21 +752,21 @@ class he extends Ye {
1696
752
  const { url: t, cache: s = !0, persistent: n = !0 } = e;
1697
753
  try {
1698
754
  let i;
1699
- s ? he.memoryCache.has(t) ? i = he.memoryCache.get(t) : (i = D.loadAsync(t, { persistent: n }), he.memoryCache.set(t, i)) : i = D.loadAsync(t, { persistent: n });
1700
- const r = await i, o = ys(r);
1701
- return this.add(o), o.animations && o.animations.length > 0 && (this.animations = o.animations, this.mixer = new Rt(o)), o;
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;
1702
758
  } catch (i) {
1703
759
  return console.error(`[Model] Failed to load model from ${t}:`, i), null;
1704
760
  }
1705
761
  }
1706
762
  playAnimation(e, t = {}) {
1707
763
  if (!this.mixer || this.animations.length === 0) return null;
1708
- const { loop: s = !0, repetitions: n = 1 / 0, timeScale: i = 1, clampWhenFinished: r = !1 } = t;
764
+ const { loop: s = !0, repetitions: n = 1 / 0, timeScale: i = 1, clampWhenFinished: a = !1 } = t;
1709
765
  let o;
1710
- if (e === void 0 ? o = this.animations[0] : typeof e == "number" ? o = this.animations[e] : o = this.animations.find((c) => c.name === e), !o)
766
+ if (e === void 0 ? o = this.animations[0] : typeof e == "number" ? o = this.animations[e] : o = this.animations.find((l) => l.name === e), !o)
1711
767
  return console.warn(`[Model] Animation not found: ${e}`), null;
1712
- let a = this.actions.get(o.name);
1713
- return a || (a = this.mixer.clipAction(o), this.actions.set(o.name, a)), a.setLoop(s ? It : Lt, n), a.clampWhenFinished = r, a.timeScale = i, a.reset().play(), a;
768
+ 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;
1714
770
  }
1715
771
  playAllAnimations(e = {}) {
1716
772
  return this.animations.map((t, s) => this.playAnimation(s, e)).filter((t) => t !== null);
@@ -1731,13 +787,13 @@ class he extends Ye {
1731
787
  * Get the axis-aligned bounding box of this model.
1732
788
  */
1733
789
  getBoundingBox() {
1734
- return new V().setFromObject(this);
790
+ return new $().setFromObject(this);
1735
791
  }
1736
792
  /**
1737
793
  * Get the center point of this model's bounding box.
1738
794
  */
1739
795
  getCenter() {
1740
- const e = new v();
796
+ const e = new C();
1741
797
  return this.getBoundingBox().getCenter(e), e;
1742
798
  }
1743
799
  /**
@@ -1745,7 +801,7 @@ class he extends Ye {
1745
801
  */
1746
802
  setMaterial(e) {
1747
803
  this.traverse((t) => {
1748
- t instanceof k && (t.material = e);
804
+ t instanceof P && (t.material = e);
1749
805
  });
1750
806
  }
1751
807
  static clearMemoryCache() {
@@ -1755,11 +811,11 @@ class he extends Ye {
1755
811
  typeof caches < "u" && await caches.delete("u-space-loader-cache");
1756
812
  }
1757
813
  }
1758
- class Js extends G {
814
+ class xn extends q {
1759
815
  isSphereMesh = !0;
1760
816
  type = "SphereMesh";
1761
817
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
1762
- super(), this.geometry = new zt(
818
+ super(), this.geometry = new ps(
1763
819
  e?.radius,
1764
820
  e?.widthSegments,
1765
821
  e?.heightSegments,
@@ -1767,23 +823,23 @@ class Js extends G {
1767
823
  e?.phiLength,
1768
824
  e?.thetaStart,
1769
825
  e?.thetaLength
1770
- ), this.material = new L(t);
826
+ ), this.material = new K(t);
1771
827
  }
1772
828
  }
1773
- class Ie extends G {
829
+ class qe extends q {
1774
830
  isTubeMesh = !0;
1775
831
  type = "TubeMesh";
1776
832
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
1777
- super(), this.geometry = new Nt(
833
+ super(), this.geometry = new ms(
1778
834
  e?.path,
1779
835
  e?.tubularSegments,
1780
836
  e?.radius,
1781
837
  e?.radialSegments,
1782
838
  e?.closed
1783
- ), this.material = new L(t);
839
+ ), this.material = new K(t);
1784
840
  }
1785
841
  }
1786
- class Rn extends Ye {
842
+ class Li extends ue {
1787
843
  isTopology = !0;
1788
844
  type = "Topology";
1789
845
  // Visuals
@@ -1829,12 +885,12 @@ class Rn extends Ye {
1829
885
  * @param bidirectional If true, adds the reverse edge as well. Default true.
1830
886
  */
1831
887
  addEdge(e, t, s, n = !0) {
1832
- const i = this.nodes.get(e), r = this.nodes.get(t);
1833
- if (!i || !r) {
888
+ const i = this.nodes.get(e), a = this.nodes.get(t);
889
+ if (!i || !a) {
1834
890
  console.error(`[Topology] Cannot add edge. One or both nodes not found: ${e}, ${t}`);
1835
891
  return;
1836
892
  }
1837
- const o = s ?? i.distanceTo(r);
893
+ const o = s ?? i.distanceTo(a);
1838
894
  this.getNeighbors(e)?.set(t, o), n && this.getNeighbors(t)?.set(e, o);
1839
895
  }
1840
896
  /**
@@ -1853,41 +909,41 @@ class Rn extends Ye {
1853
909
  if (!this.nodes.has(e) || !this.nodes.has(t))
1854
910
  return console.warn("[Topology] Start or End node not found."), [];
1855
911
  const s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
1856
- for (const [a] of this.nodes)
1857
- s.set(a, 1 / 0), n.set(a, null), i.add(a);
912
+ for (const [c] of this.nodes)
913
+ s.set(c, 1 / 0), n.set(c, null), i.add(c);
1858
914
  for (s.set(e, 0); i.size > 0; ) {
1859
- let a = null, c = 1 / 0;
1860
- for (const d of i) {
1861
- const p = s.get(d);
1862
- p < c && (c = p, a = d);
915
+ 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);
1863
919
  }
1864
- if (a === null || a === t || c === 1 / 0)
920
+ if (c === null || c === t || l === 1 / 0)
1865
921
  break;
1866
- i.delete(a);
1867
- const l = this.adjacencyMap?.get(a);
1868
- if (l)
1869
- for (const [d, p] of l) {
1870
- if (!i.has(d)) continue;
1871
- const u = s.get(a) + p;
1872
- u < s.get(d) && (s.set(d, u), n.set(d, a));
922
+ i.delete(c);
923
+ const h = this.adjacencyMap?.get(c);
924
+ 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));
1873
929
  }
1874
930
  }
1875
- const r = [];
931
+ const a = [];
1876
932
  let o = t;
1877
933
  if (n.get(t) === null && e !== t)
1878
934
  return [];
1879
935
  for (; o !== null; ) {
1880
- const a = this.nodes.get(o);
1881
- a && r.unshift(a), o = n.get(o) || null;
936
+ const c = this.nodes.get(o);
937
+ c && a.unshift(c), o = n.get(o) || null;
1882
938
  }
1883
- return r;
939
+ return a;
1884
940
  }
1885
941
  /**
1886
942
  * Renders the entire topology graph structure using TubeGeometry and Spheres.
1887
943
  */
1888
944
  renderGraph() {
1889
- this.clearGraph(), this.graphGroup = new I();
1890
- const e = new Js({
945
+ this.clearGraph(), this.graphGroup = new H();
946
+ const e = new xn({
1891
947
  geometryParameters: {
1892
948
  radius: this.parameters.nodeRadius,
1893
949
  widthSegments: 16,
@@ -1903,15 +959,15 @@ class Rn extends Ye {
1903
959
  });
1904
960
  const t = /* @__PURE__ */ new Set();
1905
961
  this.adjacencyMap.forEach((s, n) => {
1906
- s.forEach((i, r) => {
1907
- const o = [n, r].sort().join("-");
962
+ s.forEach((i, a) => {
963
+ const o = [n, a].sort().join("-");
1908
964
  if (t.has(o)) return;
1909
965
  t.add(o);
1910
- const a = this.nodes.get(n), c = this.nodes.get(r);
1911
- if (a && c) {
1912
- const l = new Dt(a, c), d = new Ie({
966
+ const c = this.nodes.get(n), l = this.nodes.get(a);
967
+ if (c && l) {
968
+ const h = new fs(c, l), u = new qe({
1913
969
  geometryParameters: {
1914
- path: l,
970
+ path: h,
1915
971
  tubularSegments: 1,
1916
972
  radius: this.parameters.edgeRadius,
1917
973
  radialSegments: 8,
@@ -1921,14 +977,14 @@ class Rn extends Ye {
1921
977
  color: this.parameters.edgeColor
1922
978
  }
1923
979
  });
1924
- Object.assign(d.userData, { from: n, to: r, weight: i, type: "edge" }), this.graphGroup.add(d);
980
+ Object.assign(u.userData, { from: n, to: a, weight: i, type: "edge" }), this.graphGroup.add(u);
1925
981
  }
1926
982
  });
1927
983
  }), this.add(this.graphGroup);
1928
984
  }
1929
985
  clearGraph() {
1930
986
  this.graphGroup && (this.remove(this.graphGroup), this.graphGroup.traverse((e) => {
1931
- e instanceof k && (e.geometry.dispose(), e.material.dispose());
987
+ e instanceof P && (e.geometry.dispose(), e.material.dispose());
1932
988
  }), this.graphGroup = null);
1933
989
  }
1934
990
  /**
@@ -1936,7 +992,7 @@ class Rn extends Ye {
1936
992
  */
1937
993
  renderPath(e, t = this.parameters.pathColor) {
1938
994
  if (e.length < 2) return;
1939
- const s = new kt(e, !1, "catmullrom", 0), n = new Ie({
995
+ const s = new gs(e, !1, "catmullrom", 0), n = new qe({
1940
996
  geometryParameters: {
1941
997
  path: s,
1942
998
  tubularSegments: e.length * 10,
@@ -1962,9 +1018,9 @@ class Rn extends Ye {
1962
1018
  });
1963
1019
  const t = [], s = /* @__PURE__ */ new Set();
1964
1020
  return this.adjacencyMap.forEach((n, i) => {
1965
- n.forEach((r, o) => {
1966
- const a = [i, o].sort().join("-");
1967
- s.has(a) || (s.add(a), t.push({ from: i, to: o, weight: r }));
1021
+ 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 }));
1968
1024
  });
1969
1025
  }), { nodes: e, edges: t };
1970
1026
  }
@@ -1974,7 +1030,7 @@ class Rn extends Ye {
1974
1030
  */
1975
1031
  importData(e) {
1976
1032
  this.clearGraph(), this.clearPaths(), this.nodes.clear(), this.adjacencyMap.clear(), Object.entries(e.nodes).forEach(([t, s]) => {
1977
- this.addNode(t, new v(s.x, s.y, s.z));
1033
+ this.addNode(t, new C(s.x, s.y, s.z));
1978
1034
  }), e.edges.forEach(({ from: t, to: s, weight: n }) => {
1979
1035
  this.addEdge(t, s, n);
1980
1036
  }), this.renderGraph();
@@ -1986,7 +1042,7 @@ class Rn extends Ye {
1986
1042
  return this.adjacencyMap.get(e);
1987
1043
  }
1988
1044
  }
1989
- class In extends Vs {
1045
+ class Pi extends wn {
1990
1046
  isPoi = !0;
1991
1047
  type = "Poi";
1992
1048
  parameters = {
@@ -2005,7 +1061,7 @@ class In extends Vs {
2005
1061
  _canvas = document.createElement("canvas");
2006
1062
  _lastParametersJSON = "";
2007
1063
  constructor(e = {}) {
2008
- super(new jt()), Object.assign(this.parameters, e), this.updateAsync();
1064
+ super(new ys()), Object.assign(this.parameters, e), this.updateAsync();
2009
1065
  }
2010
1066
  /**
2011
1067
  * Update the POI with new parameters
@@ -2021,33 +1077,33 @@ class In extends Vs {
2021
1077
  n.font = `${this.parameters.fontSize}px ${this.parameters.fontFamily}`;
2022
1078
  let i = null;
2023
1079
  this.parameters.img && (i = await this._loadImage(this.parameters.img));
2024
- const { text: r, fontSize: o, color: a, iconSize: c, padding: l, backgroundColor: d, borderRadius: p, textPosition: u, scaleFactor: m } = this.parameters, w = n.measureText(r), S = r ? w.width : 0, x = r ? o : 0;
2025
- let y = 0, _ = 0, A = 0, B = 0, E = 0, g = 0;
2026
- const b = !!i, z = !!r;
2027
- if (b && z)
2028
- switch (u) {
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)
1084
+ switch (p) {
2029
1085
  case "top":
2030
- y = Math.max(c, S), _ = c + l + x, E = (y - S) / 2, g = x / 2, A = (y - c) / 2, B = x + l;
1086
+ g = Math.max(l, S), I = l + h + w, T = (g - S) / 2, y = w / 2, B = (g - l) / 2, O = w + h;
2031
1087
  break;
2032
1088
  case "bottom":
2033
- y = Math.max(c, S), _ = c + l + x, A = (y - c) / 2, B = 0, E = (y - S) / 2, g = c + l + x / 2;
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;
2034
1090
  break;
2035
1091
  case "left":
2036
- y = c + l + S, _ = Math.max(c, x), E = 0, g = _ / 2, A = S + l, B = (_ - c) / 2;
1092
+ g = l + h + S, I = Math.max(l, w), T = 0, y = I / 2, B = S + h, O = (I - l) / 2;
2037
1093
  break;
2038
1094
  default:
2039
- y = c + l + S, _ = Math.max(c, x), A = 0, B = (_ - c) / 2, E = c + l, g = _ / 2;
1095
+ g = l + h + S, I = Math.max(l, w), B = 0, O = (I - l) / 2, T = l + h, y = I / 2;
2040
1096
  break;
2041
1097
  }
2042
- else b ? (y = c, _ = c, A = 0, B = 0) : z && (y = S, _ = x, E = 0, g = x / 2);
2043
- const N = y + l * 2, P = _ + l * 2;
2044
- if (s.width = N, s.height = P, n.font = `${o}px ${this.parameters.fontFamily}`, d && (n.fillStyle = d, this._drawRoundedRect(n, 0, 0, N, P, p), n.fill()), b && n.drawImage(i, A + l, B + l, c, c), z) {
2045
- n.fillStyle = a;
2046
- const j = n.measureText(r), U = j.actualBoundingBoxAscent + j.actualBoundingBoxDescent, ot = j.actualBoundingBoxAscent - U / 2;
2047
- n.textBaseline = "alphabetic", n.fillText(r, E + l, g + l + ot);
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) {
1101
+ 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);
2048
1104
  }
2049
- const J = this.material.map, W = new Ut(s);
2050
- W.colorSpace = Ge, this.material.map = W, J?.dispose(), this.scale.set(N * m, P * m, 1);
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);
2051
1107
  }
2052
1108
  _loadImage(e) {
2053
1109
  return new Promise((t, s) => {
@@ -2058,87 +1114,110 @@ class In extends Vs {
2058
1114
  t(e);
2059
1115
  });
2060
1116
  }
2061
- _drawRoundedRect(e, t, s, n, i, r) {
2062
- e.beginPath(), e.moveTo(t + r, s), e.lineTo(t + n - r, s), e.quadraticCurveTo(t + n, s, t + n, s + r), e.lineTo(t + n, s + i - r), e.quadraticCurveTo(t + n, s + i, t + n - r, s + i), e.lineTo(t + r, s + i), e.quadraticCurveTo(t, s + i, t, s + i - r), e.lineTo(t, s + r), e.quadraticCurveTo(t, s, t + r, s), e.closePath();
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();
2063
1119
  }
2064
1120
  dispose() {
2065
1121
  this.material.map?.dispose(), this.material.dispose();
2066
1122
  }
2067
1123
  }
2068
- class Ve extends G {
1124
+ class Nt extends q {
2069
1125
  isShapeMesh = !0;
2070
1126
  type = "ShapeMesh";
2071
1127
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
2072
- super(), this.geometry = new Ht(e?.shape, e?.curveSegments), this.material = new L(t), this.geometry.rotateX(-Math.PI / 2);
1128
+ super(), this.geometry = new ws(e?.shape, e?.curveSegments), this.material = new K(t), this.geometry.rotateX(-Math.PI / 2);
2073
1129
  }
2074
1130
  static createFromPoints(e, t = {}) {
2075
- return new Ve({
1131
+ return new Nt({
2076
1132
  ...t,
2077
1133
  geometryParameters: {
2078
1134
  ...t.geometryParameters,
2079
- shape: new $e(e.map((s) => new C(s.x, -s.z)))
1135
+ shape: new At(e.map((s) => new z(s.x, -s.z)))
2080
1136
  }
2081
1137
  });
2082
1138
  }
2083
1139
  }
2084
- class Je extends G {
1140
+ class zt extends q {
2085
1141
  isExtrudeMesh = !0;
2086
1142
  type = "ExtrudeMesh";
2087
1143
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
2088
- super(), this.geometry = new Ft(e?.shape, e?.options), this.material = new L(t), this.geometry.rotateX(-Math.PI / 2);
1144
+ super(), this.geometry = new xs(e?.shape, e?.options), this.material = new K(t), this.geometry.rotateX(-Math.PI / 2);
2089
1145
  }
2090
1146
  static createFromPoints(e, t = {}) {
2091
- return e && e.length === 0 && (e = void 0), new Je({
1147
+ return e && e.length === 0 && (e = void 0), new zt({
2092
1148
  ...t,
2093
1149
  geometryParameters: {
2094
1150
  ...t.geometryParameters,
2095
- shape: new $e(e?.map((s) => new C(s.x, -s.z)))
1151
+ shape: new At(e?.map((s) => new z(s.x, -s.z)))
2096
1152
  }
2097
1153
  });
2098
1154
  }
2099
1155
  }
2100
- class Ln extends G {
1156
+ class Ni extends q {
2101
1157
  isPlaneMesh = !0;
2102
1158
  type = "PlaneMesh";
2103
1159
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
2104
- super(), this.geometry = new Gt(
1160
+ super(), this.geometry = new Ms(
2105
1161
  e?.width,
2106
1162
  e?.height,
2107
1163
  e?.widthSegments,
2108
1164
  e?.heightSegments
2109
- ), this.material = new L(t);
1165
+ ), this.material = new K(t);
2110
1166
  }
2111
1167
  }
2112
- class zn extends G {
1168
+ class zi extends q {
2113
1169
  isCircleMesh = !0;
2114
1170
  type = "CircleMesh";
2115
1171
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
2116
1172
  super(
2117
- new $t(
1173
+ new Is(
2118
1174
  e?.radius,
2119
1175
  e?.segments,
2120
1176
  e?.thetaStart,
2121
1177
  e?.thetaLength
2122
1178
  ),
2123
- new L(t)
1179
+ new K(t)
2124
1180
  ), this.geometry.rotateX(-Math.PI / 2);
2125
1181
  }
2126
1182
  }
2127
- class F {
1183
+ class J {
2128
1184
  static traverseMeshes(e, t) {
2129
1185
  e.traverse((s) => {
2130
- s instanceof k && t(s);
1186
+ s instanceof P && t(s);
2131
1187
  });
2132
1188
  }
2133
1189
  }
2134
- class Nn {
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;
1193
+ }
1194
+ function Je(r) {
1195
+ let e = !1;
1196
+ return r.traverse((t) => {
1197
+ if (e) return;
1198
+ const s = t;
1199
+ e = s.isMesh === !0 || s.isSprite === !0;
1200
+ }), e;
1201
+ }
1202
+ function _n(r) {
1203
+ let e = r;
1204
+ for (; e; ) {
1205
+ if (!e.visible) return !1;
1206
+ e = e.parent;
1207
+ }
1208
+ return !0;
1209
+ }
1210
+ function Ze(r) {
1211
+ return r === void 0 || !Number.isFinite(r) || r <= 0 ? vn : r;
1212
+ }
1213
+ class Di {
2135
1214
  static flow(e = {}) {
2136
- const { baseColor: t = 16777215, flowColor: s = 65280, speed: n = 1, scale: i = 3, intensity: r = 4 } = e, o = H(new T(t)), a = H(new T(s)), c = _e().x.mul(i).sub(oe.mul(n)), l = ae(ye(c).add(1).mul(0.5), r);
2137
- return ce(o, a, l);
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);
2138
1217
  }
2139
1218
  static breathe(e = {}) {
2140
- const { baseColor: t = 16777215, breathColor: s = 65280, speed: n = 1, intensity: i = 2 } = e, r = H(new T(t)), o = H(new T(s)), a = ye(oe.mul(n)).add(1).mul(0.5), c = ae(a, i);
2141
- return ce(r, o, c);
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);
2142
1221
  }
2143
1222
  static fluid(e = {}) {
2144
1223
  const {
@@ -2146,81 +1225,154 @@ class Nn {
2146
1225
  flowColor: s = 255,
2147
1226
  speed: n = 1,
2148
1227
  scale: i = 1,
2149
- intensity: r = 1,
1228
+ intensity: a = 1,
2150
1229
  distortion: o = 0.5
2151
- } = e, a = H(new T(t)), c = H(new T(s)), l = _e().mul(i), d = oe.mul(n), p = Ee(l.add(d), 1, 0), u = l.add(p.mul(o)), m = Ee(u, 1, 0).add(1).mul(0.5), w = ae(m, r);
2152
- return ce(a, c, w);
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);
1232
+ }
1233
+ static outline(e = {}) {
1234
+ 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;
1241
+ return;
1242
+ }
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) => {
1251
+ 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 = {
1258
+ source: f,
1259
+ mesh: v,
1260
+ unsubscribe: f.onInstanceRenderDirty?.(() => T(M)) ?? null
1261
+ }, n.set(f, M);
1262
+ }
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));
1272
+ }
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 = () => {
1277
+ 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, {
1282
+ selectedObjects: s,
1283
+ edgeThickness: S,
1284
+ edgeGlow: w,
1285
+ downSampleRatio: m
1286
+ });
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));
1294
+ });
1295
+ return Object.defineProperties(R, {
1296
+ outlineNode: {
1297
+ get: () => a
1298
+ },
1299
+ selectedObjects: {
1300
+ get: () => t
1301
+ }
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;
2153
1305
  }
2154
1306
  }
2155
- function Dn(h) {
1307
+ function Ri(r) {
2156
1308
  }
2157
- const $ = "uSpaceHighlight", Y = `${$}/enabled`, Ze = `${$}/opacity`, et = `${$}/color`, tt = `${$}/overwrite`, st = `${$}/multiplyOpacity`, de = `${$}/instancedOriginalOpacity`, me = "uSpaceBreathe", pe = `${me}/enabled`, nt = `${me}/color`, it = `${me}/speed`, rt = `${me}/intensity`, ue = /* @__PURE__ */ new WeakMap(), Zs = We(() => {
2158
- const h = O(Y, "uint"), e = O(et, "uint"), t = O(tt, "uint"), s = Ne(e), n = Pe.mul(s), i = q(t.greaterThan(0), s, n), r = q(h.greaterThan(0), i, Pe), o = O(pe, "uint"), a = O(nt, "uint"), c = O(it, "float"), l = O(rt, "float"), d = Ne(a), p = ye(oe.mul(c)).add(1).mul(0.5), u = ae(p, l), m = ce(r, d, u);
2159
- return q(o.greaterThan(0), m, r);
2160
- })(), en = We(() => {
2161
- const h = O(Y, "uint"), e = O(Ze, "float"), t = O(st, "uint"), s = q(t.greaterThan(0), Oe.mul(e), e);
2162
- return q(h.greaterThan(0), s, Oe);
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);
2163
1315
  })();
2164
- function X(h) {
2165
- return Array.isArray(h.material) ? h.material : [h.material];
1316
+ function le(r) {
1317
+ return Array.isArray(r.material) ? r.material : [r.material];
2166
1318
  }
2167
- function Le(h) {
2168
- X(h).forEach((t) => {
1319
+ function et(r) {
1320
+ le(r).forEach((t) => {
2169
1321
  if (!t) return;
2170
- let s = ue.get(t);
1322
+ let s = Se.get(t);
2171
1323
  s || (s = {
2172
1324
  colorNode: t.colorNode,
2173
1325
  opacityNode: t.opacityNode,
2174
1326
  transparent: t.transparent,
2175
1327
  depthWrite: t.depthWrite,
2176
1328
  activeMeshes: /* @__PURE__ */ new Set()
2177
- }, ue.set(t, s)), s.activeMeshes.add(h), t.transparent = !0, t.colorNode = Zs, t.opacityNode = en, t.needsUpdate = !0;
1329
+ }, Se.set(t, s)), s.activeMeshes.add(r), t.transparent = !0, t.colorNode = Cn, t.opacityNode = On, t.needsUpdate = !0;
2178
1330
  });
2179
1331
  }
2180
- function ze(h) {
2181
- const e = h.userData[Y], t = h.userData[pe];
1332
+ function tt(r) {
1333
+ const e = r.userData[he], t = r.userData[Ie];
2182
1334
  if (e || t) return;
2183
- X(h).forEach((n) => {
1335
+ le(r).forEach((n) => {
2184
1336
  if (!n) return;
2185
- const i = ue.get(n);
2186
- i && (i.activeMeshes.delete(h), !(i.activeMeshes.size > 0) && (n.colorNode = i.colorNode, n.opacityNode = i.opacityNode, n.transparent = i.transparent, n.depthWrite = i.depthWrite, n.needsUpdate = !0, ue.delete(n)));
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)));
2187
1339
  });
2188
1340
  }
2189
- function tn(h, e, t, s) {
2190
- const n = h, i = n.setSemanticHighlight;
1341
+ function An(r, e, t, s) {
1342
+ const n = r, i = n.setInstanceHighlight;
2191
1343
  if (i)
2192
- return i.call(h, e, t, s), !0;
2193
- const r = n.setSemanticColor, o = n.setSemanticOpacity, a = n.getSemanticOpacity, c = n.getSemanticColor, l = n.hasSemanticColor;
2194
- return !r || !o ? !1 : (h.userData[de] === void 0 && (h.userData[de] = {
2195
- hasColor: l?.call(h) ?? !1,
2196
- color: c?.call(h, new T()).getHex() ?? 16777215,
2197
- opacity: a?.call(h) ?? 1
2198
- }), r.call(h, e), o.call(h, t), !0);
2199
- }
2200
- function sn(h) {
2201
- const e = h, t = e.clearSemanticHighlight;
1344
+ return i.call(r, e, t, s), !0;
1345
+ 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;
2202
1354
  if (t)
2203
- return t.call(h), !0;
2204
- const s = e.resetSemanticColor, n = e.setSemanticColor, i = e.setSemanticOpacity;
1355
+ return t.call(r), !0;
1356
+ const s = e.resetInstanceColor, n = e.setInstanceColor, i = e.setInstanceOpacity;
2205
1357
  if (!s || !i) return !1;
2206
- const r = h.userData[de];
2207
- return r && (r.hasColor && n ? n.call(h, r.color) : s.call(h), i.call(h, r.opacity), Reflect.deleteProperty(h.userData, de)), !0;
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;
2208
1360
  }
2209
- class le {
1361
+ class se {
2210
1362
  static highlightColor(e, t = {}) {
2211
- const s = Array.isArray(e) ? e : [e], { opacity: n = 0.5, color: i = 16711680, overwrite: r = !1, depthWrite: o, multiplyOpacity: a = !1 } = t, c = new T(i).getHex();
2212
- for (const l of s)
2213
- tn(l, i, n, r) || F.traverseMeshes(l, (d) => {
2214
- d.userData[Y] = 1, d.userData[Ze] = n, d.userData[et] = c, d.userData[tt] = r ? 1 : 0, d.userData[st] = a ? 1 : 0, Le(d), o !== void 0 && X(d).forEach((u) => {
2215
- u && (u.depthWrite = o);
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();
1364
+ 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) => {
1367
+ p && (p.depthWrite = o);
2216
1368
  });
2217
1369
  });
2218
1370
  }
2219
1371
  static removeHighlightColor(e) {
2220
1372
  const t = Array.isArray(e) ? e : [e];
2221
1373
  for (const s of t)
2222
- sn(s) || F.traverseMeshes(s, (n) => {
2223
- n.userData[Y] = 0, ze(n);
1374
+ Tn(s) || J.traverseMeshes(s, (n) => {
1375
+ n.userData[he] = 0, tt(n);
2224
1376
  });
2225
1377
  }
2226
1378
  static breatheColor(e, t = {}) {
@@ -2232,17 +1384,17 @@ class le {
2232
1384
  },
2233
1385
  t
2234
1386
  );
2235
- n.color = new T(n.color).getHex();
1387
+ n.color = new A(n.color).getHex();
2236
1388
  for (const i of s)
2237
- F.traverseMeshes(i, (r) => {
2238
- r.userData[pe] = 1, r.userData[nt] = n.color, r.userData[it] = n.speed, r.userData[rt] = n.intensity, Le(r);
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);
2239
1391
  });
2240
1392
  }
2241
1393
  static removeBreatheColor(e) {
2242
1394
  const t = Array.isArray(e) ? e : [e];
2243
1395
  for (const s of t)
2244
- F.traverseMeshes(s, (n) => {
2245
- n.userData[pe] = 0, ze(n);
1396
+ J.traverseMeshes(s, (n) => {
1397
+ n.userData[Ie] = 0, tt(n);
2246
1398
  });
2247
1399
  }
2248
1400
  /**
@@ -2251,10 +1403,10 @@ class le {
2251
1403
  static wireframe(e, t = !0) {
2252
1404
  const s = Array.isArray(e) ? e : [e];
2253
1405
  for (const n of s)
2254
- F.traverseMeshes(n, (i) => {
2255
- X(i).forEach((r) => {
2256
- if (!r) return;
2257
- const o = r;
1406
+ J.traverseMeshes(n, (i) => {
1407
+ le(i).forEach((a) => {
1408
+ if (!a) return;
1409
+ const o = a;
2258
1410
  o.wireframe = t, o.needsUpdate = !0;
2259
1411
  });
2260
1412
  });
@@ -2263,7 +1415,7 @@ class le {
2263
1415
  * Remove wireframe mode.
2264
1416
  */
2265
1417
  static removeWireframe(e) {
2266
- le.wireframe(e, !1);
1418
+ se.wireframe(e, !1);
2267
1419
  }
2268
1420
  /**
2269
1421
  * Fade in object(s) from fully transparent to original opacity.
@@ -2271,7 +1423,7 @@ class le {
2271
1423
  */
2272
1424
  static fadeIn(e, t = {}) {
2273
1425
  const { duration: s = 500 } = t;
2274
- return le._fade(e, 0, 1, s);
1426
+ return se._fade(e, 0, 1, s);
2275
1427
  }
2276
1428
  /**
2277
1429
  * Fade out object(s) to fully transparent.
@@ -2279,61 +1431,62 @@ class le {
2279
1431
  */
2280
1432
  static fadeOut(e, t = {}) {
2281
1433
  const { duration: s = 500 } = t;
2282
- return le._fade(e, 1, 0, s);
1434
+ return se._fade(e, 1, 0, s);
2283
1435
  }
2284
1436
  static _fade(e, t, s, n) {
2285
- const i = Array.isArray(e) ? e : [e], r = /* @__PURE__ */ new Map();
1437
+ const i = Array.isArray(e) ? e : [e], a = /* @__PURE__ */ new Map();
2286
1438
  for (const o of i)
2287
- F.traverseMeshes(o, (a) => {
2288
- X(a).forEach((c) => {
2289
- if (!c || r.has(c)) return;
2290
- const l = c.opacity, d = c.transparent, p = s >= 1 ? l : s;
2291
- r.set(c, {
2292
- material: c,
2293
- targetOpacity: p,
2294
- originalOpacity: l,
2295
- originalTransparent: d
2296
- }), c.transparent = !0, c.opacity = t, c.needsUpdate = !0;
1439
+ J.traverseMeshes(o, (c) => {
1440
+ le(c).forEach((l) => {
1441
+ if (!l || a.has(l)) return;
1442
+ const h = l.opacity, u = l.transparent, d = s >= 1 ? h : s;
1443
+ a.set(l, {
1444
+ material: l,
1445
+ targetOpacity: d,
1446
+ originalOpacity: h,
1447
+ originalTransparent: u
1448
+ }), l.transparent = !0, l.opacity = t, l.needsUpdate = !0;
2297
1449
  });
2298
1450
  });
2299
- return r.size === 0 ? Promise.resolve() : new Promise((o) => {
2300
- const a = performance.now();
2301
- let c = 0;
2302
- const l = () => {
2303
- const d = performance.now() - a, p = Math.min(d / n, 1);
1451
+ return a.size === 0 ? Promise.resolve() : new Promise((o) => {
1452
+ const c = performance.now();
1453
+ let l = 0;
1454
+ const h = () => {
1455
+ const u = performance.now() - c, d = Math.min(u / n, 1);
2304
1456
  if (!i[0].parent) {
2305
- cancelAnimationFrame(c), o();
1457
+ cancelAnimationFrame(l), o();
2306
1458
  return;
2307
1459
  }
2308
- for (const { material: m, targetOpacity: w } of r.values())
2309
- m.opacity = t + (w - t) * p, m.needsUpdate = !0;
2310
- if (p < 1)
2311
- c = requestAnimationFrame(l);
1460
+ for (const { material: m, targetOpacity: b } of a.values())
1461
+ m.opacity = t + (b - t) * d, m.needsUpdate = !0;
1462
+ if (d < 1)
1463
+ l = requestAnimationFrame(h);
2312
1464
  else {
2313
1465
  if (s >= 1)
2314
- for (const { material: m, originalOpacity: w, originalTransparent: S } of r.values())
2315
- m.opacity = w, m.transparent = S, m.needsUpdate = !0;
1466
+ for (const { material: m, originalOpacity: b, originalTransparent: S } of a.values())
1467
+ m.opacity = b, m.transparent = S, m.needsUpdate = !0;
2316
1468
  o();
2317
1469
  }
2318
1470
  };
2319
- c = requestAnimationFrame(l);
1471
+ l = requestAnimationFrame(h);
2320
1472
  });
2321
1473
  }
2322
1474
  }
2323
- const Ne = (h) => {
2324
- const e = h.shiftRight(16).bitAnd(255).toFloat().div(255), t = h.shiftRight(8).bitAnd(255).toFloat().div(255), s = h.bitAnd(255).toFloat().div(255);
2325
- return es(e, t, s);
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);
2326
1478
  };
2327
- class nn extends ws {
1479
+ class Ln extends Zs {
2328
1480
  viewer;
2329
1481
  constructor(e, t) {
2330
1482
  super(t), this.viewer = e;
2331
1483
  }
2332
1484
  _update = ({ time: e }) => {
2333
- this.update(e) && this.viewer.render();
1485
+ const t = this.update(e);
1486
+ this.viewer.invalidate(), t || this.viewer.removeEventListener("afterControlsUpdate", this._update);
2334
1487
  };
2335
1488
  easingByMode(e) {
2336
- const t = rn[e];
1489
+ const t = Pn[e];
2337
1490
  return super.easing(t);
2338
1491
  }
2339
1492
  start(e, t) {
@@ -2343,54 +1496,54 @@ class nn extends ws {
2343
1496
  return this.viewer.removeEventListener("afterControlsUpdate", this._update), super.stop();
2344
1497
  }
2345
1498
  }
2346
- function kn(h, e, t, s = {}, n, i) {
2347
- return new Promise((r, o) => {
2348
- const { duration: a = 1e3, delay: c = 0, repeat: l = !1, mode: d = "Linear.None", yoyo: p = !1 } = s, u = new nn(h, e).to(t, a).easingByMode(d).delay(c).onUpdate((m) => {
2349
- n?.(m, u);
1499
+ function ji(r, e, t, s = {}, n, i) {
1500
+ 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);
2350
1503
  }).onComplete(() => {
2351
- r();
1504
+ a();
2352
1505
  }).onStop(() => {
2353
1506
  o("animation stop");
2354
1507
  }).onStart(() => {
2355
- i?.(u);
1508
+ i?.(p);
2356
1509
  });
2357
- typeof l == "number" ? u.repeat(l) : typeof l == "boolean" && l && u.repeat(1 / 0), p && u.repeatDelay(20), u.yoyo(p), u.start();
1510
+ typeof h == "number" ? p.repeat(h) : typeof h == "boolean" && h && p.repeat(1 / 0), d && p.repeatDelay(20), p.yoyo(d), p.start();
2358
1511
  });
2359
1512
  }
2360
- const rn = {
2361
- "Linear.None": f.Linear.None,
2362
- "Quadratic.In": f.Quadratic.In,
2363
- "Quadratic.Out": f.Quadratic.Out,
2364
- "Quadratic.InOut": f.Quadratic.InOut,
2365
- "Cubic.In": f.Cubic.In,
2366
- "Cubic.Out": f.Cubic.Out,
2367
- "Cubic.InOut": f.Cubic.InOut,
2368
- "Quartic.In": f.Quartic.In,
2369
- "Quartic.Out": f.Quartic.Out,
2370
- "Quartic.InOut": f.Quartic.InOut,
2371
- "Quintic.In": f.Quintic.In,
2372
- "Quintic.Out": f.Quintic.Out,
2373
- "Quintic.InOut": f.Quintic.InOut,
2374
- "Sinusoidal.In": f.Sinusoidal.In,
2375
- "Sinusoidal.Out": f.Sinusoidal.Out,
2376
- "Sinusoidal.InOut": f.Sinusoidal.InOut,
2377
- "Exponential.In": f.Exponential.In,
2378
- "Exponential.Out": f.Exponential.Out,
2379
- "Exponential.InOut": f.Exponential.InOut,
2380
- "Circular.In": f.Circular.In,
2381
- "Circular.Out": f.Circular.Out,
2382
- "Circular.InOut": f.Circular.InOut,
2383
- "Elastic.In": f.Elastic.In,
2384
- "Elastic.Out": f.Elastic.Out,
2385
- "Elastic.InOut": f.Elastic.InOut,
2386
- "Back.In": f.Back.In,
2387
- "Back.Out": f.Back.Out,
2388
- "Back.InOut": f.Back.InOut,
2389
- "Bounce.In": f.Bounce.In,
2390
- "Bounce.Out": f.Bounce.Out,
2391
- "Bounce.InOut": f.Bounce.InOut
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
2392
1545
  };
2393
- class jn {
1546
+ class ki {
2394
1547
  scene;
2395
1548
  planes = /* @__PURE__ */ new Map();
2396
1549
  helpers = /* @__PURE__ */ new Map();
@@ -2399,7 +1552,7 @@ class jn {
2399
1552
  */
2400
1553
  group;
2401
1554
  constructor(e) {
2402
- this.scene = e, this.group = new Wt(), this.group.name = "__clippingToolGroup", this.scene.add(this.group);
1555
+ this.scene = e, this.group = new Es(), this.group.name = "__clippingToolGroup", this.scene.add(this.group);
2403
1556
  }
2404
1557
  /**
2405
1558
  * Move all current scene children (except the clipping group itself) into the ClippingGroup,
@@ -2438,35 +1591,35 @@ class jn {
2438
1591
  normal: s = { x: 0, y: -1, z: 0 },
2439
1592
  constant: n = 0,
2440
1593
  showHelper: i = !1,
2441
- helperSize: r = 5,
1594
+ helperSize: a = 5,
2442
1595
  helperColor: o = 16711680
2443
- } = t, a = new Kt(new v(s.x, s.y, s.z), n);
2444
- return this.planes.set(e, a), this._syncPlanes(), i && this.showHelper(e, r, o), a;
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;
2445
1598
  }
2446
1599
  /**
2447
1600
  * Add six clipping planes that form a box around a Box3.
2448
1601
  * Returns the six plane ids: `${id}_+x`, `${id}_-x`, etc.
2449
1602
  */
2450
1603
  addBox(e, t, s = {}) {
2451
- const { showHelpers: n = !1, helperColor: i = 16711680 } = s, r = t.min, o = t.max, a = [
1604
+ const { showHelpers: n = !1, helperColor: i = 16711680 } = s, a = t.min, o = t.max, c = [
2452
1605
  { suffix: "+x", normal: { x: -1, y: 0, z: 0 }, constant: o.x },
2453
- { suffix: "-x", normal: { x: 1, y: 0, z: 0 }, constant: -r.x },
1606
+ { suffix: "-x", normal: { x: 1, y: 0, z: 0 }, constant: -a.x },
2454
1607
  { suffix: "+y", normal: { x: 0, y: -1, z: 0 }, constant: o.y },
2455
- { suffix: "-y", normal: { x: 0, y: 1, z: 0 }, constant: -r.y },
1608
+ { suffix: "-y", normal: { x: 0, y: 1, z: 0 }, constant: -a.y },
2456
1609
  { suffix: "+z", normal: { x: 0, y: 0, z: -1 }, constant: o.z },
2457
- { suffix: "-z", normal: { x: 0, y: 0, z: 1 }, constant: -r.z }
2458
- ], c = [];
2459
- for (const l of a) {
2460
- const d = `${e}_${l.suffix}`;
2461
- this.addPlane(d, { normal: l.normal, constant: l.constant, showHelper: n, helperColor: i }), c.push(d);
1610
+ { suffix: "-z", normal: { x: 0, y: 0, z: 1 }, constant: -a.z }
1611
+ ], l = [];
1612
+ 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);
2462
1615
  }
2463
- return c;
1616
+ return l;
2464
1617
  }
2465
1618
  /**
2466
1619
  * Add a clipping box from an object's bounding box with optional padding.
2467
1620
  */
2468
1621
  addBoxFromObject(e, t, s = 0, n = {}) {
2469
- const i = new V().setFromObject(t);
1622
+ const i = new $().setFromObject(t);
2470
1623
  return i.expandByScalar(s), this.addBox(e, i, n);
2471
1624
  }
2472
1625
  /**
@@ -2506,7 +1659,7 @@ class jn {
2506
1659
  this.hideHelper(e);
2507
1660
  const n = this.planes.get(e);
2508
1661
  if (!n) return;
2509
- const i = new Qt(n, t, new T(s).getHex());
1662
+ const i = new Cs(n, t, new A(s).getHex());
2510
1663
  i.name = e, this.helpers.set(e, i), this.scene.add(i);
2511
1664
  }
2512
1665
  /**
@@ -2532,7 +1685,7 @@ class jn {
2532
1685
  this.detach(), this.removeAll(), this.scene.remove(this.group);
2533
1686
  }
2534
1687
  }
2535
- class Un {
1688
+ class Ui {
2536
1689
  scene;
2537
1690
  measurements = /* @__PURE__ */ new Map();
2538
1691
  _idCounter = 0;
@@ -2543,19 +1696,19 @@ class Un {
2543
1696
  * Measure distance between two points.
2544
1697
  */
2545
1698
  measureDistance(e, t, s = {}) {
2546
- const { lineColor: n = 16776960 } = s, i = new v(e.x, e.y, e.z), r = new v(t.x, t.y, t.z), o = i.distanceTo(r), a = `measure_dist_${this._idCounter++}`, c = new I();
2547
- c.name = a;
2548
- const l = new Q().setFromPoints([i, r]), d = new ie({ color: n }), p = new re(l, d);
2549
- c.add(p), this.scene.add(c);
2550
- const u = {
2551
- id: a,
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();
1700
+ 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);
1703
+ const p = {
1704
+ id: c,
2552
1705
  type: "distance",
2553
1706
  value: o,
2554
1707
  unit: "m",
2555
- points: [i, r],
2556
- object: c
1708
+ points: [i, a],
1709
+ object: l
2557
1710
  };
2558
- return this.measurements.set(a, u), u;
1711
+ return this.measurements.set(c, p), p;
2559
1712
  }
2560
1713
  /**
2561
1714
  * Measure the area of a polygon defined by 3+ coplanar points.
@@ -2564,37 +1717,37 @@ class Un {
2564
1717
  const { lineColor: s = 65280 } = t;
2565
1718
  if (e.length < 3)
2566
1719
  throw new Error("MeasureTool.measureArea requires at least 3 points");
2567
- const n = e.map((u) => new v(u.x, u.y, u.z)), i = this._calculatePolygonArea(n), r = `measure_area_${this._idCounter++}`, o = new I();
2568
- o.name = r;
2569
- const a = [...n, n[0]], c = new Q().setFromPoints(a), l = new ie({ color: s }), d = new re(c, l);
2570
- o.add(d), this.scene.add(o);
2571
- const p = {
2572
- id: r,
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();
1721
+ 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 = {
1725
+ id: a,
2573
1726
  type: "area",
2574
1727
  value: i,
2575
1728
  unit: "m²",
2576
1729
  points: n,
2577
1730
  object: o
2578
1731
  };
2579
- return this.measurements.set(r, p), p;
1732
+ return this.measurements.set(a, d), d;
2580
1733
  }
2581
1734
  /**
2582
1735
  * Measure the angle between three points (vertex at the middle point).
2583
1736
  */
2584
1737
  measureAngle(e, t, s, n = {}) {
2585
- const { lineColor: i = 16746496 } = n, r = new v(e.x, e.y, e.z), o = new v(t.x, t.y, t.z), a = new v(s.x, s.y, s.z), c = r.clone().sub(o).normalize(), l = a.clone().sub(o).normalize(), p = Math.acos(Math.max(-1, Math.min(1, c.dot(l)))) * 180 / Math.PI, u = `measure_angle_${this._idCounter++}`, m = new I();
2586
- m.name = u;
2587
- const w = new Q().setFromPoints([r, o, a]), S = new ie({ color: i }), x = new re(w, S);
2588
- m.add(x), this.scene.add(m);
2589
- const y = {
2590
- id: u,
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 = {
1743
+ id: p,
2591
1744
  type: "angle",
2592
- value: p,
1745
+ value: d,
2593
1746
  unit: "°",
2594
- points: [r, o, a],
1747
+ points: [a, o, c],
2595
1748
  object: m
2596
1749
  };
2597
- return this.measurements.set(u, y), y;
1750
+ return this.measurements.set(p, g), g;
2598
1751
  }
2599
1752
  /**
2600
1753
  * Get a measurement result by id.
@@ -2629,15 +1782,15 @@ class Un {
2629
1782
  * Calculate polygon area using cross product method (Newell's method).
2630
1783
  */
2631
1784
  _calculatePolygonArea(e) {
2632
- const t = e.length, s = new v();
1785
+ const t = e.length, s = new C();
2633
1786
  for (let i = 0; i < t; i++) {
2634
- const r = e[i], o = e[(i + 1) % t], a = new v().crossVectors(r, o);
2635
- s.add(a);
1787
+ const a = e[i], o = e[(i + 1) % t], c = new C().crossVectors(a, o);
1788
+ s.add(c);
2636
1789
  }
2637
- const n = new v();
1790
+ const n = new C();
2638
1791
  if (t >= 3) {
2639
- const i = e[1].clone().sub(e[0]), r = e[2].clone().sub(e[0]);
2640
- n.crossVectors(i, r).normalize();
1792
+ const i = e[1].clone().sub(e[0]), a = e[2].clone().sub(e[0]);
1793
+ n.crossVectors(i, a).normalize();
2641
1794
  }
2642
1795
  return Math.abs(s.dot(n)) / 2;
2643
1796
  }
@@ -2645,7 +1798,7 @@ class Un {
2645
1798
  this.removeAll();
2646
1799
  }
2647
1800
  }
2648
- class Hn {
1801
+ class Wi {
2649
1802
  scene;
2650
1803
  annotations = /* @__PURE__ */ new Map();
2651
1804
  _idCounter = 0;
@@ -2665,9 +1818,9 @@ class Hn {
2665
1818
  */
2666
1819
  add(e, t) {
2667
1820
  this.annotations.has(e) && this.remove(e);
2668
- const s = new I();
1821
+ const s = new H();
2669
1822
  s.name = `annotation_${e}`;
2670
- const n = new v(t.position.x, t.position.y, t.position.z);
1823
+ const n = new C(t.position.x, t.position.y, t.position.z);
2671
1824
  s.position.copy(n);
2672
1825
  const i = document.createElement("div");
2673
1826
  if (i.innerHTML = t.content, i.style.cssText = `
@@ -2679,32 +1832,32 @@ class Hn {
2679
1832
  pointer-events: auto;
2680
1833
  white-space: nowrap;
2681
1834
  `, t.labelStyle)
2682
- for (const c of Object.keys(t.labelStyle)) {
2683
- const l = t.labelStyle[c];
2684
- l !== void 0 && (i.style[c] = l);
1835
+ for (const l of Object.keys(t.labelStyle)) {
1836
+ const h = t.labelStyle[l];
1837
+ h !== void 0 && (i.style[l] = h);
2685
1838
  }
2686
- let r = null;
1839
+ let a = null;
2687
1840
  const o = t.labelOffset || { x: 0, y: 2, z: 0 };
2688
1841
  if (t.showLeaderLine !== !1) {
2689
- const { lineColor: c = 16777215 } = t, l = new Q().setFromPoints([
2690
- new v(0, 0, 0),
2691
- new v(o.x, o.y, o.z)
2692
- ]), d = new ie({ color: c });
2693
- r = new re(l, d), s.add(r);
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);
2694
1847
  }
2695
1848
  if (this._createCSSObject) {
2696
- const c = this._createCSSObject(i);
2697
- c.position.set(o.x, o.y, o.z), s.add(c);
1849
+ const l = this._createCSSObject(i);
1850
+ l.position.set(o.x, o.y, o.z), s.add(l);
2698
1851
  }
2699
1852
  this.scene.add(s);
2700
- const a = {
1853
+ const c = {
2701
1854
  id: e,
2702
1855
  options: t,
2703
1856
  group: s,
2704
1857
  labelElement: i,
2705
- line: r
1858
+ line: a
2706
1859
  };
2707
- return this.annotations.set(e, a), a;
1860
+ return this.annotations.set(e, c), c;
2708
1861
  }
2709
1862
  /**
2710
1863
  * Quick-add a text annotation.
@@ -2798,47 +1951,1109 @@ class Hn {
2798
1951
  this.removeAll();
2799
1952
  }
2800
1953
  }
2801
- const on = "0.0.29";
2802
- window.__USPACE__ = { version: on };
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;
1957
+ for (; e; ) {
1958
+ if (!e.visible) return !1;
1959
+ e = e.parent;
1960
+ }
1961
+ return !0;
1962
+ }
1963
+ function jn(r, e) {
1964
+ const t = r.elements, s = e.elements;
1965
+ for (let n = 0; n < 16; n++)
1966
+ if (Math.abs(t[n] - s[n]) > Nn) return !1;
1967
+ return !0;
1968
+ }
1969
+ function Ft(r) {
1970
+ const e = r.material;
1971
+ return Array.isArray(e) ? e : [e];
1972
+ }
1973
+ function Gt(r) {
1974
+ const e = r.userData, t = e[it];
1975
+ if (t) return t;
1976
+ const s = {
1977
+ transparent: r.transparent,
1978
+ opacity: r.opacity
1979
+ };
1980
+ return e[it] = s, s;
1981
+ }
1982
+ function kn(r, e) {
1983
+ r.traverse((t) => {
1984
+ const s = t;
1985
+ s.isMesh && Ft(s).forEach((n) => {
1986
+ 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;
1989
+ });
1990
+ });
1991
+ }
1992
+ function Un(r) {
1993
+ r.traverse((e) => {
1994
+ const t = e;
1995
+ t.isMesh && Ft(t).forEach((s) => {
1996
+ if (!s) return;
1997
+ const n = s, i = Gt(n);
1998
+ n.transparent = i.transparent, n.opacity = i.opacity, n.needsUpdate = !0;
1999
+ });
2000
+ });
2001
+ }
2002
+ class Hi extends ue {
2003
+ isInstanceObject = !0;
2004
+ type = "InstanceObject";
2005
+ instanceId = "";
2006
+ instanceKind = "";
2007
+ instanceName = "";
2008
+ geometry = new Q();
2009
+ boundingBox = null;
2010
+ boundingSphere = null;
2011
+ #t = {
2012
+ color: null,
2013
+ colorMode: rt,
2014
+ opacity: 1
2015
+ };
2016
+ #a = null;
2017
+ #s = null;
2018
+ #e = null;
2019
+ #n = null;
2020
+ #i = /* @__PURE__ */ new Set();
2021
+ #o = new L();
2022
+ #c = !1;
2023
+ #l = !0;
2024
+ #h = !1;
2025
+ #d;
2026
+ constructor(e = {}) {
2027
+ super(), this.#d = e.boundsName ?? "InstanceBounds";
2028
+ }
2029
+ setInstanceIdentity(e) {
2030
+ let t = !1;
2031
+ if (e.id !== void 0) {
2032
+ const s = e.id ?? "";
2033
+ this.instanceId !== s && (this.instanceId = s, t = !0);
2034
+ }
2035
+ if (e.kind !== void 0) {
2036
+ const s = e.kind ?? "";
2037
+ this.instanceKind !== s && (this.instanceKind = s, t = !0);
2038
+ }
2039
+ if (e.name !== void 0) {
2040
+ const s = e.name ?? "";
2041
+ this.instanceName !== s && (this.instanceName = s, t = !0);
2042
+ }
2043
+ return t && this.markInstanceRenderDirty(), this;
2044
+ }
2045
+ setInstanceBounds(e) {
2046
+ if (e.isEmpty()) return this;
2047
+ this.#s && this.remove(this.#s);
2048
+ const t = new Q();
2049
+ 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;
2053
+ }
2054
+ 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;
2056
+ }
2057
+ getInstanceRenderObject() {
2058
+ return this.#e;
2059
+ }
2060
+ setInstanceMaterializer(e) {
2061
+ return this.#n = e, this;
2062
+ }
2063
+ hasInstanceMaterializer(e) {
2064
+ return this.#n === e;
2065
+ }
2066
+ clearInstanceMaterializer(e) {
2067
+ return (e === void 0 || this.#n === e) && (this.#n = null), this;
2068
+ }
2069
+ materialize() {
2070
+ return this.#n?.() ?? this.#e ?? null;
2071
+ }
2072
+ computeBoundingBox() {
2073
+ this.boundingBox === null && (this.boundingBox = new $()), this.getInstanceBoundingBox(this.boundingBox, !1);
2074
+ }
2075
+ computeBoundingSphere() {
2076
+ if (this.boundingSphere === null && (this.boundingSphere = new ne()), this.boundingBox === null && this.computeBoundingBox(), !this.boundingBox || this.boundingBox.isEmpty()) {
2077
+ this.boundingSphere.makeEmpty();
2078
+ return;
2079
+ }
2080
+ this.boundingBox.getBoundingSphere(this.boundingSphere);
2081
+ }
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();
2085
+ }
2086
+ setInstanceVisible(e) {
2087
+ return this.visible === e ? this : (this.visible = e, this.markInstanceRenderDirty(), this);
2088
+ }
2089
+ setInstanceColor(e) {
2090
+ return this.#t.color = new A(e), this.#t.colorMode = Ee, this.#u(), this.markInstanceRenderDirty(), this;
2091
+ }
2092
+ resetInstanceColor() {
2093
+ return this.#t.color === null ? this : (this.#t.color = null, this.#t.colorMode = rt, this.#u(), this.markInstanceRenderDirty(), this);
2094
+ }
2095
+ setInstanceOpacity(e) {
2096
+ 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);
2098
+ }
2099
+ getInstanceColor(e = new A()) {
2100
+ const t = this.#m();
2101
+ return t.color ? e.copy(t.color) : e.setRGB(1, 1, 1);
2102
+ }
2103
+ hasInstanceColor() {
2104
+ return this.#m().color !== null;
2105
+ }
2106
+ getInstanceOpacity() {
2107
+ return this.#m().opacity;
2108
+ }
2109
+ setInstanceHighlight(e, t, s = !1) {
2110
+ return this.#a = {
2111
+ color: new A(e),
2112
+ colorMode: s ? Ee : Dn,
2113
+ opacity: Math.max(0, Math.min(1, t))
2114
+ }, this.#u(), this.markInstanceRenderDirty(), this;
2115
+ }
2116
+ clearInstanceHighlight() {
2117
+ return this.#a === null ? this : (this.#a = null, this.#u(), this.markInstanceRenderDirty(), this);
2118
+ }
2119
+ getInstanceColorMode() {
2120
+ return this.#m().colorMode;
2121
+ }
2122
+ onInstanceRenderDirty(e) {
2123
+ return this.#i.add(e), () => this.#i.delete(e);
2124
+ }
2125
+ markInstanceRenderDirty() {
2126
+ return this.#i.forEach((e) => e()), this;
2127
+ }
2128
+ updateMatrixWorld(e) {
2129
+ super.updateMatrixWorld(e), this.#r();
2130
+ }
2131
+ updateWorldMatrix(e, t) {
2132
+ super.updateWorldMatrix(e, t), this.#r();
2133
+ }
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());
2137
+ }
2138
+ #p() {
2139
+ this.boundingBox = null, this.boundingSphere = null;
2140
+ }
2141
+ #m() {
2142
+ return this.#a ?? this.#t;
2143
+ }
2144
+ #u() {
2145
+ if (!this.#e) return;
2146
+ const e = this.#m();
2147
+ if (e.color) {
2148
+ Un(this.#e), se.highlightColor(this.#e, {
2149
+ color: e.color,
2150
+ opacity: e.opacity,
2151
+ overwrite: e.colorMode === Ee,
2152
+ multiplyOpacity: !0
2153
+ });
2154
+ return;
2155
+ }
2156
+ se.removeHighlightColor(this.#e), kn(this.#e, e.opacity);
2157
+ }
2158
+ }
2159
+ function Fi(r) {
2160
+ return r.isInstanceObject === !0;
2161
+ }
2162
+ const Wn = /* @__PURE__ */ new Set([
2163
+ "MeshBasicMaterial",
2164
+ "MeshLambertMaterial",
2165
+ "MeshPhongMaterial",
2166
+ "MeshStandardMaterial",
2167
+ "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;
2175
+ return !0;
2176
+ }
2177
+ function $t(r) {
2178
+ let e = r;
2179
+ for (; e; ) {
2180
+ if (!e.visible) return !1;
2181
+ e = e.parent;
2182
+ }
2183
+ return !0;
2184
+ }
2185
+ function Gn(r) {
2186
+ const e = r.source.data;
2187
+ 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}`;
2191
+ }
2192
+ function $n(r) {
2193
+ 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
2217
+ ]);
2218
+ }
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;
2223
+ return Object.fromEntries(
2224
+ Object.keys(e).sort().map((t) => [t, Ae(e[t])])
2225
+ );
2226
+ }
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;
2232
+ return Object.fromEntries(
2233
+ Object.keys(t).filter((s) => s !== "metadata" && s !== "uuid" && s !== "name").sort().map((s) => [s, Te(t[s], e)])
2234
+ );
2235
+ }
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;
2240
+ const t = /* @__PURE__ */ new Map();
2241
+ Object.values(e).forEach((i) => {
2242
+ i instanceof zs && t.set(i.uuid, $n(i));
2243
+ });
2244
+ const s = {
2245
+ geometries: {},
2246
+ materials: {},
2247
+ textures: {},
2248
+ images: {},
2249
+ shapes: {},
2250
+ skeletons: {},
2251
+ animations: {},
2252
+ nodes: {}
2253
+ }, n = r.toJSON(s);
2254
+ return JSON.stringify(Ae(Te(n, t)));
2255
+ }
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]);
2259
+ return e.some((t) => t === null) ? null : JSON.stringify([
2260
+ r.index?.array.constructor.name ?? "non-indexed",
2261
+ e
2262
+ ]);
2263
+ }
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) {
2269
+ s.add(a);
2270
+ return;
2271
+ }
2272
+ if (a instanceof Ts) {
2273
+ s.add(a), n.add("skinned");
2274
+ return;
2275
+ }
2276
+ if (a.morphTargetInfluences) {
2277
+ s.add(a), n.add("morph");
2278
+ return;
2279
+ }
2280
+ if (Array.isArray(a.material)) {
2281
+ s.add(a), n.add("material-array");
2282
+ return;
2283
+ }
2284
+ const o = Kn(a.material), c = Xn(a.geometry);
2285
+ if (!o) {
2286
+ s.add(a), n.add(a.material.transparent || a.material.opacity < 0.999 ? "transparent" : `material:${a.material.type}`);
2287
+ return;
2288
+ }
2289
+ if (!c) {
2290
+ s.add(a), n.add("geometry-layout");
2291
+ return;
2292
+ }
2293
+ if (a.matrixWorld.determinant() <= 0) {
2294
+ s.add(a), n.add("negative-scale");
2295
+ return;
2296
+ }
2297
+ t.push({
2298
+ mesh: a,
2299
+ localMatrix: ot.clone().multiply(a.matrixWorld),
2300
+ materialKey: o,
2301
+ geometryKey: c
2302
+ });
2303
+ }), t.length === 0 && s.size === 0 && n.add("empty"), {
2304
+ meshes: t,
2305
+ fallbackMeshes: s,
2306
+ fallbackReasons: n
2307
+ };
2308
+ }
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);
2317
+ }), t;
2318
+ }
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;
2323
+ };
2324
+ return e.traverse((n) => {
2325
+ n instanceof P && (n.material = Array.isArray(n.material) ? n.material.map(s) : s(n.material));
2326
+ }), e;
2327
+ }
2328
+ function Vn(r) {
2329
+ return Math.max(1, Math.ceil(Math.sqrt(Math.max(1, r))));
2330
+ }
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;
2334
+ }
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;
2338
+ }
2339
+ function lt(r) {
2340
+ let e = 0, t = r.parent;
2341
+ for (; t; )
2342
+ e++, t = t.parent;
2343
+ return e;
2344
+ }
2345
+ class ei extends q {
2346
+ objectIndices;
2347
+ states;
2348
+ #t;
2349
+ constructor(e, t, s, n) {
2350
+ super(e, t), this.objectIndices = s, this.states = n, this.userData.editableGeometryBatch = !0;
2351
+ }
2352
+ raycast(e, t) {
2353
+ if (this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0)
2354
+ return !1;
2355
+ this.#t === void 0 && (this.#t = Et(this.geometry));
2356
+ 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));
2362
+ });
2363
+ }
2364
+ }
2365
+ class Gi extends ue {
2366
+ isEditableGeometryBatchLayer = !0;
2367
+ type = "EditableGeometryBatchLayer";
2368
+ options;
2369
+ stats = {
2370
+ instances: 0,
2371
+ sourceMeshes: 0,
2372
+ batches: 0,
2373
+ drawCallsSaved: 0,
2374
+ vertices: 0,
2375
+ indices: 0,
2376
+ unsupportedInstances: 0,
2377
+ unsupportedByReason: {}
2378
+ };
2379
+ #t = [];
2380
+ #a = /* @__PURE__ */ new Set();
2381
+ #s = [];
2382
+ #e = /* @__PURE__ */ new Map();
2383
+ #n = /* @__PURE__ */ new Set();
2384
+ #i = null;
2385
+ #o = new L();
2386
+ #c = !1;
2387
+ #l = !1;
2388
+ #h = !1;
2389
+ constructor(e = {}) {
2390
+ super(), this.name = "EditableGeometryBatches", this.options = {
2391
+ maxVerticesPerBatch: e.maxVerticesPerBatch ?? 15e5,
2392
+ maxIndicesPerBatch: e.maxIndicesPerBatch ?? 45e5,
2393
+ freezeAnimations: e.freezeAnimations ?? !1
2394
+ };
2395
+ }
2396
+ addSource(e) {
2397
+ if (this.#l) throw new Error("EditableGeometryBatchLayer has been disposed.");
2398
+ if (this.#c) throw new Error("EditableGeometryBatchLayer has already been built.");
2399
+ const { key: t, template: s, instances: n } = e, i = /* @__PURE__ */ new Set();
2400
+ n.forEach((l) => {
2401
+ if (i.has(l) || this.#a.has(l))
2402
+ throw new Error(
2403
+ "EditableGeometryBatchLayer cannot batch the same InstanceObject more than once."
2404
+ );
2405
+ i.add(l);
2406
+ });
2407
+ const { meshes: a, fallbackMeshes: o, fallbackReasons: c } = Qn(
2408
+ s,
2409
+ this.options.freezeAnimations
2410
+ );
2411
+ return i.forEach((l) => this.#a.add(l)), this.#t.push({
2412
+ key: t,
2413
+ template: s,
2414
+ instances: [...n],
2415
+ meshes: a,
2416
+ fallbackMeshes: o,
2417
+ fallbackReasons: c,
2418
+ bounds: new $().setFromObject(s)
2419
+ }), a.length > 0;
2420
+ }
2421
+ build() {
2422
+ if (this.#l) throw new Error("EditableGeometryBatchLayer has been disposed.");
2423
+ if (this.#c) throw new Error("EditableGeometryBatchLayer.build() can only be called once.");
2424
+ 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) => {
2426
+ if (o.length === 0) return;
2427
+ const l = c.size > 0 ? [...c] : ["unknown"];
2428
+ e.push({ key: i.key, template: a, instances: o, reasons: l }), l.forEach((h) => {
2429
+ this.stats.unsupportedByReason[h] = (this.stats.unsupportedByReason[h] ?? 0) + o.length;
2430
+ });
2431
+ };
2432
+ this.#t.forEach((i) => {
2433
+ 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() });
2436
+ });
2437
+ const c = i.fallbackReasons.size > 0 ? i.fallbackReasons : /* @__PURE__ */ new Set(["unknown"]);
2438
+ if (i.meshes.length === 0) {
2439
+ s(
2440
+ i,
2441
+ i.template,
2442
+ a.map(({ instance: l }) => l),
2443
+ c
2444
+ ), s(
2445
+ i,
2446
+ i.template,
2447
+ o,
2448
+ /* @__PURE__ */ new Set([...c, "negative-scale"])
2449
+ );
2450
+ return;
2451
+ }
2452
+ i.fallbackMeshes.size > 0 && s(
2453
+ i,
2454
+ qn(
2455
+ i.template,
2456
+ new Set(i.meshes.map(({ mesh: l }) => l))
2457
+ ),
2458
+ a.map(({ instance: l }) => l),
2459
+ c
2460
+ ), s(
2461
+ i,
2462
+ i.template,
2463
+ o,
2464
+ /* @__PURE__ */ new Set([...i.fallbackReasons, "negative-scale"])
2465
+ ), a.forEach(({ instance: l, matrix: h }) => {
2466
+ const u = this.#s.length, d = () => this.materialize(l), p = {
2467
+ instance: l,
2468
+ template: i.template,
2469
+ initialMatrix: h,
2470
+ objectIndex: u,
2471
+ materialized: !1,
2472
+ materializer: d,
2473
+ unsubscribe: () => {
2474
+ }
2475
+ };
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(
2480
+ "batchObjectIndex",
2481
+ new As(new Float32Array(I.count).fill(u), 1)
2482
+ );
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)
2496
+ };
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;
2498
+ });
2499
+ });
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());
2504
+ }), { stats: { ...this.stats }, unsupported: e };
2505
+ }
2506
+ materialize(e) {
2507
+ const t = this.#e.get(e);
2508
+ 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;
2511
+ }
2512
+ #d(e) {
2513
+ const t = [];
2514
+ let s = [], n = 0, i = 0;
2515
+ e.forEach((a) => {
2516
+ 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;
2518
+ }), 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;
2521
+ o.computeBoundingBox(), o.computeBoundingSphere();
2522
+ const c = a[0], l = a.flatMap((d) => d.objectIndices), h = Zn(c.material, this.#i), u = new ei(
2523
+ o,
2524
+ h,
2525
+ l,
2526
+ this.#s
2527
+ );
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);
2529
+ });
2530
+ }
2531
+ #r() {
2532
+ if (!(!this.#i || this.#n.size === 0 || this.#h)) {
2533
+ this.#h = !0;
2534
+ try {
2535
+ 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) => {
2538
+ 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;
2543
+ } finally {
2544
+ this.#h = !1;
2545
+ }
2546
+ this.#n.size > 0 && this.#r();
2547
+ }
2548
+ }
2549
+ #p(e) {
2550
+ this.#n.add(e), this.#r();
2551
+ }
2552
+ dispose() {
2553
+ this.#l || (this.#l = !0, this.#s.forEach((e) => {
2554
+ 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;
2557
+ e.geometry.dispose(), (Array.isArray(e.material) ? e.material : [e.material]).forEach((s) => s.dispose());
2558
+ }), this.clear());
2559
+ }
2560
+ }
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;
2564
+ for (let n = 0; n < 16; n++)
2565
+ if (Math.abs(s[n] - e[t + n]) > Kt) return !1;
2566
+ return !0;
2567
+ }
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;
2570
+ }
2571
+ function It(r, e) {
2572
+ const t = r.elements, s = e.elements;
2573
+ for (let n = 0; n < 16; n++)
2574
+ if (Math.abs(t[n] - s[n]) > Kt) return !1;
2575
+ return !0;
2576
+ }
2577
+ function _e(r) {
2578
+ let e = r;
2579
+ for (; e; ) {
2580
+ if (!e.visible) return !1;
2581
+ e = e.parent;
2582
+ }
2583
+ return !0;
2584
+ }
2585
+ function ri(r) {
2586
+ const e = r.geometry.morphAttributes;
2587
+ return Object.values(e).some((t) => t?.length);
2588
+ }
2589
+ function ai(r) {
2590
+ const e = r.material;
2591
+ if (!Array.isArray(e)) return !0;
2592
+ if (e.length === 0 || !e.every(Boolean)) return !1;
2593
+ const t = r.geometry.groups;
2594
+ return t.length === 0 ? !1 : t.every((s) => {
2595
+ const n = s.materialIndex ?? 0;
2596
+ return Number.isInteger(s.start) && s.start >= 0 && Number.isInteger(s.count) && s.count > 0 && Number.isInteger(n) && n >= 0 && n < e.length;
2597
+ });
2598
+ }
2599
+ function oi(r) {
2600
+ return !r.isSkinnedMesh && !ri(r) && ai(r);
2601
+ }
2602
+ function St(r) {
2603
+ return Array.isArray(r) ? r : [r];
2604
+ }
2605
+ function Qt(r) {
2606
+ return r.transparent || r.opacity < Xt;
2607
+ }
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;
2611
+ }
2612
+ function ci(r, e, t) {
2613
+ return Array.isArray(r) ? r.map((s) => vt(s, e, t)) : vt(r, e, t);
2614
+ }
2615
+ function li(r) {
2616
+ const e = [], t = new L();
2617
+ 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)) {
2621
+ s = !0;
2622
+ return;
2623
+ }
2624
+ n.updateWorldMatrix(!0, !1), e.push({
2625
+ mesh: n,
2626
+ localMatrix: t.clone().multiply(n.matrixWorld)
2627
+ });
2628
+ }
2629
+ }), s ? [] : e;
2630
+ }
2631
+ function hi(r) {
2632
+ const e = new $();
2633
+ return r.forEach(({ mesh: t, localMatrix: s }) => {
2634
+ const n = t.geometry;
2635
+ n.boundingBox || n.computeBoundingBox(), n.boundingBox && (pt.copy(n.boundingBox).applyMatrix4(s), e.union(pt));
2636
+ }), e;
2637
+ }
2638
+ function te(r) {
2639
+ const e = r;
2640
+ "needsUpdate" in e && (e.needsUpdate = !0);
2641
+ }
2642
+ function Bt(r, e = Mt) {
2643
+ let t = Math.max(Mt, e);
2644
+ for (; t < r; )
2645
+ t *= 2;
2646
+ return t;
2647
+ }
2648
+ function ui(r) {
2649
+ return r !== null && typeof r == "object" && Symbol.iterator in r;
2650
+ }
2651
+ class $i extends ue {
2652
+ isModelInstancedLayer = !0;
2653
+ type = "ModelInstancedLayer";
2654
+ #t = [];
2655
+ #a = /* @__PURE__ */ new Map();
2656
+ #s = /* @__PURE__ */ new Map();
2657
+ #e = /* @__PURE__ */ new Map();
2658
+ #n = !0;
2659
+ #i = !1;
2660
+ #o = !0;
2661
+ #c = si;
2662
+ #l;
2663
+ #h;
2664
+ constructor(e = {}) {
2665
+ super(), this.name = e.name ?? "ModelInstances", this.#l = e.instanceKind ?? "", this.#h = e.getHitUserData ?? (() => ({}));
2666
+ }
2667
+ get instanceKind() {
2668
+ return this.#l;
2669
+ }
2670
+ getInstances() {
2671
+ const e = [];
2672
+ return this.#r((t) => e.push(t)), e;
2673
+ }
2674
+ getInstanceById(e) {
2675
+ return this.#w(), this.#e.get(e);
2676
+ }
2677
+ hasInstance(e) {
2678
+ return this.#w(), this.#e.has(e);
2679
+ }
2680
+ getInstanceCulling() {
2681
+ return {
2682
+ enabled: this.#i,
2683
+ frustum: this.#o,
2684
+ minScreenRadius: this.#c
2685
+ };
2686
+ }
2687
+ setInstanceCulling(e = {}) {
2688
+ 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) {
2690
+ const s = Math.max(0, e.minScreenRadius);
2691
+ Math.abs(this.#c - s) > W && (this.#c = s, t = !0);
2692
+ }
2693
+ return t && this.#t.forEach((s) => this.#v(s)), this;
2694
+ }
2695
+ setInstanceVisible(e) {
2696
+ return this.visible !== e && (this.visible = e), this.#r((t) => {
2697
+ t.setInstanceVisible(e);
2698
+ }), this;
2699
+ }
2700
+ setInstanceColor(e) {
2701
+ return this.#r((t) => {
2702
+ t.setInstanceColor(e);
2703
+ }), this;
2704
+ }
2705
+ resetInstanceColor() {
2706
+ return this.#r((e) => {
2707
+ e.resetInstanceColor();
2708
+ }), this;
2709
+ }
2710
+ setInstanceOpacity(e) {
2711
+ return this.#r((t) => {
2712
+ t.setInstanceOpacity(e);
2713
+ }), this;
2714
+ }
2715
+ setInstanceHighlight(e, t, s = !1) {
2716
+ return this.#r((n) => {
2717
+ n.setInstanceHighlight(e, t, s);
2718
+ }), this;
2719
+ }
2720
+ clearInstanceHighlight() {
2721
+ return this.#r((e) => {
2722
+ e.clearInstanceHighlight();
2723
+ }), this;
2724
+ }
2725
+ reserveBatch(e, t, s) {
2726
+ const n = Math.floor(s);
2727
+ return n <= 0 ? !1 : this.#d(e, t, n) !== null;
2728
+ }
2729
+ addInstance(e, t, s) {
2730
+ return this.addInstances(e, t, [s]);
2731
+ }
2732
+ addInstances(e, t, s) {
2733
+ 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;
2736
+ const a = [], o = /* @__PURE__ */ new Set();
2737
+ 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(
2744
+ c,
2745
+ c.onInstanceRenderDirty(() => {
2746
+ this.#g(), this.#y(i);
2747
+ })
2748
+ );
2749
+ }), this.#g(), this.#b(i), this.#y(i), !0) : (!n && i.instances.length === 0 && this.#f(i), !1);
2750
+ }
2751
+ removeInstance(e) {
2752
+ return this.removeInstances([e]) > 0;
2753
+ }
2754
+ removeInstances(e) {
2755
+ const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), n = typeof e == "string" || !ui(e) ? [e] : e;
2756
+ for (const a of n)
2757
+ typeof a == "string" ? t.add(a) : this.#s.has(a) && s.add(a);
2758
+ t.size > 0 && (this.#w(), t.forEach((a) => {
2759
+ const o = this.#e.get(a);
2760
+ o && s.add(o);
2761
+ }));
2762
+ let i = 0;
2763
+ return s.forEach((a) => {
2764
+ const o = this.#s.get(a);
2765
+ o && this.#I(o, a) && i++;
2766
+ }), i;
2767
+ }
2768
+ removeBatch(e) {
2769
+ const t = this.#a.get(e);
2770
+ return t ? (this.#f(t), !0) : !1;
2771
+ }
2772
+ clearBatches() {
2773
+ return [...this.#a.values()].forEach((e) => this.#f(e)), this;
2774
+ }
2775
+ #d(e, t, s) {
2776
+ const n = this.#a.get(e);
2777
+ if (n)
2778
+ return this.#M(n, s), n;
2779
+ 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();
2783
+ o.name = e, this.add(o);
2784
+ const c = {
2785
+ url: e,
2786
+ batch: o,
2787
+ templateMeshes: i,
2788
+ templateBounds: a,
2789
+ records: [],
2790
+ instances: [],
2791
+ unsubscribeByInstance: /* @__PURE__ */ new Map(),
2792
+ capacity: Bt(s)
2793
+ };
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);
2797
+ }), this.#a.set(e, c), this.#b(c), c;
2798
+ }
2799
+ #r(e) {
2800
+ const t = /* @__PURE__ */ new Set();
2801
+ this.#a.forEach((s) => {
2802
+ s.instances.forEach((n) => {
2803
+ t.has(n) || (t.add(n), e(n));
2804
+ });
2805
+ });
2806
+ }
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(
2811
+ t.material,
2812
+ i,
2813
+ 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 = {
2821
+ batchRecord: e,
2822
+ mesh: h,
2823
+ boundsTree: void 0,
2824
+ raycastMesh: u,
2825
+ localMatrix: s.clone(),
2826
+ fullBoundingSphere: new ne(),
2827
+ materials: c,
2828
+ hasSourceTransparency: l,
2829
+ colorAttribute: i,
2830
+ opacityAttribute: a,
2831
+ renderedInstances: [],
2832
+ visibleInstances: [],
2833
+ lastCameraMatrixWorldInverse: new L(),
2834
+ lastCameraProjectionMatrix: new L(),
2835
+ lastViewportHeight: 0,
2836
+ hasLastCameraState: !1,
2837
+ dirty: !0
2838
+ };
2839
+ h.userData.getInstanceObjectByRenderIndex = (m) => d.renderedInstances[m], h.userData.raycastAcceleration = "lazy";
2840
+ 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++;
2850
+ continue;
2851
+ }
2852
+ const B = d.renderedInstances[I];
2853
+ if (!B || !_e(B)) {
2854
+ b.splice(w, 1);
2855
+ continue;
2856
+ }
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++;
2858
+ }
2859
+ }, h.onBeforeRender = (m, b, S) => this.#B(d, m, S), e.batch.add(h), d;
2860
+ }
2861
+ #m(e, t) {
2862
+ 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);
2864
+ }
2865
+ #u(e, t, s) {
2866
+ const { mesh: n, boundsTree: i, raycastMesh: a } = e;
2867
+ if (!(!i || n.count === 0)) {
2868
+ a.geometry = n.geometry, a.material = n.material;
2869
+ 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) => {
2871
+ c.instanceId = o, c.object = n, s.push(c);
2872
+ }), pe.length = 0;
2873
+ }
2874
+ }
2875
+ #M(e, t) {
2876
+ if (t <= e.capacity) return;
2877
+ e.capacity = Bt(t, e.capacity);
2878
+ 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;
2882
+ }), this.#y(e);
2883
+ }
2884
+ #I(e, t) {
2885
+ 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));
2887
+ }
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();
2890
+ 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);
2892
+ }
2893
+ #S(e) {
2894
+ e.batchRecord.batch.remove(e.mesh), e.mesh.dispose(), e.materials.forEach((t) => t.dispose());
2895
+ }
2896
+ #b(e) {
2897
+ Object.assign(e.batch.userData, {
2898
+ url: e.url,
2899
+ count: e.instances.length,
2900
+ capacity: e.capacity,
2901
+ instanceKind: this.#l
2902
+ }), delete e.batch.userData.sceneInstances, delete e.batch.userData.facilities, e.records.forEach((t) => {
2903
+ delete t.mesh.userData.instances;
2904
+ });
2905
+ }
2906
+ #E(e) {
2907
+ const t = new Set(e), s = /* @__PURE__ */ new Map();
2908
+ for (const i of e) {
2909
+ const { instanceId: a } = i;
2910
+ if (!a) continue;
2911
+ const o = s.get(a);
2912
+ if (o && o !== i) return !1;
2913
+ s.set(a, i);
2914
+ }
2915
+ let n = !0;
2916
+ return s.forEach((i, a) => {
2917
+ n && this.#r((o) => {
2918
+ !n || t.has(o) || o.instanceId === a && (n = !1);
2919
+ });
2920
+ }), n;
2921
+ }
2922
+ #w() {
2923
+ if (!this.#n) return;
2924
+ this.#e.clear();
2925
+ const e = /* @__PURE__ */ new Set();
2926
+ this.#r((t) => {
2927
+ const { instanceId: s } = t;
2928
+ if (!s || e.has(s)) return;
2929
+ const n = this.#e.get(s);
2930
+ if (n && n !== t) {
2931
+ this.#e.delete(s), e.add(s);
2932
+ return;
2933
+ }
2934
+ this.#e.set(s, t);
2935
+ }), this.#n = !1;
2936
+ }
2937
+ #g() {
2938
+ this.#n = !0;
2939
+ }
2940
+ #y(e) {
2941
+ e.records.forEach((t) => this.#v(t));
2942
+ }
2943
+ #v(e) {
2944
+ e.dirty = !0, e.hasLastCameraState = !1, e.mesh.visible = !0, e.mesh.frustumCulled = !1, te(e.batchRecord.batch);
2945
+ }
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);
2949
+ }
2950
+ #_(e) {
2951
+ const { instances: t } = e.batchRecord;
2952
+ 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;
2955
+ return !1;
2956
+ }
2957
+ #C(e) {
2958
+ return e?.getDrawingBufferSize ? (e.getDrawingBufferSize(gt), gt.y) : 0;
2959
+ }
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;
2962
+ }
2963
+ #x(e, t) {
2964
+ return this.#i && e !== void 0 && (this.#o || this.#c > 0 && t > 0);
2965
+ }
2966
+ #A(e, t) {
2967
+ if (!this.#x(e, t)) return null;
2968
+ let s = null;
2969
+ return this.#o && (dt.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse), s = ti.setFromProjectionMatrix(dt)), { camera: e, frustum: s, viewportHeight: t };
2970
+ }
2971
+ #T(e, t) {
2972
+ 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
+ }
2974
+ #L(e, t, s) {
2975
+ const n = Math.abs(t.projectionMatrix.elements[5]);
2976
+ if (n <= W) return 1 / 0;
2977
+ if (t.isOrthographicCamera)
2978
+ 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)))))
2993
+ 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));
3004
+ }), 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
+ }
3006
+ }
3007
+ const di = "0.0.30";
3008
+ typeof window < "u" && (window.__USPACE__ = { version: di });
2803
3009
  export {
2804
- Hn as AnnotationManager,
2805
- Ye as BaseGroup,
2806
- G as BaseMesh,
2807
- Vs as BaseSprite,
2808
- $n as CSS2DObject,
2809
- Kn as CSS3DObject,
2810
- Qn as CSS3DSprite,
2811
- Bs as CSSRenderer,
2812
- Ts as CameraControls,
2813
- zn as CircleMesh,
2814
- jn as ClippingTool,
2815
- Je as ExtrudeMesh,
2816
- vs as InteractionEvent,
2817
- bs as InteractionManager,
2818
- On as LightManager,
2819
- le as MaterialEffects,
2820
- Un as MeasureTool,
2821
- he as Model,
2822
- D as ModelLoaderManager,
2823
- xs as ObjectManager,
2824
- F as ObjectUtils,
2825
- Ln as PlaneMesh,
2826
- In as Poi,
2827
- Ss as RenderPipeline,
2828
- Es as RoomEnvironment,
2829
- Xs as SBMLoader,
2830
- Ls as SBMXLoader,
2831
- Pn as SceneManager,
2832
- En as Selection,
2833
- Ve as ShapeMesh,
2834
- Js as SphereMesh,
2835
- Nn as TSLEffects,
2836
- Bn as TextureLoaderManager,
2837
- Rn as Topology,
2838
- Ie as TubeMesh,
2839
- nn as Tween,
2840
- An as Viewer,
2841
- Dn as reinterpretType,
2842
- kn as tweenAnimation,
2843
- on as version
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,
3030
+ 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
2844
3059
  };