u-space 0.0.28 → 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 (73) 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 +1715 -1497
  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 +51 -51
  18. package/dist/plugins/u-manager/index.d.ts +1 -1
  19. package/dist/plugins/u-manager/index.js +8330 -8637
  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 +20 -3
  23. package/dist/plugins/u-manager/loaders/UManagerLoader.d.ts +4 -4
  24. package/dist/plugins/u-manager/semantics/objects/BuildingGroup.d.ts +12 -5
  25. package/dist/plugins/u-manager/semantics/objects/FacilityInstancedLayer.d.ts +4 -4
  26. package/dist/plugins/u-manager/semantics/objects/FloorMesh.d.ts +28 -22
  27. package/dist/plugins/u-manager/semantics/objects/SemanticGroup.d.ts +6 -6
  28. package/dist/protocol-C-OMPz15.js +10 -0
  29. package/dist/protocol-IUAzx0lk.cjs +1 -0
  30. package/dist/src/batches/EditableGeometryBatchLayer.d.ts +50 -0
  31. package/dist/src/batches/ModelInstancedLayer.d.ts +42 -0
  32. package/dist/src/batches/index.d.ts +2 -0
  33. package/dist/src/effects/TSLEffects.d.ts +24 -1
  34. package/dist/src/index.d.ts +2 -0
  35. package/dist/src/instances/InstanceObject.d.ts +57 -0
  36. package/dist/src/instances/index.d.ts +1 -0
  37. package/dist/src/interactions/MeshBVHRaycast.d.ts +9 -0
  38. package/dist/src/interactions/index.d.ts +1 -0
  39. package/dist/src/viewers/RenderPipeline.d.ts +37 -0
  40. package/dist/src/viewers/ReversedDepthSSGICompat.d.ts +10 -0
  41. package/dist/src/viewers/ReversedDepthSSRCompat.d.ts +20 -0
  42. package/dist/src/viewers/Viewer.d.ts +3 -1
  43. package/dist/src/viewers/renderInvalidation.d.ts +2 -0
  44. package/dist/src/worker/FrameTimingWindow.d.ts +16 -0
  45. package/dist/src/worker/OffscreenViewerHost.d.ts +20 -0
  46. package/dist/src/worker/WorkerDomTarget.d.ts +44 -0
  47. package/dist/src/worker/createWorkerViewer.d.ts +18 -0
  48. package/dist/src/worker/index.d.ts +2 -0
  49. package/dist/src/worker/installWorkerImageLoader.d.ts +5 -0
  50. package/dist/src/worker/protocol.d.ts +102 -0
  51. package/dist/src/worker/runtime.d.ts +2 -0
  52. package/dist/worker/index.cjs +1 -0
  53. package/dist/worker/index.js +224 -0
  54. package/dist/worker/runtime.cjs +1 -0
  55. package/dist/worker/runtime.js +418 -0
  56. package/docs/api-batches.md +112 -0
  57. package/docs/api-effects.md +2 -2
  58. package/docs/api-interactions.md +8 -0
  59. package/docs/api-managers.md +1 -1
  60. package/docs/api-objects.md +207 -0
  61. package/docs/api-plugin-u-manager.md +245 -96
  62. package/docs/api-render-pipeline.md +103 -5
  63. package/docs/api-viewer.md +188 -1
  64. package/docs/changelog.md +69 -6
  65. package/docs/examples-guide.md +111 -17
  66. package/docs/getting-started.md +1 -1
  67. package/docs/index.md +11 -4
  68. package/docs/mcp.md +29 -14
  69. package/docs/release.md +95 -0
  70. package/package.json +27 -4
  71. package/dist/plugins/u-manager/instances/SemanticInstanceObject.d.ts +0 -37
  72. package/dist/plugins/u-manager/instances/SemanticModelInstancedLayer.d.ts +0 -33
  73. package/dist/plugins/u-manager/instances/index.d.ts +0 -2
package/dist/index.js CHANGED
@@ -1,211 +1,22 @@
1
- import { Raycaster as Ne, Vector2 as C, EventDispatcher as De, Box2 as at, Matrix4 as ke, Vector3 as v, Box3 as V, Scene as je, Color as M, AmbientLight as ct, DirectionalLight as ye, PointLight as we, SpotLight as ve, HemisphereLight as be, DirectionalLightHelper as ht, PointLightHelper as lt, SpotLightHelper as dt, HemisphereLightHelper as pt, RenderPipeline as ut, PerspectiveCamera as se, Sphere as Ue, Spherical as T, 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 Mt, MeshStandardNodeMaterial as L, Loader as Tt, LoaderUtils as I, FileLoader as He, TextureLoader as Fe, Group as R, SRGBColorSpace as Ge, RepeatWrapping as xe, BufferGeometry as Q, BufferAttribute as Se, Mesh as k, FrontSide as _t, BackSide as Et, DoubleSide as Pt, REVISION as Ce, CubeTextureLoader as Ot, EquirectangularReflectionMapping as At, Sprite as Bt, AnimationMixer as It, LoopRepeat as Rt, 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 fe, 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 Te, time as oe, pow as ae, sin as ge, mix as ce, mx_noise_float as _e, Fn as We, userData as O, materialColor as Ee, select as q, materialOpacity as Pe, 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 Gn } 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 Wn, CSS3DSprite as Kn } 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 Oe } 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 Ne();
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 _n extends De {
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 _n extends De {
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 _n extends De {
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 ke();
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 En {
155
+ class Oi {
538
156
  scenes = /* @__PURE__ */ new Map();
539
157
  _activeSceneKey = null;
540
158
  /**
@@ -547,8 +165,8 @@ class En {
547
165
  * Create and register a new scene.
548
166
  */
549
167
  create(e, t = {}) {
550
- const s = new je();
551
- return t.background !== void 0 && (s.background = new M(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 En {
587
205
  const t = this.scenes.get(e);
588
206
  if (!t) return null;
589
207
  let s = null;
590
- return t.background instanceof M && (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 En {
608
226
  return this.scenes.size;
609
227
  }
610
228
  }
611
- class Pn {
229
+ class Ai {
612
230
  scene;
613
231
  lights = /* @__PURE__ */ new Map();
614
232
  helpers = /* @__PURE__ */ new Map();
@@ -616,34 +234,34 @@ class Pn {
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 ye(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 we(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 ve(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 be(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.
@@ -682,803 +300,244 @@ class Pn {
682
300
  */
683
301
  removeAll() {
684
302
  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 ye ? s = new ht(t, 1) : t instanceof we ? s = new lt(t, 0.5) : t instanceof ve ? s = new dt(t) : t instanceof be && (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 = fe(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 = fe(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: ke,
890
- Spherical: T,
891
- Box3: V,
892
- Sphere: Ue,
893
- Raycaster: Ne
894
- };
895
- Ke.install({ THREE: Cs });
896
- class Ms 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 = Ts(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, o = [];
911
- if (s !== "current") {
912
- const a = Ae[s.toUpperCase()] ?? Ae.FRONTTOP, c = a.theta, l = a.phi;
913
- o.push(
914
- this.fitToBox(e, n, {
915
- paddingLeft: i,
916
- paddingRight: i,
917
- paddingTop: i,
918
- paddingBottom: i,
919
- cover: r
920
- })
921
- ), o.push(this.rotateTo(c, l, n));
922
- } else {
923
- const a = new Ue();
924
- e.getBoundingSphere(a), a.radius += i, o.push(this.fitToSphere(a, n));
925
- }
926
- return await Promise.all(o), !0;
927
- }
928
- async flyToObject(e, t = {}) {
929
- const s = new V().setFromObject(e);
930
- return this.flyToBox(s, t);
931
- }
932
- /**
933
- * Fly camera to a specific position and look-at target.
934
- */
935
- async flyTo(e, t, s = {}) {
936
- const { enableTransition: n = !0 } = s;
937
- return this.absoluteRotations(), this.setLookAt(e.x, e.y, e.z, t.x, t.y, t.z, n);
938
- }
939
- /**
940
- * Get the current camera viewpoint data (position, target, zoom).
941
- */
942
- getCameraViewpoint() {
943
- const e = new v(), t = new v();
944
- return this.getPosition(e), this.getTarget(t), {
945
- position: { x: e.x, y: e.y, z: e.z },
946
- target: { x: t.x, y: t.y, z: t.z },
947
- zoom: this.camera.zoom
948
- };
949
- }
950
- /**
951
- * Lock camera controls (disable all user interaction).
952
- */
953
- lock() {
954
- this.enabled = !1;
955
- }
956
- /**
957
- * Unlock camera controls (re-enable user interaction).
958
- */
959
- unlock() {
960
- this.enabled = !0;
961
- }
962
- /**
963
- * Switch between 2D top-down and 3D perspective views.
964
- */
965
- async setViewMode(e, t = !0) {
966
- if (e === "2d") {
967
- const s = new v();
968
- this.getTarget(s), await this.rotateTo(0, 0, t), this.minPolarAngle = 0, this.maxPolarAngle = 0;
969
- } else
970
- this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, await this.rotateTo(0, Math.PI / 4, t);
971
- }
972
- async setCameraViewpoint(e, t = !0) {
973
- const { position: s, target: n, zoom: i = this.camera.zoom } = e;
974
- return Promise.all([
975
- this.zoomTo(i, t),
976
- this.setLookAt(s.x, s.y, s.z, n.x, n.y, n.z, t)
977
- ]);
978
- }
979
- }
980
- const Ae = {
981
- LEFT: new T(0, Math.PI / 2, -Math.PI / 2),
982
- RIGHT: new T(0, Math.PI / 2, Math.PI / 2),
983
- FRONT: new T(0, Math.PI / 2, 0),
984
- BACK: new T(0, Math.PI / 2, Math.PI),
985
- TOP: new T(0, 0, 0),
986
- BOTTOM: new T(0, Math.PI, 0),
987
- FRONTTOP: new T(0, Math.PI / 4, 0),
988
- BACKTOP: new T(0, Math.PI / 4, Math.PI),
989
- LEFTTOP: new T(0, Math.PI / 4, -Math.PI / 2),
990
- RIGHTTOP: new T(0, Math.PI / 4, Math.PI / 2),
991
- LEFTFRONTTOP: new T(0, Math.PI / 4, -Math.PI / 4),
992
- RIGHTFRONTTOP: new T(0, Math.PI / 4, Math.PI / 4),
993
- LEFTBACKTOP: new T(0, Math.PI / 4, -Math.PI / 4 * 3),
994
- RIGHTBACKTOP: new T(0, Math.PI / 4, Math.PI / 4 * 3)
995
- };
996
- function Ts(h, e) {
997
- const t = h - e;
998
- return gt.euclideanModulo(t + Math.PI, Math.PI * 2) - Math.PI;
999
- }
1000
- class _s {
1001
- environment = new is();
1002
- renderer;
1003
- pmremGenerator;
1004
- envMap = null;
1005
- constructor(e) {
1006
- this.renderer = e, this.pmremGenerator = new yt(e);
1007
- }
1008
- update() {
1009
- this.envMap || (this.envMap = this.pmremGenerator.fromScene(this.environment).texture);
1010
- }
1011
- dispose() {
1012
- this.pmremGenerator.dispose(), this.envMap?.dispose();
1013
- }
1014
- }
1015
- const te = 128;
1016
- class Es extends rs {
1017
- viewer;
1018
- overlayPass;
1019
- constructor(e) {
1020
- super(e.camera, e.el), this.viewer = e;
1021
- const t = new ne(-2, 2, 2, -2, 0, 4);
1022
- t.position.set(0, 0, 2), this.overlayPass = fe(this, t), this.setLabels("x", "y", "z");
1023
- }
1024
- _update = () => {
1025
- this.quaternion.copy(this.viewer.camera.quaternion).invert();
1026
- const e = this.location;
1027
- let t, s;
1028
- 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);
1029
- };
1030
- enable() {
1031
- return this.viewer.renderPipeline.addOverlayPass(this.overlayPass), this.viewer.addEventListener("beforeRender", this._update), this.viewer.render(), this;
1032
- }
1033
- disable() {
1034
- return this.viewer.renderPipeline.removeOverlayPass(this.overlayPass), this.viewer.removeEventListener("beforeRender", this._update), this.viewer.render(), this;
1035
- }
1036
- }
1037
- const qe = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;overflow:hidden;", Ps = qe + "z-index:0;", Os = qe + "z-index:1;";
1038
- class As {
1039
- el;
1040
- css2dRenderer = null;
1041
- css3dRenderer = null;
1042
- constructor(e) {
1043
- this.el = e, getComputedStyle(e).position === "static" && (e.style.position = "relative");
1044
- }
1045
- initCSS2DRenderer() {
1046
- const e = new os();
1047
- return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = Os, this.el.appendChild(e.domElement), this.css2dRenderer = e, e;
1048
- }
1049
- initCSS3DRenderer() {
1050
- const e = new cs();
1051
- return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = Ps, this.el.appendChild(e.domElement), this.css3dRenderer = e, e;
1052
- }
1053
- createCSS2DObject(e) {
1054
- return this.css2dRenderer || this.initCSS2DRenderer(), new as(e);
1055
- }
1056
- createCSS25DObject(e) {
1057
- return this.css3dRenderer || this.initCSS3DRenderer(), new hs(e);
1058
- }
1059
- createCSS3DObject(e) {
1060
- return this.css3dRenderer || this.initCSS3DRenderer(), new ls(e);
1061
- }
1062
- render(e, t) {
1063
- this.css2dRenderer && this.css2dRenderer.render(e, t), this.css3dRenderer && this.css3dRenderer.render(e, t);
1064
- }
1065
- resize(e, t) {
1066
- this.css2dRenderer && this.css2dRenderer.setSize(e, t), this.css3dRenderer && this.css3dRenderer.setSize(e, t);
1067
- }
1068
- dispose() {
1069
- this.css2dRenderer && (this.el.removeChild(this.css2dRenderer.domElement), this.css2dRenderer = null), this.css3dRenderer && (this.el.removeChild(this.css3dRenderer.domElement), this.css3dRenderer = null);
1070
- }
1071
- }
1072
- const Bs = "timestamp-query";
1073
- class Is {
1074
- el;
1075
- renderer;
1076
- container;
1077
- drawCallsText;
1078
- frameCallsText;
1079
- trianglesText;
1080
- pointsText;
1081
- linesText;
1082
- timestampText;
1083
- _enabled = !1;
1084
- #t = !1;
1085
- constructor(e, t) {
1086
- this.el = e, this.renderer = t;
1087
- const s = document.createElement("div");
1088
- 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;
1089
- function n(r, o = !0) {
1090
- const a = document.createElement("span");
1091
- return o && (a.style.marginLeft = "6px"), a.innerText = r, a;
1092
- }
1093
- function i() {
1094
- return document.createElement("br");
1095
- }
1096
- 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());
1097
- }
1098
- update() {
1099
- if (this._enabled) {
1100
- const { render: e } = this.renderer.info;
1101
- 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) {
1102
- this.timestampText.innerText = "0";
1103
- return;
1104
- }
1105
- this.#n(Z.RENDER).then((t) => {
1106
- this._enabled && (this.timestampText.innerText = t?.toFixed(2) ?? "0");
1107
- }), this.#n(Z.COMPUTE);
1108
- }
1109
- }
1110
- enable() {
1111
- this._enabled = !0, this.#r(!0), this.el.appendChild(this.container);
1112
- }
1113
- disable() {
1114
- this._enabled = !1, this.#r(!1), this.#o(), this.container.remove();
1115
- }
1116
- dispose() {
1117
- this.disable();
1118
- }
1119
- #e() {
1120
- return this.renderer.backend;
1121
- }
1122
- #s() {
1123
- try {
1124
- return this.renderer.hasFeature(Bs);
1125
- } catch {
1126
- return !0;
1127
- }
1128
- }
1129
- #r(e) {
1130
- const t = this.#e();
1131
- if (!t) {
1132
- this.#t = !1;
1133
- return;
1134
- }
1135
- t.trackTimestamp = e && this.#s(), this.#t = t.trackTimestamp === !0;
1136
- }
1137
- #n(e) {
1138
- const t = this.#e()?.timestampQueryPool?.[e];
1139
- return t?.resolveQueriesAsync ? Promise.resolve(t.resolveQueriesAsync()).catch(() => {
1140
- }) : Promise.resolve(void 0);
1141
- }
1142
- #o() {
1143
- this.#n(Z.RENDER), this.#n(Z.COMPUTE);
1144
- }
1145
- }
1146
- wt.enabled = !0;
1147
- class On extends De {
1148
- el;
1149
- renderer;
1150
- scene;
1151
- camera;
1152
- info;
1153
- controls;
1154
- renderPipeline;
1155
- timer;
1156
- roomEnvironment;
1157
- interactionManager;
1158
- objectManager;
1159
- viewerHelper;
1160
- cssRenderer;
1161
- frameCount = 1;
1162
- frameloop = "demand";
1163
- constructor({ el: e, rendererOptions: t }) {
1164
- 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 Ms(this.camera, this.renderer.domElement), this.renderPipeline = new Ss(this.renderer, this.scene, this.camera), this.timer = new vt(), this.roomEnvironment = new _s(this.renderer), this.interactionManager = new bs(this.renderer.domElement, this.scene, this.camera), this.objectManager = new xs(), this.viewerHelper = new Es(this), this.cssRenderer = new As(this.el), window.addEventListener("resize", this.onWindowResize);
1165
- }
1166
- onWindowResize = () => {
1167
- const e = this.el.clientWidth, t = this.el.clientHeight;
1168
- 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();
1169
- };
1170
- async init() {
1171
- await this.renderer.init(), this.roomEnvironment.update(), this.scene.environment = this.roomEnvironment.envMap;
1172
- }
1173
- setCamera(e) {
1174
- this.camera = e, this.controls.camera = e, this.interactionManager.setCamera(e), this.renderPipeline.setCamera(e), this.onWindowResize(), this.dispatchEvent({ type: "cameraChange", camera: e });
1175
- }
1176
- setCameraByType(e) {
1177
- e === "perspective" && !(this.camera instanceof se) ? this.setCamera(this.createPerspectiveCamera()) : e === "orthographic" && !(this.camera instanceof ne) && this.setCamera(this.createOrthographicCamera());
1178
- }
1179
- render(e = 1) {
1180
- return this.frameCount += e, new Promise((t) => {
1181
- const s = () => {
1182
- this.removeEventListener("afterRender", s), t();
1183
- };
1184
- this.addEventListener("afterRender", s);
1185
- });
1186
- }
1187
- animate = (e) => {
1188
- this.timer.update(e);
1189
- const t = this.timer.getDelta();
1190
- this.dispatchEvent({ type: "beforeControlsUpdate", time: e, delta: t });
1191
- let s = this.controls.update(t);
1192
- 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 }));
1193
- };
1194
- _initRenderer(e) {
1195
- const t = new bt({
1196
- reversedDepthBuffer: !0,
1197
- antialias: !1,
1198
- depth: !1,
1199
- trackTimestamp: !1,
1200
- ...e
1201
- });
1202
- 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;
1203
- }
1204
- createScene() {
1205
- const e = new je();
1206
- return e.background = new M(0), e;
1207
- }
1208
- createPerspectiveCamera() {
1209
- const e = new se(50, this.el.clientWidth / this.el.clientHeight, 0.1, 1e5);
1210
- return e.position.setScalar(5), e;
1211
- }
1212
- createOrthographicCamera() {
1213
- const e = new ne(
1214
- -this.el.clientWidth / 2,
1215
- this.el.clientWidth / 2,
1216
- this.el.clientHeight / 2,
1217
- -this.el.clientHeight / 2,
1218
- 0.1,
1219
- 1e5
1220
- );
1221
- return e.position.setScalar(5), e;
1222
- }
1223
- /**
1224
- * Manually trigger a resize update.
1225
- */
1226
- resize(e, t) {
1227
- e !== void 0 && t !== void 0 && (this.el.style.width = `${e}px`, this.el.style.height = `${t}px`), this.onWindowResize();
1228
- }
1229
- /**
1230
- * Capture a screenshot of the current render.
1231
- */
1232
- async screenshot(e = {}) {
1233
- const { type: t = "image/png", quality: s = 1 } = e, n = this.el.clientWidth, i = this.el.clientHeight, r = e.width && e.height;
1234
- r && this.renderer.setSize(e.width, e.height), await this.render();
1235
- const o = this.renderer.domElement.toDataURL(t, s);
1236
- return r && (this.renderer.setSize(n, i), this.onWindowResize()), o;
1237
- }
1238
- /**
1239
- * Set the scene background color, texture, or null.
1240
- */
1241
- setBackground(e) {
1242
- e === null ? this.scene.background = null : e instanceof M || typeof e == "number" || typeof e == "string" ? this.scene.background = new M(e) : this.scene.background = e, this.render();
1243
- }
1244
- /**
1245
- * Set the scene environment map for reflections / IBL.
1246
- */
1247
- setEnvironment(e) {
1248
- this.scene.environment = e, this.render();
303
+ for (const t of e)
304
+ this.remove(t);
1249
305
  }
1250
306
  /**
1251
- * Enable shadow rendering.
307
+ * Show a visual helper for a light.
1252
308
  */
1253
- enableShadow() {
1254
- this.renderer.shadowMap.enabled = !0, 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));
1255
315
  }
1256
316
  /**
1257
- * Disable shadow rendering.
317
+ * Hide (remove) the helper for a light.
1258
318
  */
1259
- disableShadow() {
1260
- this.renderer.shadowMap.enabled = !1, this.render();
319
+ hideHelper(e) {
320
+ const t = this.helpers.get(e);
321
+ t && (this.scene.remove(t), this.helpers.delete(e));
1261
322
  }
1262
323
  /**
1263
- * Enable linear fog.
324
+ * Show helpers for all lights.
1264
325
  */
1265
- enableFog(e = {}) {
1266
- const { color: t = 13421772, near: s = 10, far: n = 100 } = e;
1267
- this.scene.fog = new Ct(t, s, n), this.render();
326
+ showAllHelpers() {
327
+ for (const [e] of this.lights)
328
+ this.showHelper(e);
1268
329
  }
1269
330
  /**
1270
- * Enable exponential fog.
331
+ * Hide all helpers.
1271
332
  */
1272
- enableFogExp2(e = {}) {
1273
- const { color: t = 13421772, density: s = 0.01 } = e;
1274
- this.scene.fog = new Mt(t, s), this.render();
333
+ hideAllHelpers() {
334
+ const e = Array.from(this.helpers.keys());
335
+ for (const t of e)
336
+ this.hideHelper(t);
1275
337
  }
1276
- /**
1277
- * Disable fog.
1278
- */
1279
- disableFog() {
1280
- this.scene.fog = null, this.render();
338
+ _register(e, t) {
339
+ this.lights.has(e) && this.remove(e), this.lights.set(e, t), this.scene.add(t);
1281
340
  }
1282
341
  dispose() {
1283
- 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();
1284
343
  }
1285
344
  }
1286
- class Rs extends Qe {
345
+ class tn extends Tt {
1287
346
  constructor(e) {
1288
347
  super(e);
1289
348
  }
1290
349
  parse(e, t, s, n) {
1291
- if (Ls(e.slice(0, 8)) === "SBMG----") {
1292
- const r = zs(e.slice(8));
1293
- 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);
1294
353
  } else
1295
354
  return super.parse(e, t, s, n);
1296
355
  }
1297
356
  }
1298
- function Ls(h) {
1299
- return new TextDecoder().decode(new Uint8Array(h));
357
+ function sn(r) {
358
+ return new TextDecoder().decode(new Uint8Array(r));
1300
359
  }
1301
- function zs(h) {
1302
- const e = new DataView(h);
360
+ function nn(r) {
361
+ const e = new DataView(r);
1303
362
  for (let t = 0; t < e.byteLength; t++) {
1304
363
  const s = e.getUint8(t), n = (s >> 4 & 15) + (s << 4 & 240);
1305
364
  e.setUint8(t, n);
1306
365
  }
1307
366
  return e.buffer;
1308
367
  }
1309
- const Ns = 8, Ds = 130, Be = 66, ks = "SBK-----", js = "SBM-----", Xe = new TextDecoder(), Us = new TextEncoder();
1310
- function Hs(h) {
1311
- let e = Ns;
1312
- const t = new Uint8Array(h, 0, e);
1313
- if (Xe.decode(t) !== ks)
1314
- return h;
1315
- e += Ds;
1316
- 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);
1317
376
  if (n[40] === 1) {
1318
- const r = Us.encode(js), o = new Uint8Array([n[41]]), a = Fs(n), c = Gs(a);
1319
- let l = Be % c.length;
1320
- const d = e + Be, p = new Uint8Array(h, d), u = new Uint8Array(p.length);
1321
- for (let w = 0; w < p.length; w++)
1322
- u[w] = p[w] ^ c[l], l = (l + 1) % c.length;
1323
- const m = new Uint8Array(r.length + o.length + u.length);
1324
- 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;
1325
384
  }
1326
385
  }
1327
- function Fs(h) {
386
+ function un(r) {
1328
387
  const e = new Uint8Array(128);
1329
- 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;
1330
389
  }
1331
- function Gs(h) {
390
+ function dn(r) {
1332
391
  const e = new Uint8Array(64);
1333
- 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;
1334
393
  }
1335
- const $s = (h, e, t) => {
1336
- const s = h.buffer.slice(t, t + e);
1337
- 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);
1338
397
  return n = n.replace("\\", "/"), n.startsWith("Maps/") || (n = `Maps/${n}`), n;
1339
- }, Ws = (h, e, t) => {
1340
- const [s, n, i, r, o] = e, a = t || r < 1;
1341
- return new L({
1342
- name: h,
1343
- color: new M(s, n, i),
1344
- opacity: r,
1345
- 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,
1346
405
  alphaTest: 0.01,
1347
406
  side: o
1348
407
  });
1349
- }, Ks = (h) => h?.toLowerCase().endsWith(".png") ?? !1;
1350
- class Qs {
408
+ }, fn = (r) => r?.toLowerCase().endsWith(".png") ?? !1;
409
+ class gn {
1351
410
  data;
1352
411
  options;
1353
412
  textureLoader;
1354
413
  littleEndian = !0;
1355
414
  materials = /* @__PURE__ */ new Map();
1356
415
  constructor(e, t) {
1357
- 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);
1358
417
  }
1359
418
  parse(e, t) {
1360
419
  let s = this.data;
1361
- const n = Hs(this.data);
420
+ const n = hn(this.data);
1362
421
  n && (s = n);
1363
422
  const i = new DataView(s);
1364
- let r = 8;
1365
- const o = i.getUint8(r);
1366
- 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}`));
1367
426
  }
1368
427
  _parseV2(e, t, s) {
1369
- const n = new R(), i = e.getUint16(t, this.littleEndian);
428
+ const n = new H(), i = e.getUint16(t, this.littleEndian);
1370
429
  t += 2;
1371
- const r = e.getUint16(t, this.littleEndian);
430
+ const a = e.getUint16(t, this.littleEndian);
1372
431
  t += 2;
1373
432
  for (let o = 0; o < i; ++o) {
1374
- const a = e.getUint16(t, this.littleEndian).toString();
433
+ const c = e.getUint16(t, this.littleEndian).toString();
1375
434
  t += 2, t += 4, t += 4, t += 4, t += 4;
1376
- const c = e.getFloat32(t, this.littleEndian);
1377
- t += 4;
1378
435
  const l = e.getFloat32(t, this.littleEndian);
1379
436
  t += 4;
1380
- const d = e.getFloat32(t, this.littleEndian);
437
+ const h = e.getFloat32(t, this.littleEndian);
1381
438
  t += 4;
1382
- const p = e.getFloat32(t, this.littleEndian);
439
+ const u = e.getFloat32(t, this.littleEndian);
440
+ t += 4;
441
+ const d = e.getFloat32(t, this.littleEndian);
1383
442
  t += 4, t += 4, t += 4, t += 4, t += 4;
1384
- let u = e.getUint8(t);
1385
- 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);
1386
445
  const m = e.getUint16(t, this.littleEndian);
1387
446
  t += 2;
1388
- const w = m > 0 ? $s(e, m, t) : "";
1389
- if (t += m, !this.materials.has(a)) {
1390
- const x = Ws(a, [c, l, d, p, u], Ks(w));
1391
- this.materials.set(a, x), w && this.options.path && this.textureLoader.load(I.resolveURL(w, this.options.path), (y) => {
1392
- y.colorSpace = Ge, y.wrapS = xe, y.wrapT = xe, 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;
1393
452
  });
1394
453
  }
1395
454
  }
1396
- for (let o = 0; o < r; ++o) {
1397
- const a = e.getUint16(t, this.littleEndian).toString();
1398
- t += 2;
455
+ for (let o = 0; o < a; ++o) {
1399
456
  const c = e.getUint16(t, this.littleEndian).toString();
1400
457
  t += 2;
1401
- 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);
1402
461
  if (t += 2, m > 0)
1403
- for (let g = 0; g < m; g++) {
1404
- const b = new v();
1405
- 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(_);
1406
465
  }
1407
- const w = e.getUint16(t, this.littleEndian);
1408
- if (t += 2, w > 0)
1409
- 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++)
1410
469
  t += 4, t += 4, t += 4;
1411
470
  const S = e.getUint16(t, this.littleEndian);
1412
471
  if (t += 2, S > 0)
1413
- for (let g = 0; g < S; g++) {
1414
- const b = new C();
1415
- 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(_);
1416
475
  }
1417
- const x = e.getUint16(t, this.littleEndian);
1418
- if (t += 2, x > 0)
1419
- for (let g = 0; g < x; g++) {
1420
- 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);
1421
480
  t += 2;
1422
- const z = e.getUint16(t, this.littleEndian);
481
+ const k = e.getUint16(t, this.littleEndian);
1423
482
  t += 2;
1424
483
  const N = e.getUint16(t, this.littleEndian);
1425
484
  t += 2;
1426
- const P = [b, z, N];
1427
- 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]]]);
1428
487
  }
1429
- const y = [], _ = [];
1430
- for (let g = 0; g < p.length; g++) {
1431
- const b = p[g], z = l[b[0]], N = l[b[1]], P = l[b[2]];
1432
- y.push(...z.toArray(), ...N.toArray(), ...P.toArray());
1433
- let J = new C(), W = new C(), j = new C();
1434
- const U = u[g];
1435
- 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());
1436
495
  }
1437
- const A = new Float32Array(y), B = new Float32Array(_), E = new Q();
1438
- if (A.length > 0 && E.setAttribute("position", new Se(A, 3)), B.length > 0 && E.setAttribute("uv", new Se(B, 2)), E.computeVertexNormals(), this.materials.has(c)) {
1439
- const g = new k(E, this.materials.get(c));
1440
- 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);
1441
500
  }
1442
501
  }
1443
502
  s(n);
1444
503
  }
1445
504
  _parseV3(e, t, s) {
1446
- const n = new R();
505
+ const n = new H();
1447
506
  console.warn("SBMLoader: SBM version 3 is not supported yet."), s(n);
1448
507
  }
1449
508
  }
1450
- class qs extends Tt {
509
+ class yn extends ns {
1451
510
  load(e, t, s, n) {
1452
511
  let i;
1453
512
  if (this.resourcePath !== "")
1454
513
  i = this.resourcePath;
1455
514
  else if (this.path !== "") {
1456
- const a = I.extractUrlBase(e);
1457
- i = I.resolveURL(a, this.path);
515
+ const c = G.extractUrlBase(e);
516
+ i = G.resolveURL(c, this.path);
1458
517
  } else
1459
- i = I.extractUrlBase(e);
518
+ i = G.extractUrlBase(e);
1460
519
  this.manager.itemStart(e);
1461
- const r = (a) => {
1462
- n ? n(a) : console.error(a), this.manager.itemError(e), this.manager.itemEnd(e);
1463
- }, 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);
1464
523
  o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(
1465
524
  e,
1466
- (a) => {
525
+ (c) => {
1467
526
  try {
1468
527
  this.parse(
1469
- a,
528
+ c,
1470
529
  i,
1471
- (c) => {
1472
- t(c), this.manager.itemEnd(e);
530
+ (l) => {
531
+ t(l), this.manager.itemEnd(e);
1473
532
  },
1474
- r
533
+ a
1475
534
  );
1476
- } catch (c) {
1477
- r(c);
535
+ } catch (l) {
536
+ a(l);
1478
537
  }
1479
538
  },
1480
539
  s,
1481
- r
540
+ a
1482
541
  );
1483
542
  }
1484
543
  parse(e, t, s, n) {
@@ -1487,7 +546,7 @@ class qs extends Tt {
1487
546
  n?.(new Error(`SBMLoader: Invalid SBM format: ${i}`));
1488
547
  return;
1489
548
  }
1490
- new Qs(e, {
549
+ new gn(e, {
1491
550
  path: t,
1492
551
  crossOrigin: this.crossOrigin,
1493
552
  requestHeader: this.requestHeader,
@@ -1509,7 +568,7 @@ class qs extends Tt {
1509
568
  });
1510
569
  }
1511
570
  }
1512
- const Xs = [
571
+ const bn = [
1513
572
  "map",
1514
573
  "alphaMap",
1515
574
  "aoMap",
@@ -1536,36 +595,36 @@ const Xs = [
1536
595
  "thicknessMap",
1537
596
  "transmissionMap"
1538
597
  ];
1539
- function K(h) {
1540
- return h.traverse((e) => {
1541
- if (!(e instanceof k)) return;
598
+ function oe(r) {
599
+ return r.traverse((e) => {
600
+ if (!(e instanceof P)) return;
1542
601
  const t = Array.isArray(e.material) ? e.material : [e.material];
1543
602
  for (const s of t) {
1544
603
  if (!s) continue;
1545
604
  let n = !1;
1546
- for (const i of Xs) {
1547
- const r = s[i];
1548
- 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);
1549
608
  }
1550
609
  n && (s.needsUpdate = !0);
1551
610
  }
1552
- }), h;
611
+ }), r;
1553
612
  }
1554
- class D {
613
+ class X {
1555
614
  static CACHE_NAME = "u-space-model-loader-cache";
1556
- static fileLoader = new He().setResponseType("arraybuffer");
1557
- static dracoLoader = new ms().setDecoderPath(
1558
- `https://cdn.jsdelivr.net/npm/three@0.${Ce}.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/`
1559
618
  );
1560
- static ktx2Loader = new fs().setTranscoderPath(
1561
- `https://cdn.jsdelivr.net/npm/three@0.${Ce}.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/`
1562
621
  );
1563
- static gltfLoader = new Qe().setDRACOLoader(D.dracoLoader).setKTX2Loader(D.ktx2Loader).setMeshoptDecoder(Oe);
1564
- static sbmxLoader = new Rs().setDRACOLoader(D.dracoLoader).setKTX2Loader(D.ktx2Loader).setMeshoptDecoder(Oe);
1565
- static sbmLoader = new qs();
1566
- static fbxLoader = new ds();
1567
- static objLoader = new ps();
1568
- 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();
1569
628
  static setLoadingManager(e) {
1570
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;
1571
630
  }
@@ -1593,23 +652,23 @@ class D {
1593
652
  switch (t.persistent && typeof caches < "u" ? n = await this.getPersistentData(e) : n = await this.fileLoader.loadAsync(e), s) {
1594
653
  case "gltf":
1595
654
  case "glb":
1596
- const i = await this.gltfLoader.parseAsync(n, I.extractUrlBase(e));
1597
- 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);
1598
657
  case "sbmx":
1599
- const r = await this.sbmxLoader.parseAsync(n, I.extractUrlBase(e));
1600
- 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);
1601
660
  case "sbm":
1602
- const o = await this.sbmLoader.parseAsync(n, I.extractUrlBase(e));
1603
- return K(o);
661
+ const o = await this.sbmLoader.parseAsync(n, G.extractUrlBase(e));
662
+ return oe(o);
1604
663
  case "fbx":
1605
- const a = this.fbxLoader.parse(n, I.extractUrlBase(e));
1606
- return K(a);
664
+ const c = this.fbxLoader.parse(n, G.extractUrlBase(e));
665
+ return oe(c);
1607
666
  case "obj":
1608
- const c = new TextDecoder().decode(n), l = this.objLoader.parse(c);
1609
- return K(l);
667
+ const l = new TextDecoder().decode(n), h = this.objLoader.parse(l);
668
+ return oe(h);
1610
669
  case "stl":
1611
- const d = this.stlLoader.parse(n);
1612
- return new k(d, new L());
670
+ const u = this.stlLoader.parse(n);
671
+ return new P(u, new K());
1613
672
  default:
1614
673
  throw new Error(`Unsupported model format: ${s}`);
1615
674
  }
@@ -1626,10 +685,10 @@ class D {
1626
685
  }
1627
686
  }
1628
687
  }
1629
- class An {
1630
- static textureLoader = new Fe();
1631
- static hdrLoader = new gs();
1632
- static cubeTextureLoader = new Ot();
688
+ class Ti {
689
+ static textureLoader = new Ct();
690
+ static hdrLoader = new Gs();
691
+ static cubeTextureLoader = new os();
1633
692
  static setLoadingManager(e) {
1634
693
  this.textureLoader.manager = e, this.hdrLoader.manager = e, this.cubeTextureLoader.manager = e;
1635
694
  }
@@ -1638,13 +697,13 @@ class An {
1638
697
  }
1639
698
  static async loadAsyncHDR(e) {
1640
699
  const t = await this.hdrLoader.loadAsync(e);
1641
- return t.mapping = At, t;
700
+ return t.mapping = cs, t;
1642
701
  }
1643
702
  static async loadAsyncCubeTexture(e, t) {
1644
703
  return this.cubeTextureLoader.setPath(e), await this.cubeTextureLoader.loadAsync(t);
1645
704
  }
1646
705
  }
1647
- class G extends k {
706
+ class q extends P {
1648
707
  isBaseMesh = !0;
1649
708
  type = "BaseMesh";
1650
709
  castShadow = !0;
@@ -1657,7 +716,7 @@ class G extends k {
1657
716
  return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
1658
717
  }
1659
718
  }
1660
- class Ye extends R {
719
+ class ue extends H {
1661
720
  isBaseGroup = !0;
1662
721
  type = "BaseGroup";
1663
722
  ignoreInvisibleWhenRaycast = !0;
@@ -1668,7 +727,7 @@ class Ye extends R {
1668
727
  return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
1669
728
  }
1670
729
  }
1671
- class Ys extends Bt {
730
+ class wn extends ls {
1672
731
  isBaseSprite = !0;
1673
732
  type = "BaseSprite";
1674
733
  ignoreInvisibleWhenRaycast = !0;
@@ -1679,7 +738,7 @@ class Ys extends Bt {
1679
738
  return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
1680
739
  }
1681
740
  }
1682
- class he extends Ye {
741
+ class we extends ue {
1683
742
  isModel = !0;
1684
743
  type = "Model";
1685
744
  static memoryCache = /* @__PURE__ */ new Map();
@@ -1693,21 +752,21 @@ class he extends Ye {
1693
752
  const { url: t, cache: s = !0, persistent: n = !0 } = e;
1694
753
  try {
1695
754
  let i;
1696
- 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 });
1697
- const r = await i, o = ys(r);
1698
- return this.add(o), o.animations && o.animations.length > 0 && (this.animations = o.animations, this.mixer = new It(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;
1699
758
  } catch (i) {
1700
759
  return console.error(`[Model] Failed to load model from ${t}:`, i), null;
1701
760
  }
1702
761
  }
1703
762
  playAnimation(e, t = {}) {
1704
763
  if (!this.mixer || this.animations.length === 0) return null;
1705
- 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;
1706
765
  let o;
1707
- 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)
1708
767
  return console.warn(`[Model] Animation not found: ${e}`), null;
1709
- let a = this.actions.get(o.name);
1710
- return a || (a = this.mixer.clipAction(o), this.actions.set(o.name, a)), a.setLoop(s ? Rt : 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;
1711
770
  }
1712
771
  playAllAnimations(e = {}) {
1713
772
  return this.animations.map((t, s) => this.playAnimation(s, e)).filter((t) => t !== null);
@@ -1728,13 +787,13 @@ class he extends Ye {
1728
787
  * Get the axis-aligned bounding box of this model.
1729
788
  */
1730
789
  getBoundingBox() {
1731
- return new V().setFromObject(this);
790
+ return new $().setFromObject(this);
1732
791
  }
1733
792
  /**
1734
793
  * Get the center point of this model's bounding box.
1735
794
  */
1736
795
  getCenter() {
1737
- const e = new v();
796
+ const e = new C();
1738
797
  return this.getBoundingBox().getCenter(e), e;
1739
798
  }
1740
799
  /**
@@ -1742,7 +801,7 @@ class he extends Ye {
1742
801
  */
1743
802
  setMaterial(e) {
1744
803
  this.traverse((t) => {
1745
- t instanceof k && (t.material = e);
804
+ t instanceof P && (t.material = e);
1746
805
  });
1747
806
  }
1748
807
  static clearMemoryCache() {
@@ -1752,11 +811,11 @@ class he extends Ye {
1752
811
  typeof caches < "u" && await caches.delete("u-space-loader-cache");
1753
812
  }
1754
813
  }
1755
- class Vs extends G {
814
+ class xn extends q {
1756
815
  isSphereMesh = !0;
1757
816
  type = "SphereMesh";
1758
817
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
1759
- super(), this.geometry = new zt(
818
+ super(), this.geometry = new ps(
1760
819
  e?.radius,
1761
820
  e?.widthSegments,
1762
821
  e?.heightSegments,
@@ -1764,23 +823,23 @@ class Vs extends G {
1764
823
  e?.phiLength,
1765
824
  e?.thetaStart,
1766
825
  e?.thetaLength
1767
- ), this.material = new L(t);
826
+ ), this.material = new K(t);
1768
827
  }
1769
828
  }
1770
- class Ie extends G {
829
+ class qe extends q {
1771
830
  isTubeMesh = !0;
1772
831
  type = "TubeMesh";
1773
832
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
1774
- super(), this.geometry = new Nt(
833
+ super(), this.geometry = new ms(
1775
834
  e?.path,
1776
835
  e?.tubularSegments,
1777
836
  e?.radius,
1778
837
  e?.radialSegments,
1779
838
  e?.closed
1780
- ), this.material = new L(t);
839
+ ), this.material = new K(t);
1781
840
  }
1782
841
  }
1783
- class Bn extends Ye {
842
+ class Li extends ue {
1784
843
  isTopology = !0;
1785
844
  type = "Topology";
1786
845
  // Visuals
@@ -1826,12 +885,12 @@ class Bn extends Ye {
1826
885
  * @param bidirectional If true, adds the reverse edge as well. Default true.
1827
886
  */
1828
887
  addEdge(e, t, s, n = !0) {
1829
- const i = this.nodes.get(e), r = this.nodes.get(t);
1830
- if (!i || !r) {
888
+ const i = this.nodes.get(e), a = this.nodes.get(t);
889
+ if (!i || !a) {
1831
890
  console.error(`[Topology] Cannot add edge. One or both nodes not found: ${e}, ${t}`);
1832
891
  return;
1833
892
  }
1834
- const o = s ?? i.distanceTo(r);
893
+ const o = s ?? i.distanceTo(a);
1835
894
  this.getNeighbors(e)?.set(t, o), n && this.getNeighbors(t)?.set(e, o);
1836
895
  }
1837
896
  /**
@@ -1850,41 +909,41 @@ class Bn extends Ye {
1850
909
  if (!this.nodes.has(e) || !this.nodes.has(t))
1851
910
  return console.warn("[Topology] Start or End node not found."), [];
1852
911
  const s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
1853
- for (const [a] of this.nodes)
1854
- 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);
1855
914
  for (s.set(e, 0); i.size > 0; ) {
1856
- let a = null, c = 1 / 0;
1857
- for (const d of i) {
1858
- const p = s.get(d);
1859
- 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);
1860
919
  }
1861
- if (a === null || a === t || c === 1 / 0)
920
+ if (c === null || c === t || l === 1 / 0)
1862
921
  break;
1863
- i.delete(a);
1864
- const l = this.adjacencyMap?.get(a);
1865
- if (l)
1866
- for (const [d, p] of l) {
1867
- if (!i.has(d)) continue;
1868
- const u = s.get(a) + p;
1869
- 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));
1870
929
  }
1871
930
  }
1872
- const r = [];
931
+ const a = [];
1873
932
  let o = t;
1874
933
  if (n.get(t) === null && e !== t)
1875
934
  return [];
1876
935
  for (; o !== null; ) {
1877
- const a = this.nodes.get(o);
1878
- 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;
1879
938
  }
1880
- return r;
939
+ return a;
1881
940
  }
1882
941
  /**
1883
942
  * Renders the entire topology graph structure using TubeGeometry and Spheres.
1884
943
  */
1885
944
  renderGraph() {
1886
- this.clearGraph(), this.graphGroup = new R();
1887
- const e = new Vs({
945
+ this.clearGraph(), this.graphGroup = new H();
946
+ const e = new xn({
1888
947
  geometryParameters: {
1889
948
  radius: this.parameters.nodeRadius,
1890
949
  widthSegments: 16,
@@ -1900,15 +959,15 @@ class Bn extends Ye {
1900
959
  });
1901
960
  const t = /* @__PURE__ */ new Set();
1902
961
  this.adjacencyMap.forEach((s, n) => {
1903
- s.forEach((i, r) => {
1904
- const o = [n, r].sort().join("-");
962
+ s.forEach((i, a) => {
963
+ const o = [n, a].sort().join("-");
1905
964
  if (t.has(o)) return;
1906
965
  t.add(o);
1907
- const a = this.nodes.get(n), c = this.nodes.get(r);
1908
- if (a && c) {
1909
- 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({
1910
969
  geometryParameters: {
1911
- path: l,
970
+ path: h,
1912
971
  tubularSegments: 1,
1913
972
  radius: this.parameters.edgeRadius,
1914
973
  radialSegments: 8,
@@ -1918,14 +977,14 @@ class Bn extends Ye {
1918
977
  color: this.parameters.edgeColor
1919
978
  }
1920
979
  });
1921
- 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);
1922
981
  }
1923
982
  });
1924
983
  }), this.add(this.graphGroup);
1925
984
  }
1926
985
  clearGraph() {
1927
986
  this.graphGroup && (this.remove(this.graphGroup), this.graphGroup.traverse((e) => {
1928
- e instanceof k && (e.geometry.dispose(), e.material.dispose());
987
+ e instanceof P && (e.geometry.dispose(), e.material.dispose());
1929
988
  }), this.graphGroup = null);
1930
989
  }
1931
990
  /**
@@ -1933,7 +992,7 @@ class Bn extends Ye {
1933
992
  */
1934
993
  renderPath(e, t = this.parameters.pathColor) {
1935
994
  if (e.length < 2) return;
1936
- const s = new kt(e, !1, "catmullrom", 0), n = new Ie({
995
+ const s = new gs(e, !1, "catmullrom", 0), n = new qe({
1937
996
  geometryParameters: {
1938
997
  path: s,
1939
998
  tubularSegments: e.length * 10,
@@ -1959,9 +1018,9 @@ class Bn extends Ye {
1959
1018
  });
1960
1019
  const t = [], s = /* @__PURE__ */ new Set();
1961
1020
  return this.adjacencyMap.forEach((n, i) => {
1962
- n.forEach((r, o) => {
1963
- const a = [i, o].sort().join("-");
1964
- 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 }));
1965
1024
  });
1966
1025
  }), { nodes: e, edges: t };
1967
1026
  }
@@ -1971,7 +1030,7 @@ class Bn extends Ye {
1971
1030
  */
1972
1031
  importData(e) {
1973
1032
  this.clearGraph(), this.clearPaths(), this.nodes.clear(), this.adjacencyMap.clear(), Object.entries(e.nodes).forEach(([t, s]) => {
1974
- this.addNode(t, new v(s.x, s.y, s.z));
1033
+ this.addNode(t, new C(s.x, s.y, s.z));
1975
1034
  }), e.edges.forEach(({ from: t, to: s, weight: n }) => {
1976
1035
  this.addEdge(t, s, n);
1977
1036
  }), this.renderGraph();
@@ -1983,7 +1042,7 @@ class Bn extends Ye {
1983
1042
  return this.adjacencyMap.get(e);
1984
1043
  }
1985
1044
  }
1986
- class In extends Ys {
1045
+ class Pi extends wn {
1987
1046
  isPoi = !0;
1988
1047
  type = "Poi";
1989
1048
  parameters = {
@@ -2002,7 +1061,7 @@ class In extends Ys {
2002
1061
  _canvas = document.createElement("canvas");
2003
1062
  _lastParametersJSON = "";
2004
1063
  constructor(e = {}) {
2005
- super(new jt()), Object.assign(this.parameters, e), this.updateAsync();
1064
+ super(new ys()), Object.assign(this.parameters, e), this.updateAsync();
2006
1065
  }
2007
1066
  /**
2008
1067
  * Update the POI with new parameters
@@ -2018,33 +1077,33 @@ class In extends Ys {
2018
1077
  n.font = `${this.parameters.fontSize}px ${this.parameters.fontFamily}`;
2019
1078
  let i = null;
2020
1079
  this.parameters.img && (i = await this._loadImage(this.parameters.img));
2021
- 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;
2022
- let y = 0, _ = 0, A = 0, B = 0, E = 0, g = 0;
2023
- const b = !!i, z = !!r;
2024
- if (b && z)
2025
- 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) {
2026
1085
  case "top":
2027
- 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;
2028
1087
  break;
2029
1088
  case "bottom":
2030
- 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;
2031
1090
  break;
2032
1091
  case "left":
2033
- 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;
2034
1093
  break;
2035
1094
  default:
2036
- 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;
2037
1096
  break;
2038
1097
  }
2039
- else b ? (y = c, _ = c, A = 0, B = 0) : z && (y = S, _ = x, E = 0, g = x / 2);
2040
- const N = y + l * 2, P = _ + l * 2;
2041
- 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) {
2042
- n.fillStyle = a;
2043
- const j = n.measureText(r), U = j.actualBoundingBoxAscent + j.actualBoundingBoxDescent, ot = j.actualBoundingBoxAscent - U / 2;
2044
- 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);
2045
1104
  }
2046
- const J = this.material.map, W = new Ut(s);
2047
- 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);
2048
1107
  }
2049
1108
  _loadImage(e) {
2050
1109
  return new Promise((t, s) => {
@@ -2055,87 +1114,110 @@ class In extends Ys {
2055
1114
  t(e);
2056
1115
  });
2057
1116
  }
2058
- _drawRoundedRect(e, t, s, n, i, r) {
2059
- 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();
2060
1119
  }
2061
1120
  dispose() {
2062
1121
  this.material.map?.dispose(), this.material.dispose();
2063
1122
  }
2064
1123
  }
2065
- class Ve extends G {
1124
+ class Nt extends q {
2066
1125
  isShapeMesh = !0;
2067
1126
  type = "ShapeMesh";
2068
1127
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
2069
- 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);
2070
1129
  }
2071
1130
  static createFromPoints(e, t = {}) {
2072
- return new Ve({
1131
+ return new Nt({
2073
1132
  ...t,
2074
1133
  geometryParameters: {
2075
1134
  ...t.geometryParameters,
2076
- 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)))
2077
1136
  }
2078
1137
  });
2079
1138
  }
2080
1139
  }
2081
- class Je extends G {
1140
+ class zt extends q {
2082
1141
  isExtrudeMesh = !0;
2083
1142
  type = "ExtrudeMesh";
2084
1143
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
2085
- 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);
2086
1145
  }
2087
1146
  static createFromPoints(e, t = {}) {
2088
- return e && e.length === 0 && (e = void 0), new Je({
1147
+ return e && e.length === 0 && (e = void 0), new zt({
2089
1148
  ...t,
2090
1149
  geometryParameters: {
2091
1150
  ...t.geometryParameters,
2092
- 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)))
2093
1152
  }
2094
1153
  });
2095
1154
  }
2096
1155
  }
2097
- class Rn extends G {
1156
+ class Ni extends q {
2098
1157
  isPlaneMesh = !0;
2099
1158
  type = "PlaneMesh";
2100
1159
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
2101
- super(), this.geometry = new Gt(
1160
+ super(), this.geometry = new Ms(
2102
1161
  e?.width,
2103
1162
  e?.height,
2104
1163
  e?.widthSegments,
2105
1164
  e?.heightSegments
2106
- ), this.material = new L(t);
1165
+ ), this.material = new K(t);
2107
1166
  }
2108
1167
  }
2109
- class Ln extends G {
1168
+ class zi extends q {
2110
1169
  isCircleMesh = !0;
2111
1170
  type = "CircleMesh";
2112
1171
  constructor({ geometryParameters: e, materialParameters: t } = {}) {
2113
1172
  super(
2114
- new $t(
1173
+ new Is(
2115
1174
  e?.radius,
2116
1175
  e?.segments,
2117
1176
  e?.thetaStart,
2118
1177
  e?.thetaLength
2119
1178
  ),
2120
- new L(t)
1179
+ new K(t)
2121
1180
  ), this.geometry.rotateX(-Math.PI / 2);
2122
1181
  }
2123
1182
  }
2124
- class F {
1183
+ class J {
2125
1184
  static traverseMeshes(e, t) {
2126
1185
  e.traverse((s) => {
2127
- s instanceof k && t(s);
1186
+ s instanceof P && t(s);
2128
1187
  });
2129
1188
  }
2130
1189
  }
2131
- class zn {
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 {
2132
1214
  static flow(e = {}) {
2133
- const { baseColor: t = 16777215, flowColor: s = 65280, speed: n = 1, scale: i = 3, intensity: r = 4 } = e, o = H(new M(t)), a = H(new M(s)), c = Te().x.mul(i).sub(oe.mul(n)), l = ae(ge(c).add(1).mul(0.5), r);
2134
- 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);
2135
1217
  }
2136
1218
  static breathe(e = {}) {
2137
- const { baseColor: t = 16777215, breathColor: s = 65280, speed: n = 1, intensity: i = 2 } = e, r = H(new M(t)), o = H(new M(s)), a = ge(oe.mul(n)).add(1).mul(0.5), c = ae(a, i);
2138
- 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);
2139
1221
  }
2140
1222
  static fluid(e = {}) {
2141
1223
  const {
@@ -2143,81 +1225,154 @@ class zn {
2143
1225
  flowColor: s = 255,
2144
1226
  speed: n = 1,
2145
1227
  scale: i = 1,
2146
- intensity: r = 1,
1228
+ intensity: a = 1,
2147
1229
  distortion: o = 0.5
2148
- } = e, a = H(new M(t)), c = H(new M(s)), l = Te().mul(i), d = oe.mul(n), p = _e(l.add(d), 1, 0), u = l.add(p.mul(o)), m = _e(u, 1, 0).add(1).mul(0.5), w = ae(m, r);
2149
- 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;
2150
1305
  }
2151
1306
  }
2152
- function Nn(h) {
1307
+ function Ri(r) {
2153
1308
  }
2154
- 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(), Js = We(() => {
2155
- const h = O(Y, "uint"), e = O(et, "uint"), t = O(tt, "uint"), s = ze(e), n = Ee.mul(s), i = q(t.greaterThan(0), s, n), r = q(h.greaterThan(0), i, Ee), o = O(pe, "uint"), a = O(nt, "uint"), c = O(it, "float"), l = O(rt, "float"), d = ze(a), p = ge(oe.mul(c)).add(1).mul(0.5), u = ae(p, l), m = ce(r, d, u);
2156
- return q(o.greaterThan(0), m, r);
2157
- })(), Zs = We(() => {
2158
- const h = O(Y, "uint"), e = O(Ze, "float"), t = O(st, "uint"), s = q(t.greaterThan(0), Pe.mul(e), e);
2159
- return q(h.greaterThan(0), s, Pe);
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);
2160
1315
  })();
2161
- function X(h) {
2162
- return Array.isArray(h.material) ? h.material : [h.material];
1316
+ function le(r) {
1317
+ return Array.isArray(r.material) ? r.material : [r.material];
2163
1318
  }
2164
- function Re(h) {
2165
- X(h).forEach((t) => {
1319
+ function et(r) {
1320
+ le(r).forEach((t) => {
2166
1321
  if (!t) return;
2167
- let s = ue.get(t);
1322
+ let s = Se.get(t);
2168
1323
  s || (s = {
2169
1324
  colorNode: t.colorNode,
2170
1325
  opacityNode: t.opacityNode,
2171
1326
  transparent: t.transparent,
2172
1327
  depthWrite: t.depthWrite,
2173
1328
  activeMeshes: /* @__PURE__ */ new Set()
2174
- }, ue.set(t, s)), s.activeMeshes.add(h), t.transparent = !0, t.colorNode = Js, t.opacityNode = Zs, t.needsUpdate = !0;
1329
+ }, Se.set(t, s)), s.activeMeshes.add(r), t.transparent = !0, t.colorNode = Cn, t.opacityNode = On, t.needsUpdate = !0;
2175
1330
  });
2176
1331
  }
2177
- function Le(h) {
2178
- const e = h.userData[Y], t = h.userData[pe];
1332
+ function tt(r) {
1333
+ const e = r.userData[he], t = r.userData[Ie];
2179
1334
  if (e || t) return;
2180
- X(h).forEach((n) => {
1335
+ le(r).forEach((n) => {
2181
1336
  if (!n) return;
2182
- const i = ue.get(n);
2183
- 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)));
2184
1339
  });
2185
1340
  }
2186
- function en(h, e, t, s) {
2187
- const n = h, i = n.setSemanticHighlight;
1341
+ function An(r, e, t, s) {
1342
+ const n = r, i = n.setInstanceHighlight;
2188
1343
  if (i)
2189
- return i.call(h, e, t, s), !0;
2190
- const r = n.setSemanticColor, o = n.setSemanticOpacity, a = n.getSemanticOpacity, c = n.getSemanticColor, l = n.hasSemanticColor;
2191
- return !r || !o ? !1 : (h.userData[de] === void 0 && (h.userData[de] = {
2192
- hasColor: l?.call(h) ?? !1,
2193
- color: c?.call(h, new M()).getHex() ?? 16777215,
2194
- opacity: a?.call(h) ?? 1
2195
- }), r.call(h, e), o.call(h, t), !0);
2196
- }
2197
- function tn(h) {
2198
- 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;
2199
1354
  if (t)
2200
- return t.call(h), !0;
2201
- 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;
2202
1357
  if (!s || !i) return !1;
2203
- const r = h.userData[de];
2204
- 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;
2205
1360
  }
2206
- class le {
1361
+ class se {
2207
1362
  static highlightColor(e, t = {}) {
2208
- 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 M(i).getHex();
2209
- for (const l of s)
2210
- en(l, i, n, r) || F.traverseMeshes(l, (d) => {
2211
- d.userData[Y] = 1, d.userData[Ze] = n, d.userData[et] = c, d.userData[tt] = r ? 1 : 0, d.userData[st] = a ? 1 : 0, Re(d), o !== void 0 && X(d).forEach((u) => {
2212
- 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);
2213
1368
  });
2214
1369
  });
2215
1370
  }
2216
1371
  static removeHighlightColor(e) {
2217
1372
  const t = Array.isArray(e) ? e : [e];
2218
1373
  for (const s of t)
2219
- tn(s) || F.traverseMeshes(s, (n) => {
2220
- n.userData[Y] = 0, Le(n);
1374
+ Tn(s) || J.traverseMeshes(s, (n) => {
1375
+ n.userData[he] = 0, tt(n);
2221
1376
  });
2222
1377
  }
2223
1378
  static breatheColor(e, t = {}) {
@@ -2229,17 +1384,17 @@ class le {
2229
1384
  },
2230
1385
  t
2231
1386
  );
2232
- n.color = new M(n.color).getHex();
1387
+ n.color = new A(n.color).getHex();
2233
1388
  for (const i of s)
2234
- F.traverseMeshes(i, (r) => {
2235
- r.userData[pe] = 1, r.userData[nt] = n.color, r.userData[it] = n.speed, r.userData[rt] = n.intensity, Re(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);
2236
1391
  });
2237
1392
  }
2238
1393
  static removeBreatheColor(e) {
2239
1394
  const t = Array.isArray(e) ? e : [e];
2240
1395
  for (const s of t)
2241
- F.traverseMeshes(s, (n) => {
2242
- n.userData[pe] = 0, Le(n);
1396
+ J.traverseMeshes(s, (n) => {
1397
+ n.userData[Ie] = 0, tt(n);
2243
1398
  });
2244
1399
  }
2245
1400
  /**
@@ -2248,10 +1403,10 @@ class le {
2248
1403
  static wireframe(e, t = !0) {
2249
1404
  const s = Array.isArray(e) ? e : [e];
2250
1405
  for (const n of s)
2251
- F.traverseMeshes(n, (i) => {
2252
- X(i).forEach((r) => {
2253
- if (!r) return;
2254
- const o = r;
1406
+ J.traverseMeshes(n, (i) => {
1407
+ le(i).forEach((a) => {
1408
+ if (!a) return;
1409
+ const o = a;
2255
1410
  o.wireframe = t, o.needsUpdate = !0;
2256
1411
  });
2257
1412
  });
@@ -2260,7 +1415,7 @@ class le {
2260
1415
  * Remove wireframe mode.
2261
1416
  */
2262
1417
  static removeWireframe(e) {
2263
- le.wireframe(e, !1);
1418
+ se.wireframe(e, !1);
2264
1419
  }
2265
1420
  /**
2266
1421
  * Fade in object(s) from fully transparent to original opacity.
@@ -2268,7 +1423,7 @@ class le {
2268
1423
  */
2269
1424
  static fadeIn(e, t = {}) {
2270
1425
  const { duration: s = 500 } = t;
2271
- return le._fade(e, 0, 1, s);
1426
+ return se._fade(e, 0, 1, s);
2272
1427
  }
2273
1428
  /**
2274
1429
  * Fade out object(s) to fully transparent.
@@ -2276,61 +1431,62 @@ class le {
2276
1431
  */
2277
1432
  static fadeOut(e, t = {}) {
2278
1433
  const { duration: s = 500 } = t;
2279
- return le._fade(e, 1, 0, s);
1434
+ return se._fade(e, 1, 0, s);
2280
1435
  }
2281
1436
  static _fade(e, t, s, n) {
2282
- const i = Array.isArray(e) ? e : [e], r = /* @__PURE__ */ new Map();
1437
+ const i = Array.isArray(e) ? e : [e], a = /* @__PURE__ */ new Map();
2283
1438
  for (const o of i)
2284
- F.traverseMeshes(o, (a) => {
2285
- X(a).forEach((c) => {
2286
- if (!c || r.has(c)) return;
2287
- const l = c.opacity, d = c.transparent, p = s >= 1 ? l : s;
2288
- r.set(c, {
2289
- material: c,
2290
- targetOpacity: p,
2291
- originalOpacity: l,
2292
- originalTransparent: d
2293
- }), 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;
2294
1449
  });
2295
1450
  });
2296
- return r.size === 0 ? Promise.resolve() : new Promise((o) => {
2297
- const a = performance.now();
2298
- let c = 0;
2299
- const l = () => {
2300
- 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);
2301
1456
  if (!i[0].parent) {
2302
- cancelAnimationFrame(c), o();
1457
+ cancelAnimationFrame(l), o();
2303
1458
  return;
2304
1459
  }
2305
- for (const { material: m, targetOpacity: w } of r.values())
2306
- m.opacity = t + (w - t) * p, m.needsUpdate = !0;
2307
- if (p < 1)
2308
- 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);
2309
1464
  else {
2310
1465
  if (s >= 1)
2311
- for (const { material: m, originalOpacity: w, originalTransparent: S } of r.values())
2312
- 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;
2313
1468
  o();
2314
1469
  }
2315
1470
  };
2316
- c = requestAnimationFrame(l);
1471
+ l = requestAnimationFrame(h);
2317
1472
  });
2318
1473
  }
2319
1474
  }
2320
- const ze = (h) => {
2321
- 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);
2322
- 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);
2323
1478
  };
2324
- class sn extends ws {
1479
+ class Ln extends Zs {
2325
1480
  viewer;
2326
1481
  constructor(e, t) {
2327
1482
  super(t), this.viewer = e;
2328
1483
  }
2329
1484
  _update = ({ time: e }) => {
2330
- this.update(e) && this.viewer.render();
1485
+ const t = this.update(e);
1486
+ this.viewer.invalidate(), t || this.viewer.removeEventListener("afterControlsUpdate", this._update);
2331
1487
  };
2332
1488
  easingByMode(e) {
2333
- const t = nn[e];
1489
+ const t = Pn[e];
2334
1490
  return super.easing(t);
2335
1491
  }
2336
1492
  start(e, t) {
@@ -2340,54 +1496,54 @@ class sn extends ws {
2340
1496
  return this.viewer.removeEventListener("afterControlsUpdate", this._update), super.stop();
2341
1497
  }
2342
1498
  }
2343
- function Dn(h, e, t, s = {}, n, i) {
2344
- return new Promise((r, o) => {
2345
- const { duration: a = 1e3, delay: c = 0, repeat: l = !1, mode: d = "Linear.None", yoyo: p = !1 } = s, u = new sn(h, e).to(t, a).easingByMode(d).delay(c).onUpdate((m) => {
2346
- 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);
2347
1503
  }).onComplete(() => {
2348
- r();
1504
+ a();
2349
1505
  }).onStop(() => {
2350
1506
  o("animation stop");
2351
1507
  }).onStart(() => {
2352
- i?.(u);
1508
+ i?.(p);
2353
1509
  });
2354
- 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();
2355
1511
  });
2356
1512
  }
2357
- const nn = {
2358
- "Linear.None": f.Linear.None,
2359
- "Quadratic.In": f.Quadratic.In,
2360
- "Quadratic.Out": f.Quadratic.Out,
2361
- "Quadratic.InOut": f.Quadratic.InOut,
2362
- "Cubic.In": f.Cubic.In,
2363
- "Cubic.Out": f.Cubic.Out,
2364
- "Cubic.InOut": f.Cubic.InOut,
2365
- "Quartic.In": f.Quartic.In,
2366
- "Quartic.Out": f.Quartic.Out,
2367
- "Quartic.InOut": f.Quartic.InOut,
2368
- "Quintic.In": f.Quintic.In,
2369
- "Quintic.Out": f.Quintic.Out,
2370
- "Quintic.InOut": f.Quintic.InOut,
2371
- "Sinusoidal.In": f.Sinusoidal.In,
2372
- "Sinusoidal.Out": f.Sinusoidal.Out,
2373
- "Sinusoidal.InOut": f.Sinusoidal.InOut,
2374
- "Exponential.In": f.Exponential.In,
2375
- "Exponential.Out": f.Exponential.Out,
2376
- "Exponential.InOut": f.Exponential.InOut,
2377
- "Circular.In": f.Circular.In,
2378
- "Circular.Out": f.Circular.Out,
2379
- "Circular.InOut": f.Circular.InOut,
2380
- "Elastic.In": f.Elastic.In,
2381
- "Elastic.Out": f.Elastic.Out,
2382
- "Elastic.InOut": f.Elastic.InOut,
2383
- "Back.In": f.Back.In,
2384
- "Back.Out": f.Back.Out,
2385
- "Back.InOut": f.Back.InOut,
2386
- "Bounce.In": f.Bounce.In,
2387
- "Bounce.Out": f.Bounce.Out,
2388
- "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
2389
1545
  };
2390
- class kn {
1546
+ class ki {
2391
1547
  scene;
2392
1548
  planes = /* @__PURE__ */ new Map();
2393
1549
  helpers = /* @__PURE__ */ new Map();
@@ -2396,7 +1552,7 @@ class kn {
2396
1552
  */
2397
1553
  group;
2398
1554
  constructor(e) {
2399
- 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);
2400
1556
  }
2401
1557
  /**
2402
1558
  * Move all current scene children (except the clipping group itself) into the ClippingGroup,
@@ -2435,35 +1591,35 @@ class kn {
2435
1591
  normal: s = { x: 0, y: -1, z: 0 },
2436
1592
  constant: n = 0,
2437
1593
  showHelper: i = !1,
2438
- helperSize: r = 5,
1594
+ helperSize: a = 5,
2439
1595
  helperColor: o = 16711680
2440
- } = t, a = new Kt(new v(s.x, s.y, s.z), n);
2441
- 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;
2442
1598
  }
2443
1599
  /**
2444
1600
  * Add six clipping planes that form a box around a Box3.
2445
1601
  * Returns the six plane ids: `${id}_+x`, `${id}_-x`, etc.
2446
1602
  */
2447
1603
  addBox(e, t, s = {}) {
2448
- 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 = [
2449
1605
  { suffix: "+x", normal: { x: -1, y: 0, z: 0 }, constant: o.x },
2450
- { 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 },
2451
1607
  { suffix: "+y", normal: { x: 0, y: -1, z: 0 }, constant: o.y },
2452
- { 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 },
2453
1609
  { suffix: "+z", normal: { x: 0, y: 0, z: -1 }, constant: o.z },
2454
- { suffix: "-z", normal: { x: 0, y: 0, z: 1 }, constant: -r.z }
2455
- ], c = [];
2456
- for (const l of a) {
2457
- const d = `${e}_${l.suffix}`;
2458
- 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);
2459
1615
  }
2460
- return c;
1616
+ return l;
2461
1617
  }
2462
1618
  /**
2463
1619
  * Add a clipping box from an object's bounding box with optional padding.
2464
1620
  */
2465
1621
  addBoxFromObject(e, t, s = 0, n = {}) {
2466
- const i = new V().setFromObject(t);
1622
+ const i = new $().setFromObject(t);
2467
1623
  return i.expandByScalar(s), this.addBox(e, i, n);
2468
1624
  }
2469
1625
  /**
@@ -2503,7 +1659,7 @@ class kn {
2503
1659
  this.hideHelper(e);
2504
1660
  const n = this.planes.get(e);
2505
1661
  if (!n) return;
2506
- const i = new Qt(n, t, new M(s).getHex());
1662
+ const i = new Cs(n, t, new A(s).getHex());
2507
1663
  i.name = e, this.helpers.set(e, i), this.scene.add(i);
2508
1664
  }
2509
1665
  /**
@@ -2529,7 +1685,7 @@ class kn {
2529
1685
  this.detach(), this.removeAll(), this.scene.remove(this.group);
2530
1686
  }
2531
1687
  }
2532
- class jn {
1688
+ class Ui {
2533
1689
  scene;
2534
1690
  measurements = /* @__PURE__ */ new Map();
2535
1691
  _idCounter = 0;
@@ -2540,19 +1696,19 @@ class jn {
2540
1696
  * Measure distance between two points.
2541
1697
  */
2542
1698
  measureDistance(e, t, s = {}) {
2543
- 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 R();
2544
- c.name = a;
2545
- const l = new Q().setFromPoints([i, r]), d = new ie({ color: n }), p = new re(l, d);
2546
- c.add(p), this.scene.add(c);
2547
- const u = {
2548
- 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,
2549
1705
  type: "distance",
2550
1706
  value: o,
2551
1707
  unit: "m",
2552
- points: [i, r],
2553
- object: c
1708
+ points: [i, a],
1709
+ object: l
2554
1710
  };
2555
- return this.measurements.set(a, u), u;
1711
+ return this.measurements.set(c, p), p;
2556
1712
  }
2557
1713
  /**
2558
1714
  * Measure the area of a polygon defined by 3+ coplanar points.
@@ -2561,37 +1717,37 @@ class jn {
2561
1717
  const { lineColor: s = 65280 } = t;
2562
1718
  if (e.length < 3)
2563
1719
  throw new Error("MeasureTool.measureArea requires at least 3 points");
2564
- const n = e.map((u) => new v(u.x, u.y, u.z)), i = this._calculatePolygonArea(n), r = `measure_area_${this._idCounter++}`, o = new R();
2565
- o.name = r;
2566
- const a = [...n, n[0]], c = new Q().setFromPoints(a), l = new ie({ color: s }), d = new re(c, l);
2567
- o.add(d), this.scene.add(o);
2568
- const p = {
2569
- 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,
2570
1726
  type: "area",
2571
1727
  value: i,
2572
1728
  unit: "m²",
2573
1729
  points: n,
2574
1730
  object: o
2575
1731
  };
2576
- return this.measurements.set(r, p), p;
1732
+ return this.measurements.set(a, d), d;
2577
1733
  }
2578
1734
  /**
2579
1735
  * Measure the angle between three points (vertex at the middle point).
2580
1736
  */
2581
1737
  measureAngle(e, t, s, n = {}) {
2582
- 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 R();
2583
- m.name = u;
2584
- const w = new Q().setFromPoints([r, o, a]), S = new ie({ color: i }), x = new re(w, S);
2585
- m.add(x), this.scene.add(m);
2586
- const y = {
2587
- 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,
2588
1744
  type: "angle",
2589
- value: p,
1745
+ value: d,
2590
1746
  unit: "°",
2591
- points: [r, o, a],
1747
+ points: [a, o, c],
2592
1748
  object: m
2593
1749
  };
2594
- return this.measurements.set(u, y), y;
1750
+ return this.measurements.set(p, g), g;
2595
1751
  }
2596
1752
  /**
2597
1753
  * Get a measurement result by id.
@@ -2626,15 +1782,15 @@ class jn {
2626
1782
  * Calculate polygon area using cross product method (Newell's method).
2627
1783
  */
2628
1784
  _calculatePolygonArea(e) {
2629
- const t = e.length, s = new v();
1785
+ const t = e.length, s = new C();
2630
1786
  for (let i = 0; i < t; i++) {
2631
- const r = e[i], o = e[(i + 1) % t], a = new v().crossVectors(r, o);
2632
- s.add(a);
1787
+ const a = e[i], o = e[(i + 1) % t], c = new C().crossVectors(a, o);
1788
+ s.add(c);
2633
1789
  }
2634
- const n = new v();
1790
+ const n = new C();
2635
1791
  if (t >= 3) {
2636
- const i = e[1].clone().sub(e[0]), r = e[2].clone().sub(e[0]);
2637
- 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();
2638
1794
  }
2639
1795
  return Math.abs(s.dot(n)) / 2;
2640
1796
  }
@@ -2642,7 +1798,7 @@ class jn {
2642
1798
  this.removeAll();
2643
1799
  }
2644
1800
  }
2645
- class Un {
1801
+ class Wi {
2646
1802
  scene;
2647
1803
  annotations = /* @__PURE__ */ new Map();
2648
1804
  _idCounter = 0;
@@ -2662,9 +1818,9 @@ class Un {
2662
1818
  */
2663
1819
  add(e, t) {
2664
1820
  this.annotations.has(e) && this.remove(e);
2665
- const s = new R();
1821
+ const s = new H();
2666
1822
  s.name = `annotation_${e}`;
2667
- 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);
2668
1824
  s.position.copy(n);
2669
1825
  const i = document.createElement("div");
2670
1826
  if (i.innerHTML = t.content, i.style.cssText = `
@@ -2676,32 +1832,32 @@ class Un {
2676
1832
  pointer-events: auto;
2677
1833
  white-space: nowrap;
2678
1834
  `, t.labelStyle)
2679
- for (const c of Object.keys(t.labelStyle)) {
2680
- const l = t.labelStyle[c];
2681
- 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);
2682
1838
  }
2683
- let r = null;
1839
+ let a = null;
2684
1840
  const o = t.labelOffset || { x: 0, y: 2, z: 0 };
2685
1841
  if (t.showLeaderLine !== !1) {
2686
- const { lineColor: c = 16777215 } = t, l = new Q().setFromPoints([
2687
- new v(0, 0, 0),
2688
- new v(o.x, o.y, o.z)
2689
- ]), d = new ie({ color: c });
2690
- 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);
2691
1847
  }
2692
1848
  if (this._createCSSObject) {
2693
- const c = this._createCSSObject(i);
2694
- 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);
2695
1851
  }
2696
1852
  this.scene.add(s);
2697
- const a = {
1853
+ const c = {
2698
1854
  id: e,
2699
1855
  options: t,
2700
1856
  group: s,
2701
1857
  labelElement: i,
2702
- line: r
1858
+ line: a
2703
1859
  };
2704
- return this.annotations.set(e, a), a;
1860
+ return this.annotations.set(e, c), c;
2705
1861
  }
2706
1862
  /**
2707
1863
  * Quick-add a text annotation.
@@ -2795,47 +1951,1109 @@ class Un {
2795
1951
  this.removeAll();
2796
1952
  }
2797
1953
  }
2798
- const rn = "0.0.28";
2799
- window.__USPACE__ = { version: rn };
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 });
2800
3009
  export {
2801
- Un as AnnotationManager,
2802
- Ye as BaseGroup,
2803
- G as BaseMesh,
2804
- Ys as BaseSprite,
2805
- Gn as CSS2DObject,
2806
- Wn as CSS3DObject,
2807
- Kn as CSS3DSprite,
2808
- As as CSSRenderer,
2809
- Ms as CameraControls,
2810
- Ln as CircleMesh,
2811
- kn as ClippingTool,
2812
- Je as ExtrudeMesh,
2813
- vs as InteractionEvent,
2814
- bs as InteractionManager,
2815
- Pn as LightManager,
2816
- le as MaterialEffects,
2817
- jn as MeasureTool,
2818
- he as Model,
2819
- D as ModelLoaderManager,
2820
- xs as ObjectManager,
2821
- F as ObjectUtils,
2822
- Rn as PlaneMesh,
2823
- In as Poi,
2824
- Ss as RenderPipeline,
2825
- _s as RoomEnvironment,
2826
- qs as SBMLoader,
2827
- Rs as SBMXLoader,
2828
- En as SceneManager,
2829
- _n as Selection,
2830
- Ve as ShapeMesh,
2831
- Vs as SphereMesh,
2832
- zn as TSLEffects,
2833
- An as TextureLoaderManager,
2834
- Bn as Topology,
2835
- Ie as TubeMesh,
2836
- sn as Tween,
2837
- On as Viewer,
2838
- Nn as reinterpretType,
2839
- Dn as tweenAnimation,
2840
- rn 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
2841
3059
  };