u-space 0.0.3 → 0.0.7

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 (74) hide show
  1. package/dist/index.cjs +1 -2074
  2. package/dist/index.js +1077 -1509
  3. package/dist/plugins/u-manager/flows/ComponentFlowParser.d.ts +8 -0
  4. package/dist/plugins/u-manager/flows/FlowParser.d.ts +48 -0
  5. package/dist/plugins/u-manager/flows/edges/index.d.ts +9 -0
  6. package/dist/plugins/u-manager/flows/index.d.ts +4 -0
  7. package/dist/plugins/u-manager/flows/nodes/ColorNode.d.ts +8 -0
  8. package/dist/plugins/u-manager/flows/nodes/ConditionNode.d.ts +9 -0
  9. package/dist/plugins/u-manager/flows/nodes/DataExtractionNode.d.ts +8 -0
  10. package/dist/plugins/u-manager/flows/nodes/DataFilterNode.d.ts +8 -0
  11. package/dist/plugins/u-manager/flows/nodes/DelayNode.d.ts +8 -0
  12. package/dist/plugins/u-manager/flows/nodes/EmissiveNode.d.ts +8 -0
  13. package/dist/plugins/u-manager/flows/nodes/FlyToNode.d.ts +8 -0
  14. package/dist/plugins/u-manager/flows/nodes/HideNode.d.ts +10 -0
  15. package/dist/plugins/u-manager/flows/nodes/HighlightNode.d.ts +8 -0
  16. package/dist/plugins/u-manager/flows/nodes/MeshNode.d.ts +8 -0
  17. package/dist/plugins/u-manager/flows/nodes/MeshesNode.d.ts +8 -0
  18. package/dist/plugins/u-manager/flows/nodes/ModelNode.d.ts +8 -0
  19. package/dist/plugins/u-manager/flows/nodes/ModelsNode.d.ts +8 -0
  20. package/dist/plugins/u-manager/flows/nodes/Node.d.ts +52 -0
  21. package/dist/plugins/u-manager/flows/nodes/NumberNode.d.ts +8 -0
  22. package/dist/plugins/u-manager/flows/nodes/OpacityNode.d.ts +8 -0
  23. package/dist/plugins/u-manager/flows/nodes/POINode.d.ts +8 -0
  24. package/dist/plugins/u-manager/flows/nodes/POISNode.d.ts +8 -0
  25. package/dist/plugins/u-manager/flows/nodes/PathNode.d.ts +8 -0
  26. package/dist/plugins/u-manager/flows/nodes/PathsNode.d.ts +8 -0
  27. package/dist/plugins/u-manager/flows/nodes/RotateNode.d.ts +8 -0
  28. package/dist/plugins/u-manager/flows/nodes/ScaleNode.d.ts +8 -0
  29. package/dist/plugins/u-manager/flows/nodes/ShowNode.d.ts +10 -0
  30. package/dist/plugins/u-manager/flows/nodes/SpaceNode.d.ts +8 -0
  31. package/dist/plugins/u-manager/flows/nodes/SpacesNode.d.ts +8 -0
  32. package/dist/plugins/u-manager/flows/nodes/StartNode.d.ts +7 -0
  33. package/dist/plugins/u-manager/flows/nodes/TranslateNode.d.ts +8 -0
  34. package/dist/plugins/u-manager/flows/nodes/UnEmissiveNode.d.ts +10 -0
  35. package/dist/plugins/u-manager/flows/nodes/UnHighlightNode.d.ts +10 -0
  36. package/dist/plugins/u-manager/flows/nodes/UnOpacityNode.d.ts +8 -0
  37. package/dist/plugins/u-manager/flows/nodes/UserDataNode.d.ts +8 -0
  38. package/dist/plugins/u-manager/flows/nodes/clip-animation/ClipAnimationNode.d.ts +8 -0
  39. package/dist/plugins/u-manager/flows/nodes/clip-animation/UnClipAnimationNode.d.ts +8 -0
  40. package/dist/plugins/u-manager/flows/nodes/clip-animation/index.d.ts +2 -0
  41. package/dist/plugins/u-manager/flows/nodes/component-tween-animation/ComponentTweenAnimationNode.d.ts +8 -0
  42. package/dist/plugins/u-manager/flows/nodes/component-tween-animation/UnComponentTweenAnimationNode.d.ts +8 -0
  43. package/dist/plugins/u-manager/flows/nodes/component-tween-animation/index.d.ts +2 -0
  44. package/dist/plugins/u-manager/flows/nodes/component-tween-animation/utils.d.ts +5 -0
  45. package/dist/plugins/u-manager/flows/nodes/index.d.ts +34 -0
  46. package/dist/plugins/u-manager/flows/nodes/tween-animation/TweenAnimationNode.d.ts +8 -0
  47. package/dist/plugins/u-manager/flows/nodes/tween-animation/UnTweenAnimationNode.d.ts +8 -0
  48. package/dist/plugins/u-manager/flows/nodes/tween-animation/index.d.ts +2 -0
  49. package/dist/plugins/u-manager/flows/nodes/tween-animation/utils.d.ts +5 -0
  50. package/dist/plugins/u-manager/flows/types.d.ts +81 -0
  51. package/dist/plugins/u-manager/flows/utils.d.ts +14 -0
  52. package/dist/plugins/u-manager/index.cjs +59 -59
  53. package/dist/plugins/u-manager/index.d.ts +1 -0
  54. package/dist/plugins/u-manager/index.js +9718 -8616
  55. package/dist/src/effects/MaterialEffects.d.ts +10 -3
  56. package/dist/src/index.d.ts +8 -0
  57. package/dist/src/objects/Model.d.ts +14 -1
  58. package/dist/src/objects/Poi.d.ts +4 -0
  59. package/dist/src/viewers/CSSRenderer.d.ts +19 -0
  60. package/dist/src/viewers/CameraControls.d.ts +7 -0
  61. package/dist/src/viewers/RenderPipeline.d.ts +30 -2
  62. package/dist/src/viewers/Viewer.d.ts +6 -0
  63. package/dist/src/viewers/index.d.ts +2 -0
  64. package/docs/api-css-renderer.md +43 -0
  65. package/docs/api-effects.md +49 -11
  66. package/docs/api-objects.md +58 -0
  67. package/docs/api-render-pipeline.md +114 -0
  68. package/docs/api-viewer.md +37 -4
  69. package/docs/examples-guide.md +40 -0
  70. package/docs/getting-started.md +12 -0
  71. package/docs/index.md +6 -0
  72. package/package.json +1 -1
  73. package/dist/index.cjs.map +0 -1
  74. package/dist/index.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,20 +1,27 @@
1
- import { Raycaster, Vector2, RenderPipeline as RenderPipeline$1, Sphere, Box3, Spherical, Matrix4, Quaternion, Vector4, Vector3, MathUtils, PMREMGenerator, OrthographicCamera, TimestampQuery, Cache, EventDispatcher, Timer, PerspectiveCamera, WebGPURenderer, PCFShadowMap, AgXToneMapping, Scene, Color, MeshStandardNodeMaterial, Loader, LoaderUtils, FileLoader, TextureLoader, Group, SRGBColorSpace, RepeatWrapping, BufferGeometry, BufferAttribute, Mesh, FrontSide, BackSide, DoubleSide, REVISION, CubeTextureLoader, EquirectangularReflectionMapping, Sprite, SphereGeometry, TubeGeometry, LineCurve3, CatmullRomCurve3, SpriteNodeMaterial, CanvasTexture, ShapeGeometry, Shape, ExtrudeGeometry, PlaneGeometry, CircleGeometry } from "three/webgpu";
2
- import { pass, blendColor, color, uv, time, pow, sin, mix, mx_noise_float, Fn, userData, materialColor, select, materialOpacity, vec3 } from "three/tsl";
3
- import CameraControlsBase from "camera-controls";
4
- import { RoomEnvironment as RoomEnvironment$1 } from "three/addons/environments/RoomEnvironment.js";
5
- import { ViewHelper } from "three/addons/helpers/ViewHelper.js";
6
- import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
7
- import { FBXLoader } from "three/addons/loaders/FBXLoader.js";
8
- import { OBJLoader } from "three/addons/loaders/OBJLoader.js";
9
- import { STLLoader } from "three/addons/loaders/STLLoader.js";
10
- import { DRACOLoader } from "three/addons/loaders/DRACOLoader.js";
11
- import { KTX2Loader } from "three/addons/loaders/KTX2Loader.js";
12
- import { MeshoptDecoder } from "three/addons/libs/meshopt_decoder.module.js";
13
- import { HDRLoader } from "three/addons/loaders/HDRLoader.js";
14
- import { clone } from "three/addons/utils/SkeletonUtils.js";
15
- import { Color as Color$1 } from "three";
16
- import { Easing, Tween as Tween$1 } from "three/addons/libs/tween.module.js";
17
- class InteractionEvent {
1
+ import { Raycaster as Te, Vector2 as R, RenderPipeline as $e, PerspectiveCamera as K, Sphere as Se, Box3 as xe, Spherical as C, Matrix4 as We, Quaternion as Ke, Vector4 as Qe, Vector3 as oe, MathUtils as Xe, PMREMGenerator as qe, OrthographicCamera as Q, TimestampQuery as Ye, Cache as Je, EventDispatcher as Ze, Timer as Ve, WebGPURenderer as et, PCFShadowMap as tt, AgXToneMapping as st, Scene as it, Color as V, MeshStandardNodeMaterial as L, Loader as nt, LoaderUtils as I, FileLoader as Ee, TextureLoader as Me, Group as ee, SRGBColorSpace as Pe, RepeatWrapping as ce, BufferGeometry as rt, BufferAttribute as he, Mesh as z, FrontSide as at, BackSide as ot, DoubleSide as ct, REVISION as le, CubeTextureLoader as ht, EquirectangularReflectionMapping as lt, Sprite as dt, AnimationMixer as pt, LoopRepeat as ut, LoopOnce as mt, SphereGeometry as gt, TubeGeometry as ft, LineCurve3 as yt, CatmullRomCurve3 as wt, SpriteNodeMaterial as vt, CanvasTexture as bt, ShapeGeometry as Ct, Shape as Oe, ExtrudeGeometry as Tt, PlaneGeometry as St, CircleGeometry as xt } from "three/webgpu";
2
+ import { pass as re, mrt as Et, output as Mt, add as de, blendColor as Pt, emissive as Ot, normalView as Rt, velocity as It, color as j, uv as pe, time as X, pow as q, sin as ae, mix as Y, mx_noise_float as ue, Fn as Re, userData as O, materialColor as me, select as J, materialOpacity as Lt, vec3 as At } from "three/tsl";
3
+ import { bloom as Nt } from "three/addons/tsl/display/BloomNode.js";
4
+ import { ssgi as Bt } from "three/addons/tsl/display/SSGINode.js";
5
+ import { traa as _t } from "three/addons/tsl/display/TRAANode.js";
6
+ import Ie from "camera-controls";
7
+ import { RoomEnvironment as Dt } from "three/addons/environments/RoomEnvironment.js";
8
+ import { ViewHelper as jt } from "three/addons/helpers/ViewHelper.js";
9
+ import { CSS2DRenderer as Ut, CSS2DObject as kt } from "three/addons/renderers/CSS2DRenderer.js";
10
+ import { CSS2DObject as pi } from "three/addons/renderers/CSS2DRenderer.js";
11
+ import { CSS3DRenderer as Gt, CSS3DSprite as Ft, CSS3DObject as zt } from "three/addons/renderers/CSS3DRenderer.js";
12
+ import { CSS3DObject as mi, CSS3DSprite as gi } from "three/addons/renderers/CSS3DRenderer.js";
13
+ import { GLTFLoader as Le } from "three/addons/loaders/GLTFLoader.js";
14
+ import { FBXLoader as Ht } from "three/addons/loaders/FBXLoader.js";
15
+ import { OBJLoader as $t } from "three/addons/loaders/OBJLoader.js";
16
+ import { STLLoader as Wt } from "three/addons/loaders/STLLoader.js";
17
+ import { DRACOLoader as Kt } from "three/addons/loaders/DRACOLoader.js";
18
+ import { KTX2Loader as Qt } from "three/addons/loaders/KTX2Loader.js";
19
+ import { MeshoptDecoder as ge } from "three/addons/libs/meshopt_decoder.module.js";
20
+ import { HDRLoader as Xt } from "three/addons/loaders/HDRLoader.js";
21
+ import { clone as qt } from "three/addons/utils/SkeletonUtils.js";
22
+ import { Color as U } from "three";
23
+ import { Easing as u, Tween as Yt } from "three/addons/libs/tween.module.js";
24
+ class Jt {
18
25
  /** The type of event (e.g., 'click', 'pointerdown'). */
19
26
  type;
20
27
  /** The original 3D object that triggered the event. */
@@ -25,19 +32,15 @@ class InteractionEvent {
25
32
  intersect;
26
33
  /** The original DOM event, or undefined if not applicable. */
27
34
  originalEvent;
28
- _propagationStopped = false;
29
- constructor(init) {
30
- this.type = init.type;
31
- this.target = init.target;
32
- this.currentTarget = init.target;
33
- this.intersect = init.intersect;
34
- this.originalEvent = init.originalEvent;
35
+ _propagationStopped = !1;
36
+ constructor(e) {
37
+ this.type = e.type, this.target = e.target, this.currentTarget = e.target, this.intersect = e.intersect, this.originalEvent = e.originalEvent;
35
38
  }
36
39
  /**
37
40
  * Stops the event from bubbling up the parent chain.
38
41
  */
39
42
  stopPropagation() {
40
- this._propagationStopped = true;
43
+ this._propagationStopped = !0;
41
44
  }
42
45
  /**
43
46
  * Returns true if `stopPropagation()` has been called.
@@ -46,15 +49,15 @@ class InteractionEvent {
46
49
  return this._propagationStopped;
47
50
  }
48
51
  }
49
- class InteractionManager {
52
+ class Zt {
50
53
  domElement;
51
54
  scene;
52
55
  camera;
53
- raycaster = new Raycaster();
54
- pointer = new Vector2();
56
+ raycaster = new Te();
57
+ pointer = new R();
55
58
  hoveredObject = null;
56
59
  pointerDownTime = 0;
57
- pointerDownPos = new Vector2();
60
+ pointerDownPos = new R();
58
61
  clickTimer = null;
59
62
  longPressThreshold = 500;
60
63
  moveThreshold = 0.01;
@@ -66,142 +69,92 @@ class InteractionManager {
66
69
  * Whether to enable pointer move events (pointermove, pointerenter, pointerleave).
67
70
  * Disabled by default for performance optimization.
68
71
  */
69
- pointerMoveEventsEnabled = false;
70
- constructor(domElement, scene, camera) {
71
- this.domElement = domElement;
72
- this.scene = scene;
73
- this.camera = camera;
74
- this.raycaster.params.Points.threshold = 0.1;
75
- this.raycaster.params.Line.threshold = 0.1;
76
- this.targetObjects = this.scene.children;
77
- this._bindEvents();
72
+ pointerMoveEventsEnabled = !1;
73
+ constructor(e, t, s) {
74
+ 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();
78
75
  }
79
76
  /**
80
77
  * Updates the camera reference (useful when switching cameras).
81
78
  */
82
- setCamera(camera) {
83
- this.camera = camera;
79
+ setCamera(e) {
80
+ this.camera = e;
84
81
  }
85
82
  _bindEvents() {
86
- this.domElement.addEventListener("click", this._onClick);
87
- this.domElement.addEventListener("dblclick", this._onDblClick);
88
- this.domElement.addEventListener("contextmenu", this._onContextMenu);
89
- this.domElement.addEventListener("pointerdown", this._onPointerDown);
90
- this.domElement.addEventListener("pointerup", this._onPointerUp);
91
- this.domElement.addEventListener("pointermove", this._onPointerMove);
92
- }
93
- _updatePointer(event) {
94
- const rect = this.domElement.getBoundingClientRect();
95
- this.pointer.x = (event.clientX - rect.left) / rect.width * 2 - 1;
96
- this.pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
83
+ 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);
84
+ }
85
+ _updatePointer(e) {
86
+ const t = this.domElement.getBoundingClientRect();
87
+ this.pointer.x = (e.clientX - t.left) / t.width * 2 - 1, this.pointer.y = -((e.clientY - t.top) / t.height) * 2 + 1;
97
88
  }
98
89
  _getIntersects() {
99
- this.raycaster.setFromCamera(this.pointer, this.camera);
100
- return this.raycaster.intersectObjects(this.targetObjects, true);
90
+ return this.raycaster.setFromCamera(this.pointer, this.camera), this.raycaster.intersectObjects(this.targetObjects, !0);
101
91
  }
102
92
  /**
103
93
  * Dispatches an event to the target object and bubbles up the parent chain.
104
94
  */
105
- _dispatchToTarget(type, target, intersect, originalEvent) {
106
- const event3d = new InteractionEvent({
107
- type,
108
- target,
109
- intersect,
110
- originalEvent
95
+ _dispatchToTarget(e, t, s, i) {
96
+ const n = new Jt({
97
+ type: e,
98
+ target: t,
99
+ intersect: s,
100
+ originalEvent: i
111
101
  });
112
- let current = target;
113
- while (current && !event3d.propagationStopped) {
114
- event3d.currentTarget = current;
115
- current.dispatchEvent({ type, event: event3d });
116
- current = current.parent;
117
- }
102
+ let r = t;
103
+ for (; r && !n.propagationStopped; )
104
+ n.currentTarget = r, r.dispatchEvent({ type: e, event: n }), r = r.parent;
118
105
  }
119
106
  /**
120
107
  * Handles a DOM event by raycasting and dispatching to the first intersected object.
121
108
  */
122
- _handleEvent(type, originalEvent) {
123
- this._updatePointer(originalEvent);
124
- const intersects = this._getIntersects();
125
- if (intersects.length === 0) return;
126
- const hit = intersects[0];
127
- this._dispatchToTarget(type, hit.object, hit, originalEvent);
109
+ _handleEvent(e, t) {
110
+ this._updatePointer(t);
111
+ const s = this._getIntersects();
112
+ if (s.length === 0) return;
113
+ const i = s[0];
114
+ this._dispatchToTarget(e, i.object, i, t);
128
115
  }
129
116
  _onClick = (e) => {
130
- const duration = Date.now() - this.pointerDownTime;
131
- const moveDistance = this.pointer.distanceTo(this.pointerDownPos);
132
- if (duration > this.longPressThreshold || moveDistance > this.moveThreshold) {
133
- return;
134
- }
135
- if (this.clickTimer) {
136
- clearTimeout(this.clickTimer);
137
- this.clickTimer = null;
138
- return;
117
+ const t = Date.now() - this.pointerDownTime, s = this.pointer.distanceTo(this.pointerDownPos);
118
+ if (!(t > this.longPressThreshold || s > this.moveThreshold)) {
119
+ if (this.clickTimer) {
120
+ clearTimeout(this.clickTimer), this.clickTimer = null;
121
+ return;
122
+ }
123
+ this.clickTimer = setTimeout(() => {
124
+ this._handleEvent("click", e), this.clickTimer = null;
125
+ }, 200);
139
126
  }
140
- this.clickTimer = setTimeout(() => {
141
- this._handleEvent("click", e);
142
- this.clickTimer = null;
143
- }, 200);
144
127
  };
145
128
  _onDblClick = (e) => {
146
- if (this.clickTimer) {
147
- clearTimeout(this.clickTimer);
148
- this.clickTimer = null;
149
- }
150
- this._handleEvent("dblclick", e);
129
+ this.clickTimer && (clearTimeout(this.clickTimer), this.clickTimer = null), this._handleEvent("dblclick", e);
151
130
  };
152
131
  _onContextMenu = (e) => {
153
132
  e.preventDefault();
154
133
  };
155
134
  _onPointerDown = (e) => {
156
- this.pointerDownTime = Date.now();
157
- this._updatePointer(e);
158
- this.pointerDownPos.copy(this.pointer);
159
- this._handleEvent("pointerdown", e);
135
+ this.pointerDownTime = Date.now(), this._updatePointer(e), this.pointerDownPos.copy(this.pointer), this._handleEvent("pointerdown", e);
160
136
  };
161
137
  _onPointerUp = (e) => {
162
- this._updatePointer(e);
163
- if (e.button === 2) {
164
- const duration = Date.now() - this.pointerDownTime;
165
- const moveDistance = this.pointer.distanceTo(this.pointerDownPos);
166
- if (duration <= this.longPressThreshold && moveDistance <= this.moveThreshold) {
167
- this._handleEvent("rightclick", e);
168
- }
138
+ if (this._updatePointer(e), e.button === 2) {
139
+ const t = Date.now() - this.pointerDownTime, s = this.pointer.distanceTo(this.pointerDownPos);
140
+ t <= this.longPressThreshold && s <= this.moveThreshold && this._handleEvent("rightclick", e);
169
141
  }
170
142
  this._handleEvent("pointerup", e);
171
143
  };
172
144
  _onPointerMove = (e) => {
173
145
  if (!this.pointerMoveEventsEnabled) return;
174
146
  this._updatePointer(e);
175
- const intersects = this._getIntersects();
176
- const hitObject = intersects.length > 0 ? intersects[0].object : null;
177
- const intersect = intersects.length > 0 ? intersects[0] : null;
178
- if (this.hoveredObject !== hitObject) {
179
- if (this.hoveredObject) {
180
- this._dispatchToTarget("pointerleave", this.hoveredObject, null, e);
181
- }
182
- this.hoveredObject = hitObject;
183
- if (hitObject && intersect) {
184
- this._dispatchToTarget("pointerenter", hitObject, intersect, e);
185
- }
186
- }
187
- if (hitObject && intersect) {
188
- this._dispatchToTarget("pointermove", hitObject, intersect, e);
189
- }
147
+ const t = this._getIntersects(), s = t.length > 0 ? t[0].object : null, i = t.length > 0 ? t[0] : null;
148
+ this.hoveredObject !== s && (this.hoveredObject && this._dispatchToTarget("pointerleave", this.hoveredObject, null, e), this.hoveredObject = s, s && i && this._dispatchToTarget("pointerenter", s, i, e)), s && i && this._dispatchToTarget("pointermove", s, i, e);
190
149
  };
191
150
  /**
192
151
  * Cleans up event listeners.
193
152
  */
194
153
  dispose() {
195
- this.domElement.removeEventListener("click", this._onClick);
196
- this.domElement.removeEventListener("dblclick", this._onDblClick);
197
- this.domElement.removeEventListener("contextmenu", this._onContextMenu);
198
- this.domElement.removeEventListener("pointerdown", this._onPointerDown);
199
- this.domElement.removeEventListener("pointerup", this._onPointerUp);
200
- this.domElement.removeEventListener("pointermove", this._onPointerMove);
201
- this.hoveredObject = null;
154
+ 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.hoveredObject = null;
202
155
  }
203
156
  }
204
- class ObjectManager {
157
+ class Vt {
205
158
  idMap = /* @__PURE__ */ new Map();
206
159
  nameMap = /* @__PURE__ */ new Map();
207
160
  typeMap = /* @__PURE__ */ new Map();
@@ -211,117 +164,85 @@ class ObjectManager {
211
164
  * Add an object with a custom id.
212
165
  * One object can have multiple ids.
213
166
  */
214
- add(id, object) {
215
- if (this.idMap.has(id)) {
216
- console.warn(`ObjectManager: Object with id ${id} already exists.`);
167
+ add(e, t) {
168
+ if (this.idMap.has(e)) {
169
+ console.warn(`ObjectManager: Object with id ${e} already exists.`);
217
170
  return;
218
171
  }
219
- this.idMap.set(id, object);
220
- this.allObjects.add(object);
221
- if (!this.objectIds.has(object)) {
222
- this.objectIds.set(object, /* @__PURE__ */ new Set());
223
- }
224
- this.objectIds.get(object).add(id);
225
- if (object.name) {
226
- if (!this.nameMap.has(object.name)) {
227
- this.nameMap.set(object.name, /* @__PURE__ */ new Set());
228
- }
229
- this.nameMap.get(object.name).add(object);
230
- }
231
- if (object.type) {
232
- if (!this.typeMap.has(object.type)) {
233
- this.typeMap.set(object.type, /* @__PURE__ */ new Set());
234
- }
235
- this.typeMap.get(object.type).add(object);
236
- }
172
+ 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));
237
173
  }
238
174
  /**
239
175
  * Get an object by its custom id.
240
176
  */
241
- getById(id) {
242
- return this.idMap.get(id);
177
+ getById(e) {
178
+ return this.idMap.get(e);
243
179
  }
244
180
  /**
245
181
  * Get all objects with a given name.
246
182
  */
247
- getByName(name) {
248
- return this.nameMap.get(name) || /* @__PURE__ */ new Set();
183
+ getByName(e) {
184
+ return this.nameMap.get(e) || /* @__PURE__ */ new Set();
249
185
  }
250
186
  /**
251
187
  * Get all objects with a given type.
252
188
  */
253
- getByType(type) {
254
- return this.typeMap.get(type) || /* @__PURE__ */ new Set();
189
+ getByType(e) {
190
+ return this.typeMap.get(e) || /* @__PURE__ */ new Set();
255
191
  }
256
192
  /**
257
193
  * Get all ids associated with an object.
258
194
  */
259
- getObjectIds(object) {
260
- return this.objectIds.get(object) || /* @__PURE__ */ new Set();
195
+ getObjectIds(e) {
196
+ return this.objectIds.get(e) || /* @__PURE__ */ new Set();
261
197
  }
262
198
  /**
263
199
  * Remove an object and all its associated ids.
264
200
  */
265
- remove(object) {
266
- const ids = this.objectIds.get(object);
267
- if (ids) {
268
- for (const id of ids) {
269
- this.idMap.delete(id);
270
- }
271
- this.objectIds.delete(object);
201
+ remove(e) {
202
+ const t = this.objectIds.get(e);
203
+ if (t) {
204
+ for (const s of t)
205
+ this.idMap.delete(s);
206
+ this.objectIds.delete(e);
272
207
  }
273
- if (object.name && this.nameMap.has(object.name)) {
274
- const set = this.nameMap.get(object.name);
275
- set.delete(object);
276
- if (set.size === 0) {
277
- this.nameMap.delete(object.name);
278
- }
208
+ if (e.name && this.nameMap.has(e.name)) {
209
+ const s = this.nameMap.get(e.name);
210
+ s.delete(e), s.size === 0 && this.nameMap.delete(e.name);
279
211
  }
280
- if (object.type && this.typeMap.has(object.type)) {
281
- const set = this.typeMap.get(object.type);
282
- set.delete(object);
283
- if (set.size === 0) {
284
- this.typeMap.delete(object.type);
285
- }
212
+ if (e.type && this.typeMap.has(e.type)) {
213
+ const s = this.typeMap.get(e.type);
214
+ s.delete(e), s.size === 0 && this.typeMap.delete(e.type);
286
215
  }
287
- this.allObjects.delete(object);
216
+ this.allObjects.delete(e);
288
217
  }
289
218
  /**
290
219
  * Remove an object by its id.
291
220
  */
292
- removeById(id) {
293
- const object = this.idMap.get(id);
294
- if (object) {
295
- this.remove(object);
296
- }
221
+ removeById(e) {
222
+ const t = this.idMap.get(e);
223
+ t && this.remove(t);
297
224
  }
298
225
  /**
299
226
  * Remove all objects with a given name.
300
227
  */
301
- removeByName(name) {
302
- const objects = this.getByName(name);
303
- for (const object of objects) {
304
- this.remove(object);
305
- }
228
+ removeByName(e) {
229
+ const t = this.getByName(e);
230
+ for (const s of t)
231
+ this.remove(s);
306
232
  }
307
233
  /**
308
234
  * Remove all objects with a given type.
309
235
  */
310
- removeByType(type) {
311
- const objects = this.getByType(type);
312
- for (const object of objects) {
313
- this.remove(object);
314
- }
236
+ removeByType(e) {
237
+ const t = this.getByType(e);
238
+ for (const s of t)
239
+ this.remove(s);
315
240
  }
316
241
  /**
317
242
  * Clear all cached objects.
318
243
  */
319
244
  clear() {
320
- this.idMap.clear();
321
- this.nameMap.clear();
322
- this.typeMap.clear();
323
- this.objectIds.clear();
324
- this.allObjects.clear();
245
+ this.idMap.clear(), this.nameMap.clear(), this.typeMap.clear(), this.objectIds.clear(), this.allObjects.clear();
325
246
  }
326
247
  /**
327
248
  * Get all cached objects as a Set.
@@ -336,202 +257,287 @@ class ObjectManager {
336
257
  return this.allObjects.size;
337
258
  }
338
259
  }
339
- class RenderPipeline extends RenderPipeline$1 {
260
+ class es extends $e {
340
261
  scene;
341
262
  camera;
342
- currentOutputNode;
263
+ scenePass;
343
264
  needsUpdateOutputNode;
344
- #overlayPasses;
345
- constructor(...args) {
346
- const [renderer, scene, camera] = args;
347
- super(renderer);
348
- this.scene = scene;
349
- this.camera = camera;
350
- this.currentOutputNode = pass(scene, camera);
351
- this.needsUpdateOutputNode = true;
352
- this.#overlayPasses = /* @__PURE__ */ new Set();
353
- }
354
- addOverlayPass(pass2) {
355
- this.#overlayPasses.add(pass2);
356
- this.needsUpdateOutputNode = true;
357
- }
358
- removeOverlayPass(pass2) {
359
- this.#overlayPasses.delete(pass2);
360
- this.needsUpdateOutputNode = true;
361
- }
362
- setCamera(camera) {
363
- this.camera = camera;
364
- this.needsUpdateOutputNode = true;
365
- }
366
- setCurrentOutputNode(node) {
367
- this.currentOutputNode.dispose();
368
- this.currentOutputNode = node;
369
- this.needsUpdateOutputNode = true;
265
+ #r;
266
+ #t;
267
+ #s = !1;
268
+ #a = { strength: 1, radius: 0, threshold: 0 };
269
+ #c = null;
270
+ #n = !1;
271
+ #e = {
272
+ sliceCount: 1,
273
+ stepCount: 12,
274
+ aoIntensity: 1,
275
+ giIntensity: 10,
276
+ radius: 12,
277
+ thickness: 1
278
+ };
279
+ #h = null;
280
+ #o = !1;
281
+ #l = null;
282
+ #d = null;
283
+ constructor(...e) {
284
+ const [t, s, i] = e;
285
+ super(t), this.scene = s, this.camera = i, this.scenePass = re(s, i), this.needsUpdateOutputNode = !0, this.#r = /* @__PURE__ */ new Set(), this.#t = [], this.#p();
286
+ }
287
+ /** @deprecated Use `scenePass` instead */
288
+ get currentOutputNode() {
289
+ return this.scenePass;
290
+ }
291
+ addOverlayPass(e) {
292
+ this.#r.add(e), this.needsUpdateOutputNode = !0;
293
+ }
294
+ removeOverlayPass(e) {
295
+ this.#r.delete(e), this.needsUpdateOutputNode = !0;
370
296
  }
297
+ setCamera(e) {
298
+ this.camera = e, this.#i();
299
+ }
300
+ /** @deprecated Use `setOutputComposer` instead */
301
+ setCurrentOutputNode(e) {
302
+ this.setOutputComposer(() => e);
303
+ }
304
+ /** @deprecated Use `setOutputComposer(null)` instead */
371
305
  resetCurrentOutputNode() {
372
- this.currentOutputNode.dispose();
373
- this.currentOutputNode = pass(this.scene, this.camera);
374
- this.needsUpdateOutputNode = true;
375
- }
376
- #updateOutputNode() {
377
- let currentNode = this.currentOutputNode;
378
- if (this.#overlayPasses.size > 0) {
379
- this.#overlayPasses.forEach((overlayPass) => {
380
- currentNode = blendColor(currentNode, overlayPass);
381
- });
306
+ this.setOutputComposer(null);
307
+ }
308
+ setOutputComposer(e) {
309
+ this.#d = e, this.needsUpdateOutputNode = !0;
310
+ }
311
+ enableBloom(e) {
312
+ e && Object.assign(this.#a, e), this.#s = !0, this.#i();
313
+ }
314
+ disableBloom() {
315
+ this.#s = !1, this.#c = null, this.#i();
316
+ }
317
+ updateBloom(e) {
318
+ Object.assign(this.#a, e), this.#s && (this.needsUpdateOutputNode = !0);
319
+ }
320
+ enableSSGI(e) {
321
+ e && Object.assign(this.#e, e), this.#n = !0, this.#i();
322
+ }
323
+ disableSSGI() {
324
+ this.#n = !1, this.#h = null, this.#i();
325
+ }
326
+ updateSSGI(e) {
327
+ if (Object.assign(this.#e, e), this.#h) {
328
+ const t = this.#h;
329
+ 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);
382
330
  }
383
- this.outputNode = currentNode;
384
- this.needsUpdate = true;
385
331
  }
386
- render() {
387
- if (this.needsUpdateOutputNode) {
388
- this.#updateOutputNode();
389
- this.needsUpdateOutputNode = false;
332
+ enableTRAA() {
333
+ this.#o = !0, this.#i();
334
+ }
335
+ disableTRAA() {
336
+ this.#o = !1, this.#l = null, this.#i();
337
+ }
338
+ #i() {
339
+ const e = this.scenePass;
340
+ this.scenePass = re(this.scene, this.camera), this.#p(), this.needsUpdateOutputNode = !0, e.dispose();
341
+ }
342
+ #p() {
343
+ if (this.#s || this.#n || this.#o) {
344
+ const t = { output: Mt };
345
+ this.#s && (t.emissive = Ot), this.#n && (t.normal = Rt), this.#o && (t.velocity = It), this.scenePass.setMRT(Et(t));
390
346
  }
391
- super.render();
347
+ }
348
+ #u() {
349
+ for (const e of this.#t)
350
+ e.dispose();
351
+ this.#t = [];
352
+ }
353
+ #m() {
354
+ let e = this.scenePass.getTextureNode();
355
+ if (this.#n)
356
+ if (!(this.camera instanceof K))
357
+ console.warn("RenderPipeline: SSGI requires a PerspectiveCamera, skipping.");
358
+ else {
359
+ const t = this.scenePass.getTextureNode(), s = this.scenePass.getTextureNode("depth"), i = this.scenePass.getTextureNode("normal"), n = Bt(t, s, i, this.camera);
360
+ n.sliceCount.value = this.#e.sliceCount, n.stepCount.value = this.#e.stepCount, n.aoIntensity.value = this.#e.aoIntensity, n.giIntensity.value = this.#e.giIntensity, n.radius.value = this.#e.radius, n.thickness.value = this.#e.thickness, this.#h = n, e = de(e, n), this.#t.push(n);
361
+ }
362
+ if (this.#s) {
363
+ const t = this.scenePass.getTextureNode("emissive");
364
+ this.#c = Nt(
365
+ t,
366
+ this.#a.strength,
367
+ this.#a.radius,
368
+ this.#a.threshold
369
+ ), e = de(e, this.#c), this.#t.push(this.#c);
370
+ }
371
+ return e;
372
+ }
373
+ #g() {
374
+ this.#u();
375
+ let e;
376
+ if (this.#d ? e = this.#d(this.scenePass) : this.#s || this.#n ? e = this.#m() : e = this.scenePass, this.#o) {
377
+ const t = this.scenePass.getTextureNode("depth"), s = this.scenePass.getTextureNode("velocity");
378
+ this.#l = _t(e, t, s, this.camera), this.#t.push(this.#l), e = this.#l;
379
+ }
380
+ this.#r.size > 0 && this.#r.forEach((t) => {
381
+ const s = Pt(e, t);
382
+ this.#t.push(s), e = s;
383
+ }), this.outputNode = e, this.needsUpdate = !0;
384
+ }
385
+ render() {
386
+ this.needsUpdateOutputNode && (this.#g(), this.needsUpdateOutputNode = !1), super.render();
387
+ }
388
+ dispose() {
389
+ this.#u(), this.scenePass.dispose(), super.dispose();
392
390
  }
393
391
  }
394
- const subsetOfTHREE = {
395
- Vector2,
396
- Vector3,
397
- Vector4,
398
- Quaternion,
399
- Matrix4,
400
- Spherical,
401
- Box3,
402
- Sphere,
403
- Raycaster
392
+ const ts = {
393
+ Vector2: R,
394
+ Vector3: oe,
395
+ Vector4: Qe,
396
+ Quaternion: Ke,
397
+ Matrix4: We,
398
+ Spherical: C,
399
+ Box3: xe,
400
+ Sphere: Se,
401
+ Raycaster: Te
404
402
  };
405
- CameraControlsBase.install({ THREE: subsetOfTHREE });
406
- class CameraControls extends CameraControlsBase {
407
- constructor(...args) {
408
- super(...args);
409
- this.minDistance = 0.2;
410
- this.smoothTime = 0.2;
411
- this.dollySpeed = 0.2;
403
+ Ie.install({ THREE: ts });
404
+ class ss extends Ie {
405
+ constructor(...e) {
406
+ super(...e), this.minDistance = 0.2, this.smoothTime = 0.2, this.dollySpeed = 0.2;
412
407
  }
413
408
  /**
414
409
  * Set absolute angle for azimuth to avoid spinning
415
410
  */
416
411
  absoluteRotations() {
417
- this.azimuthAngle = absoluteAngle(this.azimuthAngle, 0);
412
+ this.azimuthAngle = is(this.azimuthAngle, 0);
418
413
  }
419
- async flyToBox(box, options = {}) {
420
- if (box.isEmpty()) {
421
- console.warn("CameraControls.flyToBox: The provided Box3 is empty.");
422
- return false;
423
- }
414
+ async flyToBox(e, t = {}) {
415
+ if (e.isEmpty())
416
+ return console.warn("CameraControls.flyToBox: The provided Box3 is empty."), !1;
424
417
  this.absoluteRotations();
425
- const { viewpoint = "frontTop", enableTransition = true, padding = 0.1, cover = false } = options;
426
- const promises = [];
427
- if (viewpoint !== "current") {
428
- const spherical = viewpointsSpherical[viewpoint.toUpperCase()] ?? viewpointsSpherical.FRONTTOP;
429
- const azimuthAngle = spherical.theta, polarAngle = spherical.phi;
430
- promises.push(
431
- this.fitToBox(box, enableTransition, {
432
- paddingLeft: padding,
433
- paddingRight: padding,
434
- paddingTop: padding,
435
- paddingBottom: padding,
436
- cover
418
+ const { viewpoint: s = "frontTop", enableTransition: i = !0, padding: n = 0.1, cover: r = !1 } = t, o = [];
419
+ if (s !== "current") {
420
+ const c = fe[s.toUpperCase()] ?? fe.FRONTTOP, h = c.theta, l = c.phi;
421
+ o.push(
422
+ this.fitToBox(e, i, {
423
+ paddingLeft: n,
424
+ paddingRight: n,
425
+ paddingTop: n,
426
+ paddingBottom: n,
427
+ cover: r
437
428
  })
438
- );
439
- promises.push(this.rotateTo(azimuthAngle, polarAngle, enableTransition));
429
+ ), o.push(this.rotateTo(h, l, i));
440
430
  } else {
441
- const sphere = new Sphere();
442
- box.getBoundingSphere(sphere);
443
- sphere.radius += padding;
444
- promises.push(this.fitToSphere(sphere, enableTransition));
431
+ const c = new Se();
432
+ e.getBoundingSphere(c), c.radius += n, o.push(this.fitToSphere(c, i));
445
433
  }
446
- await Promise.all(promises);
447
- return true;
434
+ return await Promise.all(o), !0;
448
435
  }
449
- async flyToObject(object, options = {}) {
450
- const box = new Box3().setFromObject(object);
451
- return this.flyToBox(box, options);
436
+ async flyToObject(e, t = {}) {
437
+ const s = new xe().setFromObject(e);
438
+ return this.flyToBox(s, t);
439
+ }
440
+ async setCameraViewpoint(e, t = !0) {
441
+ const { position: s, target: i, zoom: n = this.camera.zoom } = e;
442
+ return Promise.all([
443
+ this.zoomTo(n, t),
444
+ this.setLookAt(s.x, s.y, s.z, i.x, i.y, i.z, t)
445
+ ]);
452
446
  }
453
447
  }
454
- const viewpointsSpherical = {
455
- LEFT: new Spherical(0, Math.PI / 2, -Math.PI / 2),
456
- RIGHT: new Spherical(0, Math.PI / 2, Math.PI / 2),
457
- FRONT: new Spherical(0, Math.PI / 2, 0),
458
- BACK: new Spherical(0, Math.PI / 2, Math.PI),
459
- TOP: new Spherical(0, 0, 0),
460
- BOTTOM: new Spherical(0, Math.PI, 0),
461
- FRONTTOP: new Spherical(0, Math.PI / 4, 0),
462
- BACKTOP: new Spherical(0, Math.PI / 4, Math.PI),
463
- LEFTTOP: new Spherical(0, Math.PI / 4, -Math.PI / 2),
464
- RIGHTTOP: new Spherical(0, Math.PI / 4, Math.PI / 2),
465
- LEFTFRONTTOP: new Spherical(0, Math.PI / 4, -Math.PI / 4),
466
- RIGHTFRONTTOP: new Spherical(0, Math.PI / 4, Math.PI / 4),
467
- LEFTBACKTOP: new Spherical(0, Math.PI / 4, -Math.PI / 4 * 3),
468
- RIGHTBACKTOP: new Spherical(0, Math.PI / 4, Math.PI / 4 * 3)
448
+ const fe = {
449
+ LEFT: new C(0, Math.PI / 2, -Math.PI / 2),
450
+ RIGHT: new C(0, Math.PI / 2, Math.PI / 2),
451
+ FRONT: new C(0, Math.PI / 2, 0),
452
+ BACK: new C(0, Math.PI / 2, Math.PI),
453
+ TOP: new C(0, 0, 0),
454
+ BOTTOM: new C(0, Math.PI, 0),
455
+ FRONTTOP: new C(0, Math.PI / 4, 0),
456
+ BACKTOP: new C(0, Math.PI / 4, Math.PI),
457
+ LEFTTOP: new C(0, Math.PI / 4, -Math.PI / 2),
458
+ RIGHTTOP: new C(0, Math.PI / 4, Math.PI / 2),
459
+ LEFTFRONTTOP: new C(0, Math.PI / 4, -Math.PI / 4),
460
+ RIGHTFRONTTOP: new C(0, Math.PI / 4, Math.PI / 4),
461
+ LEFTBACKTOP: new C(0, Math.PI / 4, -Math.PI / 4 * 3),
462
+ RIGHTBACKTOP: new C(0, Math.PI / 4, Math.PI / 4 * 3)
469
463
  };
470
- function absoluteAngle(targetAngle, sourceAngle) {
471
- const angle = targetAngle - sourceAngle;
472
- return MathUtils.euclideanModulo(angle + Math.PI, Math.PI * 2) - Math.PI;
464
+ function is(a, e) {
465
+ const t = a - e;
466
+ return Xe.euclideanModulo(t + Math.PI, Math.PI * 2) - Math.PI;
473
467
  }
474
- class RoomEnvironment {
475
- environment = new RoomEnvironment$1();
468
+ class ns {
469
+ environment = new Dt();
476
470
  renderer;
477
471
  pmremGenerator;
478
472
  envMap = null;
479
- constructor(renderer) {
480
- this.renderer = renderer;
481
- this.pmremGenerator = new PMREMGenerator(renderer);
473
+ constructor(e) {
474
+ this.renderer = e, this.pmremGenerator = new qe(e);
482
475
  }
483
476
  update() {
484
- if (!this.envMap) {
485
- this.envMap = this.pmremGenerator.fromScene(this.environment).texture;
486
- }
477
+ this.envMap || (this.envMap = this.pmremGenerator.fromScene(this.environment).texture);
487
478
  }
488
479
  dispose() {
489
- this.pmremGenerator.dispose();
490
- this.envMap?.dispose();
480
+ this.pmremGenerator.dispose(), this.envMap?.dispose();
491
481
  }
492
482
  }
493
- const dim = 128;
494
- class ViewerHelper extends ViewHelper {
483
+ const $ = 128;
484
+ class rs extends jt {
495
485
  viewer;
496
486
  overlayPass;
497
- constructor(viewer) {
498
- super(viewer.camera, viewer.el);
499
- this.viewer = viewer;
500
- const orthoCamera = new OrthographicCamera(-2, 2, 2, -2, 0, 4);
501
- orthoCamera.position.set(0, 0, 2);
502
- this.overlayPass = pass(this, orthoCamera);
503
- this.setLabels("x", "y", "z");
487
+ constructor(e) {
488
+ super(e.camera, e.el), this.viewer = e;
489
+ const t = new Q(-2, 2, 2, -2, 0, 4);
490
+ t.position.set(0, 0, 2), this.overlayPass = re(this, t), this.setLabels("x", "y", "z");
504
491
  }
505
492
  _update = () => {
506
493
  this.quaternion.copy(this.viewer.camera.quaternion).invert();
507
- const location = this.location;
508
- let x, y;
509
- if (location.left !== null) {
510
- x = location.left;
511
- } else {
512
- x = this.viewer.el.offsetWidth - dim - location.right;
513
- }
514
- if (location.top !== null) {
515
- y = location.top;
516
- } else {
517
- y = this.viewer.el.offsetHeight - dim - location.bottom;
518
- }
519
- this.overlayPass.setViewport(x, y, dim, dim);
494
+ const e = this.location;
495
+ let t, s;
496
+ e.left !== null ? t = e.left : t = this.viewer.el.offsetWidth - $ - e.right, e.top !== null ? s = e.top : s = this.viewer.el.offsetHeight - $ - e.bottom, this.overlayPass.setViewport(t, s, $, $);
520
497
  };
521
498
  enable() {
522
- this.viewer.renderPipeline.addOverlayPass(this.overlayPass);
523
- this.viewer.addEventListener("beforeRender", this._update);
524
- this.viewer.render();
525
- return this;
499
+ return this.viewer.renderPipeline.addOverlayPass(this.overlayPass), this.viewer.addEventListener("beforeRender", this._update), this.viewer.render(), this;
526
500
  }
527
501
  disable() {
528
- this.viewer.renderPipeline.removeOverlayPass(this.overlayPass);
529
- this.viewer.removeEventListener("beforeRender", this._update);
530
- this.viewer.render();
531
- return this;
502
+ return this.viewer.renderPipeline.removeOverlayPass(this.overlayPass), this.viewer.removeEventListener("beforeRender", this._update), this.viewer.render(), this;
532
503
  }
533
504
  }
534
- class Info {
505
+ const Ae = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;overflow:hidden;", as = Ae + "z-index:0;", os = Ae + "z-index:1;";
506
+ class cs {
507
+ el;
508
+ css2dRenderer = null;
509
+ css3dRenderer = null;
510
+ constructor(e) {
511
+ this.el = e, getComputedStyle(e).position === "static" && (e.style.position = "relative");
512
+ }
513
+ initCSS2DRenderer() {
514
+ const e = new Ut();
515
+ return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = os, this.el.appendChild(e.domElement), this.css2dRenderer = e, e;
516
+ }
517
+ initCSS3DRenderer() {
518
+ const e = new Gt();
519
+ return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = as, this.el.appendChild(e.domElement), this.css3dRenderer = e, e;
520
+ }
521
+ createCSS2DObject(e) {
522
+ return this.css2dRenderer || this.initCSS2DRenderer(), new kt(e);
523
+ }
524
+ createCSS25DObject(e) {
525
+ return this.css3dRenderer || this.initCSS3DRenderer(), new Ft(e);
526
+ }
527
+ createCSS3DObject(e) {
528
+ return this.css3dRenderer || this.initCSS3DRenderer(), new zt(e);
529
+ }
530
+ render(e, t) {
531
+ this.css2dRenderer && this.css2dRenderer.render(e, t), this.css3dRenderer && this.css3dRenderer.render(e, t);
532
+ }
533
+ resize(e, t) {
534
+ this.css2dRenderer && this.css2dRenderer.setSize(e, t), this.css3dRenderer && this.css3dRenderer.setSize(e, t);
535
+ }
536
+ dispose() {
537
+ this.css2dRenderer && (this.el.removeChild(this.css2dRenderer.domElement), this.css2dRenderer = null), this.css3dRenderer && (this.el.removeChild(this.css3dRenderer.domElement), this.css3dRenderer = null);
538
+ }
539
+ }
540
+ class hs {
535
541
  el;
536
542
  renderer;
537
543
  container;
@@ -541,79 +547,40 @@ class Info {
541
547
  pointsText;
542
548
  linesText;
543
549
  timestampText;
544
- _enabled = false;
545
- constructor(el, renderer) {
546
- this.el = el;
547
- this.renderer = renderer;
548
- const container = document.createElement("div");
549
- container.style.position = "absolute";
550
- container.style.left = "12px";
551
- container.style.bottom = "12px";
552
- container.style.fontSize = "12px";
553
- container.style.color = "#fff";
554
- container.style.pointerEvents = "none";
555
- this.container = container;
556
- function createTextEl(text, isMarginLeft = true) {
557
- const el2 = document.createElement("span");
558
- if (isMarginLeft) el2.style.marginLeft = "6px";
559
- el2.innerText = text;
560
- return el2;
561
- }
562
- function createBr() {
550
+ _enabled = !1;
551
+ constructor(e, t) {
552
+ this.el = e, this.renderer = t;
553
+ const s = document.createElement("div");
554
+ 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;
555
+ function i(r, o = !0) {
556
+ const c = document.createElement("span");
557
+ return o && (c.style.marginLeft = "6px"), c.innerText = r, c;
558
+ }
559
+ function n() {
563
560
  return document.createElement("br");
564
561
  }
565
- this.drawCallsText = createTextEl("0");
566
- this.frameCallsText = createTextEl("0");
567
- this.trianglesText = createTextEl("0");
568
- this.linesText = createTextEl("0");
569
- this.pointsText = createTextEl("0");
570
- this.timestampText = createTextEl("0");
571
- this.container.appendChild(createTextEl("draw calls", false));
572
- this.container.appendChild(this.drawCallsText);
573
- this.container.appendChild(createBr());
574
- this.container.appendChild(createTextEl("frame calls", false));
575
- this.container.appendChild(this.frameCallsText);
576
- this.container.appendChild(createBr());
577
- this.container.appendChild(createTextEl("triangles", false));
578
- this.container.appendChild(this.trianglesText);
579
- this.container.appendChild(createBr());
580
- this.container.appendChild(createTextEl("points", false));
581
- this.container.appendChild(this.pointsText);
582
- this.container.appendChild(createBr());
583
- this.container.appendChild(createTextEl("lines", false));
584
- this.container.appendChild(this.linesText);
585
- this.container.appendChild(createBr());
586
- this.container.appendChild(createTextEl("timestamp", false));
587
- this.container.appendChild(this.timestampText);
588
- this.container.appendChild(createBr());
562
+ this.drawCallsText = i("0"), this.frameCallsText = i("0"), this.trianglesText = i("0"), this.linesText = i("0"), this.pointsText = i("0"), this.timestampText = i("0"), this.container.appendChild(i("draw calls", !1)), this.container.appendChild(this.drawCallsText), this.container.appendChild(n()), this.container.appendChild(i("frame calls", !1)), this.container.appendChild(this.frameCallsText), this.container.appendChild(n()), this.container.appendChild(i("triangles", !1)), this.container.appendChild(this.trianglesText), this.container.appendChild(n()), this.container.appendChild(i("points", !1)), this.container.appendChild(this.pointsText), this.container.appendChild(n()), this.container.appendChild(i("lines", !1)), this.container.appendChild(this.linesText), this.container.appendChild(n()), this.container.appendChild(i("timestamp", !1)), this.container.appendChild(this.timestampText), this.container.appendChild(n());
589
563
  }
590
564
  update() {
591
565
  if (this._enabled) {
592
- const { render } = this.renderer.info;
593
- this.drawCallsText.innerText = render.drawCalls.toString();
594
- this.frameCallsText.innerText = render.frameCalls.toString();
595
- this.trianglesText.innerText = render.triangles.toString();
596
- this.pointsText.innerText = render.points.toString();
597
- this.linesText.innerText = render.lines.toString();
598
- this.renderer.resolveTimestampsAsync(TimestampQuery.RENDER).then((timestamps) => {
599
- this.timestampText.innerText = timestamps?.toFixed(2) ?? "0";
566
+ const { render: e } = this.renderer.info;
567
+ 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.renderer.resolveTimestampsAsync(Ye.RENDER).then((t) => {
568
+ this.timestampText.innerText = t?.toFixed(2) ?? "0";
600
569
  });
601
570
  }
602
571
  }
603
572
  enable() {
604
- this._enabled = true;
605
- this.el.appendChild(this.container);
573
+ this._enabled = !0, this.el.appendChild(this.container);
606
574
  }
607
575
  disable() {
608
- this._enabled = false;
609
- this.container.remove();
576
+ this._enabled = !1, this.container.remove();
610
577
  }
611
578
  dispose() {
612
579
  this.disable();
613
580
  }
614
581
  }
615
- Cache.enabled = true;
616
- class Viewer extends EventDispatcher {
582
+ Je.enabled = !0;
583
+ class ei extends Ze {
617
584
  el;
618
585
  renderer;
619
586
  scene;
@@ -626,121 +593,60 @@ class Viewer extends EventDispatcher {
626
593
  interactionManager;
627
594
  objectManager;
628
595
  viewerHelper;
596
+ cssRenderer;
629
597
  frameCount = 1;
630
598
  frameloop = "demand";
631
- constructor({ el, rendererOptions }) {
632
- super();
633
- this.el = el;
634
- this.renderer = this._initRenderer(rendererOptions);
635
- this.scene = this.createScene();
636
- this.camera = this.createPerspectiveCamera();
637
- this.info = new Info(this.el, this.renderer);
638
- this.controls = new CameraControls(this.camera, this.renderer.domElement);
639
- this.renderPipeline = new RenderPipeline(this.renderer, this.scene, this.camera);
640
- this.timer = new Timer();
641
- this.roomEnvironment = new RoomEnvironment(this.renderer);
642
- this.interactionManager = new InteractionManager(this.renderer.domElement, this.scene, this.camera);
643
- this.objectManager = new ObjectManager();
644
- this.viewerHelper = new ViewerHelper(this);
645
- window.addEventListener("resize", this.onWindowResize);
599
+ constructor({ el: e, rendererOptions: t }) {
600
+ super(), this.el = e, this.renderer = this._initRenderer(t), this.scene = this.createScene(), this.camera = this.createPerspectiveCamera(), this.info = new hs(this.el, this.renderer), this.controls = new ss(this.camera, this.renderer.domElement), this.renderPipeline = new es(this.renderer, this.scene, this.camera), this.timer = new Ve(), this.roomEnvironment = new ns(this.renderer), this.interactionManager = new Zt(this.renderer.domElement, this.scene, this.camera), this.objectManager = new Vt(), this.viewerHelper = new rs(this), this.cssRenderer = new cs(this.el), window.addEventListener("resize", this.onWindowResize);
646
601
  }
647
602
  onWindowResize = () => {
648
- const width = this.el.clientWidth;
649
- const height = this.el.clientHeight;
650
- if (this.camera instanceof PerspectiveCamera) {
651
- this.camera.aspect = width / height;
652
- this.camera.updateProjectionMatrix();
653
- } else if (this.camera instanceof OrthographicCamera) {
654
- this.camera.left = -width / 2;
655
- this.camera.right = width / 2;
656
- this.camera.top = height / 2;
657
- this.camera.bottom = -height / 2;
658
- this.camera.updateProjectionMatrix();
659
- }
660
- this.renderer.setSize(width, height);
661
- this.render();
603
+ const e = this.el.clientWidth, t = this.el.clientHeight;
604
+ this.camera instanceof K ? (this.camera.aspect = e / t, this.camera.updateProjectionMatrix()) : this.camera instanceof Q && (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();
662
605
  };
663
606
  async init() {
664
- await this.renderer.init();
665
- this.roomEnvironment.update();
666
- this.scene.environment = this.roomEnvironment.envMap;
667
- }
668
- setCamera(camera) {
669
- this.camera = camera;
670
- this.controls.camera = camera;
671
- this.interactionManager.setCamera(camera);
672
- this.renderPipeline.setCamera(camera);
673
- this.onWindowResize();
674
- this.dispatchEvent({ type: "cameraChange", camera });
675
- }
676
- setCameraByType(type) {
677
- if (type === "perspective" && !(this.camera instanceof PerspectiveCamera)) {
678
- this.setCamera(this.createPerspectiveCamera());
679
- } else if (type === "orthographic" && !(this.camera instanceof OrthographicCamera)) {
680
- this.setCamera(this.createOrthographicCamera());
681
- }
607
+ await this.renderer.init(), this.roomEnvironment.update(), this.scene.environment = this.roomEnvironment.envMap;
608
+ }
609
+ setCamera(e) {
610
+ this.camera = e, this.controls.camera = e, this.interactionManager.setCamera(e), this.renderPipeline.setCamera(e), this.onWindowResize(), this.dispatchEvent({ type: "cameraChange", camera: e });
682
611
  }
683
- render(frame = 1) {
684
- this.frameCount += frame;
685
- return new Promise((resolve) => {
686
- const fn = () => {
687
- this.removeEventListener("afterRender", fn);
688
- resolve();
612
+ setCameraByType(e) {
613
+ e === "perspective" && !(this.camera instanceof K) ? this.setCamera(this.createPerspectiveCamera()) : e === "orthographic" && !(this.camera instanceof Q) && this.setCamera(this.createOrthographicCamera());
614
+ }
615
+ render(e = 1) {
616
+ return this.frameCount += e, new Promise((t) => {
617
+ const s = () => {
618
+ this.removeEventListener("afterRender", s), t();
689
619
  };
690
- this.addEventListener("afterRender", fn);
620
+ this.addEventListener("afterRender", s);
691
621
  });
692
622
  }
693
- animate = (time2) => {
694
- this.timer.update(time2);
695
- this.dispatchEvent({ type: "beforeControlsUpdate", time: time2 });
696
- let needsRender = this.controls.update(this.timer.getDelta());
697
- this.dispatchEvent({ type: "afterControlsUpdate", time: time2 });
698
- if (this.frameCount > 0) {
699
- this.frameCount--;
700
- needsRender = true;
701
- }
702
- if (this.frameloop === "always") {
703
- needsRender = true;
704
- }
705
- if (needsRender) {
706
- this.dispatchEvent({ type: "beforeRender", time: time2 });
707
- this.renderer.info.reset();
708
- this.renderPipeline.render();
709
- this.info.update();
710
- this.dispatchEvent({ type: "afterRender", time: time2 });
711
- }
623
+ animate = (e) => {
624
+ this.timer.update(e);
625
+ const t = this.timer.getDelta();
626
+ this.dispatchEvent({ type: "beforeControlsUpdate", time: e, delta: t });
627
+ let s = this.controls.update(t);
628
+ 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 }));
712
629
  };
713
- _initRenderer(rendererOptions) {
714
- const renderer = new WebGPURenderer({
715
- logarithmicDepthBuffer: true,
716
- antialias: false,
717
- depth: false,
718
- trackTimestamp: true,
719
- ...rendererOptions
630
+ _initRenderer(e) {
631
+ const t = new et({
632
+ logarithmicDepthBuffer: !0,
633
+ antialias: !1,
634
+ depth: !1,
635
+ trackTimestamp: !0,
636
+ ...e
720
637
  });
721
- renderer.setSize(this.el.clientWidth, this.el.clientHeight);
722
- renderer.shadowMap.enabled = true;
723
- renderer.shadowMap.type = PCFShadowMap;
724
- renderer.toneMapping = AgXToneMapping;
725
- renderer.toneMappingExposure = 1;
726
- renderer.info.autoReset = false;
727
- renderer.setPixelRatio(window.devicePixelRatio);
728
- renderer.setAnimationLoop(this.animate);
729
- this.el.appendChild(renderer.domElement);
730
- return renderer;
638
+ return t.setSize(this.el.clientWidth, this.el.clientHeight), t.shadowMap.enabled = !0, t.shadowMap.type = tt, t.toneMapping = st, t.toneMappingExposure = 1, t.info.autoReset = !1, t.setPixelRatio(window.devicePixelRatio), t.setAnimationLoop(this.animate), this.el.appendChild(t.domElement), t;
731
639
  }
732
640
  createScene() {
733
- const scene = new Scene();
734
- scene.background = new Color(0);
735
- return scene;
641
+ const e = new it();
642
+ return e.background = new V(0), e;
736
643
  }
737
644
  createPerspectiveCamera() {
738
- const camera = new PerspectiveCamera(50, this.el.clientWidth / this.el.clientHeight, 0.1, 1e5);
739
- camera.position.setScalar(5);
740
- return camera;
645
+ const e = new K(50, this.el.clientWidth / this.el.clientHeight, 0.1, 1e5);
646
+ return e.position.setScalar(5), e;
741
647
  }
742
648
  createOrthographicCamera() {
743
- const camera = new OrthographicCamera(
649
+ const e = new Q(
744
650
  -this.el.clientWidth / 2,
745
651
  this.el.clientWidth / 2,
746
652
  this.el.clientHeight / 2,
@@ -748,621 +654,444 @@ class Viewer extends EventDispatcher {
748
654
  0.1,
749
655
  1e5
750
656
  );
751
- camera.position.setScalar(5);
752
- return camera;
657
+ return e.position.setScalar(5), e;
753
658
  }
754
659
  dispose() {
755
- this.el.removeChild(this.renderer.domElement);
756
- window.removeEventListener("resize", this.onWindowResize);
757
- this.info.dispose();
758
- this.interactionManager.dispose();
759
- this.roomEnvironment.dispose();
760
- this.renderPipeline.dispose();
761
- this.renderer.dispose();
660
+ 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();
762
661
  }
763
662
  }
764
- class SBMXLoader extends GLTFLoader {
765
- constructor(manager) {
766
- super(manager);
767
- }
768
- parse(data, path, onLoad, onError) {
769
- const formatName = getAsciiString(data.slice(0, 8));
770
- switch (formatName) {
771
- case "SBMG----": {
772
- const swappedBuffer = swapBytes(data.slice(8));
773
- return super.parse(swappedBuffer, path, onLoad, onError);
774
- }
775
- default: {
776
- return super.parse(data, path, onLoad, onError);
777
- }
778
- }
663
+ class ls extends Le {
664
+ constructor(e) {
665
+ super(e);
666
+ }
667
+ parse(e, t, s, i) {
668
+ if (ds(e.slice(0, 8)) === "SBMG----") {
669
+ const r = ps(e.slice(8));
670
+ return super.parse(r, t, s, i);
671
+ } else
672
+ return super.parse(e, t, s, i);
779
673
  }
780
674
  }
781
- function getAsciiString(buf) {
782
- const decoder = new TextDecoder();
783
- return decoder.decode(new Uint8Array(buf));
675
+ function ds(a) {
676
+ return new TextDecoder().decode(new Uint8Array(a));
784
677
  }
785
- function swapBytes(buffer) {
786
- const view = new DataView(buffer);
787
- for (let i = 0; i < view.byteLength; i++) {
788
- const byte = view.getUint8(i);
789
- const swappedByte = (byte >> 4 & 15) + (byte << 4 & 240);
790
- view.setUint8(i, swappedByte);
791
- }
792
- return view.buffer;
678
+ function ps(a) {
679
+ const e = new DataView(a);
680
+ for (let t = 0; t < e.byteLength; t++) {
681
+ const s = e.getUint8(t), i = (s >> 4 & 15) + (s << 4 & 240);
682
+ e.setUint8(t, i);
683
+ }
684
+ return e.buffer;
793
685
  }
794
- const BYTE_LENGTH_MAGIC = 8;
795
- const BYTE_LENGTH_HEAD = 130;
796
- const BYTE_LENGTH_ATTACH = 66;
797
- const MAGIC_SBK = "SBK-----";
798
- const MAGIC_SBM = "SBM-----";
799
- const textDecoder = new TextDecoder();
800
- const textEncoder = new TextEncoder();
801
- function decodeSbk(buffer) {
802
- let read = BYTE_LENGTH_MAGIC;
803
- const magicBytes = new Uint8Array(buffer, 0, read);
804
- const magic = textDecoder.decode(magicBytes);
805
- if (magic !== MAGIC_SBK) {
806
- return buffer;
807
- }
808
- read += BYTE_LENGTH_HEAD;
809
- const headBytes = new Uint8Array(buffer, 0, read);
810
- const version = headBytes[40];
811
- if (version === 1) {
812
- const magicBuf = textEncoder.encode(MAGIC_SBM);
813
- const versionBuf = new Uint8Array([headBytes[41]]);
814
- const sbmKey = getSbmKey(headBytes);
815
- const encodeKey = getLeftKey(sbmKey);
816
- let j = BYTE_LENGTH_ATTACH % encodeKey.length;
817
- const offset = read + BYTE_LENGTH_ATTACH;
818
- const bodyBytes = new Uint8Array(buffer, offset);
819
- const bodyBuf = new Uint8Array(bodyBytes.length);
820
- for (let i = 0; i < bodyBytes.length; i++) {
821
- bodyBuf[i] = bodyBytes[i] ^ encodeKey[j];
822
- j = (j + 1) % encodeKey.length;
823
- }
824
- const buf = new Uint8Array(magicBuf.length + versionBuf.length + bodyBuf.length);
825
- buf.set(magicBuf);
826
- buf.set(versionBuf, magicBuf.length);
827
- buf.set(bodyBuf, magicBuf.length + versionBuf.length);
828
- return buf.buffer;
686
+ const us = 8, ms = 130, ye = 66, gs = "SBK-----", fs = "SBM-----", Ne = new TextDecoder(), ys = new TextEncoder();
687
+ function ws(a) {
688
+ let e = us;
689
+ const t = new Uint8Array(a, 0, e);
690
+ if (Ne.decode(t) !== gs)
691
+ return a;
692
+ e += ms;
693
+ const i = new Uint8Array(a, 0, e);
694
+ if (i[40] === 1) {
695
+ const r = ys.encode(fs), o = new Uint8Array([i[41]]), c = vs(i), h = bs(c);
696
+ let l = ye % h.length;
697
+ const d = e + ye, g = new Uint8Array(a, d), p = new Uint8Array(g.length);
698
+ for (let v = 0; v < g.length; v++)
699
+ p[v] = g[v] ^ h[l], l = (l + 1) % h.length;
700
+ const y = new Uint8Array(r.length + o.length + p.length);
701
+ return y.set(r), y.set(o, r.length), y.set(p, r.length + o.length), y.buffer;
829
702
  }
830
703
  }
831
- function getSbmKey(headBuffer) {
832
- const bytes = new Uint8Array(128);
833
- bytes.set(headBuffer.slice(42, 42 + 32), 0);
834
- bytes.set(headBuffer.slice(74, 74 + 64), 32);
835
- bytes.set(headBuffer.slice(8, 8 + 32), 96);
836
- return bytes;
704
+ function vs(a) {
705
+ const e = new Uint8Array(128);
706
+ return e.set(a.slice(42, 74), 0), e.set(a.slice(74, 138), 32), e.set(a.slice(8, 40), 96), e;
837
707
  }
838
- function getLeftKey(sbmKey) {
839
- const bytes = new Uint8Array(64);
840
- bytes.set(sbmKey.slice(0, 8), 0);
841
- bytes.set(sbmKey.slice(24, 24 + 8), 8);
842
- bytes.set(sbmKey.slice(40, 40 + 16), 16);
843
- bytes.set(sbmKey.slice(64, 64 + 24), 32);
844
- bytes.set(sbmKey.slice(96, 96 + 8), 56);
845
- return bytes;
708
+ function bs(a) {
709
+ const e = new Uint8Array(64);
710
+ return e.set(a.slice(0, 8), 0), e.set(a.slice(24, 32), 8), e.set(a.slice(40, 56), 16), e.set(a.slice(64, 88), 32), e.set(a.slice(96, 104), 56), e;
846
711
  }
847
- const getTextureName = (dataView, texnamelen, offset) => {
848
- const temp = dataView.buffer.slice(offset, offset + texnamelen);
849
- let textureName = textDecoder.decode(temp);
850
- textureName = textureName.replace("\\", "/");
851
- if (!textureName.startsWith("Maps/")) {
852
- textureName = `Maps/${textureName}`;
853
- }
854
- return textureName;
855
- };
856
- const generateSbmMaterial = (materialId, arr, png) => {
857
- const [d0, d1, d2, d3, side] = arr;
858
- const trans = png || d3 < 1;
859
- const material = new MeshStandardNodeMaterial({
860
- name: materialId,
861
- color: new Color(d0, d1, d2),
862
- opacity: d3,
863
- transparent: trans,
712
+ const Cs = (a, e, t) => {
713
+ const s = a.buffer.slice(t, t + e);
714
+ let i = Ne.decode(s);
715
+ return i = i.replace("\\", "/"), i.startsWith("Maps/") || (i = `Maps/${i}`), i;
716
+ }, Ts = (a, e, t) => {
717
+ const [s, i, n, r, o] = e, c = t || r < 1;
718
+ return new L({
719
+ name: a,
720
+ color: new V(s, i, n),
721
+ opacity: r,
722
+ transparent: c,
864
723
  alphaTest: 0.01,
865
- side
724
+ side: o
866
725
  });
867
- return material;
868
- };
869
- const isPNG = (textureUrl) => {
870
- return textureUrl?.toLowerCase().endsWith(".png") ?? false;
871
- };
872
- class SBMParser {
726
+ }, Ss = (a) => a?.toLowerCase().endsWith(".png") ?? !1;
727
+ class xs {
873
728
  data;
874
729
  options;
875
730
  textureLoader;
876
- littleEndian = true;
731
+ littleEndian = !0;
877
732
  materials = /* @__PURE__ */ new Map();
878
- constructor(data, options) {
879
- this.data = data;
880
- this.options = options;
881
- this.textureLoader = new TextureLoader(options.manager);
882
- this.textureLoader.setCrossOrigin(options.crossOrigin);
883
- this.textureLoader.setRequestHeader(options.requestHeader);
884
- }
885
- parse(onLoad, onError) {
886
- let buffer = this.data;
887
- const decodeBuffer = decodeSbk(this.data);
888
- if (decodeBuffer) {
889
- buffer = decodeBuffer;
890
- }
891
- const dataView = new DataView(buffer);
892
- let offset = 8;
893
- const version = dataView.getUint8(offset);
894
- offset += 1;
895
- if (version === 1) {
896
- this._parseV2(dataView, offset, onLoad);
897
- } else if (version === 2) {
898
- this._parseV2(dataView, offset, onLoad);
899
- } else if (version === 3) {
900
- this._parseV3(dataView, offset, onLoad);
901
- } else {
902
- onError?.(new Error(`SBMLoader: Unsupported SBM version: ${version}`));
903
- }
904
- }
905
- _parseV2(dataView, offset, onLoad) {
906
- const sbm = new Group();
907
- const materialCount = dataView.getUint16(offset, this.littleEndian);
908
- offset += 2;
909
- const meshCount = dataView.getUint16(offset, this.littleEndian);
910
- offset += 2;
911
- for (let i = 0; i < materialCount; ++i) {
912
- const materialId = dataView.getUint16(offset, this.littleEndian).toString();
913
- offset += 2;
914
- offset += 4;
915
- offset += 4;
916
- offset += 4;
917
- offset += 4;
918
- const d0 = dataView.getFloat32(offset, this.littleEndian);
919
- offset += 4;
920
- const d1 = dataView.getFloat32(offset, this.littleEndian);
921
- offset += 4;
922
- const d2 = dataView.getFloat32(offset, this.littleEndian);
923
- offset += 4;
924
- const d3 = dataView.getFloat32(offset, this.littleEndian);
925
- offset += 4;
926
- offset += 4;
927
- offset += 4;
928
- offset += 4;
929
- offset += 4;
930
- let side = dataView.getUint8(offset);
931
- offset += 1;
932
- if (side === 0) side = FrontSide;
933
- else if (side === 1) side = BackSide;
934
- else if (side === 2) side = DoubleSide;
935
- const textureNameLength = dataView.getUint16(offset, this.littleEndian);
936
- offset += 2;
937
- const textureName = textureNameLength > 0 ? getTextureName(dataView, textureNameLength, offset) : "";
938
- offset += textureNameLength;
939
- if (!this.materials.has(materialId)) {
940
- const materialInfo = [d0, d1, d2, d3, side];
941
- const material = generateSbmMaterial(materialId, materialInfo, isPNG(textureName));
942
- this.materials.set(materialId, material);
943
- if (textureName && this.options.path) {
944
- this.textureLoader.load(LoaderUtils.resolveURL(textureName, this.options.path), (texture) => {
945
- texture.colorSpace = SRGBColorSpace;
946
- texture.wrapS = RepeatWrapping;
947
- texture.wrapT = RepeatWrapping;
948
- texture.flipY = false;
949
- texture.anisotropy = 16;
950
- material.map = texture;
951
- });
952
- }
733
+ constructor(e, t) {
734
+ this.data = e, this.options = t, this.textureLoader = new Me(t.manager), this.textureLoader.setCrossOrigin(t.crossOrigin), this.textureLoader.setRequestHeader(t.requestHeader);
735
+ }
736
+ parse(e, t) {
737
+ let s = this.data;
738
+ const i = ws(this.data);
739
+ i && (s = i);
740
+ const n = new DataView(s);
741
+ let r = 8;
742
+ const o = n.getUint8(r);
743
+ r += 1, o === 1 ? this._parseV2(n, r, e) : o === 2 ? this._parseV2(n, r, e) : o === 3 ? this._parseV3(n, r, e) : t?.(new Error(`SBMLoader: Unsupported SBM version: ${o}`));
744
+ }
745
+ _parseV2(e, t, s) {
746
+ const i = new ee(), n = e.getUint16(t, this.littleEndian);
747
+ t += 2;
748
+ const r = e.getUint16(t, this.littleEndian);
749
+ t += 2;
750
+ for (let o = 0; o < n; ++o) {
751
+ const c = e.getUint16(t, this.littleEndian).toString();
752
+ t += 2, t += 4, t += 4, t += 4, t += 4;
753
+ const h = e.getFloat32(t, this.littleEndian);
754
+ t += 4;
755
+ const l = e.getFloat32(t, this.littleEndian);
756
+ t += 4;
757
+ const d = e.getFloat32(t, this.littleEndian);
758
+ t += 4;
759
+ const g = e.getFloat32(t, this.littleEndian);
760
+ t += 4, t += 4, t += 4, t += 4, t += 4;
761
+ let p = e.getUint8(t);
762
+ t += 1, p === 0 ? p = at : p === 1 ? p = ot : p === 2 && (p = ct);
763
+ const y = e.getUint16(t, this.littleEndian);
764
+ t += 2;
765
+ const v = y > 0 ? Cs(e, y, t) : "";
766
+ if (t += y, !this.materials.has(c)) {
767
+ const b = Ts(c, [h, l, d, g, p], Ss(v));
768
+ this.materials.set(c, b), v && this.options.path && this.textureLoader.load(I.resolveURL(v, this.options.path), (f) => {
769
+ f.colorSpace = Pe, f.wrapS = ce, f.wrapT = ce, f.flipY = !1, f.anisotropy = 16, b.map = f;
770
+ });
953
771
  }
954
772
  }
955
- for (let i = 0; i < meshCount; ++i) {
956
- const meshId = dataView.getUint16(offset, this.littleEndian).toString();
957
- offset += 2;
958
- const materialId = dataView.getUint16(offset, this.littleEndian).toString();
959
- offset += 2;
960
- const vertices = [];
961
- const texcoords = [];
962
- const faces = [];
963
- const faceVertexUvs = [];
964
- const verticesCount = dataView.getUint16(offset, this.littleEndian);
965
- offset += 2;
966
- if (verticesCount > 0) {
967
- for (let j = 0; j < verticesCount; j++) {
968
- const vector3 = new Vector3();
969
- vector3.setX(dataView.getFloat32(offset, this.littleEndian));
970
- offset += 4;
971
- vector3.setY(dataView.getFloat32(offset, this.littleEndian));
972
- offset += 4;
973
- vector3.setZ(dataView.getFloat32(offset, this.littleEndian));
974
- offset += 4;
975
- vertices.push(vector3);
976
- }
977
- }
978
- const normalsCount = dataView.getUint16(offset, this.littleEndian);
979
- offset += 2;
980
- if (normalsCount > 0) {
981
- for (let j = 0; j < normalsCount; j++) {
982
- offset += 4;
983
- offset += 4;
984
- offset += 4;
985
- }
986
- }
987
- const texcoordCount = dataView.getUint16(offset, this.littleEndian);
988
- offset += 2;
989
- if (texcoordCount > 0) {
990
- for (let j = 0; j < texcoordCount; j++) {
991
- const texcoord = new Vector2();
992
- texcoord.setX(dataView.getFloat32(offset, this.littleEndian));
993
- offset += 4;
994
- texcoord.setY(dataView.getFloat32(offset, this.littleEndian));
995
- offset += 4;
996
- texcoords.push(texcoord);
773
+ for (let o = 0; o < r; ++o) {
774
+ const c = e.getUint16(t, this.littleEndian).toString();
775
+ t += 2;
776
+ const h = e.getUint16(t, this.littleEndian).toString();
777
+ t += 2;
778
+ const l = [], d = [], g = [], p = [], y = e.getUint16(t, this.littleEndian);
779
+ if (t += 2, y > 0)
780
+ for (let m = 0; m < y; m++) {
781
+ const w = new oe();
782
+ w.setX(e.getFloat32(t, this.littleEndian)), t += 4, w.setY(e.getFloat32(t, this.littleEndian)), t += 4, w.setZ(e.getFloat32(t, this.littleEndian)), t += 4, l.push(w);
997
783
  }
998
- }
999
- const idxCount = dataView.getUint16(offset, this.littleEndian);
1000
- offset += 2;
1001
- if (idxCount > 0) {
1002
- for (let j = 0; j < idxCount; j++) {
1003
- const a = dataView.getUint16(offset, this.littleEndian);
1004
- offset += 2;
1005
- const b = dataView.getUint16(offset, this.littleEndian);
1006
- offset += 2;
1007
- const c = dataView.getUint16(offset, this.littleEndian);
1008
- offset += 2;
1009
- const face = [a, b, c];
1010
- faces.push(face);
1011
- if (texcoords.length > 0) {
1012
- faceVertexUvs.push([texcoords[face[0]], texcoords[face[1]], texcoords[face[2]]]);
1013
- }
784
+ const v = e.getUint16(t, this.littleEndian);
785
+ if (t += 2, v > 0)
786
+ for (let m = 0; m < v; m++)
787
+ t += 4, t += 4, t += 4;
788
+ const S = e.getUint16(t, this.littleEndian);
789
+ if (t += 2, S > 0)
790
+ for (let m = 0; m < S; m++) {
791
+ const w = new R();
792
+ w.setX(e.getFloat32(t, this.littleEndian)), t += 4, w.setY(e.getFloat32(t, this.littleEndian)), t += 4, d.push(w);
1014
793
  }
1015
- }
1016
- const positions = [], uvs = [];
1017
- for (let i2 = 0; i2 < faces.length; i2++) {
1018
- const face = faces[i2];
1019
- const vertex = vertices[face[0]], vertex2 = vertices[face[1]], vertex3 = vertices[face[2]];
1020
- positions.push(...vertex.toArray(), ...vertex2.toArray(), ...vertex3.toArray());
1021
- let uv2 = new Vector2(), uv22 = new Vector2(), uv3 = new Vector2();
1022
- const vertexUvs = faceVertexUvs[i2];
1023
- if (vertexUvs !== void 0) {
1024
- uv2 = vertexUvs[0];
1025
- uv22 = vertexUvs[1];
1026
- uv3 = vertexUvs[2];
794
+ const b = e.getUint16(t, this.littleEndian);
795
+ if (t += 2, b > 0)
796
+ for (let m = 0; m < b; m++) {
797
+ const w = e.getUint16(t, this.littleEndian);
798
+ t += 2;
799
+ const A = e.getUint16(t, this.littleEndian);
800
+ t += 2;
801
+ const N = e.getUint16(t, this.littleEndian);
802
+ t += 2;
803
+ const E = [w, A, N];
804
+ g.push(E), d.length > 0 && p.push([d[E[0]], d[E[1]], d[E[2]]]);
1027
805
  }
1028
- uvs.push(...uv2.toArray(), ...uv22.toArray(), ...uv3.toArray());
806
+ const f = [], T = [];
807
+ for (let m = 0; m < g.length; m++) {
808
+ const w = g[m], A = l[w[0]], N = l[w[1]], E = l[w[2]];
809
+ f.push(...A.toArray(), ...N.toArray(), ...E.toArray());
810
+ let H = new R(), G = new R(), _ = new R();
811
+ const D = p[m];
812
+ D !== void 0 && (H = D[0], G = D[1], _ = D[2]), T.push(...H.toArray(), ...G.toArray(), ..._.toArray());
1029
813
  }
1030
- const positionArray = new Float32Array(positions), uvArray = new Float32Array(uvs);
1031
- const bufferGeometry = new BufferGeometry();
1032
- if (positionArray.length > 0) {
1033
- bufferGeometry.setAttribute("position", new BufferAttribute(positionArray, 3));
1034
- }
1035
- if (uvArray.length > 0) {
1036
- bufferGeometry.setAttribute("uv", new BufferAttribute(uvArray, 2));
1037
- }
1038
- bufferGeometry.computeVertexNormals();
1039
- if (this.materials.has(materialId)) {
1040
- const sbmChild = new Mesh(bufferGeometry, this.materials.get(materialId));
1041
- sbmChild.name = meshId;
1042
- sbmChild.castShadow = true;
1043
- sbmChild.receiveShadow = true;
1044
- sbm.add(sbmChild);
814
+ const M = new Float32Array(f), P = new Float32Array(T), x = new rt();
815
+ if (M.length > 0 && x.setAttribute("position", new he(M, 3)), P.length > 0 && x.setAttribute("uv", new he(P, 2)), x.computeVertexNormals(), this.materials.has(h)) {
816
+ const m = new z(x, this.materials.get(h));
817
+ m.name = c, m.castShadow = !0, m.receiveShadow = !0, i.add(m);
1045
818
  }
1046
819
  }
1047
- onLoad(sbm);
820
+ s(i);
1048
821
  }
1049
- _parseV3(_dataView, _offset, onLoad) {
1050
- const sbm = new Group();
1051
- console.warn("SBMLoader: SBM version 3 is not supported yet.");
1052
- onLoad(sbm);
822
+ _parseV3(e, t, s) {
823
+ const i = new ee();
824
+ console.warn("SBMLoader: SBM version 3 is not supported yet."), s(i);
1053
825
  }
1054
826
  }
1055
- class SBMLoader extends Loader {
1056
- load(url, onLoad, onProgress, onError) {
1057
- let resourcePath;
1058
- if (this.resourcePath !== "") {
1059
- resourcePath = this.resourcePath;
1060
- } else if (this.path !== "") {
1061
- const relativeUrl = LoaderUtils.extractUrlBase(url);
1062
- resourcePath = LoaderUtils.resolveURL(relativeUrl, this.path);
1063
- } else {
1064
- resourcePath = LoaderUtils.extractUrlBase(url);
1065
- }
1066
- this.manager.itemStart(url);
1067
- const _onError = (e) => {
1068
- if (onError) {
1069
- onError(e);
1070
- } else {
1071
- console.error(e);
1072
- }
1073
- this.manager.itemError(url);
1074
- this.manager.itemEnd(url);
1075
- };
1076
- const loader = new FileLoader(this.manager);
1077
- loader.setPath(this.path);
1078
- loader.setResponseType("arraybuffer");
1079
- loader.setRequestHeader(this.requestHeader);
1080
- loader.setWithCredentials(this.withCredentials);
1081
- loader.load(
1082
- url,
1083
- (data) => {
827
+ class Es extends nt {
828
+ load(e, t, s, i) {
829
+ let n;
830
+ if (this.resourcePath !== "")
831
+ n = this.resourcePath;
832
+ else if (this.path !== "") {
833
+ const c = I.extractUrlBase(e);
834
+ n = I.resolveURL(c, this.path);
835
+ } else
836
+ n = I.extractUrlBase(e);
837
+ this.manager.itemStart(e);
838
+ const r = (c) => {
839
+ i ? i(c) : console.error(c), this.manager.itemError(e), this.manager.itemEnd(e);
840
+ }, o = new Ee(this.manager);
841
+ o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(
842
+ e,
843
+ (c) => {
1084
844
  try {
1085
845
  this.parse(
1086
- data,
1087
- resourcePath,
1088
- (sbm) => {
1089
- onLoad(sbm);
1090
- this.manager.itemEnd(url);
846
+ c,
847
+ n,
848
+ (h) => {
849
+ t(h), this.manager.itemEnd(e);
1091
850
  },
1092
- _onError
851
+ r
1093
852
  );
1094
- } catch (e) {
1095
- _onError(e);
853
+ } catch (h) {
854
+ r(h);
1096
855
  }
1097
856
  },
1098
- onProgress,
1099
- _onError
857
+ s,
858
+ r
1100
859
  );
1101
860
  }
1102
- parse(data, path, onLoad, onError) {
1103
- const formatName = new TextDecoder().decode(data.slice(0, 8));
1104
- if (formatName !== "SBK-----" && formatName !== "SBM-----") {
1105
- onError?.(new Error(`SBMLoader: Invalid SBM format: ${formatName}`));
861
+ parse(e, t, s, i) {
862
+ const n = new TextDecoder().decode(e.slice(0, 8));
863
+ if (n !== "SBK-----" && n !== "SBM-----") {
864
+ i?.(new Error(`SBMLoader: Invalid SBM format: ${n}`));
1106
865
  return;
1107
866
  }
1108
- const parser = new SBMParser(data, {
1109
- path,
867
+ new xs(e, {
868
+ path: t,
1110
869
  crossOrigin: this.crossOrigin,
1111
870
  requestHeader: this.requestHeader,
1112
871
  manager: this.manager
1113
- });
1114
- parser.parse(onLoad, onError);
872
+ }).parse(s, i);
1115
873
  }
1116
- parseAsync(data, path) {
1117
- return new Promise((resolve, reject) => {
874
+ parseAsync(e, t) {
875
+ return new Promise((s, i) => {
1118
876
  this.parse(
1119
- data,
1120
- path,
1121
- (sbm) => {
1122
- resolve(sbm);
877
+ e,
878
+ t,
879
+ (n) => {
880
+ s(n);
1123
881
  },
1124
- (err) => {
1125
- reject(err);
882
+ (n) => {
883
+ i(n);
1126
884
  }
1127
885
  );
1128
886
  });
1129
887
  }
1130
888
  }
1131
- class ModelLoaderManager {
889
+ class B {
1132
890
  static CACHE_NAME = "u-space-model-loader-cache";
1133
- static fileLoader = new FileLoader().setResponseType("arraybuffer");
1134
- static dracoLoader = new DRACOLoader().setDecoderPath(
1135
- `https://cdn.jsdelivr.net/npm/three@0.${REVISION}.0/examples/jsm/libs/draco/`
891
+ static fileLoader = new Ee().setResponseType("arraybuffer");
892
+ static dracoLoader = new Kt().setDecoderPath(
893
+ `https://cdn.jsdelivr.net/npm/three@0.${le}.0/examples/jsm/libs/draco/`
1136
894
  );
1137
- static ktx2Loader = new KTX2Loader().setTranscoderPath(
1138
- `https://cdn.jsdelivr.net/npm/three@0.${REVISION}.0/examples/jsm/libs/basis/`
895
+ static ktx2Loader = new Qt().setTranscoderPath(
896
+ `https://cdn.jsdelivr.net/npm/three@0.${le}.0/examples/jsm/libs/basis/`
1139
897
  );
1140
- static gltfLoader = new GLTFLoader().setDRACOLoader(ModelLoaderManager.dracoLoader).setKTX2Loader(ModelLoaderManager.ktx2Loader).setMeshoptDecoder(MeshoptDecoder);
1141
- static sbmxLoader = new SBMXLoader().setDRACOLoader(ModelLoaderManager.dracoLoader).setKTX2Loader(ModelLoaderManager.ktx2Loader).setMeshoptDecoder(MeshoptDecoder);
1142
- static sbmLoader = new SBMLoader();
1143
- static fbxLoader = new FBXLoader();
1144
- static objLoader = new OBJLoader();
1145
- static stlLoader = new STLLoader();
1146
- static setLoadingManager(loadingManager) {
1147
- this.fileLoader.manager = loadingManager;
1148
- this.dracoLoader.manager = loadingManager;
1149
- this.ktx2Loader.manager = loadingManager;
1150
- this.gltfLoader.manager = loadingManager;
1151
- this.sbmxLoader.manager = loadingManager;
1152
- this.sbmLoader.manager = loadingManager;
1153
- this.fbxLoader.manager = loadingManager;
1154
- this.objLoader.manager = loadingManager;
1155
- this.stlLoader.manager = loadingManager;
898
+ static gltfLoader = new Le().setDRACOLoader(B.dracoLoader).setKTX2Loader(B.ktx2Loader).setMeshoptDecoder(ge);
899
+ static sbmxLoader = new ls().setDRACOLoader(B.dracoLoader).setKTX2Loader(B.ktx2Loader).setMeshoptDecoder(ge);
900
+ static sbmLoader = new Es();
901
+ static fbxLoader = new Ht();
902
+ static objLoader = new $t();
903
+ static stlLoader = new Wt();
904
+ static setLoadingManager(e) {
905
+ 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;
1156
906
  }
1157
907
  /**
1158
908
  * Set the renderer to enable KTX2 support and other renderer-dependent features.
1159
909
  */
1160
- static async setRenderer(renderer) {
1161
- await renderer.init();
1162
- this.ktx2Loader.detectSupport(renderer);
910
+ static async setRenderer(e) {
911
+ await e.init(), this.ktx2Loader.detectSupport(e);
1163
912
  }
1164
913
  /**
1165
914
  * Configure Draco decoder path.
1166
915
  */
1167
- static setDracoPath(path) {
1168
- this.dracoLoader.setDecoderPath(path);
916
+ static setDracoPath(e) {
917
+ this.dracoLoader.setDecoderPath(e);
1169
918
  }
1170
919
  /**
1171
920
  * Configure KTX2 transcoder path.
1172
921
  */
1173
- static setKTX2Path(path) {
1174
- this.ktx2Loader.setTranscoderPath(path);
1175
- }
1176
- static async loadAsync(url, parameters = { persistent: true }) {
1177
- const extension = url.split(".").pop()?.split("?")[0].toLowerCase();
1178
- let buffer;
1179
- if (parameters.persistent && typeof caches !== "undefined") {
1180
- buffer = await this.getPersistentData(url);
1181
- } else {
1182
- buffer = await this.fileLoader.loadAsync(url);
1183
- }
1184
- switch (extension) {
922
+ static setKTX2Path(e) {
923
+ this.ktx2Loader.setTranscoderPath(e);
924
+ }
925
+ static async loadAsync(e, t = { persistent: !0 }) {
926
+ const s = e.split(".").pop()?.split("?")[0].toLowerCase();
927
+ let i;
928
+ switch (t.persistent && typeof caches < "u" ? i = await this.getPersistentData(e) : i = await this.fileLoader.loadAsync(e), s) {
1185
929
  case "gltf":
1186
930
  case "glb":
1187
- const gltf = await this.gltfLoader.parseAsync(buffer, LoaderUtils.extractUrlBase(url));
1188
- return gltf.scene;
931
+ const n = await this.gltfLoader.parseAsync(i, I.extractUrlBase(e));
932
+ return n.scene.animations = n.animations, n.scene;
1189
933
  case "sbmx":
1190
- const sbmx = await this.sbmxLoader.parseAsync(buffer, LoaderUtils.extractUrlBase(url));
1191
- return sbmx.scene;
934
+ const r = await this.sbmxLoader.parseAsync(i, I.extractUrlBase(e));
935
+ return r.scene.animations = r.animations, r.scene;
1192
936
  case "sbm":
1193
- const sbm = await this.sbmLoader.parseAsync(buffer, LoaderUtils.extractUrlBase(url));
1194
- return sbm;
937
+ return await this.sbmLoader.parseAsync(i, I.extractUrlBase(e));
1195
938
  case "fbx":
1196
- const fbx = this.fbxLoader.parse(buffer, LoaderUtils.extractUrlBase(url));
1197
- return fbx;
939
+ return this.fbxLoader.parse(i, I.extractUrlBase(e));
1198
940
  case "obj":
1199
- const text = new TextDecoder().decode(buffer);
1200
- const obj = this.objLoader.parse(text);
1201
- return obj;
941
+ const h = new TextDecoder().decode(i);
942
+ return this.objLoader.parse(h);
1202
943
  case "stl":
1203
- const geometry = this.stlLoader.parse(buffer);
1204
- const mesh = new Mesh(geometry, new MeshStandardNodeMaterial());
1205
- return mesh;
944
+ const d = this.stlLoader.parse(i);
945
+ return new z(d, new L());
1206
946
  default:
1207
- throw new Error(`Unsupported model format: ${extension}`);
947
+ throw new Error(`Unsupported model format: ${s}`);
1208
948
  }
1209
949
  }
1210
- static async getPersistentData(url) {
950
+ static async getPersistentData(e) {
1211
951
  try {
1212
- const cache = await caches.open(this.CACHE_NAME);
1213
- const cachedResponse = await cache.match(url);
1214
- if (cachedResponse) {
1215
- return await cachedResponse.arrayBuffer();
1216
- }
1217
- const buffer = await this.fileLoader.loadAsync(url);
1218
- const response = new Response(buffer);
1219
- await cache.put(url, response);
1220
- return buffer;
1221
- } catch (error) {
1222
- console.warn(`[LoaderManager] Failed to use Cache API for ${url}:`, error);
1223
- return await this.fileLoader.loadAsync(url);
952
+ const t = await caches.open(this.CACHE_NAME), s = await t.match(e);
953
+ if (s)
954
+ return await s.arrayBuffer();
955
+ const i = await this.fileLoader.loadAsync(e), n = new Response(i);
956
+ return await t.put(e, n), i;
957
+ } catch (t) {
958
+ return console.warn(`[LoaderManager] Failed to use Cache API for ${e}:`, t), await this.fileLoader.loadAsync(e);
1224
959
  }
1225
960
  }
1226
961
  }
1227
- class TextureLoaderManager {
1228
- static textureLoader = new TextureLoader();
1229
- static hdrLoader = new HDRLoader();
1230
- static cubeTextureLoader = new CubeTextureLoader();
1231
- static setLoadingManager(loadingManager) {
1232
- this.textureLoader.manager = loadingManager;
1233
- this.hdrLoader.manager = loadingManager;
1234
- this.cubeTextureLoader.manager = loadingManager;
1235
- }
1236
- static async loadAsyncTexture(url) {
1237
- const texture = await this.textureLoader.loadAsync(url);
1238
- return texture;
1239
- }
1240
- static async loadAsyncHDR(url) {
1241
- const dataTexture = await this.hdrLoader.loadAsync(url);
1242
- dataTexture.mapping = EquirectangularReflectionMapping;
1243
- return dataTexture;
1244
- }
1245
- static async loadAsyncCubeTexture(path, urls) {
1246
- this.cubeTextureLoader.setPath(path);
1247
- const cubeTexture = await this.cubeTextureLoader.loadAsync(urls);
1248
- return cubeTexture;
962
+ class ti {
963
+ static textureLoader = new Me();
964
+ static hdrLoader = new Xt();
965
+ static cubeTextureLoader = new ht();
966
+ static setLoadingManager(e) {
967
+ this.textureLoader.manager = e, this.hdrLoader.manager = e, this.cubeTextureLoader.manager = e;
968
+ }
969
+ static async loadAsyncTexture(e) {
970
+ return await this.textureLoader.loadAsync(e);
971
+ }
972
+ static async loadAsyncHDR(e) {
973
+ const t = await this.hdrLoader.loadAsync(e);
974
+ return t.mapping = lt, t;
975
+ }
976
+ static async loadAsyncCubeTexture(e, t) {
977
+ return this.cubeTextureLoader.setPath(e), await this.cubeTextureLoader.loadAsync(t);
1249
978
  }
1250
979
  }
1251
- class BaseMesh extends Mesh {
1252
- isBaseMesh = true;
980
+ class k extends z {
981
+ isBaseMesh = !0;
1253
982
  type = "BaseMesh";
1254
- ignoreInvisibleWhenRaycast = true;
1255
- constructor(...args) {
1256
- super(...args);
983
+ ignoreInvisibleWhenRaycast = !0;
984
+ constructor(...e) {
985
+ super(...e);
1257
986
  }
1258
- raycast(raycaster, intersects) {
1259
- if (this.visible === false && this.ignoreInvisibleWhenRaycast === true) {
1260
- return false;
1261
- }
1262
- return super.raycast(raycaster, intersects);
987
+ raycast(e, t) {
988
+ return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
1263
989
  }
1264
990
  }
1265
- class BaseGroup extends Group {
1266
- isBaseGroup = true;
991
+ class Be extends ee {
992
+ isBaseGroup = !0;
1267
993
  type = "BaseGroup";
1268
- ignoreInvisibleWhenRaycast = true;
1269
- constructor(...args) {
1270
- super(...args);
994
+ ignoreInvisibleWhenRaycast = !0;
995
+ constructor(...e) {
996
+ super(...e);
1271
997
  }
1272
- raycast(raycaster, intersects) {
1273
- if (this.visible === false && this.ignoreInvisibleWhenRaycast === true) {
1274
- return false;
1275
- }
1276
- return super.raycast(raycaster, intersects);
998
+ raycast(e, t) {
999
+ return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
1277
1000
  }
1278
1001
  }
1279
- class BaseSprite extends Sprite {
1280
- isBaseSprite = true;
1002
+ class Ms extends dt {
1003
+ isBaseSprite = !0;
1281
1004
  type = "BaseSprite";
1282
- ignoreInvisibleWhenRaycast = true;
1283
- constructor(...args) {
1284
- super(...args);
1005
+ ignoreInvisibleWhenRaycast = !0;
1006
+ constructor(...e) {
1007
+ super(...e);
1285
1008
  }
1286
- raycast(raycaster, intersects) {
1287
- if (this.visible === false && this.ignoreInvisibleWhenRaycast === true) {
1288
- return false;
1289
- }
1290
- return super.raycast(raycaster, intersects);
1009
+ raycast(e, t) {
1010
+ return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
1291
1011
  }
1292
1012
  }
1293
- class Model extends BaseGroup {
1294
- isModel = true;
1013
+ class Z extends Be {
1014
+ isModel = !0;
1295
1015
  type = "Model";
1296
1016
  static memoryCache = /* @__PURE__ */ new Map();
1017
+ mixer = null;
1018
+ animations = [];
1019
+ actions = /* @__PURE__ */ new Map();
1297
1020
  constructor() {
1298
1021
  super();
1299
1022
  }
1300
- async loadAsync(parameters) {
1301
- const { url, cache = true, persistent = true } = parameters;
1023
+ async loadAsync(e) {
1024
+ const { url: t, cache: s = !0, persistent: i = !0 } = e;
1302
1025
  try {
1303
- let objectPromise;
1304
- if (cache) {
1305
- if (Model.memoryCache.has(url)) {
1306
- objectPromise = Model.memoryCache.get(url);
1307
- } else {
1308
- objectPromise = ModelLoaderManager.loadAsync(url, { persistent });
1309
- Model.memoryCache.set(url, objectPromise);
1310
- }
1311
- } else {
1312
- objectPromise = ModelLoaderManager.loadAsync(url, { persistent });
1313
- }
1314
- const object = await objectPromise;
1315
- const clonedObject = clone(object);
1316
- this.add(clonedObject);
1317
- return clonedObject;
1318
- } catch (error) {
1319
- console.error(`[Model] Failed to load model from ${url}:`, error);
1320
- return null;
1026
+ let n;
1027
+ s ? Z.memoryCache.has(t) ? n = Z.memoryCache.get(t) : (n = B.loadAsync(t, { persistent: i }), Z.memoryCache.set(t, n)) : n = B.loadAsync(t, { persistent: i });
1028
+ const r = await n, o = qt(r);
1029
+ return this.add(o), o.animations && o.animations.length > 0 && (this.animations = o.animations, this.mixer = new pt(o)), o;
1030
+ } catch (n) {
1031
+ return console.error(`[Model] Failed to load model from ${t}:`, n), null;
1032
+ }
1033
+ }
1034
+ playAnimation(e, t = {}) {
1035
+ if (!this.mixer || this.animations.length === 0) return null;
1036
+ const { loop: s = !0, repetitions: i = 1 / 0, timeScale: n = 1, clampWhenFinished: r = !1 } = t;
1037
+ let o;
1038
+ if (e === void 0 ? o = this.animations[0] : typeof e == "number" ? o = this.animations[e] : o = this.animations.find((h) => h.name === e), !o)
1039
+ return console.warn(`[Model] Animation not found: ${e}`), null;
1040
+ let c = this.actions.get(o.name);
1041
+ return c || (c = this.mixer.clipAction(o), this.actions.set(o.name, c)), c.setLoop(s ? ut : mt, i), c.clampWhenFinished = r, c.timeScale = n, c.reset().play(), c;
1042
+ }
1043
+ playAllAnimations(e = {}) {
1044
+ return this.animations.map((t, s) => this.playAnimation(s, e)).filter((t) => t !== null);
1045
+ }
1046
+ stopAnimation(e) {
1047
+ if (!this.mixer) return;
1048
+ if (e === void 0) {
1049
+ this.mixer.stopAllAction();
1050
+ return;
1321
1051
  }
1052
+ let t;
1053
+ typeof e == "number" ? t = this.animations[e]?.name : t = e, t && this.actions.get(t)?.stop();
1054
+ }
1055
+ updateAnimation(e) {
1056
+ this.mixer?.update(e);
1322
1057
  }
1323
1058
  static clearMemoryCache() {
1324
1059
  this.memoryCache.clear();
1325
1060
  }
1326
1061
  static async clearPersistentCache() {
1327
- if (typeof caches !== "undefined") {
1328
- await caches.delete("u-space-loader-cache");
1329
- }
1062
+ typeof caches < "u" && await caches.delete("u-space-loader-cache");
1330
1063
  }
1331
1064
  }
1332
- class SphereMesh extends BaseMesh {
1333
- isSphereMesh = true;
1065
+ class Ps extends k {
1066
+ isSphereMesh = !0;
1334
1067
  type = "SphereMesh";
1335
- constructor({ geometryParameters, materialParameters } = {}) {
1336
- super();
1337
- this.geometry = new SphereGeometry(
1338
- geometryParameters?.radius,
1339
- geometryParameters?.widthSegments,
1340
- geometryParameters?.heightSegments,
1341
- geometryParameters?.phiStart,
1342
- geometryParameters?.phiLength,
1343
- geometryParameters?.thetaStart,
1344
- geometryParameters?.thetaLength
1345
- );
1346
- this.material = new MeshStandardNodeMaterial(materialParameters);
1068
+ constructor({ geometryParameters: e, materialParameters: t } = {}) {
1069
+ super(), this.geometry = new gt(
1070
+ e?.radius,
1071
+ e?.widthSegments,
1072
+ e?.heightSegments,
1073
+ e?.phiStart,
1074
+ e?.phiLength,
1075
+ e?.thetaStart,
1076
+ e?.thetaLength
1077
+ ), this.material = new L(t);
1347
1078
  }
1348
1079
  }
1349
- class TubeMesh extends BaseMesh {
1350
- isTubeMesh = true;
1080
+ class we extends k {
1081
+ isTubeMesh = !0;
1351
1082
  type = "TubeMesh";
1352
- constructor({ geometryParameters, materialParameters } = {}) {
1353
- super();
1354
- this.geometry = new TubeGeometry(
1355
- geometryParameters?.path,
1356
- geometryParameters?.tubularSegments,
1357
- geometryParameters?.radius,
1358
- geometryParameters?.radialSegments,
1359
- geometryParameters?.closed
1360
- );
1361
- this.material = new MeshStandardNodeMaterial(materialParameters);
1083
+ constructor({ geometryParameters: e, materialParameters: t } = {}) {
1084
+ super(), this.geometry = new ft(
1085
+ e?.path,
1086
+ e?.tubularSegments,
1087
+ e?.radius,
1088
+ e?.radialSegments,
1089
+ e?.closed
1090
+ ), this.material = new L(t);
1362
1091
  }
1363
1092
  }
1364
- class Topology extends BaseGroup {
1365
- isTopology = true;
1093
+ class si extends Be {
1094
+ isTopology = !0;
1366
1095
  type = "Topology";
1367
1096
  // Visuals
1368
1097
  parameters = {
@@ -1377,37 +1106,27 @@ class Topology extends BaseGroup {
1377
1106
  adjacencyMap = /* @__PURE__ */ new Map();
1378
1107
  graphGroup = null;
1379
1108
  pathMeshes = [];
1380
- constructor(parameters) {
1381
- super();
1382
- if (parameters) {
1383
- Object.assign(this.parameters, parameters);
1384
- }
1109
+ constructor(e) {
1110
+ super(), e && Object.assign(this.parameters, e);
1385
1111
  }
1386
1112
  /**
1387
1113
  * Add a node to the topology graph.
1388
1114
  * @param id Unique identifier for the node
1389
1115
  * @param position 3D position of the node
1390
1116
  */
1391
- addNode(id, position) {
1392
- if (this.nodes.has(id)) {
1393
- console.warn(`[Topology] Node ${id} already exists. Overwriting.`);
1394
- }
1395
- this.nodes.set(id, position);
1396
- if (!this.adjacencyMap.has(id)) {
1397
- this.adjacencyMap.set(id, /* @__PURE__ */ new Map());
1398
- }
1117
+ addNode(e, t) {
1118
+ this.nodes.has(e) && console.warn(`[Topology] Node ${e} already exists. Overwriting.`), this.nodes.set(e, t), this.adjacencyMap.has(e) || this.adjacencyMap.set(e, /* @__PURE__ */ new Map());
1399
1119
  }
1400
1120
  /**
1401
1121
  * Remove a node from the topology graph.
1402
1122
  * @param id Unique identifier for the node
1403
1123
  */
1404
- removeNode(id) {
1405
- if (!this.nodes.has(id)) {
1406
- console.warn(`[Topology] Node ${id} does not exist.`);
1124
+ removeNode(e) {
1125
+ if (!this.nodes.has(e)) {
1126
+ console.warn(`[Topology] Node ${e} does not exist.`);
1407
1127
  return;
1408
1128
  }
1409
- this.nodes.delete(id);
1410
- this.adjacencyMap.delete(id);
1129
+ this.nodes.delete(e), this.adjacencyMap.delete(e);
1411
1130
  }
1412
1131
  /**
1413
1132
  * Add an edge between two nodes.
@@ -1416,18 +1135,14 @@ class Topology extends BaseGroup {
1416
1135
  * @param weight Cost of the edge. Defaults to Euclidean distance.
1417
1136
  * @param bidirectional If true, adds the reverse edge as well. Default true.
1418
1137
  */
1419
- addEdge(from, to, weight, bidirectional = true) {
1420
- const fromPos = this.nodes.get(from);
1421
- const toPos = this.nodes.get(to);
1422
- if (!fromPos || !toPos) {
1423
- console.error(`[Topology] Cannot add edge. One or both nodes not found: ${from}, ${to}`);
1138
+ addEdge(e, t, s, i = !0) {
1139
+ const n = this.nodes.get(e), r = this.nodes.get(t);
1140
+ if (!n || !r) {
1141
+ console.error(`[Topology] Cannot add edge. One or both nodes not found: ${e}, ${t}`);
1424
1142
  return;
1425
1143
  }
1426
- const dist = weight ?? fromPos.distanceTo(toPos);
1427
- this.getNeighbors(from)?.set(to, dist);
1428
- if (bidirectional) {
1429
- this.getNeighbors(to)?.set(from, dist);
1430
- }
1144
+ const o = s ?? n.distanceTo(r);
1145
+ this.getNeighbors(e)?.set(t, o), i && this.getNeighbors(t)?.set(e, o);
1431
1146
  }
1432
1147
  /**
1433
1148
  * Remove an edge between two nodes.
@@ -1435,80 +1150,51 @@ class Topology extends BaseGroup {
1435
1150
  * @param to Node ID
1436
1151
  * @param bidirectional If true, removes the reverse edge as well. Default true.
1437
1152
  */
1438
- removeEdge(from, to, bidirectional = true) {
1439
- const fromNeighbors = this.getNeighbors(from);
1440
- fromNeighbors?.delete(to);
1441
- if (bidirectional) {
1442
- const toNeighbors = this.getNeighbors(to);
1443
- toNeighbors?.delete(from);
1444
- }
1153
+ removeEdge(e, t, s = !0) {
1154
+ this.getNeighbors(e)?.delete(t), s && this.getNeighbors(t)?.delete(e);
1445
1155
  }
1446
1156
  /**
1447
1157
  * Find the shortest path between start and end nodes using Dijkstra's algorithm.
1448
1158
  */
1449
- getShortestPath(startId, endId) {
1450
- if (!this.nodes.has(startId) || !this.nodes.has(endId)) {
1451
- console.warn(`[Topology] Start or End node not found.`);
1452
- return [];
1453
- }
1454
- const distances = /* @__PURE__ */ new Map();
1455
- const previous = /* @__PURE__ */ new Map();
1456
- const unvisited = /* @__PURE__ */ new Set();
1457
- for (const [id] of this.nodes) {
1458
- distances.set(id, Infinity);
1459
- previous.set(id, null);
1460
- unvisited.add(id);
1461
- }
1462
- distances.set(startId, 0);
1463
- while (unvisited.size > 0) {
1464
- let currentId = null;
1465
- let minDist = Infinity;
1466
- for (const id of unvisited) {
1467
- const d = distances.get(id);
1468
- if (d < minDist) {
1469
- minDist = d;
1470
- currentId = id;
1471
- }
1472
- }
1473
- if (currentId === null || currentId === endId) {
1474
- break;
1159
+ getShortestPath(e, t) {
1160
+ if (!this.nodes.has(e) || !this.nodes.has(t))
1161
+ return console.warn("[Topology] Start or End node not found."), [];
1162
+ const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
1163
+ for (const [c] of this.nodes)
1164
+ s.set(c, 1 / 0), i.set(c, null), n.add(c);
1165
+ for (s.set(e, 0); n.size > 0; ) {
1166
+ let c = null, h = 1 / 0;
1167
+ for (const d of n) {
1168
+ const g = s.get(d);
1169
+ g < h && (h = g, c = d);
1475
1170
  }
1476
- if (minDist === Infinity) {
1171
+ if (c === null || c === t || h === 1 / 0)
1477
1172
  break;
1478
- }
1479
- unvisited.delete(currentId);
1480
- const neighbors = this.adjacencyMap?.get(currentId);
1481
- if (!neighbors) {
1482
- continue;
1483
- }
1484
- for (const [to, weight] of neighbors) {
1485
- if (!unvisited.has(to)) continue;
1486
- const alt = distances.get(currentId) + weight;
1487
- if (alt < distances.get(to)) {
1488
- distances.set(to, alt);
1489
- previous.set(to, currentId);
1173
+ n.delete(c);
1174
+ const l = this.adjacencyMap?.get(c);
1175
+ if (l)
1176
+ for (const [d, g] of l) {
1177
+ if (!n.has(d)) continue;
1178
+ const p = s.get(c) + g;
1179
+ p < s.get(d) && (s.set(d, p), i.set(d, c));
1490
1180
  }
1491
- }
1492
1181
  }
1493
- const path = [];
1494
- let curr = endId;
1495
- if (previous.get(endId) === null && startId !== endId) {
1182
+ const r = [];
1183
+ let o = t;
1184
+ if (i.get(t) === null && e !== t)
1496
1185
  return [];
1186
+ for (; o !== null; ) {
1187
+ const c = this.nodes.get(o);
1188
+ c && r.unshift(c), o = i.get(o) || null;
1497
1189
  }
1498
- while (curr !== null) {
1499
- const pos = this.nodes.get(curr);
1500
- if (pos) path.unshift(pos);
1501
- curr = previous.get(curr) || null;
1502
- }
1503
- return path;
1190
+ return r;
1504
1191
  }
1505
1192
  /**
1506
1193
  * Renders the entire topology graph structure using TubeGeometry and Spheres.
1507
1194
  */
1508
1195
  renderGraph() {
1509
- this.clearGraph();
1510
- this.graphGroup = new Group();
1511
- const _dummySphere = new SphereMesh({
1196
+ this.clearGraph(), this.graphGroup = new ee();
1197
+ const e = new Ps({
1512
1198
  geometryParameters: {
1513
1199
  radius: this.parameters.nodeRadius,
1514
1200
  widthSegments: 16,
@@ -1518,128 +1204,97 @@ class Topology extends BaseGroup {
1518
1204
  color: this.parameters.nodeColor
1519
1205
  }
1520
1206
  });
1521
- this.nodes.forEach((pos, id) => {
1522
- const nodeMesh = _dummySphere.clone();
1523
- nodeMesh.position.copy(pos);
1524
- Object.assign(nodeMesh.userData, { id, type: "node" });
1525
- this.graphGroup.add(nodeMesh);
1207
+ this.nodes.forEach((s, i) => {
1208
+ const n = e.clone();
1209
+ n.position.copy(s), Object.assign(n.userData, { id: i, type: "node" }), this.graphGroup.add(n);
1526
1210
  });
1527
- const processedEdges = /* @__PURE__ */ new Set();
1528
- this.adjacencyMap.forEach((edges, from) => {
1529
- edges.forEach((weight, to) => {
1530
- const key = [from, to].sort().join("-");
1531
- if (processedEdges.has(key)) return;
1532
- processedEdges.add(key);
1533
- const p1 = this.nodes.get(from);
1534
- const p2 = this.nodes.get(to);
1535
- if (p1 && p2) {
1536
- const path = new LineCurve3(p1, p2);
1537
- const tubeMesh = new TubeMesh({
1211
+ const t = /* @__PURE__ */ new Set();
1212
+ this.adjacencyMap.forEach((s, i) => {
1213
+ s.forEach((n, r) => {
1214
+ const o = [i, r].sort().join("-");
1215
+ if (t.has(o)) return;
1216
+ t.add(o);
1217
+ const c = this.nodes.get(i), h = this.nodes.get(r);
1218
+ if (c && h) {
1219
+ const l = new yt(c, h), d = new we({
1538
1220
  geometryParameters: {
1539
- path,
1221
+ path: l,
1540
1222
  tubularSegments: 1,
1541
1223
  radius: this.parameters.edgeRadius,
1542
1224
  radialSegments: 8,
1543
- closed: false
1225
+ closed: !1
1544
1226
  },
1545
1227
  materialParameters: {
1546
1228
  color: this.parameters.edgeColor
1547
1229
  }
1548
1230
  });
1549
- Object.assign(tubeMesh.userData, { from, to, weight, type: "edge" });
1550
- this.graphGroup.add(tubeMesh);
1231
+ Object.assign(d.userData, { from: i, to: r, weight: n, type: "edge" }), this.graphGroup.add(d);
1551
1232
  }
1552
1233
  });
1553
- });
1554
- this.add(this.graphGroup);
1234
+ }), this.add(this.graphGroup);
1555
1235
  }
1556
1236
  clearGraph() {
1557
- if (this.graphGroup) {
1558
- this.remove(this.graphGroup);
1559
- this.graphGroup.traverse((child) => {
1560
- if (child instanceof Mesh) {
1561
- child.geometry.dispose();
1562
- child.material.dispose();
1563
- }
1564
- });
1565
- this.graphGroup = null;
1566
- }
1237
+ this.graphGroup && (this.remove(this.graphGroup), this.graphGroup.traverse((e) => {
1238
+ e instanceof z && (e.geometry.dispose(), e.material.dispose());
1239
+ }), this.graphGroup = null);
1567
1240
  }
1568
1241
  /**
1569
1242
  * Visualizes a path using TubeGeometry (CatmullRomCurve3).
1570
1243
  */
1571
- renderPath(points, color2 = this.parameters.pathColor) {
1572
- if (points.length < 2) return;
1573
- const curve = new CatmullRomCurve3(points, false, "catmullrom", 0);
1574
- const mesh = new TubeMesh({
1244
+ renderPath(e, t = this.parameters.pathColor) {
1245
+ if (e.length < 2) return;
1246
+ const s = new wt(e, !1, "catmullrom", 0), i = new we({
1575
1247
  geometryParameters: {
1576
- path: curve,
1577
- tubularSegments: points.length * 10,
1248
+ path: s,
1249
+ tubularSegments: e.length * 10,
1578
1250
  radius: this.parameters.pathRadius,
1579
- closed: false
1251
+ closed: !1
1580
1252
  },
1581
1253
  materialParameters: {
1582
- color: color2
1254
+ color: t
1583
1255
  }
1584
1256
  });
1585
- this.add(mesh);
1586
- this.pathMeshes.push(mesh);
1587
- return mesh;
1257
+ return this.add(i), this.pathMeshes.push(i), i;
1588
1258
  }
1589
1259
  clearPaths() {
1590
- this.pathMeshes.forEach((m) => {
1591
- this.remove(m);
1592
- m.geometry.dispose();
1593
- m.material.dispose();
1594
- });
1595
- this.pathMeshes = [];
1260
+ this.pathMeshes.forEach((e) => {
1261
+ this.remove(e), e.geometry.dispose(), e.material.dispose();
1262
+ }), this.pathMeshes = [];
1596
1263
  }
1597
1264
  /** Export nodes and edges as a JSON-serializable object. */
1598
1265
  exportData() {
1599
- const nodes = {};
1600
- this.nodes.forEach((pos, id) => {
1601
- nodes[id] = { x: pos.x, y: pos.y, z: pos.z };
1266
+ const e = {};
1267
+ this.nodes.forEach((i, n) => {
1268
+ e[n] = { x: i.x, y: i.y, z: i.z };
1602
1269
  });
1603
- const edges = [];
1604
- const processed = /* @__PURE__ */ new Set();
1605
- this.adjacencyMap.forEach((neighbors, from) => {
1606
- neighbors.forEach((weight, to) => {
1607
- const key = [from, to].sort().join("-");
1608
- if (!processed.has(key)) {
1609
- processed.add(key);
1610
- edges.push({ from, to, weight });
1611
- }
1270
+ const t = [], s = /* @__PURE__ */ new Set();
1271
+ return this.adjacencyMap.forEach((i, n) => {
1272
+ i.forEach((r, o) => {
1273
+ const c = [n, o].sort().join("-");
1274
+ s.has(c) || (s.add(c), t.push({ from: n, to: o, weight: r }));
1612
1275
  });
1613
- });
1614
- return { nodes, edges };
1276
+ }), { nodes: e, edges: t };
1615
1277
  }
1616
1278
  /**
1617
1279
  * Load topology from a previously exported data object.
1618
1280
  * Replaces all current nodes, edges, and path meshes, then re-renders the graph.
1619
1281
  */
1620
- importData(data) {
1621
- this.clearGraph();
1622
- this.clearPaths();
1623
- this.nodes.clear();
1624
- this.adjacencyMap.clear();
1625
- Object.entries(data.nodes).forEach(([id, pos]) => {
1626
- this.addNode(id, new Vector3(pos.x, pos.y, pos.z));
1627
- });
1628
- data.edges.forEach(({ from, to, weight }) => {
1629
- this.addEdge(from, to, weight);
1630
- });
1631
- this.renderGraph();
1282
+ importData(e) {
1283
+ this.clearGraph(), this.clearPaths(), this.nodes.clear(), this.adjacencyMap.clear(), Object.entries(e.nodes).forEach(([t, s]) => {
1284
+ this.addNode(t, new oe(s.x, s.y, s.z));
1285
+ }), e.edges.forEach(({ from: t, to: s, weight: i }) => {
1286
+ this.addEdge(t, s, i);
1287
+ }), this.renderGraph();
1632
1288
  }
1633
1289
  dispose() {
1634
- this.clearGraph();
1635
- this.clearPaths();
1290
+ this.clearGraph(), this.clearPaths();
1636
1291
  }
1637
- getNeighbors(id) {
1638
- return this.adjacencyMap.get(id);
1292
+ getNeighbors(e) {
1293
+ return this.adjacencyMap.get(e);
1639
1294
  }
1640
1295
  }
1641
- class Poi extends BaseSprite {
1642
- isPoi = true;
1296
+ class ii extends Ms {
1297
+ isPoi = !0;
1643
1298
  type = "Poi";
1644
1299
  parameters = {
1645
1300
  img: "",
@@ -1656,419 +1311,332 @@ class Poi extends BaseSprite {
1656
1311
  };
1657
1312
  _canvas = document.createElement("canvas");
1658
1313
  _lastParametersJSON = "";
1659
- constructor(parameters = {}) {
1660
- super(new SpriteNodeMaterial());
1661
- Object.assign(this.parameters, parameters);
1662
- this.updateAsync();
1314
+ constructor(e = {}) {
1315
+ super(new vt()), Object.assign(this.parameters, e), this.updateAsync();
1663
1316
  }
1664
1317
  /**
1665
1318
  * Update the POI with new parameters
1666
1319
  * @param parameters Partial POI parameters
1667
1320
  */
1668
- async updateAsync(parameters = {}) {
1669
- Object.assign(this.parameters, parameters);
1670
- const json = JSON.stringify(this.parameters);
1671
- if (json === this._lastParametersJSON) return;
1672
- this._lastParametersJSON = json;
1673
- const canvas = this._canvas;
1674
- const ctx = canvas.getContext("2d");
1675
- if (!ctx) return;
1676
- ctx.font = `${this.parameters.fontSize}px ${this.parameters.fontFamily}`;
1677
- let image = null;
1678
- if (this.parameters.img) {
1679
- image = await this._loadImage(this.parameters.img);
1680
- }
1681
- const { text, fontSize, color: color2, iconSize, padding, backgroundColor, borderRadius, textPosition, scaleFactor } = this.parameters;
1682
- const textMetrics = ctx.measureText(text);
1683
- const textWidth = text ? textMetrics.width : 0;
1684
- const textHeight = text ? fontSize : 0;
1685
- let contentWidth = 0;
1686
- let contentHeight = 0;
1687
- let iconX = 0, iconY = 0;
1688
- let textX = 0, textY = 0;
1689
- const hasImage = !!image;
1690
- const hasText = !!text;
1691
- if (hasImage && hasText) {
1692
- switch (textPosition) {
1321
+ async updateAsync(e = {}) {
1322
+ Object.assign(this.parameters, e);
1323
+ const t = JSON.stringify(this.parameters);
1324
+ if (t === this._lastParametersJSON) return;
1325
+ this._lastParametersJSON = t;
1326
+ const s = this._canvas, i = s.getContext("2d");
1327
+ if (!i) return;
1328
+ i.font = `${this.parameters.fontSize}px ${this.parameters.fontFamily}`;
1329
+ let n = null;
1330
+ this.parameters.img && (n = await this._loadImage(this.parameters.img));
1331
+ const { text: r, fontSize: o, color: c, iconSize: h, padding: l, backgroundColor: d, borderRadius: g, textPosition: p, scaleFactor: y } = this.parameters, v = i.measureText(r), S = r ? v.width : 0, b = r ? o : 0;
1332
+ let f = 0, T = 0, M = 0, P = 0, x = 0, m = 0;
1333
+ const w = !!n, A = !!r;
1334
+ if (w && A)
1335
+ switch (p) {
1693
1336
  case "top":
1694
- contentWidth = Math.max(iconSize, textWidth);
1695
- contentHeight = iconSize + padding + textHeight;
1696
- textX = (contentWidth - textWidth) / 2;
1697
- textY = textHeight / 2;
1698
- iconX = (contentWidth - iconSize) / 2;
1699
- iconY = textHeight + padding;
1337
+ f = Math.max(h, S), T = h + l + b, x = (f - S) / 2, m = b / 2, M = (f - h) / 2, P = b + l;
1700
1338
  break;
1701
1339
  case "bottom":
1702
- contentWidth = Math.max(iconSize, textWidth);
1703
- contentHeight = iconSize + padding + textHeight;
1704
- iconX = (contentWidth - iconSize) / 2;
1705
- iconY = 0;
1706
- textX = (contentWidth - textWidth) / 2;
1707
- textY = iconSize + padding + textHeight / 2;
1340
+ f = Math.max(h, S), T = h + l + b, M = (f - h) / 2, P = 0, x = (f - S) / 2, m = h + l + b / 2;
1708
1341
  break;
1709
1342
  case "left":
1710
- contentWidth = iconSize + padding + textWidth;
1711
- contentHeight = Math.max(iconSize, textHeight);
1712
- textX = 0;
1713
- textY = contentHeight / 2;
1714
- iconX = textWidth + padding;
1715
- iconY = (contentHeight - iconSize) / 2;
1343
+ f = h + l + S, T = Math.max(h, b), x = 0, m = T / 2, M = S + l, P = (T - h) / 2;
1716
1344
  break;
1717
- case "right":
1718
1345
  default:
1719
- contentWidth = iconSize + padding + textWidth;
1720
- contentHeight = Math.max(iconSize, textHeight);
1721
- iconX = 0;
1722
- iconY = (contentHeight - iconSize) / 2;
1723
- textX = iconSize + padding;
1724
- textY = contentHeight / 2;
1346
+ f = h + l + S, T = Math.max(h, b), M = 0, P = (T - h) / 2, x = h + l, m = T / 2;
1725
1347
  break;
1726
1348
  }
1727
- } else if (hasImage) {
1728
- contentWidth = iconSize;
1729
- contentHeight = iconSize;
1730
- iconX = 0;
1731
- iconY = 0;
1732
- } else if (hasText) {
1733
- contentWidth = textWidth;
1734
- contentHeight = textHeight;
1735
- textX = 0;
1736
- textY = textHeight / 2;
1737
- }
1738
- const canvasWidth = contentWidth + padding * 2;
1739
- const canvasHeight = contentHeight + padding * 2;
1740
- canvas.width = canvasWidth;
1741
- canvas.height = canvasHeight;
1742
- ctx.font = `${fontSize}px ${this.parameters.fontFamily}`;
1743
- if (backgroundColor) {
1744
- ctx.fillStyle = backgroundColor;
1745
- this._drawRoundedRect(ctx, 0, 0, canvasWidth, canvasHeight, borderRadius);
1746
- ctx.fill();
1747
- }
1748
- if (hasImage) {
1749
- ctx.drawImage(image, iconX + padding, iconY + padding, iconSize, iconSize);
1750
- }
1751
- if (hasText) {
1752
- ctx.fillStyle = color2;
1753
- const metrics = ctx.measureText(text);
1754
- const actualTextHeight = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent;
1755
- const baselineOffset = metrics.actualBoundingBoxAscent - actualTextHeight / 2;
1756
- ctx.textBaseline = "alphabetic";
1757
- ctx.fillText(text, textX + padding, textY + padding + baselineOffset);
1758
- }
1759
- const oldTexture = this.material.map;
1760
- const texture = new CanvasTexture(canvas);
1761
- texture.colorSpace = SRGBColorSpace;
1762
- this.material.map = texture;
1763
- oldTexture?.dispose();
1764
- this.scale.set(canvasWidth * scaleFactor, canvasHeight * scaleFactor, 1);
1765
- }
1766
- _loadImage(img) {
1767
- return new Promise((resolve, reject) => {
1768
- if (typeof img === "string") {
1769
- const _img = new Image();
1770
- _img.crossOrigin = "Anonymous";
1771
- _img.onload = () => resolve(_img);
1772
- _img.onerror = () => reject(new Error(`Failed to load image: ${img}`));
1773
- _img.src = img;
1774
- } else {
1775
- resolve(img);
1776
- }
1349
+ else w ? (f = h, T = h, M = 0, P = 0) : A && (f = S, T = b, x = 0, m = b / 2);
1350
+ const N = f + l * 2, E = T + l * 2;
1351
+ if (s.width = N, s.height = E, i.font = `${o}px ${this.parameters.fontFamily}`, d && (i.fillStyle = d, this._drawRoundedRect(i, 0, 0, N, E, g), i.fill()), w && i.drawImage(n, M + l, P + l, h, h), A) {
1352
+ i.fillStyle = c;
1353
+ const _ = i.measureText(r), D = _.actualBoundingBoxAscent + _.actualBoundingBoxDescent, He = _.actualBoundingBoxAscent - D / 2;
1354
+ i.textBaseline = "alphabetic", i.fillText(r, x + l, m + l + He);
1355
+ }
1356
+ const H = this.material.map, G = new bt(s);
1357
+ G.colorSpace = Pe, this.material.map = G, H?.dispose(), this.scale.set(N * y, E * y, 1);
1358
+ }
1359
+ _loadImage(e) {
1360
+ return new Promise((t, s) => {
1361
+ if (typeof e == "string") {
1362
+ const i = new Image();
1363
+ i.crossOrigin = "Anonymous", i.onload = () => t(i), i.onerror = () => s(new Error(`Failed to load image: ${e}`)), i.src = e;
1364
+ } else
1365
+ t(e);
1777
1366
  });
1778
1367
  }
1779
- _drawRoundedRect(ctx, x, y, width, height, radius) {
1780
- ctx.beginPath();
1781
- ctx.moveTo(x + radius, y);
1782
- ctx.lineTo(x + width - radius, y);
1783
- ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
1784
- ctx.lineTo(x + width, y + height - radius);
1785
- ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
1786
- ctx.lineTo(x + radius, y + height);
1787
- ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
1788
- ctx.lineTo(x, y + radius);
1789
- ctx.quadraticCurveTo(x, y, x + radius, y);
1790
- ctx.closePath();
1368
+ _drawRoundedRect(e, t, s, i, n, r) {
1369
+ e.beginPath(), e.moveTo(t + r, s), e.lineTo(t + i - r, s), e.quadraticCurveTo(t + i, s, t + i, s + r), e.lineTo(t + i, s + n - r), e.quadraticCurveTo(t + i, s + n, t + i - r, s + n), e.lineTo(t + r, s + n), e.quadraticCurveTo(t, s + n, t, s + n - r), e.lineTo(t, s + r), e.quadraticCurveTo(t, s, t + r, s), e.closePath();
1791
1370
  }
1792
1371
  dispose() {
1793
- this.material.map?.dispose();
1794
- this.material.dispose();
1372
+ this.material.map?.dispose(), this.material.dispose();
1795
1373
  }
1796
1374
  }
1797
- class ShapeMesh extends BaseMesh {
1798
- isShapeMesh = true;
1375
+ class _e extends k {
1376
+ isShapeMesh = !0;
1799
1377
  type = "ShapeMesh";
1800
- constructor({ geometryParameters, materialParameters } = {}) {
1801
- super();
1802
- this.geometry = new ShapeGeometry(geometryParameters?.shape, geometryParameters?.curveSegments);
1803
- this.material = new MeshStandardNodeMaterial(materialParameters);
1804
- this.geometry.rotateX(-Math.PI / 2);
1378
+ constructor({ geometryParameters: e, materialParameters: t } = {}) {
1379
+ super(), this.geometry = new Ct(e?.shape, e?.curveSegments), this.material = new L(t), this.geometry.rotateX(-Math.PI / 2);
1805
1380
  }
1806
- static createFromPoints(points, parameters = {}) {
1807
- return new ShapeMesh({
1808
- ...parameters,
1381
+ static createFromPoints(e, t = {}) {
1382
+ return new _e({
1383
+ ...t,
1809
1384
  geometryParameters: {
1810
- ...parameters.geometryParameters,
1811
- shape: new Shape(points.map((point) => new Vector2(point.x, -point.z)))
1385
+ ...t.geometryParameters,
1386
+ shape: new Oe(e.map((s) => new R(s.x, -s.z)))
1812
1387
  }
1813
1388
  });
1814
1389
  }
1815
1390
  }
1816
- class ExtrudeMesh extends BaseMesh {
1817
- isExtrudeMesh = true;
1391
+ class De extends k {
1392
+ isExtrudeMesh = !0;
1818
1393
  type = "ExtrudeMesh";
1819
- constructor({ geometryParameters, materialParameters } = {}) {
1820
- super();
1821
- this.geometry = new ExtrudeGeometry(geometryParameters?.shape, geometryParameters?.options);
1822
- this.material = new MeshStandardNodeMaterial(materialParameters);
1823
- this.geometry.rotateX(-Math.PI / 2);
1394
+ constructor({ geometryParameters: e, materialParameters: t } = {}) {
1395
+ super(), this.geometry = new Tt(e?.shape, e?.options), this.material = new L(t), this.geometry.rotateX(-Math.PI / 2);
1824
1396
  }
1825
- static createFromPoints(points, parameters = {}) {
1826
- return new ExtrudeMesh({
1827
- ...parameters,
1397
+ static createFromPoints(e, t = {}) {
1398
+ return new De({
1399
+ ...t,
1828
1400
  geometryParameters: {
1829
- ...parameters.geometryParameters,
1830
- shape: new Shape(points.map((point) => new Vector2(point.x, -point.z)))
1401
+ ...t.geometryParameters,
1402
+ shape: new Oe(e.map((s) => new R(s.x, -s.z)))
1831
1403
  }
1832
1404
  });
1833
1405
  }
1834
1406
  }
1835
- class PlaneMesh extends BaseMesh {
1836
- isPlaneMesh = true;
1407
+ class ni extends k {
1408
+ isPlaneMesh = !0;
1837
1409
  type = "PlaneMesh";
1838
- constructor({ geometryParameters, materialParameters } = {}) {
1839
- super();
1840
- this.geometry = new PlaneGeometry(
1841
- geometryParameters?.width,
1842
- geometryParameters?.height,
1843
- geometryParameters?.widthSegments,
1844
- geometryParameters?.heightSegments
1845
- );
1846
- this.material = new MeshStandardNodeMaterial(materialParameters);
1410
+ constructor({ geometryParameters: e, materialParameters: t } = {}) {
1411
+ super(), this.geometry = new St(
1412
+ e?.width,
1413
+ e?.height,
1414
+ e?.widthSegments,
1415
+ e?.heightSegments
1416
+ ), this.material = new L(t);
1847
1417
  }
1848
1418
  }
1849
- class CircleMesh extends BaseMesh {
1850
- isCircleMesh = true;
1419
+ class ri extends k {
1420
+ isCircleMesh = !0;
1851
1421
  type = "CircleMesh";
1852
- constructor({ geometryParameters, materialParameters } = {}) {
1422
+ constructor({ geometryParameters: e, materialParameters: t } = {}) {
1853
1423
  super(
1854
- new CircleGeometry(
1855
- geometryParameters?.radius,
1856
- geometryParameters?.segments,
1857
- geometryParameters?.thetaStart,
1858
- geometryParameters?.thetaLength
1424
+ new xt(
1425
+ e?.radius,
1426
+ e?.segments,
1427
+ e?.thetaStart,
1428
+ e?.thetaLength
1859
1429
  ),
1860
- new MeshStandardNodeMaterial(materialParameters)
1861
- );
1862
- this.geometry.rotateX(-Math.PI / 2);
1430
+ new L(t)
1431
+ ), this.geometry.rotateX(-Math.PI / 2);
1863
1432
  }
1864
1433
  }
1865
- class ObjectUtils {
1866
- static traverseMeshes(object, callback) {
1867
- object.traverse((child) => {
1868
- if (child instanceof Mesh) {
1869
- callback(child);
1870
- }
1434
+ class W {
1435
+ static traverseMeshes(e, t) {
1436
+ e.traverse((s) => {
1437
+ s instanceof z && t(s);
1871
1438
  });
1872
1439
  }
1873
1440
  }
1874
- class TSLEffects {
1875
- static flow(parameters = {}) {
1876
- const { baseColor = 16777215, flowColor = 65280, speed = 1, scale = 3, intensity = 4 } = parameters;
1877
- const baseColorNode = color(new Color$1(baseColor));
1878
- const flowColorNode = color(new Color$1(flowColor));
1879
- const flow = uv().x.mul(scale).sub(time.mul(speed));
1880
- const pattern = pow(sin(flow).add(1).mul(0.5), intensity);
1881
- return mix(baseColorNode, flowColorNode, pattern);
1882
- }
1883
- static breathe(parameters = {}) {
1884
- const { baseColor = 16777215, breathColor = 65280, speed = 1, intensity = 2 } = parameters;
1885
- const baseColorNode = color(new Color$1(baseColor));
1886
- const breathColorNode = color(new Color$1(breathColor));
1887
- const osc = sin(time.mul(speed)).add(1).mul(0.5);
1888
- const pattern = pow(osc, intensity);
1889
- return mix(baseColorNode, breathColorNode, pattern);
1890
- }
1891
- static fluid(parameters = {}) {
1441
+ class ai {
1442
+ static flow(e = {}) {
1443
+ const { baseColor: t = 16777215, flowColor: s = 65280, speed: i = 1, scale: n = 3, intensity: r = 4 } = e, o = j(new U(t)), c = j(new U(s)), h = pe().x.mul(n).sub(X.mul(i)), l = q(ae(h).add(1).mul(0.5), r);
1444
+ return Y(o, c, l);
1445
+ }
1446
+ static breathe(e = {}) {
1447
+ const { baseColor: t = 16777215, breathColor: s = 65280, speed: i = 1, intensity: n = 2 } = e, r = j(new U(t)), o = j(new U(s)), c = ae(X.mul(i)).add(1).mul(0.5), h = q(c, n);
1448
+ return Y(r, o, h);
1449
+ }
1450
+ static fluid(e = {}) {
1892
1451
  const {
1893
- baseColor = 16777215,
1894
- flowColor = 255,
1895
- speed = 1,
1896
- scale = 1,
1897
- intensity = 1,
1898
- distortion = 0.5
1899
- } = parameters;
1900
- const baseColorNode = color(new Color$1(baseColor));
1901
- const flowColorNode = color(new Color$1(flowColor));
1902
- const uvNode = uv().mul(scale);
1903
- const timeNode = time.mul(speed);
1904
- const noiseNode = mx_noise_float(uvNode.add(timeNode), 1, 0);
1905
- const distortedUV = uvNode.add(noiseNode.mul(distortion));
1906
- const pattern = mx_noise_float(distortedUV, 1, 0).add(1).mul(0.5);
1907
- const fluidPattern = pow(pattern, intensity);
1908
- return mix(baseColorNode, flowColorNode, fluidPattern);
1452
+ baseColor: t = 16777215,
1453
+ flowColor: s = 255,
1454
+ speed: i = 1,
1455
+ scale: n = 1,
1456
+ intensity: r = 1,
1457
+ distortion: o = 0.5
1458
+ } = e, c = j(new U(t)), h = j(new U(s)), l = pe().mul(n), d = X.mul(i), g = ue(l.add(d), 1, 0), p = l.add(g.mul(o)), y = ue(p, 1, 0).add(1).mul(0.5), v = q(y, r);
1459
+ return Y(c, h, v);
1909
1460
  }
1910
1461
  }
1911
- function reinterpretType(_value) {
1462
+ function oi(a) {
1912
1463
  }
1913
- const _highlightKey = "uSpaceHighlight";
1914
- const _highlightEnabledKey = `${_highlightKey}/enabled`;
1915
- const _highlightOpacityKey = `${_highlightKey}/opacity`;
1916
- const _highlightColorKey = `${_highlightKey}/color`;
1917
- const _highlightOverwriteKey = `${_highlightKey}/overwrite`;
1918
- const _highlightColorNode = Fn(() => {
1919
- const enabled = userData(_highlightEnabledKey, "uint");
1920
- const colorUint = userData(_highlightColorKey, "uint");
1921
- const overwrite = userData(_highlightOverwriteKey, "uint");
1922
- const hlColorRaw = uintToColor(colorUint);
1923
- const tintedColor = materialColor.mul(hlColorRaw);
1924
- const finalHlColor = select(overwrite.greaterThan(0), hlColorRaw, tintedColor);
1925
- const hlColor = select(enabled.greaterThan(0), finalHlColor, materialColor);
1926
- return hlColor;
1927
- })();
1928
- const _highlightOpacityNode = Fn(() => {
1929
- const enabled = userData(_highlightEnabledKey, "uint");
1930
- const opacity = userData(_highlightOpacityKey, "float");
1931
- const hlOpacity = select(enabled.greaterThan(0), opacity, materialOpacity);
1932
- return hlOpacity;
1464
+ const ie = "uSpaceHighlight", F = `${ie}/enabled`, je = `${ie}/opacity`, Ue = `${ie}/color`, ke = `${ie}/overwrite`, ne = "uSpaceBreathe", te = `${ne}/enabled`, Ge = `${ne}/color`, Fe = `${ne}/speed`, ze = `${ne}/intensity`, se = /* @__PURE__ */ new WeakMap(), Os = Re(() => {
1465
+ const a = O(F, "uint"), e = O(Ue, "uint"), t = O(ke, "uint"), s = Ce(e), i = me.mul(s), n = J(t.greaterThan(0), s, i), r = J(a.greaterThan(0), n, me), o = O(te, "uint"), c = O(Ge, "uint"), h = O(Fe, "float"), l = O(ze, "float"), d = Ce(c), g = ae(X.mul(h)).add(1).mul(0.5), p = q(g, l), y = Y(r, d, p);
1466
+ return J(o.greaterThan(0), y, r);
1467
+ })(), Rs = Re(() => {
1468
+ const a = O(F, "uint"), e = O(je, "float");
1469
+ return J(a.greaterThan(0), e, Lt);
1933
1470
  })();
1934
- class MaterialEffects {
1935
- static highlight(object, options = {}) {
1936
- const highlightOptions = Object.assign(
1471
+ function ve(a) {
1472
+ const e = a.material;
1473
+ if (!e || Array.isArray(e)) return;
1474
+ let t = se.get(e);
1475
+ t || (t = {
1476
+ colorNode: e.colorNode,
1477
+ opacityNode: e.opacityNode,
1478
+ transparent: e.transparent,
1479
+ activeMeshes: /* @__PURE__ */ new Set()
1480
+ }, se.set(e, t)), t.activeMeshes.add(a), e.transparent = !0, e.colorNode = Os, e.opacityNode = Rs, e.needsUpdate = !0;
1481
+ }
1482
+ function be(a) {
1483
+ const e = a.userData[F], t = a.userData[te];
1484
+ if (e || t) return;
1485
+ const s = a.material;
1486
+ if (!s || Array.isArray(s)) return;
1487
+ const i = se.get(s);
1488
+ i && (i.activeMeshes.delete(a), !(i.activeMeshes.size > 0) && (s.colorNode = i.colorNode, s.opacityNode = i.opacityNode, s.transparent = i.transparent, s.needsUpdate = !0, se.delete(s)));
1489
+ }
1490
+ class ci {
1491
+ static highlightColor(e, t = {}) {
1492
+ const s = Array.isArray(e) ? e : [e], i = Object.assign(
1937
1493
  {
1938
- enabled: true,
1939
1494
  opacity: 0.5,
1940
1495
  color: 16711680,
1941
- overwrite: false
1496
+ overwrite: !1
1942
1497
  },
1943
- options
1498
+ t
1944
1499
  );
1945
- highlightOptions.color = new Color(highlightOptions.color).getHex();
1946
- ObjectUtils.traverseMeshes(object, (mesh) => {
1947
- mesh.userData[_highlightEnabledKey] = highlightOptions.enabled ? 1 : 0;
1948
- mesh.userData[_highlightOpacityKey] = highlightOptions.opacity;
1949
- mesh.userData[_highlightColorKey] = highlightOptions.color;
1950
- mesh.userData[_highlightOverwriteKey] = highlightOptions.overwrite ? 1 : 0;
1951
- const material = mesh.material;
1952
- if (material && !Array.isArray(material)) {
1953
- material.transparent = true;
1954
- material.colorNode = _highlightColorNode;
1955
- material.opacityNode = _highlightOpacityNode;
1956
- material.needsUpdate = true;
1957
- }
1958
- });
1500
+ i.color = new V(i.color).getHex();
1501
+ for (const n of s)
1502
+ W.traverseMeshes(n, (r) => {
1503
+ r.userData[F] = 1, r.userData[je] = i.opacity, r.userData[Ue] = i.color, r.userData[ke] = i.overwrite ? 1 : 0, ve(r);
1504
+ });
1505
+ }
1506
+ static removeHighlightColor(e) {
1507
+ const t = Array.isArray(e) ? e : [e];
1508
+ for (const s of t)
1509
+ W.traverseMeshes(s, (i) => {
1510
+ i.userData[F] = 0, be(i);
1511
+ });
1512
+ }
1513
+ static breatheColor(e, t = {}) {
1514
+ const s = Array.isArray(e) ? e : [e], i = Object.assign(
1515
+ {
1516
+ color: 65280,
1517
+ speed: 1,
1518
+ intensity: 2
1519
+ },
1520
+ t
1521
+ );
1522
+ i.color = new V(i.color).getHex();
1523
+ for (const n of s)
1524
+ W.traverseMeshes(n, (r) => {
1525
+ r.userData[te] = 1, r.userData[Ge] = i.color, r.userData[Fe] = i.speed, r.userData[ze] = i.intensity, ve(r);
1526
+ });
1527
+ }
1528
+ static removeBreatheColor(e) {
1529
+ const t = Array.isArray(e) ? e : [e];
1530
+ for (const s of t)
1531
+ W.traverseMeshes(s, (i) => {
1532
+ i.userData[te] = 0, be(i);
1533
+ });
1959
1534
  }
1960
1535
  }
1961
- const uintToColor = (colorUint) => {
1962
- const r = colorUint.shiftRight(16).bitAnd(255).toFloat().div(255);
1963
- const g = colorUint.shiftRight(8).bitAnd(255).toFloat().div(255);
1964
- const b = colorUint.bitAnd(255).toFloat().div(255);
1965
- return vec3(r, g, b);
1536
+ const Ce = (a) => {
1537
+ const e = a.shiftRight(16).bitAnd(255).toFloat().div(255), t = a.shiftRight(8).bitAnd(255).toFloat().div(255), s = a.bitAnd(255).toFloat().div(255);
1538
+ return At(e, t, s);
1966
1539
  };
1967
- class Tween extends Tween$1 {
1540
+ class Is extends Yt {
1968
1541
  viewer;
1969
- constructor(viewer, source) {
1970
- super(source);
1971
- this.viewer = viewer;
1972
- }
1973
- _update = ({ time: time2 }) => {
1974
- const needsRender = this.update(time2);
1975
- if (needsRender) {
1976
- this.viewer.render();
1977
- }
1542
+ constructor(e, t) {
1543
+ super(t), this.viewer = e;
1544
+ }
1545
+ _update = ({ time: e }) => {
1546
+ this.update(e) && this.viewer.render();
1978
1547
  };
1979
- easingByMode(mode) {
1980
- const tweenModeFunc = animationModeEnum[mode];
1981
- return super.easing(tweenModeFunc);
1548
+ easingByMode(e) {
1549
+ const t = Ls[e];
1550
+ return super.easing(t);
1982
1551
  }
1983
- start(time2, overrideStartingValues) {
1984
- this.viewer.addEventListener("afterControlsUpdate", this._update);
1985
- return super.start(time2, overrideStartingValues);
1552
+ start(e, t) {
1553
+ return this.viewer.addEventListener("afterControlsUpdate", this._update), super.start(e, t);
1986
1554
  }
1987
1555
  stop() {
1988
- this.viewer.removeEventListener("afterControlsUpdate", this._update);
1989
- return super.stop();
1556
+ return this.viewer.removeEventListener("afterControlsUpdate", this._update), super.stop();
1990
1557
  }
1991
1558
  }
1992
- function tweenAnimation(viewer, source, target, options = {}, onUpdate, onStart) {
1993
- return new Promise((resolve, reject) => {
1994
- const { duration = 1e3, delay = 0, repeat = false, mode = "Linear.None", yoyo = false } = options;
1995
- const tween = new Tween(viewer, source).to(target, duration).easingByMode(mode).delay(delay).onUpdate((e) => {
1996
- onUpdate?.(e, tween);
1559
+ function hi(a, e, t, s = {}, i, n) {
1560
+ return new Promise((r, o) => {
1561
+ const { duration: c = 1e3, delay: h = 0, repeat: l = !1, mode: d = "Linear.None", yoyo: g = !1 } = s, p = new Is(a, e).to(t, c).easingByMode(d).delay(h).onUpdate((y) => {
1562
+ i?.(y, p);
1997
1563
  }).onComplete(() => {
1998
- resolve();
1564
+ r();
1999
1565
  }).onStop(() => {
2000
- reject("animation stop");
1566
+ o("animation stop");
2001
1567
  }).onStart(() => {
2002
- onStart?.(tween);
1568
+ n?.(p);
2003
1569
  });
2004
- if (typeof repeat === "number") tween.repeat(repeat);
2005
- else if (typeof repeat === "boolean" && repeat) tween.repeat(Infinity);
2006
- if (yoyo) tween.repeatDelay(20);
2007
- tween.yoyo(yoyo);
2008
- tween.start();
1570
+ typeof l == "number" ? p.repeat(l) : typeof l == "boolean" && l && p.repeat(1 / 0), g && p.repeatDelay(20), p.yoyo(g), p.start();
2009
1571
  });
2010
1572
  }
2011
- const animationModeEnum = {
2012
- "Linear.None": Easing.Linear.None,
2013
- "Quadratic.In": Easing.Quadratic.In,
2014
- "Quadratic.Out": Easing.Quadratic.Out,
2015
- "Quadratic.InOut": Easing.Quadratic.InOut,
2016
- "Cubic.In": Easing.Cubic.In,
2017
- "Cubic.Out": Easing.Cubic.Out,
2018
- "Cubic.InOut": Easing.Cubic.InOut,
2019
- "Quartic.In": Easing.Quartic.In,
2020
- "Quartic.Out": Easing.Quartic.Out,
2021
- "Quartic.InOut": Easing.Quartic.InOut,
2022
- "Quintic.In": Easing.Quintic.In,
2023
- "Quintic.Out": Easing.Quintic.Out,
2024
- "Quintic.InOut": Easing.Quintic.InOut,
2025
- "Sinusoidal.In": Easing.Sinusoidal.In,
2026
- "Sinusoidal.Out": Easing.Sinusoidal.Out,
2027
- "Sinusoidal.InOut": Easing.Sinusoidal.InOut,
2028
- "Exponential.In": Easing.Exponential.In,
2029
- "Exponential.Out": Easing.Exponential.Out,
2030
- "Exponential.InOut": Easing.Exponential.InOut,
2031
- "Circular.In": Easing.Circular.In,
2032
- "Circular.Out": Easing.Circular.Out,
2033
- "Circular.InOut": Easing.Circular.InOut,
2034
- "Elastic.In": Easing.Elastic.In,
2035
- "Elastic.Out": Easing.Elastic.Out,
2036
- "Elastic.InOut": Easing.Elastic.InOut,
2037
- "Back.In": Easing.Back.In,
2038
- "Back.Out": Easing.Back.Out,
2039
- "Back.InOut": Easing.Back.InOut,
2040
- "Bounce.In": Easing.Bounce.In,
2041
- "Bounce.Out": Easing.Bounce.Out,
2042
- "Bounce.InOut": Easing.Bounce.InOut
2043
- };
1573
+ const Ls = {
1574
+ "Linear.None": u.Linear.None,
1575
+ "Quadratic.In": u.Quadratic.In,
1576
+ "Quadratic.Out": u.Quadratic.Out,
1577
+ "Quadratic.InOut": u.Quadratic.InOut,
1578
+ "Cubic.In": u.Cubic.In,
1579
+ "Cubic.Out": u.Cubic.Out,
1580
+ "Cubic.InOut": u.Cubic.InOut,
1581
+ "Quartic.In": u.Quartic.In,
1582
+ "Quartic.Out": u.Quartic.Out,
1583
+ "Quartic.InOut": u.Quartic.InOut,
1584
+ "Quintic.In": u.Quintic.In,
1585
+ "Quintic.Out": u.Quintic.Out,
1586
+ "Quintic.InOut": u.Quintic.InOut,
1587
+ "Sinusoidal.In": u.Sinusoidal.In,
1588
+ "Sinusoidal.Out": u.Sinusoidal.Out,
1589
+ "Sinusoidal.InOut": u.Sinusoidal.InOut,
1590
+ "Exponential.In": u.Exponential.In,
1591
+ "Exponential.Out": u.Exponential.Out,
1592
+ "Exponential.InOut": u.Exponential.InOut,
1593
+ "Circular.In": u.Circular.In,
1594
+ "Circular.Out": u.Circular.Out,
1595
+ "Circular.InOut": u.Circular.InOut,
1596
+ "Elastic.In": u.Elastic.In,
1597
+ "Elastic.Out": u.Elastic.Out,
1598
+ "Elastic.InOut": u.Elastic.InOut,
1599
+ "Back.In": u.Back.In,
1600
+ "Back.Out": u.Back.Out,
1601
+ "Back.InOut": u.Back.InOut,
1602
+ "Bounce.In": u.Bounce.In,
1603
+ "Bounce.Out": u.Bounce.Out,
1604
+ "Bounce.InOut": u.Bounce.InOut
1605
+ }, As = "0.0.5";
1606
+ window.__USPACE__ = { version: As };
2044
1607
  export {
2045
- BaseGroup,
2046
- BaseMesh,
2047
- BaseSprite,
2048
- CameraControls,
2049
- CircleMesh,
2050
- ExtrudeMesh,
2051
- InteractionEvent,
2052
- InteractionManager,
2053
- MaterialEffects,
2054
- Model,
2055
- ModelLoaderManager,
2056
- ObjectManager,
2057
- ObjectUtils,
2058
- PlaneMesh,
2059
- Poi,
2060
- RoomEnvironment,
2061
- SBMLoader,
2062
- SBMXLoader,
2063
- ShapeMesh,
2064
- SphereMesh,
2065
- TSLEffects,
2066
- TextureLoaderManager,
2067
- Topology,
2068
- TubeMesh,
2069
- Tween,
2070
- Viewer,
2071
- reinterpretType,
2072
- tweenAnimation
1608
+ Be as BaseGroup,
1609
+ k as BaseMesh,
1610
+ Ms as BaseSprite,
1611
+ pi as CSS2DObject,
1612
+ mi as CSS3DObject,
1613
+ gi as CSS3DSprite,
1614
+ cs as CSSRenderer,
1615
+ ss as CameraControls,
1616
+ ri as CircleMesh,
1617
+ De as ExtrudeMesh,
1618
+ Jt as InteractionEvent,
1619
+ Zt as InteractionManager,
1620
+ ci as MaterialEffects,
1621
+ Z as Model,
1622
+ B as ModelLoaderManager,
1623
+ Vt as ObjectManager,
1624
+ W as ObjectUtils,
1625
+ ni as PlaneMesh,
1626
+ ii as Poi,
1627
+ es as RenderPipeline,
1628
+ ns as RoomEnvironment,
1629
+ Es as SBMLoader,
1630
+ ls as SBMXLoader,
1631
+ _e as ShapeMesh,
1632
+ Ps as SphereMesh,
1633
+ ai as TSLEffects,
1634
+ ti as TextureLoaderManager,
1635
+ si as Topology,
1636
+ we as TubeMesh,
1637
+ Is as Tween,
1638
+ ei as Viewer,
1639
+ oi as reinterpretType,
1640
+ hi as tweenAnimation,
1641
+ As as version
2073
1642
  };
2074
- //# sourceMappingURL=index.js.map