u-space 0.0.5 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +16 -1
- package/dist/index.js +1657 -412
- package/dist/plugins/u-manager/flows/ComponentFlowParser.d.ts +8 -0
- package/dist/plugins/u-manager/flows/FlowParser.d.ts +48 -0
- package/dist/plugins/u-manager/flows/edges/index.d.ts +9 -0
- package/dist/plugins/u-manager/flows/index.d.ts +4 -0
- package/dist/plugins/u-manager/flows/nodes/ColorNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/ConditionNode.d.ts +9 -0
- package/dist/plugins/u-manager/flows/nodes/DataExtractionNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/DataFilterNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/DelayNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/EmissiveNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/FlyToNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/HideNode.d.ts +10 -0
- package/dist/plugins/u-manager/flows/nodes/HighlightNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/MeshNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/MeshesNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/ModelNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/ModelsNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/Node.d.ts +52 -0
- package/dist/plugins/u-manager/flows/nodes/NumberNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/OpacityNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/POINode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/POISNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/PathNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/PathsNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/RotateNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/ScaleNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/ShowNode.d.ts +10 -0
- package/dist/plugins/u-manager/flows/nodes/SpaceNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/SpacesNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/StartNode.d.ts +7 -0
- package/dist/plugins/u-manager/flows/nodes/TranslateNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/UnEmissiveNode.d.ts +10 -0
- package/dist/plugins/u-manager/flows/nodes/UnHighlightNode.d.ts +10 -0
- package/dist/plugins/u-manager/flows/nodes/UnOpacityNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/UserDataNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/clip-animation/ClipAnimationNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/clip-animation/UnClipAnimationNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/clip-animation/index.d.ts +2 -0
- package/dist/plugins/u-manager/flows/nodes/component-tween-animation/ComponentTweenAnimationNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/component-tween-animation/UnComponentTweenAnimationNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/component-tween-animation/index.d.ts +2 -0
- package/dist/plugins/u-manager/flows/nodes/component-tween-animation/utils.d.ts +5 -0
- package/dist/plugins/u-manager/flows/nodes/index.d.ts +34 -0
- package/dist/plugins/u-manager/flows/nodes/tween-animation/TweenAnimationNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/tween-animation/UnTweenAnimationNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/tween-animation/index.d.ts +2 -0
- package/dist/plugins/u-manager/flows/nodes/tween-animation/utils.d.ts +5 -0
- package/dist/plugins/u-manager/flows/types.d.ts +81 -0
- package/dist/plugins/u-manager/flows/utils.d.ts +14 -0
- package/dist/plugins/u-manager/index.cjs +59 -59
- package/dist/plugins/u-manager/index.d.ts +1 -0
- package/dist/plugins/u-manager/index.js +9692 -8601
- package/dist/src/effects/MaterialEffects.d.ts +33 -3
- package/dist/src/index.d.ts +9 -0
- package/dist/src/interactions/InteractionManager.d.ts +31 -0
- package/dist/src/interactions/Selection.d.ts +77 -0
- package/dist/src/interactions/index.d.ts +1 -0
- package/dist/src/managers/LightManager.d.ts +101 -0
- package/dist/src/managers/ObjectManager.d.ts +33 -1
- package/dist/src/managers/SceneManager.d.ts +57 -0
- package/dist/src/managers/index.d.ts +2 -0
- package/dist/src/objects/Model.d.ts +13 -1
- package/dist/src/tools/AnnotationManager.d.ts +104 -0
- package/dist/src/tools/ClippingTool.d.ts +96 -0
- package/dist/src/tools/MeasureTool.d.ts +80 -0
- package/dist/src/tools/index.d.ts +3 -0
- package/dist/src/viewers/CSSRenderer.d.ts +19 -0
- package/dist/src/viewers/CameraControls.d.ts +30 -0
- package/dist/src/viewers/RenderPipeline.d.ts +30 -2
- package/dist/src/viewers/Viewer.d.ts +54 -1
- package/dist/src/viewers/index.d.ts +2 -0
- package/docs/api-camera-controls.md +146 -0
- package/docs/api-css-renderer.md +43 -0
- package/docs/api-effects.md +95 -15
- package/docs/api-interactions.md +107 -7
- package/docs/api-managers.md +181 -0
- package/docs/api-objects.md +46 -13
- package/docs/api-plugin-atmosphere.md +10 -0
- package/docs/api-plugin-curve-movement.md +38 -0
- package/docs/api-plugin-keyboard-controls.md +40 -0
- package/docs/api-plugin-minimap.md +36 -0
- package/docs/api-plugin-object-controls.md +67 -0
- package/docs/api-plugin-tiles.md +26 -0
- package/docs/api-plugin-topology-drawer.md +74 -0
- package/docs/api-plugin-tracking-controls.md +23 -0
- package/docs/api-plugin-u-manager.md +123 -0
- package/docs/api-render-pipeline.md +114 -0
- package/docs/api-tools.md +254 -0
- package/docs/api-viewer.md +97 -0
- package/docs/changelog.md +105 -0
- package/docs/examples-guide.md +130 -0
- package/docs/getting-started.md +13 -1
- package/docs/index.md +20 -12
- package/package.json +1 -1
- package/docs/api-plugins.md +0 -449
package/dist/index.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
import { Raycaster as
|
|
2
|
-
import { pass as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
1
|
+
import { Raycaster as Be, Vector2 as S, EventDispatcher as Le, Box2 as tt, Matrix4 as Ie, Vector3 as w, Box3 as q, Scene as Re, Color as B, AmbientLight as st, DirectionalLight as ue, PointLight as me, SpotLight as ge, HemisphereLight as fe, DirectionalLightHelper as nt, PointLightHelper as it, SpotLightHelper as rt, HemisphereLightHelper as ot, RenderPipeline as at, PerspectiveCamera as J, Sphere as ze, Spherical as C, Quaternion as ct, Vector4 as ht, MathUtils as lt, PMREMGenerator as dt, OrthographicCamera as V, TimestampQuery as pt, Cache as ut, Timer as mt, WebGPURenderer as gt, PCFShadowMap as ft, AgXToneMapping as yt, Fog as wt, FogExp2 as bt, MeshStandardNodeMaterial as R, Loader as vt, LoaderUtils as L, FileLoader as Ne, TextureLoader as je, Group as I, SRGBColorSpace as De, RepeatWrapping as ye, BufferGeometry as K, BufferAttribute as we, Mesh as G, FrontSide as xt, BackSide as St, DoubleSide as Ct, REVISION as be, CubeTextureLoader as _t, EquirectangularReflectionMapping as Mt, Sprite as Tt, AnimationMixer as Pt, LoopRepeat as Et, LoopOnce as Ot, SphereGeometry as At, TubeGeometry as Bt, LineCurve3 as Lt, CatmullRomCurve3 as It, SpriteNodeMaterial as Rt, CanvasTexture as zt, ShapeGeometry as Nt, Shape as ke, ExtrudeGeometry as jt, PlaneGeometry as Dt, CircleGeometry as kt, ClippingGroup as Ht, Plane as Ut, PlaneHelper as Ft, LineBasicMaterial as Z, Line as ee } from "three/webgpu";
|
|
2
|
+
import { pass as de, mrt as Gt, output as $t, add as ve, blendColor as Wt, emissive as Kt, normalView as Qt, velocity as qt, color as H, uv as xe, time as te, pow as se, sin as pe, mix as ne, mx_noise_float as Se, Fn as He, userData as A, materialColor as Ce, select as ie, materialOpacity as Xt, vec3 as Yt } from "three/tsl";
|
|
3
|
+
import { bloom as Jt } from "three/addons/tsl/display/BloomNode.js";
|
|
4
|
+
import { ssgi as Vt } from "three/addons/tsl/display/SSGINode.js";
|
|
5
|
+
import { traa as Zt } from "three/addons/tsl/display/TRAANode.js";
|
|
6
|
+
import Ue from "camera-controls";
|
|
7
|
+
import { RoomEnvironment as es } from "three/addons/environments/RoomEnvironment.js";
|
|
8
|
+
import { ViewHelper as ts } from "three/addons/helpers/ViewHelper.js";
|
|
9
|
+
import { CSS2DRenderer as ss, CSS2DObject as ns } from "three/addons/renderers/CSS2DRenderer.js";
|
|
10
|
+
import { CSS2DObject as Nn } from "three/addons/renderers/CSS2DRenderer.js";
|
|
11
|
+
import { CSS3DRenderer as is, CSS3DSprite as rs, CSS3DObject as os } from "three/addons/renderers/CSS3DRenderer.js";
|
|
12
|
+
import { CSS3DObject as Dn, CSS3DSprite as kn } from "three/addons/renderers/CSS3DRenderer.js";
|
|
13
|
+
import { GLTFLoader as Fe } from "three/addons/loaders/GLTFLoader.js";
|
|
14
|
+
import { FBXLoader as as } from "three/addons/loaders/FBXLoader.js";
|
|
15
|
+
import { OBJLoader as cs } from "three/addons/loaders/OBJLoader.js";
|
|
16
|
+
import { STLLoader as hs } from "three/addons/loaders/STLLoader.js";
|
|
17
|
+
import { DRACOLoader as ls } from "three/addons/loaders/DRACOLoader.js";
|
|
18
|
+
import { KTX2Loader as ds } from "three/addons/loaders/KTX2Loader.js";
|
|
19
|
+
import { MeshoptDecoder as _e } from "three/addons/libs/meshopt_decoder.module.js";
|
|
20
|
+
import { HDRLoader as ps } from "three/addons/loaders/HDRLoader.js";
|
|
21
|
+
import { clone as us } from "three/addons/utils/SkeletonUtils.js";
|
|
22
|
+
import { Color as U } from "three";
|
|
23
|
+
import { Easing as m, Tween as ms } from "three/addons/libs/tween.module.js";
|
|
24
|
+
class gs {
|
|
18
25
|
/** The type of event (e.g., 'click', 'pointerdown'). */
|
|
19
26
|
type;
|
|
20
27
|
/** The original 3D object that triggered the event. */
|
|
@@ -42,11 +49,11 @@ class Ot {
|
|
|
42
49
|
return this._propagationStopped;
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
|
-
class
|
|
52
|
+
class fs {
|
|
46
53
|
domElement;
|
|
47
54
|
scene;
|
|
48
55
|
camera;
|
|
49
|
-
raycaster = new
|
|
56
|
+
raycaster = new Be();
|
|
50
57
|
pointer = new S();
|
|
51
58
|
hoveredObject = null;
|
|
52
59
|
pointerDownTime = 0;
|
|
@@ -63,6 +70,14 @@ class Pt {
|
|
|
63
70
|
* Disabled by default for performance optimization.
|
|
64
71
|
*/
|
|
65
72
|
pointerMoveEventsEnabled = !1;
|
|
73
|
+
/**
|
|
74
|
+
* Whether interaction is enabled globally.
|
|
75
|
+
*/
|
|
76
|
+
_enabled = !0;
|
|
77
|
+
/**
|
|
78
|
+
* Objects excluded from raycasting (via addIgnore or setInteractable(false)).
|
|
79
|
+
*/
|
|
80
|
+
_excludeSet = /* @__PURE__ */ new Set();
|
|
66
81
|
constructor(e, t, s) {
|
|
67
82
|
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();
|
|
68
83
|
}
|
|
@@ -72,6 +87,39 @@ class Pt {
|
|
|
72
87
|
setCamera(e) {
|
|
73
88
|
this.camera = e;
|
|
74
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Enable all interactions.
|
|
92
|
+
*/
|
|
93
|
+
enable() {
|
|
94
|
+
this._enabled = !0;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Disable all interactions.
|
|
98
|
+
*/
|
|
99
|
+
disable() {
|
|
100
|
+
this._enabled = !1;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Set whether a specific object is interactable.
|
|
104
|
+
* When set to false, the object and its children are excluded from raycasting.
|
|
105
|
+
*/
|
|
106
|
+
setInteractable(e, t) {
|
|
107
|
+
t ? this._excludeSet.delete(e) : this._excludeSet.add(e);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Add an object to the exclude list (will not receive any events).
|
|
111
|
+
* Alias for `setInteractable(object, false)`.
|
|
112
|
+
*/
|
|
113
|
+
addIgnore(e) {
|
|
114
|
+
this._excludeSet.add(e);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Remove an object from the exclude list.
|
|
118
|
+
* Alias for `setInteractable(object, true)`.
|
|
119
|
+
*/
|
|
120
|
+
removeIgnore(e) {
|
|
121
|
+
this._excludeSet.delete(e);
|
|
122
|
+
}
|
|
75
123
|
_bindEvents() {
|
|
76
124
|
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);
|
|
77
125
|
}
|
|
@@ -80,13 +128,23 @@ class Pt {
|
|
|
80
128
|
this.pointer.x = (e.clientX - t.left) / t.width * 2 - 1, this.pointer.y = -((e.clientY - t.top) / t.height) * 2 + 1;
|
|
81
129
|
}
|
|
82
130
|
_getIntersects() {
|
|
83
|
-
|
|
131
|
+
this.raycaster.setFromCamera(this.pointer, this.camera);
|
|
132
|
+
const e = this.raycaster.intersectObjects(this.targetObjects, !0);
|
|
133
|
+
return this._excludeSet.size > 0 ? e.filter((t) => {
|
|
134
|
+
let s = t.object;
|
|
135
|
+
for (; s; ) {
|
|
136
|
+
if (this._excludeSet.has(s))
|
|
137
|
+
return !1;
|
|
138
|
+
s = s.parent;
|
|
139
|
+
}
|
|
140
|
+
return !0;
|
|
141
|
+
}) : e;
|
|
84
142
|
}
|
|
85
143
|
/**
|
|
86
144
|
* Dispatches an event to the target object and bubbles up the parent chain.
|
|
87
145
|
*/
|
|
88
146
|
_dispatchToTarget(e, t, s, n) {
|
|
89
|
-
const i = new
|
|
147
|
+
const i = new gs({
|
|
90
148
|
type: e,
|
|
91
149
|
target: t,
|
|
92
150
|
intersect: s,
|
|
@@ -100,6 +158,7 @@ class Pt {
|
|
|
100
158
|
* Handles a DOM event by raycasting and dispatching to the first intersected object.
|
|
101
159
|
*/
|
|
102
160
|
_handleEvent(e, t) {
|
|
161
|
+
if (!this._enabled) return;
|
|
103
162
|
this._updatePointer(t);
|
|
104
163
|
const s = this._getIntersects();
|
|
105
164
|
if (s.length === 0) return;
|
|
@@ -135,7 +194,7 @@ class Pt {
|
|
|
135
194
|
this._handleEvent("pointerup", e);
|
|
136
195
|
};
|
|
137
196
|
_onPointerMove = (e) => {
|
|
138
|
-
if (!this.pointerMoveEventsEnabled) return;
|
|
197
|
+
if (!this._enabled || !this.pointerMoveEventsEnabled) return;
|
|
139
198
|
this._updatePointer(e);
|
|
140
199
|
const t = this._getIntersects(), s = t.length > 0 ? t[0].object : null, n = t.length > 0 ? t[0] : null;
|
|
141
200
|
this.hoveredObject !== s && (this.hoveredObject && this._dispatchToTarget("pointerleave", this.hoveredObject, null, e), this.hoveredObject = s, s && n && this._dispatchToTarget("pointerenter", s, n, e)), s && n && this._dispatchToTarget("pointermove", s, n, e);
|
|
@@ -144,10 +203,146 @@ class Pt {
|
|
|
144
203
|
* Cleans up event listeners.
|
|
145
204
|
*/
|
|
146
205
|
dispose() {
|
|
147
|
-
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;
|
|
206
|
+
this.domElement.removeEventListener("click", this._onClick), this.domElement.removeEventListener("dblclick", this._onDblClick), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.clickTimer && (clearTimeout(this.clickTimer), this.clickTimer = null), this.hoveredObject = null, this._excludeSet.clear();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
class bn extends Le {
|
|
210
|
+
scene;
|
|
211
|
+
camera;
|
|
212
|
+
domElement;
|
|
213
|
+
/** The container element for the selection box overlay (domElement's parent). */
|
|
214
|
+
_container;
|
|
215
|
+
_selected = /* @__PURE__ */ new Set();
|
|
216
|
+
// Box selection state
|
|
217
|
+
_boxSelectionEnabled = !1;
|
|
218
|
+
_isSelecting = !1;
|
|
219
|
+
_startPoint = new S();
|
|
220
|
+
_endPoint = new S();
|
|
221
|
+
_selectionBox = null;
|
|
222
|
+
_deep = !0;
|
|
223
|
+
/**
|
|
224
|
+
* Objects available for selection (defaults to scene.children).
|
|
225
|
+
*/
|
|
226
|
+
targetObjects = null;
|
|
227
|
+
constructor(e, t, s) {
|
|
228
|
+
super(), this.domElement = e, this._container = e.parentElement ?? e, this.scene = t, this.camera = s;
|
|
229
|
+
}
|
|
230
|
+
get selected() {
|
|
231
|
+
return this._selected;
|
|
232
|
+
}
|
|
233
|
+
get selectedArray() {
|
|
234
|
+
return Array.from(this._selected);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Select one or more objects.
|
|
238
|
+
*/
|
|
239
|
+
select(e) {
|
|
240
|
+
const t = Array.isArray(e) ? e : [e], s = [];
|
|
241
|
+
for (const n of t)
|
|
242
|
+
this._selected.has(n) || (this._selected.add(n), s.push(n));
|
|
243
|
+
s.length > 0 && (this.dispatchEvent({ type: "select", objects: s }), this.dispatchEvent({ type: "change", selected: this._selected }));
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Deselect one or more objects.
|
|
247
|
+
*/
|
|
248
|
+
deselect(e) {
|
|
249
|
+
const t = Array.isArray(e) ? e : [e], s = [];
|
|
250
|
+
for (const n of t)
|
|
251
|
+
this._selected.delete(n) && s.push(n);
|
|
252
|
+
s.length > 0 && (this.dispatchEvent({ type: "deselect", objects: s }), this.dispatchEvent({ type: "change", selected: this._selected }));
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Toggle selection of an object.
|
|
256
|
+
*/
|
|
257
|
+
toggle(e) {
|
|
258
|
+
this._selected.has(e) ? this.deselect(e) : this.select(e);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Clear all selections.
|
|
262
|
+
*/
|
|
263
|
+
clear() {
|
|
264
|
+
if (this._selected.size === 0) return;
|
|
265
|
+
const e = Array.from(this._selected);
|
|
266
|
+
this._selected.clear(), this.dispatchEvent({ type: "deselect", objects: e }), this.dispatchEvent({ type: "change", selected: this._selected });
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Check if an object is selected.
|
|
270
|
+
*/
|
|
271
|
+
isSelected(e) {
|
|
272
|
+
return this._selected.has(e);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Enable rubber-band box selection mode.
|
|
276
|
+
*/
|
|
277
|
+
enableBoxSelection(e = {}) {
|
|
278
|
+
this._boxSelectionEnabled || (this._boxSelectionEnabled = !0, this._deep = e.deep ?? !0, this._selectionBox = document.createElement("div"), this._selectionBox.style.cssText = `
|
|
279
|
+
position: absolute;
|
|
280
|
+
border: 1px dashed #55aaff;
|
|
281
|
+
background: rgba(75, 160, 255, 0.15);
|
|
282
|
+
pointer-events: none;
|
|
283
|
+
display: none;
|
|
284
|
+
z-index: 9999;
|
|
285
|
+
`, e.className && (this._selectionBox.className = e.className), this._container.style.position = this._container.style.position || "relative", this._container.appendChild(this._selectionBox), this.domElement.addEventListener("pointerdown", this._onBoxPointerDown), this.domElement.addEventListener("pointermove", this._onBoxPointerMove), this.domElement.addEventListener("pointerup", this._onBoxPointerUp));
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Disable box selection mode.
|
|
289
|
+
*/
|
|
290
|
+
disableBoxSelection() {
|
|
291
|
+
this._boxSelectionEnabled && (this._boxSelectionEnabled = !1, this.domElement.removeEventListener("pointerdown", this._onBoxPointerDown), this.domElement.removeEventListener("pointermove", this._onBoxPointerMove), this.domElement.removeEventListener("pointerup", this._onBoxPointerUp), this._selectionBox && (this._selectionBox.remove(), this._selectionBox = null));
|
|
292
|
+
}
|
|
293
|
+
setCamera(e) {
|
|
294
|
+
this.camera = e;
|
|
295
|
+
}
|
|
296
|
+
_onBoxPointerDown = (e) => {
|
|
297
|
+
if (e.button !== 0) return;
|
|
298
|
+
this._isSelecting = !0;
|
|
299
|
+
const t = this._container.getBoundingClientRect();
|
|
300
|
+
this._startPoint.set(e.clientX - t.left, e.clientY - t.top), this._endPoint.copy(this._startPoint), this._selectionBox && (this._selectionBox.style.display = "block", this._updateBoxElement());
|
|
301
|
+
};
|
|
302
|
+
_onBoxPointerMove = (e) => {
|
|
303
|
+
if (!this._isSelecting) return;
|
|
304
|
+
const t = this._container.getBoundingClientRect();
|
|
305
|
+
this._endPoint.set(e.clientX - t.left, e.clientY - t.top), this._updateBoxElement();
|
|
306
|
+
};
|
|
307
|
+
_onBoxPointerUp = () => {
|
|
308
|
+
if (!this._isSelecting) return;
|
|
309
|
+
this._isSelecting = !1, this._selectionBox && (this._selectionBox.style.display = "none");
|
|
310
|
+
const e = this._getObjectsInBox();
|
|
311
|
+
this.clear(), e.length > 0 && this.select(e);
|
|
312
|
+
};
|
|
313
|
+
_updateBoxElement() {
|
|
314
|
+
if (!this._selectionBox) return;
|
|
315
|
+
const e = Math.min(this._startPoint.x, this._endPoint.x), t = Math.min(this._startPoint.y, this._endPoint.y), s = Math.abs(this._endPoint.x - this._startPoint.x), n = Math.abs(this._endPoint.y - this._startPoint.y);
|
|
316
|
+
this._selectionBox.style.left = `${e}px`, this._selectionBox.style.top = `${t}px`, this._selectionBox.style.width = `${s}px`, this._selectionBox.style.height = `${n}px`;
|
|
317
|
+
}
|
|
318
|
+
_getObjectsInBox() {
|
|
319
|
+
const e = this._container.getBoundingClientRect(), t = e.width, s = e.height, n = new S(
|
|
320
|
+
this._startPoint.x / t * 2 - 1,
|
|
321
|
+
-(this._startPoint.y / s) * 2 + 1
|
|
322
|
+
), i = new S(
|
|
323
|
+
this._endPoint.x / t * 2 - 1,
|
|
324
|
+
-(this._endPoint.y / s) * 2 + 1
|
|
325
|
+
), r = new tt(
|
|
326
|
+
new S(Math.min(n.x, i.x), Math.min(n.y, i.y)),
|
|
327
|
+
new S(Math.max(n.x, i.x), Math.max(n.y, i.y))
|
|
328
|
+
), o = this.targetObjects || this.scene.children, a = [], c = new Ie();
|
|
329
|
+
c.multiplyMatrices(this.camera.projectionMatrix, this.camera.matrixWorldInverse);
|
|
330
|
+
const h = (d) => {
|
|
331
|
+
if (!d.visible) return;
|
|
332
|
+
const p = new w();
|
|
333
|
+
if (p.setFromMatrixPosition(d.matrixWorld), p.applyMatrix4(c), p.z > -1 && p.z < 1 && r.containsPoint(new S(p.x, p.y)) && a.push(d), this._deep)
|
|
334
|
+
for (const u of d.children)
|
|
335
|
+
h(u);
|
|
336
|
+
};
|
|
337
|
+
for (const d of o)
|
|
338
|
+
h(d);
|
|
339
|
+
return a;
|
|
340
|
+
}
|
|
341
|
+
dispose() {
|
|
342
|
+
this.disableBoxSelection(), this._selected.clear();
|
|
148
343
|
}
|
|
149
344
|
}
|
|
150
|
-
class
|
|
345
|
+
class ys {
|
|
151
346
|
idMap = /* @__PURE__ */ new Map();
|
|
152
347
|
nameMap = /* @__PURE__ */ new Map();
|
|
153
348
|
typeMap = /* @__PURE__ */ new Map();
|
|
@@ -249,55 +444,416 @@ class St {
|
|
|
249
444
|
get size() {
|
|
250
445
|
return this.allObjects.size;
|
|
251
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* Show an object by id.
|
|
449
|
+
*/
|
|
450
|
+
show(e) {
|
|
451
|
+
const t = this.idMap.get(e);
|
|
452
|
+
t && (t.visible = !0);
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Hide an object by id.
|
|
456
|
+
*/
|
|
457
|
+
hide(e) {
|
|
458
|
+
const t = this.idMap.get(e);
|
|
459
|
+
t && (t.visible = !1);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Show only the specified objects, hide all others.
|
|
463
|
+
*/
|
|
464
|
+
isolate(e) {
|
|
465
|
+
const t = new Set(e);
|
|
466
|
+
for (const [s, n] of this.idMap)
|
|
467
|
+
n.visible = t.has(s);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Set the opacity of an object's materials.
|
|
471
|
+
*/
|
|
472
|
+
setOpacity(e, t) {
|
|
473
|
+
const s = this.idMap.get(e);
|
|
474
|
+
s && s.traverse((n) => {
|
|
475
|
+
if (!n.isMesh) return;
|
|
476
|
+
const i = n.material;
|
|
477
|
+
if (!i) return;
|
|
478
|
+
const r = Array.isArray(i) ? i : [i];
|
|
479
|
+
for (const o of r)
|
|
480
|
+
o.transparent = t < 1, o.opacity = t, o.needsUpdate = !0;
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Get the bounding box of an object by id, or all objects if no id provided.
|
|
485
|
+
*/
|
|
486
|
+
getBoundingBox(e) {
|
|
487
|
+
const t = new q();
|
|
488
|
+
if (e) {
|
|
489
|
+
const s = this.idMap.get(e);
|
|
490
|
+
s && t.setFromObject(s);
|
|
491
|
+
} else
|
|
492
|
+
for (const s of this.allObjects)
|
|
493
|
+
t.expandByObject(s);
|
|
494
|
+
return t;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Iterate over all managed objects.
|
|
498
|
+
*/
|
|
499
|
+
forEach(e) {
|
|
500
|
+
for (const t of this.allObjects) {
|
|
501
|
+
const s = this.objectIds.get(t) || /* @__PURE__ */ new Set();
|
|
502
|
+
e(t, s);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Filter objects by a predicate.
|
|
507
|
+
*/
|
|
508
|
+
filter(e) {
|
|
509
|
+
const t = [];
|
|
510
|
+
for (const s of this.allObjects)
|
|
511
|
+
e(s) && t.push(s);
|
|
512
|
+
return t;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Show all managed objects.
|
|
516
|
+
*/
|
|
517
|
+
showAll() {
|
|
518
|
+
for (const e of this.allObjects)
|
|
519
|
+
e.visible = !0;
|
|
520
|
+
}
|
|
252
521
|
}
|
|
253
|
-
class
|
|
522
|
+
class vn {
|
|
523
|
+
scenes = /* @__PURE__ */ new Map();
|
|
524
|
+
_activeSceneKey = null;
|
|
525
|
+
/**
|
|
526
|
+
* Add a scene with a key.
|
|
527
|
+
*/
|
|
528
|
+
add(e, t) {
|
|
529
|
+
this.scenes.set(e, t);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Create and register a new scene.
|
|
533
|
+
*/
|
|
534
|
+
create(e, t = {}) {
|
|
535
|
+
const s = new Re();
|
|
536
|
+
return t.background !== void 0 && (s.background = new B(t.background)), this.scenes.set(e, s), s;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Get a scene by key.
|
|
540
|
+
*/
|
|
541
|
+
get(e) {
|
|
542
|
+
return this.scenes.get(e);
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Remove a scene by key.
|
|
546
|
+
*/
|
|
547
|
+
remove(e) {
|
|
548
|
+
this.scenes.delete(e), this._activeSceneKey === e && (this._activeSceneKey = null);
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Get the currently active scene key.
|
|
552
|
+
*/
|
|
553
|
+
get activeKey() {
|
|
554
|
+
return this._activeSceneKey;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Set the active scene key (for external use to track which scene is active).
|
|
558
|
+
*/
|
|
559
|
+
set activeKey(e) {
|
|
560
|
+
this._activeSceneKey = e;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* List all registered scene keys.
|
|
564
|
+
*/
|
|
565
|
+
keys() {
|
|
566
|
+
return Array.from(this.scenes.keys());
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Serialize scene metadata to JSON (children names/ids, background, etc.).
|
|
570
|
+
*/
|
|
571
|
+
serialize(e) {
|
|
572
|
+
const t = this.scenes.get(e);
|
|
573
|
+
if (!t) return null;
|
|
574
|
+
let s = null;
|
|
575
|
+
return t.background instanceof B && (s = `#${t.background.getHexString()}`), {
|
|
576
|
+
name: t.name || e,
|
|
577
|
+
background: s,
|
|
578
|
+
environmentRotation: {
|
|
579
|
+
x: t.environmentRotation?.x ?? 0,
|
|
580
|
+
y: t.environmentRotation?.y ?? 0,
|
|
581
|
+
z: t.environmentRotation?.z ?? 0
|
|
582
|
+
},
|
|
583
|
+
children: t.children.map((n) => n.name || n.uuid)
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Clear all scenes.
|
|
588
|
+
*/
|
|
589
|
+
clear() {
|
|
590
|
+
this.scenes.clear(), this._activeSceneKey = null;
|
|
591
|
+
}
|
|
592
|
+
get size() {
|
|
593
|
+
return this.scenes.size;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
class xn {
|
|
597
|
+
scene;
|
|
598
|
+
lights = /* @__PURE__ */ new Map();
|
|
599
|
+
helpers = /* @__PURE__ */ new Map();
|
|
600
|
+
constructor(e) {
|
|
601
|
+
this.scene = e;
|
|
602
|
+
}
|
|
603
|
+
addAmbient(e, t = {}) {
|
|
604
|
+
const { color: s = 16777215, intensity: n = 0.5 } = t, i = new st(s, n);
|
|
605
|
+
return i.name = e, this._register(e, i), i;
|
|
606
|
+
}
|
|
607
|
+
addDirectional(e, t = {}) {
|
|
608
|
+
const { color: s = 16777215, intensity: n = 1, position: i = { x: 5, y: 10, z: 5 }, castShadow: r = !1, shadowMapSize: o = 1024 } = t, a = new ue(s, n);
|
|
609
|
+
return a.position.set(i.x, i.y, i.z), a.castShadow = r, r && a.shadow.mapSize.setScalar(o), a.name = e, this._register(e, a), a;
|
|
610
|
+
}
|
|
611
|
+
addPoint(e, t = {}) {
|
|
612
|
+
const { color: s = 16777215, intensity: n = 1, distance: i = 0, decay: r = 2, position: o = { x: 0, y: 5, z: 0 }, castShadow: a = !1 } = t, c = new me(s, n, i, r);
|
|
613
|
+
return c.position.set(o.x, o.y, o.z), c.castShadow = a, c.name = e, this._register(e, c), c;
|
|
614
|
+
}
|
|
615
|
+
addSpot(e, t = {}) {
|
|
616
|
+
const {
|
|
617
|
+
color: s = 16777215,
|
|
618
|
+
intensity: n = 1,
|
|
619
|
+
distance: i = 0,
|
|
620
|
+
angle: r = Math.PI / 6,
|
|
621
|
+
penumbra: o = 0.1,
|
|
622
|
+
decay: a = 2,
|
|
623
|
+
position: c = { x: 0, y: 10, z: 0 },
|
|
624
|
+
target: h,
|
|
625
|
+
castShadow: d = !1
|
|
626
|
+
} = t, p = new ge(s, n, i, r, o, a);
|
|
627
|
+
return p.position.set(c.x, c.y, c.z), h && p.target.position.set(h.x, h.y, h.z), p.castShadow = d, p.name = e, this._register(e, p), p;
|
|
628
|
+
}
|
|
629
|
+
addHemisphere(e, t = {}) {
|
|
630
|
+
const { skyColor: s = 8900331, groundColor: n = 3549447, intensity: i = 0.6 } = t, r = new fe(s, n, i);
|
|
631
|
+
return r.name = e, this._register(e, r), r;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Apply a lighting preset to the scene.
|
|
635
|
+
*/
|
|
636
|
+
applyPreset(e) {
|
|
637
|
+
switch (this.removeAll(), e) {
|
|
638
|
+
case "indoor":
|
|
639
|
+
this.addAmbient("preset_ambient", { intensity: 0.4 }), this.addPoint("preset_point1", { position: { x: 0, y: 3, z: 0 }, intensity: 1, castShadow: !0 }), this.addPoint("preset_point2", { position: { x: 3, y: 2, z: -3 }, intensity: 0.5 });
|
|
640
|
+
break;
|
|
641
|
+
case "outdoor":
|
|
642
|
+
this.addHemisphere("preset_hemi", { skyColor: 8900331, groundColor: 3549447, intensity: 0.6 }), this.addDirectional("preset_sun", { position: { x: 10, y: 20, z: 10 }, intensity: 1.5, castShadow: !0, shadowMapSize: 2048 });
|
|
643
|
+
break;
|
|
644
|
+
case "studio":
|
|
645
|
+
this.addAmbient("preset_ambient", { intensity: 0.3 }), this.addDirectional("preset_key", { position: { x: 5, y: 8, z: 5 }, intensity: 1.2, castShadow: !0 }), this.addDirectional("preset_fill", { position: { x: -5, y: 5, z: -2 }, intensity: 0.6 }), this.addDirectional("preset_back", { position: { x: 0, y: 5, z: -8 }, intensity: 0.4 });
|
|
646
|
+
break;
|
|
647
|
+
case "warehouse":
|
|
648
|
+
this.addAmbient("preset_ambient", { intensity: 0.2 }), this.addPoint("preset_light1", { position: { x: -5, y: 6, z: -5 }, intensity: 2, distance: 20 }), this.addPoint("preset_light2", { position: { x: 5, y: 6, z: -5 }, intensity: 2, distance: 20 }), this.addPoint("preset_light3", { position: { x: -5, y: 6, z: 5 }, intensity: 2, distance: 20 }), this.addPoint("preset_light4", { position: { x: 5, y: 6, z: 5 }, intensity: 2, distance: 20 });
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Get a light by id.
|
|
654
|
+
*/
|
|
655
|
+
get(e) {
|
|
656
|
+
return this.lights.get(e);
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Remove a light by id.
|
|
660
|
+
*/
|
|
661
|
+
remove(e) {
|
|
662
|
+
const t = this.lights.get(e);
|
|
663
|
+
t && (this.scene.remove(t), this.lights.delete(e)), this.hideHelper(e);
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Remove all lights managed by this manager.
|
|
667
|
+
*/
|
|
668
|
+
removeAll() {
|
|
669
|
+
const e = Array.from(this.lights.keys());
|
|
670
|
+
for (const t of e)
|
|
671
|
+
this.remove(t);
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Show a visual helper for a light.
|
|
675
|
+
*/
|
|
676
|
+
showHelper(e) {
|
|
677
|
+
if (this.helpers.has(e)) return;
|
|
678
|
+
const t = this.lights.get(e);
|
|
679
|
+
if (!t) return;
|
|
680
|
+
let s = null;
|
|
681
|
+
t instanceof ue ? s = new nt(t, 1) : t instanceof me ? s = new it(t, 0.5) : t instanceof ge ? s = new rt(t) : t instanceof fe && (s = new ot(t, 1)), s && (this.scene.add(s), this.helpers.set(e, s));
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Hide (remove) the helper for a light.
|
|
685
|
+
*/
|
|
686
|
+
hideHelper(e) {
|
|
687
|
+
const t = this.helpers.get(e);
|
|
688
|
+
t && (this.scene.remove(t), this.helpers.delete(e));
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Show helpers for all lights.
|
|
692
|
+
*/
|
|
693
|
+
showAllHelpers() {
|
|
694
|
+
for (const [e] of this.lights)
|
|
695
|
+
this.showHelper(e);
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Hide all helpers.
|
|
699
|
+
*/
|
|
700
|
+
hideAllHelpers() {
|
|
701
|
+
const e = Array.from(this.helpers.keys());
|
|
702
|
+
for (const t of e)
|
|
703
|
+
this.hideHelper(t);
|
|
704
|
+
}
|
|
705
|
+
_register(e, t) {
|
|
706
|
+
this.lights.has(e) && this.remove(e), this.lights.set(e, t), this.scene.add(t);
|
|
707
|
+
}
|
|
708
|
+
dispose() {
|
|
709
|
+
this.removeAll(), this.hideAllHelpers();
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
class ws extends at {
|
|
254
713
|
scene;
|
|
255
714
|
camera;
|
|
256
|
-
|
|
715
|
+
scenePass;
|
|
257
716
|
needsUpdateOutputNode;
|
|
258
|
-
#
|
|
717
|
+
#r;
|
|
718
|
+
#t;
|
|
719
|
+
#s = !1;
|
|
720
|
+
#o = { strength: 1, radius: 0, threshold: 0 };
|
|
721
|
+
#c = null;
|
|
722
|
+
#i = !1;
|
|
723
|
+
#e = {
|
|
724
|
+
sliceCount: 1,
|
|
725
|
+
stepCount: 12,
|
|
726
|
+
aoIntensity: 1,
|
|
727
|
+
giIntensity: 10,
|
|
728
|
+
radius: 12,
|
|
729
|
+
thickness: 1
|
|
730
|
+
};
|
|
731
|
+
#h = null;
|
|
732
|
+
#a = !1;
|
|
733
|
+
#l = null;
|
|
734
|
+
#d = null;
|
|
259
735
|
constructor(...e) {
|
|
260
736
|
const [t, s, n] = e;
|
|
261
|
-
super(t), this.scene = s, this.camera = n, this.
|
|
737
|
+
super(t), this.scene = s, this.camera = n, this.scenePass = de(s, n), this.needsUpdateOutputNode = !0, this.#r = /* @__PURE__ */ new Set(), this.#t = [], this.#p();
|
|
738
|
+
}
|
|
739
|
+
/** @deprecated Use `scenePass` instead */
|
|
740
|
+
get currentOutputNode() {
|
|
741
|
+
return this.scenePass;
|
|
262
742
|
}
|
|
263
743
|
addOverlayPass(e) {
|
|
264
|
-
this.#
|
|
744
|
+
this.#r.add(e), this.needsUpdateOutputNode = !0;
|
|
265
745
|
}
|
|
266
746
|
removeOverlayPass(e) {
|
|
267
|
-
this.#
|
|
747
|
+
this.#r.delete(e), this.needsUpdateOutputNode = !0;
|
|
268
748
|
}
|
|
269
749
|
setCamera(e) {
|
|
270
|
-
this.camera = e, this
|
|
750
|
+
this.camera = e, this.#n();
|
|
271
751
|
}
|
|
752
|
+
/** @deprecated Use `setOutputComposer` instead */
|
|
272
753
|
setCurrentOutputNode(e) {
|
|
273
|
-
this.
|
|
754
|
+
this.setOutputComposer(() => e);
|
|
274
755
|
}
|
|
756
|
+
/** @deprecated Use `setOutputComposer(null)` instead */
|
|
275
757
|
resetCurrentOutputNode() {
|
|
276
|
-
this.
|
|
758
|
+
this.setOutputComposer(null);
|
|
759
|
+
}
|
|
760
|
+
setOutputComposer(e) {
|
|
761
|
+
this.#d = e, this.needsUpdateOutputNode = !0;
|
|
762
|
+
}
|
|
763
|
+
enableBloom(e) {
|
|
764
|
+
e && Object.assign(this.#o, e), this.#s = !0, this.#n();
|
|
765
|
+
}
|
|
766
|
+
disableBloom() {
|
|
767
|
+
this.#s = !1, this.#c = null, this.#n();
|
|
768
|
+
}
|
|
769
|
+
updateBloom(e) {
|
|
770
|
+
Object.assign(this.#o, e), this.#s && (this.needsUpdateOutputNode = !0);
|
|
771
|
+
}
|
|
772
|
+
enableSSGI(e) {
|
|
773
|
+
e && Object.assign(this.#e, e), this.#i = !0, this.#n();
|
|
774
|
+
}
|
|
775
|
+
disableSSGI() {
|
|
776
|
+
this.#i = !1, this.#h = null, this.#n();
|
|
777
|
+
}
|
|
778
|
+
updateSSGI(e) {
|
|
779
|
+
if (Object.assign(this.#e, e), this.#h) {
|
|
780
|
+
const t = this.#h;
|
|
781
|
+
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);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
enableTRAA() {
|
|
785
|
+
this.#a = !0, this.#n();
|
|
786
|
+
}
|
|
787
|
+
disableTRAA() {
|
|
788
|
+
this.#a = !1, this.#l = null, this.#n();
|
|
789
|
+
}
|
|
790
|
+
#n() {
|
|
791
|
+
const e = this.scenePass;
|
|
792
|
+
this.scenePass = de(this.scene, this.camera), this.#p(), this.needsUpdateOutputNode = !0, e.dispose();
|
|
277
793
|
}
|
|
278
|
-
#
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
794
|
+
#p() {
|
|
795
|
+
if (this.#s || this.#i || this.#a) {
|
|
796
|
+
const t = { output: $t };
|
|
797
|
+
this.#s && (t.emissive = Kt), this.#i && (t.normal = Qt), this.#a && (t.velocity = qt), this.scenePass.setMRT(Gt(t));
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
#u() {
|
|
801
|
+
for (const e of this.#t)
|
|
802
|
+
e.dispose();
|
|
803
|
+
this.#t = [];
|
|
804
|
+
}
|
|
805
|
+
#m() {
|
|
806
|
+
let e = this.scenePass.getTextureNode();
|
|
807
|
+
if (this.#i)
|
|
808
|
+
if (!(this.camera instanceof J))
|
|
809
|
+
console.warn("RenderPipeline: SSGI requires a PerspectiveCamera, skipping.");
|
|
810
|
+
else {
|
|
811
|
+
const t = this.scenePass.getTextureNode(), s = this.scenePass.getTextureNode("depth"), n = this.scenePass.getTextureNode("normal"), i = Vt(t, s, n, this.camera);
|
|
812
|
+
i.sliceCount.value = this.#e.sliceCount, i.stepCount.value = this.#e.stepCount, i.aoIntensity.value = this.#e.aoIntensity, i.giIntensity.value = this.#e.giIntensity, i.radius.value = this.#e.radius, i.thickness.value = this.#e.thickness, this.#h = i, e = ve(e, i), this.#t.push(i);
|
|
813
|
+
}
|
|
814
|
+
if (this.#s) {
|
|
815
|
+
const t = this.scenePass.getTextureNode("emissive");
|
|
816
|
+
this.#c = Jt(
|
|
817
|
+
t,
|
|
818
|
+
this.#o.strength,
|
|
819
|
+
this.#o.radius,
|
|
820
|
+
this.#o.threshold
|
|
821
|
+
), e = ve(e, this.#c), this.#t.push(this.#c);
|
|
822
|
+
}
|
|
823
|
+
return e;
|
|
824
|
+
}
|
|
825
|
+
#g() {
|
|
826
|
+
this.#u();
|
|
827
|
+
let e;
|
|
828
|
+
if (this.#d ? e = this.#d(this.scenePass) : this.#s || this.#i ? e = this.#m() : e = this.scenePass, this.#a) {
|
|
829
|
+
const t = this.scenePass.getTextureNode("depth"), s = this.scenePass.getTextureNode("velocity");
|
|
830
|
+
this.#l = Zt(e, t, s, this.camera), this.#t.push(this.#l), e = this.#l;
|
|
831
|
+
}
|
|
832
|
+
this.#r.size > 0 && this.#r.forEach((t) => {
|
|
833
|
+
const s = Wt(e, t);
|
|
834
|
+
this.#t.push(s), e = s;
|
|
282
835
|
}), this.outputNode = e, this.needsUpdate = !0;
|
|
283
836
|
}
|
|
284
837
|
render() {
|
|
285
|
-
this.needsUpdateOutputNode && (this.#
|
|
838
|
+
this.needsUpdateOutputNode && (this.#g(), this.needsUpdateOutputNode = !1), super.render();
|
|
839
|
+
}
|
|
840
|
+
dispose() {
|
|
841
|
+
this.#u(), this.scenePass.dispose(), super.dispose();
|
|
286
842
|
}
|
|
287
843
|
}
|
|
288
|
-
const
|
|
844
|
+
const bs = {
|
|
289
845
|
Vector2: S,
|
|
290
|
-
Vector3:
|
|
291
|
-
Vector4:
|
|
292
|
-
Quaternion:
|
|
293
|
-
Matrix4:
|
|
294
|
-
Spherical:
|
|
295
|
-
Box3:
|
|
296
|
-
Sphere:
|
|
297
|
-
Raycaster:
|
|
846
|
+
Vector3: w,
|
|
847
|
+
Vector4: ht,
|
|
848
|
+
Quaternion: ct,
|
|
849
|
+
Matrix4: Ie,
|
|
850
|
+
Spherical: C,
|
|
851
|
+
Box3: q,
|
|
852
|
+
Sphere: ze,
|
|
853
|
+
Raycaster: Be
|
|
298
854
|
};
|
|
299
|
-
|
|
300
|
-
class
|
|
855
|
+
Ue.install({ THREE: bs });
|
|
856
|
+
class vs extends Ue {
|
|
301
857
|
constructor(...e) {
|
|
302
858
|
super(...e), this.minDistance = 0.2, this.smoothTime = 0.2, this.dollySpeed = 0.2;
|
|
303
859
|
}
|
|
@@ -305,16 +861,16 @@ class Bt extends Ce {
|
|
|
305
861
|
* Set absolute angle for azimuth to avoid spinning
|
|
306
862
|
*/
|
|
307
863
|
absoluteRotations() {
|
|
308
|
-
this.azimuthAngle =
|
|
864
|
+
this.azimuthAngle = xs(this.azimuthAngle, 0);
|
|
309
865
|
}
|
|
310
866
|
async flyToBox(e, t = {}) {
|
|
311
867
|
if (e.isEmpty())
|
|
312
868
|
return console.warn("CameraControls.flyToBox: The provided Box3 is empty."), !1;
|
|
313
869
|
this.absoluteRotations();
|
|
314
|
-
const { viewpoint: s = "frontTop", enableTransition: n = !0, padding: i = 0.1, cover: r = !1 } = t,
|
|
870
|
+
const { viewpoint: s = "frontTop", enableTransition: n = !0, padding: i = 0.1, cover: r = !1 } = t, o = [];
|
|
315
871
|
if (s !== "current") {
|
|
316
|
-
const
|
|
317
|
-
|
|
872
|
+
const a = Me[s.toUpperCase()] ?? Me.FRONTTOP, c = a.theta, h = a.phi;
|
|
873
|
+
o.push(
|
|
318
874
|
this.fitToBox(e, n, {
|
|
319
875
|
paddingLeft: i,
|
|
320
876
|
paddingRight: i,
|
|
@@ -322,45 +878,92 @@ class Bt extends Ce {
|
|
|
322
878
|
paddingBottom: i,
|
|
323
879
|
cover: r
|
|
324
880
|
})
|
|
325
|
-
),
|
|
881
|
+
), o.push(this.rotateTo(c, h, n));
|
|
326
882
|
} else {
|
|
327
|
-
const
|
|
328
|
-
e.getBoundingSphere(
|
|
883
|
+
const a = new ze();
|
|
884
|
+
e.getBoundingSphere(a), a.radius += i, o.push(this.fitToSphere(a, n));
|
|
329
885
|
}
|
|
330
|
-
return await Promise.all(
|
|
886
|
+
return await Promise.all(o), !0;
|
|
331
887
|
}
|
|
332
888
|
async flyToObject(e, t = {}) {
|
|
333
|
-
const s = new
|
|
889
|
+
const s = new q().setFromObject(e);
|
|
334
890
|
return this.flyToBox(s, t);
|
|
335
891
|
}
|
|
892
|
+
/**
|
|
893
|
+
* Fly camera to a specific position and look-at target.
|
|
894
|
+
*/
|
|
895
|
+
async flyTo(e, t, s = {}) {
|
|
896
|
+
const { enableTransition: n = !0 } = s;
|
|
897
|
+
return this.absoluteRotations(), this.setLookAt(e.x, e.y, e.z, t.x, t.y, t.z, n);
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Get the current camera viewpoint data (position, target, zoom).
|
|
901
|
+
*/
|
|
902
|
+
getCameraViewpoint() {
|
|
903
|
+
const e = new w(), t = new w();
|
|
904
|
+
return this.getPosition(e), this.getTarget(t), {
|
|
905
|
+
position: { x: e.x, y: e.y, z: e.z },
|
|
906
|
+
target: { x: t.x, y: t.y, z: t.z },
|
|
907
|
+
zoom: this.camera.zoom
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Lock camera controls (disable all user interaction).
|
|
912
|
+
*/
|
|
913
|
+
lock() {
|
|
914
|
+
this.enabled = !1;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Unlock camera controls (re-enable user interaction).
|
|
918
|
+
*/
|
|
919
|
+
unlock() {
|
|
920
|
+
this.enabled = !0;
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Switch between 2D top-down and 3D perspective views.
|
|
924
|
+
*/
|
|
925
|
+
async setViewMode(e, t = !0) {
|
|
926
|
+
if (e === "2d") {
|
|
927
|
+
const s = new w();
|
|
928
|
+
this.getTarget(s), await this.rotateTo(0, 0, t), this.minPolarAngle = 0, this.maxPolarAngle = 0;
|
|
929
|
+
} else
|
|
930
|
+
this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, await this.rotateTo(0, Math.PI / 4, t);
|
|
931
|
+
}
|
|
932
|
+
async setCameraViewpoint(e, t = !0) {
|
|
933
|
+
const { position: s, target: n, zoom: i = this.camera.zoom } = e;
|
|
934
|
+
return Promise.all([
|
|
935
|
+
this.zoomTo(i, t),
|
|
936
|
+
this.setLookAt(s.x, s.y, s.z, n.x, n.y, n.z, t)
|
|
937
|
+
]);
|
|
938
|
+
}
|
|
336
939
|
}
|
|
337
|
-
const
|
|
338
|
-
LEFT: new
|
|
339
|
-
RIGHT: new
|
|
340
|
-
FRONT: new
|
|
341
|
-
BACK: new
|
|
342
|
-
TOP: new
|
|
343
|
-
BOTTOM: new
|
|
344
|
-
FRONTTOP: new
|
|
345
|
-
BACKTOP: new
|
|
346
|
-
LEFTTOP: new
|
|
347
|
-
RIGHTTOP: new
|
|
348
|
-
LEFTFRONTTOP: new
|
|
349
|
-
RIGHTFRONTTOP: new
|
|
350
|
-
LEFTBACKTOP: new
|
|
351
|
-
RIGHTBACKTOP: new
|
|
940
|
+
const Me = {
|
|
941
|
+
LEFT: new C(0, Math.PI / 2, -Math.PI / 2),
|
|
942
|
+
RIGHT: new C(0, Math.PI / 2, Math.PI / 2),
|
|
943
|
+
FRONT: new C(0, Math.PI / 2, 0),
|
|
944
|
+
BACK: new C(0, Math.PI / 2, Math.PI),
|
|
945
|
+
TOP: new C(0, 0, 0),
|
|
946
|
+
BOTTOM: new C(0, Math.PI, 0),
|
|
947
|
+
FRONTTOP: new C(0, Math.PI / 4, 0),
|
|
948
|
+
BACKTOP: new C(0, Math.PI / 4, Math.PI),
|
|
949
|
+
LEFTTOP: new C(0, Math.PI / 4, -Math.PI / 2),
|
|
950
|
+
RIGHTTOP: new C(0, Math.PI / 4, Math.PI / 2),
|
|
951
|
+
LEFTFRONTTOP: new C(0, Math.PI / 4, -Math.PI / 4),
|
|
952
|
+
RIGHTFRONTTOP: new C(0, Math.PI / 4, Math.PI / 4),
|
|
953
|
+
LEFTBACKTOP: new C(0, Math.PI / 4, -Math.PI / 4 * 3),
|
|
954
|
+
RIGHTBACKTOP: new C(0, Math.PI / 4, Math.PI / 4 * 3)
|
|
352
955
|
};
|
|
353
|
-
function
|
|
354
|
-
const t =
|
|
355
|
-
return
|
|
956
|
+
function xs(l, e) {
|
|
957
|
+
const t = l - e;
|
|
958
|
+
return lt.euclideanModulo(t + Math.PI, Math.PI * 2) - Math.PI;
|
|
356
959
|
}
|
|
357
|
-
class
|
|
358
|
-
environment = new
|
|
960
|
+
class Ss {
|
|
961
|
+
environment = new es();
|
|
359
962
|
renderer;
|
|
360
963
|
pmremGenerator;
|
|
361
964
|
envMap = null;
|
|
362
965
|
constructor(e) {
|
|
363
|
-
this.renderer = e, this.pmremGenerator = new
|
|
966
|
+
this.renderer = e, this.pmremGenerator = new dt(e);
|
|
364
967
|
}
|
|
365
968
|
update() {
|
|
366
969
|
this.envMap || (this.envMap = this.pmremGenerator.fromScene(this.environment).texture);
|
|
@@ -369,20 +972,20 @@ class Rt {
|
|
|
369
972
|
this.pmremGenerator.dispose(), this.envMap?.dispose();
|
|
370
973
|
}
|
|
371
974
|
}
|
|
372
|
-
const
|
|
373
|
-
class
|
|
975
|
+
const Y = 128;
|
|
976
|
+
class Cs extends ts {
|
|
374
977
|
viewer;
|
|
375
978
|
overlayPass;
|
|
376
979
|
constructor(e) {
|
|
377
980
|
super(e.camera, e.el), this.viewer = e;
|
|
378
|
-
const t = new
|
|
379
|
-
t.position.set(0, 0, 2), this.overlayPass =
|
|
981
|
+
const t = new V(-2, 2, 2, -2, 0, 4);
|
|
982
|
+
t.position.set(0, 0, 2), this.overlayPass = de(this, t), this.setLabels("x", "y", "z");
|
|
380
983
|
}
|
|
381
984
|
_update = () => {
|
|
382
985
|
this.quaternion.copy(this.viewer.camera.quaternion).invert();
|
|
383
986
|
const e = this.location;
|
|
384
987
|
let t, s;
|
|
385
|
-
e.left !== null ? t = e.left : t = this.viewer.el.offsetWidth -
|
|
988
|
+
e.left !== null ? t = e.left : t = this.viewer.el.offsetWidth - Y - e.right, e.top !== null ? s = e.top : s = this.viewer.el.offsetHeight - Y - e.bottom, this.overlayPass.setViewport(t, s, Y, Y);
|
|
386
989
|
};
|
|
387
990
|
enable() {
|
|
388
991
|
return this.viewer.renderPipeline.addOverlayPass(this.overlayPass), this.viewer.addEventListener("beforeRender", this._update), this.viewer.render(), this;
|
|
@@ -391,7 +994,42 @@ class _t extends wt {
|
|
|
391
994
|
return this.viewer.renderPipeline.removeOverlayPass(this.overlayPass), this.viewer.removeEventListener("beforeRender", this._update), this.viewer.render(), this;
|
|
392
995
|
}
|
|
393
996
|
}
|
|
394
|
-
|
|
997
|
+
const Ge = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;overflow:hidden;", _s = Ge + "z-index:0;", Ms = Ge + "z-index:1;";
|
|
998
|
+
class Ts {
|
|
999
|
+
el;
|
|
1000
|
+
css2dRenderer = null;
|
|
1001
|
+
css3dRenderer = null;
|
|
1002
|
+
constructor(e) {
|
|
1003
|
+
this.el = e, getComputedStyle(e).position === "static" && (e.style.position = "relative");
|
|
1004
|
+
}
|
|
1005
|
+
initCSS2DRenderer() {
|
|
1006
|
+
const e = new ss();
|
|
1007
|
+
return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = Ms, this.el.appendChild(e.domElement), this.css2dRenderer = e, e;
|
|
1008
|
+
}
|
|
1009
|
+
initCSS3DRenderer() {
|
|
1010
|
+
const e = new is();
|
|
1011
|
+
return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = _s, this.el.appendChild(e.domElement), this.css3dRenderer = e, e;
|
|
1012
|
+
}
|
|
1013
|
+
createCSS2DObject(e) {
|
|
1014
|
+
return this.css2dRenderer || this.initCSS2DRenderer(), new ns(e);
|
|
1015
|
+
}
|
|
1016
|
+
createCSS25DObject(e) {
|
|
1017
|
+
return this.css3dRenderer || this.initCSS3DRenderer(), new rs(e);
|
|
1018
|
+
}
|
|
1019
|
+
createCSS3DObject(e) {
|
|
1020
|
+
return this.css3dRenderer || this.initCSS3DRenderer(), new os(e);
|
|
1021
|
+
}
|
|
1022
|
+
render(e, t) {
|
|
1023
|
+
this.css2dRenderer && this.css2dRenderer.render(e, t), this.css3dRenderer && this.css3dRenderer.render(e, t);
|
|
1024
|
+
}
|
|
1025
|
+
resize(e, t) {
|
|
1026
|
+
this.css2dRenderer && this.css2dRenderer.setSize(e, t), this.css3dRenderer && this.css3dRenderer.setSize(e, t);
|
|
1027
|
+
}
|
|
1028
|
+
dispose() {
|
|
1029
|
+
this.css2dRenderer && (this.el.removeChild(this.css2dRenderer.domElement), this.css2dRenderer = null), this.css3dRenderer && (this.el.removeChild(this.css3dRenderer.domElement), this.css3dRenderer = null);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
class Ps {
|
|
395
1033
|
el;
|
|
396
1034
|
renderer;
|
|
397
1035
|
container;
|
|
@@ -406,9 +1044,9 @@ class Nt {
|
|
|
406
1044
|
this.el = e, this.renderer = t;
|
|
407
1045
|
const s = document.createElement("div");
|
|
408
1046
|
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;
|
|
409
|
-
function n(r,
|
|
410
|
-
const
|
|
411
|
-
return
|
|
1047
|
+
function n(r, o = !0) {
|
|
1048
|
+
const a = document.createElement("span");
|
|
1049
|
+
return o && (a.style.marginLeft = "6px"), a.innerText = r, a;
|
|
412
1050
|
}
|
|
413
1051
|
function i() {
|
|
414
1052
|
return document.createElement("br");
|
|
@@ -418,7 +1056,7 @@ class Nt {
|
|
|
418
1056
|
update() {
|
|
419
1057
|
if (this._enabled) {
|
|
420
1058
|
const { render: e } = this.renderer.info;
|
|
421
|
-
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(
|
|
1059
|
+
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(pt.RENDER).then((t) => {
|
|
422
1060
|
this.timestampText.innerText = t?.toFixed(2) ?? "0";
|
|
423
1061
|
});
|
|
424
1062
|
}
|
|
@@ -433,8 +1071,8 @@ class Nt {
|
|
|
433
1071
|
this.disable();
|
|
434
1072
|
}
|
|
435
1073
|
}
|
|
436
|
-
|
|
437
|
-
class
|
|
1074
|
+
ut.enabled = !0;
|
|
1075
|
+
class Sn extends Le {
|
|
438
1076
|
el;
|
|
439
1077
|
renderer;
|
|
440
1078
|
scene;
|
|
@@ -447,14 +1085,15 @@ class Cs extends Ge {
|
|
|
447
1085
|
interactionManager;
|
|
448
1086
|
objectManager;
|
|
449
1087
|
viewerHelper;
|
|
1088
|
+
cssRenderer;
|
|
450
1089
|
frameCount = 1;
|
|
451
1090
|
frameloop = "demand";
|
|
452
1091
|
constructor({ el: e, rendererOptions: t }) {
|
|
453
|
-
super(), this.el = e, this.renderer = this._initRenderer(t), this.scene = this.createScene(), this.camera = this.createPerspectiveCamera(), this.info = new
|
|
1092
|
+
super(), this.el = e, this.renderer = this._initRenderer(t), this.scene = this.createScene(), this.camera = this.createPerspectiveCamera(), this.info = new Ps(this.el, this.renderer), this.controls = new vs(this.camera, this.renderer.domElement), this.renderPipeline = new ws(this.renderer, this.scene, this.camera), this.timer = new mt(), this.roomEnvironment = new Ss(this.renderer), this.interactionManager = new fs(this.renderer.domElement, this.scene, this.camera), this.objectManager = new ys(), this.viewerHelper = new Cs(this), this.cssRenderer = new Ts(this.el), window.addEventListener("resize", this.onWindowResize);
|
|
454
1093
|
}
|
|
455
1094
|
onWindowResize = () => {
|
|
456
1095
|
const e = this.el.clientWidth, t = this.el.clientHeight;
|
|
457
|
-
this.camera instanceof
|
|
1096
|
+
this.camera instanceof J ? (this.camera.aspect = e / t, this.camera.updateProjectionMatrix()) : this.camera instanceof V && (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();
|
|
458
1097
|
};
|
|
459
1098
|
async init() {
|
|
460
1099
|
await this.renderer.init(), this.roomEnvironment.update(), this.scene.environment = this.roomEnvironment.envMap;
|
|
@@ -463,7 +1102,7 @@ class Cs extends Ge {
|
|
|
463
1102
|
this.camera = e, this.controls.camera = e, this.interactionManager.setCamera(e), this.renderPipeline.setCamera(e), this.onWindowResize(), this.dispatchEvent({ type: "cameraChange", camera: e });
|
|
464
1103
|
}
|
|
465
1104
|
setCameraByType(e) {
|
|
466
|
-
e === "perspective" && !(this.camera instanceof
|
|
1105
|
+
e === "perspective" && !(this.camera instanceof J) ? this.setCamera(this.createPerspectiveCamera()) : e === "orthographic" && !(this.camera instanceof V) && this.setCamera(this.createOrthographicCamera());
|
|
467
1106
|
}
|
|
468
1107
|
render(e = 1) {
|
|
469
1108
|
return this.frameCount += e, new Promise((t) => {
|
|
@@ -478,28 +1117,28 @@ class Cs extends Ge {
|
|
|
478
1117
|
const t = this.timer.getDelta();
|
|
479
1118
|
this.dispatchEvent({ type: "beforeControlsUpdate", time: e, delta: t });
|
|
480
1119
|
let s = this.controls.update(t);
|
|
481
|
-
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.info.update(), this.dispatchEvent({ type: "afterRender", time: e, delta: t }));
|
|
1120
|
+
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 }));
|
|
482
1121
|
};
|
|
483
1122
|
_initRenderer(e) {
|
|
484
|
-
const t = new
|
|
1123
|
+
const t = new gt({
|
|
485
1124
|
logarithmicDepthBuffer: !0,
|
|
486
1125
|
antialias: !1,
|
|
487
1126
|
depth: !1,
|
|
488
1127
|
trackTimestamp: !0,
|
|
489
1128
|
...e
|
|
490
1129
|
});
|
|
491
|
-
return t.setSize(this.el.clientWidth, this.el.clientHeight), t.shadowMap.enabled = !0, t.shadowMap.type =
|
|
1130
|
+
return t.setSize(this.el.clientWidth, this.el.clientHeight), t.shadowMap.enabled = !0, t.shadowMap.type = ft, t.toneMapping = yt, t.toneMappingExposure = 1, t.info.autoReset = !1, t.setPixelRatio(window.devicePixelRatio), t.setAnimationLoop(this.animate), this.el.appendChild(t.domElement), t;
|
|
492
1131
|
}
|
|
493
1132
|
createScene() {
|
|
494
|
-
const e = new
|
|
495
|
-
return e.background = new
|
|
1133
|
+
const e = new Re();
|
|
1134
|
+
return e.background = new B(0), e;
|
|
496
1135
|
}
|
|
497
1136
|
createPerspectiveCamera() {
|
|
498
|
-
const e = new
|
|
1137
|
+
const e = new J(50, this.el.clientWidth / this.el.clientHeight, 0.1, 1e5);
|
|
499
1138
|
return e.position.setScalar(5), e;
|
|
500
1139
|
}
|
|
501
1140
|
createOrthographicCamera() {
|
|
502
|
-
const e = new
|
|
1141
|
+
const e = new V(
|
|
503
1142
|
-this.el.clientWidth / 2,
|
|
504
1143
|
this.el.clientWidth / 2,
|
|
505
1144
|
this.el.clientHeight / 2,
|
|
@@ -509,202 +1148,261 @@ class Cs extends Ge {
|
|
|
509
1148
|
);
|
|
510
1149
|
return e.position.setScalar(5), e;
|
|
511
1150
|
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Manually trigger a resize update.
|
|
1153
|
+
*/
|
|
1154
|
+
resize(e, t) {
|
|
1155
|
+
e !== void 0 && t !== void 0 && (this.el.style.width = `${e}px`, this.el.style.height = `${t}px`), this.onWindowResize();
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Capture a screenshot of the current render.
|
|
1159
|
+
*/
|
|
1160
|
+
async screenshot(e = {}) {
|
|
1161
|
+
const { type: t = "image/png", quality: s = 1 } = e, n = this.el.clientWidth, i = this.el.clientHeight, r = e.width && e.height;
|
|
1162
|
+
r && this.renderer.setSize(e.width, e.height), await this.render();
|
|
1163
|
+
const o = this.renderer.domElement.toDataURL(t, s);
|
|
1164
|
+
return r && (this.renderer.setSize(n, i), this.onWindowResize()), o;
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Set the scene background color, texture, or null.
|
|
1168
|
+
*/
|
|
1169
|
+
setBackground(e) {
|
|
1170
|
+
e === null ? this.scene.background = null : e instanceof B || typeof e == "number" || typeof e == "string" ? this.scene.background = new B(e) : this.scene.background = e, this.render();
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Set the scene environment map for reflections / IBL.
|
|
1174
|
+
*/
|
|
1175
|
+
setEnvironment(e) {
|
|
1176
|
+
this.scene.environment = e, this.render();
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Enable shadow rendering.
|
|
1180
|
+
*/
|
|
1181
|
+
enableShadow() {
|
|
1182
|
+
this.renderer.shadowMap.enabled = !0, this.render();
|
|
1183
|
+
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Disable shadow rendering.
|
|
1186
|
+
*/
|
|
1187
|
+
disableShadow() {
|
|
1188
|
+
this.renderer.shadowMap.enabled = !1, this.render();
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Enable linear fog.
|
|
1192
|
+
*/
|
|
1193
|
+
enableFog(e = {}) {
|
|
1194
|
+
const { color: t = 13421772, near: s = 10, far: n = 100 } = e;
|
|
1195
|
+
this.scene.fog = new wt(t, s, n), this.render();
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Enable exponential fog.
|
|
1199
|
+
*/
|
|
1200
|
+
enableFogExp2(e = {}) {
|
|
1201
|
+
const { color: t = 13421772, density: s = 0.01 } = e;
|
|
1202
|
+
this.scene.fog = new bt(t, s), this.render();
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Disable fog.
|
|
1206
|
+
*/
|
|
1207
|
+
disableFog() {
|
|
1208
|
+
this.scene.fog = null, this.render();
|
|
1209
|
+
}
|
|
512
1210
|
dispose() {
|
|
513
|
-
this.el.removeChild(this.renderer.domElement), window.removeEventListener("resize", this.onWindowResize), this.info.dispose(), this.interactionManager.dispose(), this.roomEnvironment.dispose(), this.renderPipeline.dispose(), this.renderer.dispose();
|
|
1211
|
+
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();
|
|
514
1212
|
}
|
|
515
1213
|
}
|
|
516
|
-
class
|
|
1214
|
+
class Es extends Fe {
|
|
517
1215
|
constructor(e) {
|
|
518
1216
|
super(e);
|
|
519
1217
|
}
|
|
520
1218
|
parse(e, t, s, n) {
|
|
521
|
-
if (
|
|
522
|
-
const r =
|
|
1219
|
+
if (Os(e.slice(0, 8)) === "SBMG----") {
|
|
1220
|
+
const r = As(e.slice(8));
|
|
523
1221
|
return super.parse(r, t, s, n);
|
|
524
1222
|
} else
|
|
525
1223
|
return super.parse(e, t, s, n);
|
|
526
1224
|
}
|
|
527
1225
|
}
|
|
528
|
-
function
|
|
529
|
-
return new TextDecoder().decode(new Uint8Array(
|
|
1226
|
+
function Os(l) {
|
|
1227
|
+
return new TextDecoder().decode(new Uint8Array(l));
|
|
530
1228
|
}
|
|
531
|
-
function
|
|
532
|
-
const e = new DataView(
|
|
1229
|
+
function As(l) {
|
|
1230
|
+
const e = new DataView(l);
|
|
533
1231
|
for (let t = 0; t < e.byteLength; t++) {
|
|
534
1232
|
const s = e.getUint8(t), n = (s >> 4 & 15) + (s << 4 & 240);
|
|
535
1233
|
e.setUint8(t, n);
|
|
536
1234
|
}
|
|
537
1235
|
return e.buffer;
|
|
538
1236
|
}
|
|
539
|
-
const
|
|
540
|
-
function
|
|
541
|
-
let e =
|
|
542
|
-
const t = new Uint8Array(
|
|
543
|
-
if (
|
|
544
|
-
return
|
|
545
|
-
e +=
|
|
546
|
-
const n = new Uint8Array(
|
|
1237
|
+
const Bs = 8, Ls = 130, Te = 66, Is = "SBK-----", Rs = "SBM-----", $e = new TextDecoder(), zs = new TextEncoder();
|
|
1238
|
+
function Ns(l) {
|
|
1239
|
+
let e = Bs;
|
|
1240
|
+
const t = new Uint8Array(l, 0, e);
|
|
1241
|
+
if ($e.decode(t) !== Is)
|
|
1242
|
+
return l;
|
|
1243
|
+
e += Ls;
|
|
1244
|
+
const n = new Uint8Array(l, 0, e);
|
|
547
1245
|
if (n[40] === 1) {
|
|
548
|
-
const r =
|
|
549
|
-
let
|
|
550
|
-
const
|
|
551
|
-
for (let
|
|
552
|
-
u[
|
|
553
|
-
const
|
|
554
|
-
return
|
|
1246
|
+
const r = zs.encode(Rs), o = new Uint8Array([n[41]]), a = js(n), c = Ds(a);
|
|
1247
|
+
let h = Te % c.length;
|
|
1248
|
+
const d = e + Te, p = new Uint8Array(l, d), u = new Uint8Array(p.length);
|
|
1249
|
+
for (let b = 0; b < p.length; b++)
|
|
1250
|
+
u[b] = p[b] ^ c[h], h = (h + 1) % c.length;
|
|
1251
|
+
const g = new Uint8Array(r.length + o.length + u.length);
|
|
1252
|
+
return g.set(r), g.set(o, r.length), g.set(u, r.length + o.length), g.buffer;
|
|
555
1253
|
}
|
|
556
1254
|
}
|
|
557
|
-
function
|
|
1255
|
+
function js(l) {
|
|
558
1256
|
const e = new Uint8Array(128);
|
|
559
|
-
return e.set(
|
|
1257
|
+
return e.set(l.slice(42, 74), 0), e.set(l.slice(74, 138), 32), e.set(l.slice(8, 40), 96), e;
|
|
560
1258
|
}
|
|
561
|
-
function
|
|
1259
|
+
function Ds(l) {
|
|
562
1260
|
const e = new Uint8Array(64);
|
|
563
|
-
return e.set(
|
|
1261
|
+
return e.set(l.slice(0, 8), 0), e.set(l.slice(24, 32), 8), e.set(l.slice(40, 56), 16), e.set(l.slice(64, 88), 32), e.set(l.slice(96, 104), 56), e;
|
|
564
1262
|
}
|
|
565
|
-
const
|
|
566
|
-
const s =
|
|
567
|
-
let n =
|
|
1263
|
+
const ks = (l, e, t) => {
|
|
1264
|
+
const s = l.buffer.slice(t, t + e);
|
|
1265
|
+
let n = $e.decode(s);
|
|
568
1266
|
return n = n.replace("\\", "/"), n.startsWith("Maps/") || (n = `Maps/${n}`), n;
|
|
569
|
-
},
|
|
570
|
-
const [s, n, i, r,
|
|
571
|
-
return new
|
|
572
|
-
name:
|
|
573
|
-
color: new
|
|
1267
|
+
}, Hs = (l, e, t) => {
|
|
1268
|
+
const [s, n, i, r, o] = e, a = t || r < 1;
|
|
1269
|
+
return new R({
|
|
1270
|
+
name: l,
|
|
1271
|
+
color: new B(s, n, i),
|
|
574
1272
|
opacity: r,
|
|
575
|
-
transparent:
|
|
1273
|
+
transparent: a,
|
|
576
1274
|
alphaTest: 0.01,
|
|
577
|
-
side:
|
|
1275
|
+
side: o
|
|
578
1276
|
});
|
|
579
|
-
},
|
|
580
|
-
class
|
|
1277
|
+
}, Us = (l) => l?.toLowerCase().endsWith(".png") ?? !1;
|
|
1278
|
+
class Fs {
|
|
581
1279
|
data;
|
|
582
1280
|
options;
|
|
583
1281
|
textureLoader;
|
|
584
1282
|
littleEndian = !0;
|
|
585
1283
|
materials = /* @__PURE__ */ new Map();
|
|
586
1284
|
constructor(e, t) {
|
|
587
|
-
this.data = e, this.options = t, this.textureLoader = new
|
|
1285
|
+
this.data = e, this.options = t, this.textureLoader = new je(t.manager), this.textureLoader.setCrossOrigin(t.crossOrigin), this.textureLoader.setRequestHeader(t.requestHeader);
|
|
588
1286
|
}
|
|
589
1287
|
parse(e, t) {
|
|
590
1288
|
let s = this.data;
|
|
591
|
-
const n =
|
|
1289
|
+
const n = Ns(this.data);
|
|
592
1290
|
n && (s = n);
|
|
593
1291
|
const i = new DataView(s);
|
|
594
1292
|
let r = 8;
|
|
595
|
-
const
|
|
596
|
-
r += 1,
|
|
1293
|
+
const o = i.getUint8(r);
|
|
1294
|
+
r += 1, o === 1 ? this._parseV2(i, r, e) : o === 2 ? this._parseV2(i, r, e) : o === 3 ? this._parseV3(i, r, e) : t?.(new Error(`SBMLoader: Unsupported SBM version: ${o}`));
|
|
597
1295
|
}
|
|
598
1296
|
_parseV2(e, t, s) {
|
|
599
|
-
const n = new
|
|
1297
|
+
const n = new I(), i = e.getUint16(t, this.littleEndian);
|
|
600
1298
|
t += 2;
|
|
601
1299
|
const r = e.getUint16(t, this.littleEndian);
|
|
602
1300
|
t += 2;
|
|
603
|
-
for (let
|
|
604
|
-
const
|
|
1301
|
+
for (let o = 0; o < i; ++o) {
|
|
1302
|
+
const a = e.getUint16(t, this.littleEndian).toString();
|
|
605
1303
|
t += 2, t += 4, t += 4, t += 4, t += 4;
|
|
1304
|
+
const c = e.getFloat32(t, this.littleEndian);
|
|
1305
|
+
t += 4;
|
|
606
1306
|
const h = e.getFloat32(t, this.littleEndian);
|
|
607
1307
|
t += 4;
|
|
608
|
-
const
|
|
1308
|
+
const d = e.getFloat32(t, this.littleEndian);
|
|
609
1309
|
t += 4;
|
|
610
1310
|
const p = e.getFloat32(t, this.littleEndian);
|
|
611
|
-
t += 4;
|
|
612
|
-
const g = e.getFloat32(t, this.littleEndian);
|
|
613
1311
|
t += 4, t += 4, t += 4, t += 4, t += 4;
|
|
614
1312
|
let u = e.getUint8(t);
|
|
615
|
-
t += 1, u === 0 ? u =
|
|
616
|
-
const
|
|
1313
|
+
t += 1, u === 0 ? u = xt : u === 1 ? u = St : u === 2 && (u = Ct);
|
|
1314
|
+
const g = e.getUint16(t, this.littleEndian);
|
|
617
1315
|
t += 2;
|
|
618
|
-
const
|
|
619
|
-
if (t +=
|
|
620
|
-
const
|
|
621
|
-
this.materials.set(
|
|
622
|
-
|
|
1316
|
+
const b = g > 0 ? ks(e, g, t) : "";
|
|
1317
|
+
if (t += g, !this.materials.has(a)) {
|
|
1318
|
+
const x = Hs(a, [c, h, d, p, u], Us(b));
|
|
1319
|
+
this.materials.set(a, x), b && this.options.path && this.textureLoader.load(L.resolveURL(b, this.options.path), (y) => {
|
|
1320
|
+
y.colorSpace = De, y.wrapS = ye, y.wrapT = ye, y.flipY = !1, y.anisotropy = 16, x.map = y;
|
|
623
1321
|
});
|
|
624
1322
|
}
|
|
625
1323
|
}
|
|
626
|
-
for (let
|
|
627
|
-
const
|
|
1324
|
+
for (let o = 0; o < r; ++o) {
|
|
1325
|
+
const a = e.getUint16(t, this.littleEndian).toString();
|
|
628
1326
|
t += 2;
|
|
629
|
-
const
|
|
1327
|
+
const c = e.getUint16(t, this.littleEndian).toString();
|
|
630
1328
|
t += 2;
|
|
631
|
-
const
|
|
632
|
-
if (t += 2,
|
|
633
|
-
for (let
|
|
634
|
-
const
|
|
635
|
-
|
|
1329
|
+
const h = [], d = [], p = [], u = [], g = e.getUint16(t, this.littleEndian);
|
|
1330
|
+
if (t += 2, g > 0)
|
|
1331
|
+
for (let f = 0; f < g; f++) {
|
|
1332
|
+
const v = new w();
|
|
1333
|
+
v.setX(e.getFloat32(t, this.littleEndian)), t += 4, v.setY(e.getFloat32(t, this.littleEndian)), t += 4, v.setZ(e.getFloat32(t, this.littleEndian)), t += 4, h.push(v);
|
|
636
1334
|
}
|
|
637
|
-
const
|
|
638
|
-
if (t += 2,
|
|
639
|
-
for (let
|
|
1335
|
+
const b = e.getUint16(t, this.littleEndian);
|
|
1336
|
+
if (t += 2, b > 0)
|
|
1337
|
+
for (let f = 0; f < b; f++)
|
|
640
1338
|
t += 4, t += 4, t += 4;
|
|
1339
|
+
const _ = e.getUint16(t, this.littleEndian);
|
|
1340
|
+
if (t += 2, _ > 0)
|
|
1341
|
+
for (let f = 0; f < _; f++) {
|
|
1342
|
+
const v = new S();
|
|
1343
|
+
v.setX(e.getFloat32(t, this.littleEndian)), t += 4, v.setY(e.getFloat32(t, this.littleEndian)), t += 4, d.push(v);
|
|
1344
|
+
}
|
|
641
1345
|
const x = e.getUint16(t, this.littleEndian);
|
|
642
1346
|
if (t += 2, x > 0)
|
|
643
|
-
for (let
|
|
644
|
-
const
|
|
645
|
-
y.setX(e.getFloat32(t, this.littleEndian)), t += 4, y.setY(e.getFloat32(t, this.littleEndian)), t += 4, p.push(y);
|
|
646
|
-
}
|
|
647
|
-
const b = e.getUint16(t, this.littleEndian);
|
|
648
|
-
if (t += 2, b > 0)
|
|
649
|
-
for (let m = 0; m < b; m++) {
|
|
650
|
-
const y = e.getUint16(t, this.littleEndian);
|
|
1347
|
+
for (let f = 0; f < x; f++) {
|
|
1348
|
+
const v = e.getUint16(t, this.littleEndian);
|
|
651
1349
|
t += 2;
|
|
652
|
-
const
|
|
1350
|
+
const z = e.getUint16(t, this.littleEndian);
|
|
653
1351
|
t += 2;
|
|
654
|
-
const
|
|
1352
|
+
const N = e.getUint16(t, this.littleEndian);
|
|
655
1353
|
t += 2;
|
|
656
|
-
const
|
|
657
|
-
|
|
1354
|
+
const P = [v, z, N];
|
|
1355
|
+
p.push(P), d.length > 0 && u.push([d[P[0]], d[P[1]], d[P[2]]]);
|
|
658
1356
|
}
|
|
659
|
-
const
|
|
660
|
-
for (let
|
|
661
|
-
const
|
|
662
|
-
|
|
663
|
-
let
|
|
664
|
-
const
|
|
665
|
-
|
|
1357
|
+
const y = [], M = [];
|
|
1358
|
+
for (let f = 0; f < p.length; f++) {
|
|
1359
|
+
const v = p[f], z = h[v[0]], N = h[v[1]], P = h[v[2]];
|
|
1360
|
+
y.push(...z.toArray(), ...N.toArray(), ...P.toArray());
|
|
1361
|
+
let X = new S(), W = new S(), D = new S();
|
|
1362
|
+
const k = u[f];
|
|
1363
|
+
k !== void 0 && (X = k[0], W = k[1], D = k[2]), M.push(...X.toArray(), ...W.toArray(), ...D.toArray());
|
|
666
1364
|
}
|
|
667
|
-
const
|
|
668
|
-
if (
|
|
669
|
-
const
|
|
670
|
-
|
|
1365
|
+
const E = new Float32Array(y), O = new Float32Array(M), T = new K();
|
|
1366
|
+
if (E.length > 0 && T.setAttribute("position", new we(E, 3)), O.length > 0 && T.setAttribute("uv", new we(O, 2)), T.computeVertexNormals(), this.materials.has(c)) {
|
|
1367
|
+
const f = new G(T, this.materials.get(c));
|
|
1368
|
+
f.name = a, f.castShadow = !0, f.receiveShadow = !0, n.add(f);
|
|
671
1369
|
}
|
|
672
1370
|
}
|
|
673
1371
|
s(n);
|
|
674
1372
|
}
|
|
675
1373
|
_parseV3(e, t, s) {
|
|
676
|
-
const n = new
|
|
1374
|
+
const n = new I();
|
|
677
1375
|
console.warn("SBMLoader: SBM version 3 is not supported yet."), s(n);
|
|
678
1376
|
}
|
|
679
1377
|
}
|
|
680
|
-
class
|
|
1378
|
+
class Gs extends vt {
|
|
681
1379
|
load(e, t, s, n) {
|
|
682
1380
|
let i;
|
|
683
1381
|
if (this.resourcePath !== "")
|
|
684
1382
|
i = this.resourcePath;
|
|
685
1383
|
else if (this.path !== "") {
|
|
686
|
-
const
|
|
687
|
-
i = L.resolveURL(
|
|
1384
|
+
const a = L.extractUrlBase(e);
|
|
1385
|
+
i = L.resolveURL(a, this.path);
|
|
688
1386
|
} else
|
|
689
1387
|
i = L.extractUrlBase(e);
|
|
690
1388
|
this.manager.itemStart(e);
|
|
691
|
-
const r = (
|
|
692
|
-
n ? n(
|
|
693
|
-
},
|
|
694
|
-
|
|
1389
|
+
const r = (a) => {
|
|
1390
|
+
n ? n(a) : console.error(a), this.manager.itemError(e), this.manager.itemEnd(e);
|
|
1391
|
+
}, o = new Ne(this.manager);
|
|
1392
|
+
o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(
|
|
695
1393
|
e,
|
|
696
|
-
(
|
|
1394
|
+
(a) => {
|
|
697
1395
|
try {
|
|
698
1396
|
this.parse(
|
|
699
|
-
|
|
1397
|
+
a,
|
|
700
1398
|
i,
|
|
701
|
-
(
|
|
702
|
-
t(
|
|
1399
|
+
(c) => {
|
|
1400
|
+
t(c), this.manager.itemEnd(e);
|
|
703
1401
|
},
|
|
704
1402
|
r
|
|
705
1403
|
);
|
|
706
|
-
} catch (
|
|
707
|
-
r(
|
|
1404
|
+
} catch (c) {
|
|
1405
|
+
r(c);
|
|
708
1406
|
}
|
|
709
1407
|
},
|
|
710
1408
|
s,
|
|
@@ -717,7 +1415,7 @@ class Jt extends Qe {
|
|
|
717
1415
|
n?.(new Error(`SBMLoader: Invalid SBM format: ${i}`));
|
|
718
1416
|
return;
|
|
719
1417
|
}
|
|
720
|
-
new
|
|
1418
|
+
new Fs(e, {
|
|
721
1419
|
path: t,
|
|
722
1420
|
crossOrigin: this.crossOrigin,
|
|
723
1421
|
requestHeader: this.requestHeader,
|
|
@@ -739,21 +1437,21 @@ class Jt extends Qe {
|
|
|
739
1437
|
});
|
|
740
1438
|
}
|
|
741
1439
|
}
|
|
742
|
-
class
|
|
1440
|
+
class j {
|
|
743
1441
|
static CACHE_NAME = "u-space-model-loader-cache";
|
|
744
|
-
static fileLoader = new
|
|
745
|
-
static dracoLoader = new
|
|
746
|
-
`https://cdn.jsdelivr.net/npm/three@0.${
|
|
1442
|
+
static fileLoader = new Ne().setResponseType("arraybuffer");
|
|
1443
|
+
static dracoLoader = new ls().setDecoderPath(
|
|
1444
|
+
`https://cdn.jsdelivr.net/npm/three@0.${be}.0/examples/jsm/libs/draco/`
|
|
747
1445
|
);
|
|
748
|
-
static ktx2Loader = new
|
|
749
|
-
`https://cdn.jsdelivr.net/npm/three@0.${
|
|
1446
|
+
static ktx2Loader = new ds().setTranscoderPath(
|
|
1447
|
+
`https://cdn.jsdelivr.net/npm/three@0.${be}.0/examples/jsm/libs/basis/`
|
|
750
1448
|
);
|
|
751
|
-
static gltfLoader = new
|
|
752
|
-
static sbmxLoader = new
|
|
753
|
-
static sbmLoader = new
|
|
754
|
-
static fbxLoader = new
|
|
755
|
-
static objLoader = new
|
|
756
|
-
static stlLoader = new
|
|
1449
|
+
static gltfLoader = new Fe().setDRACOLoader(j.dracoLoader).setKTX2Loader(j.ktx2Loader).setMeshoptDecoder(_e);
|
|
1450
|
+
static sbmxLoader = new Es().setDRACOLoader(j.dracoLoader).setKTX2Loader(j.ktx2Loader).setMeshoptDecoder(_e);
|
|
1451
|
+
static sbmLoader = new Gs();
|
|
1452
|
+
static fbxLoader = new as();
|
|
1453
|
+
static objLoader = new cs();
|
|
1454
|
+
static stlLoader = new hs();
|
|
757
1455
|
static setLoadingManager(e) {
|
|
758
1456
|
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;
|
|
759
1457
|
}
|
|
@@ -791,11 +1489,11 @@ class R {
|
|
|
791
1489
|
case "fbx":
|
|
792
1490
|
return this.fbxLoader.parse(n, L.extractUrlBase(e));
|
|
793
1491
|
case "obj":
|
|
794
|
-
const
|
|
795
|
-
return this.objLoader.parse(
|
|
1492
|
+
const c = new TextDecoder().decode(n);
|
|
1493
|
+
return this.objLoader.parse(c);
|
|
796
1494
|
case "stl":
|
|
797
|
-
const
|
|
798
|
-
return new
|
|
1495
|
+
const d = this.stlLoader.parse(n);
|
|
1496
|
+
return new G(d, new R());
|
|
799
1497
|
default:
|
|
800
1498
|
throw new Error(`Unsupported model format: ${s}`);
|
|
801
1499
|
}
|
|
@@ -812,10 +1510,10 @@ class R {
|
|
|
812
1510
|
}
|
|
813
1511
|
}
|
|
814
1512
|
}
|
|
815
|
-
class
|
|
816
|
-
static textureLoader = new
|
|
817
|
-
static hdrLoader = new
|
|
818
|
-
static cubeTextureLoader = new
|
|
1513
|
+
class Cn {
|
|
1514
|
+
static textureLoader = new je();
|
|
1515
|
+
static hdrLoader = new ps();
|
|
1516
|
+
static cubeTextureLoader = new _t();
|
|
819
1517
|
static setLoadingManager(e) {
|
|
820
1518
|
this.textureLoader.manager = e, this.hdrLoader.manager = e, this.cubeTextureLoader.manager = e;
|
|
821
1519
|
}
|
|
@@ -824,13 +1522,13 @@ class xs {
|
|
|
824
1522
|
}
|
|
825
1523
|
static async loadAsyncHDR(e) {
|
|
826
1524
|
const t = await this.hdrLoader.loadAsync(e);
|
|
827
|
-
return t.mapping =
|
|
1525
|
+
return t.mapping = Mt, t;
|
|
828
1526
|
}
|
|
829
1527
|
static async loadAsyncCubeTexture(e, t) {
|
|
830
1528
|
return this.cubeTextureLoader.setPath(e), await this.cubeTextureLoader.loadAsync(t);
|
|
831
1529
|
}
|
|
832
1530
|
}
|
|
833
|
-
class
|
|
1531
|
+
class $ extends G {
|
|
834
1532
|
isBaseMesh = !0;
|
|
835
1533
|
type = "BaseMesh";
|
|
836
1534
|
ignoreInvisibleWhenRaycast = !0;
|
|
@@ -841,7 +1539,7 @@ class j extends F {
|
|
|
841
1539
|
return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
|
|
842
1540
|
}
|
|
843
1541
|
}
|
|
844
|
-
class
|
|
1542
|
+
class We extends I {
|
|
845
1543
|
isBaseGroup = !0;
|
|
846
1544
|
type = "BaseGroup";
|
|
847
1545
|
ignoreInvisibleWhenRaycast = !0;
|
|
@@ -852,7 +1550,7 @@ class Ee extends Q {
|
|
|
852
1550
|
return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
|
|
853
1551
|
}
|
|
854
1552
|
}
|
|
855
|
-
class
|
|
1553
|
+
class $s extends Tt {
|
|
856
1554
|
isBaseSprite = !0;
|
|
857
1555
|
type = "BaseSprite";
|
|
858
1556
|
ignoreInvisibleWhenRaycast = !0;
|
|
@@ -863,7 +1561,7 @@ class Zt extends Ve {
|
|
|
863
1561
|
return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
|
|
864
1562
|
}
|
|
865
1563
|
}
|
|
866
|
-
class
|
|
1564
|
+
class re extends We {
|
|
867
1565
|
isModel = !0;
|
|
868
1566
|
type = "Model";
|
|
869
1567
|
static memoryCache = /* @__PURE__ */ new Map();
|
|
@@ -877,9 +1575,9 @@ class W extends Ee {
|
|
|
877
1575
|
const { url: t, cache: s = !0, persistent: n = !0 } = e;
|
|
878
1576
|
try {
|
|
879
1577
|
let i;
|
|
880
|
-
s ?
|
|
881
|
-
const r = await i,
|
|
882
|
-
return this.add(
|
|
1578
|
+
s ? re.memoryCache.has(t) ? i = re.memoryCache.get(t) : (i = j.loadAsync(t, { persistent: n }), re.memoryCache.set(t, i)) : i = j.loadAsync(t, { persistent: n });
|
|
1579
|
+
const r = await i, o = us(r);
|
|
1580
|
+
return this.add(o), o.animations && o.animations.length > 0 && (this.animations = o.animations, this.mixer = new Pt(o)), o;
|
|
883
1581
|
} catch (i) {
|
|
884
1582
|
return console.error(`[Model] Failed to load model from ${t}:`, i), null;
|
|
885
1583
|
}
|
|
@@ -887,11 +1585,11 @@ class W extends Ee {
|
|
|
887
1585
|
playAnimation(e, t = {}) {
|
|
888
1586
|
if (!this.mixer || this.animations.length === 0) return null;
|
|
889
1587
|
const { loop: s = !0, repetitions: n = 1 / 0, timeScale: i = 1, clampWhenFinished: r = !1 } = t;
|
|
890
|
-
let
|
|
891
|
-
if (e === void 0 ?
|
|
1588
|
+
let o;
|
|
1589
|
+
if (e === void 0 ? o = this.animations[0] : typeof e == "number" ? o = this.animations[e] : o = this.animations.find((c) => c.name === e), !o)
|
|
892
1590
|
return console.warn(`[Model] Animation not found: ${e}`), null;
|
|
893
|
-
let
|
|
894
|
-
return
|
|
1591
|
+
let a = this.actions.get(o.name);
|
|
1592
|
+
return a || (a = this.mixer.clipAction(o), this.actions.set(o.name, a)), a.setLoop(s ? Et : Ot, n), a.clampWhenFinished = r, a.timeScale = i, a.reset().play(), a;
|
|
895
1593
|
}
|
|
896
1594
|
playAllAnimations(e = {}) {
|
|
897
1595
|
return this.animations.map((t, s) => this.playAnimation(s, e)).filter((t) => t !== null);
|
|
@@ -908,6 +1606,27 @@ class W extends Ee {
|
|
|
908
1606
|
updateAnimation(e) {
|
|
909
1607
|
this.mixer?.update(e);
|
|
910
1608
|
}
|
|
1609
|
+
/**
|
|
1610
|
+
* Get the axis-aligned bounding box of this model.
|
|
1611
|
+
*/
|
|
1612
|
+
getBoundingBox() {
|
|
1613
|
+
return new q().setFromObject(this);
|
|
1614
|
+
}
|
|
1615
|
+
/**
|
|
1616
|
+
* Get the center point of this model's bounding box.
|
|
1617
|
+
*/
|
|
1618
|
+
getCenter() {
|
|
1619
|
+
const e = new w();
|
|
1620
|
+
return this.getBoundingBox().getCenter(e), e;
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Set the material for all meshes in this model.
|
|
1624
|
+
*/
|
|
1625
|
+
setMaterial(e) {
|
|
1626
|
+
this.traverse((t) => {
|
|
1627
|
+
t instanceof G && (t.material = e);
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
911
1630
|
static clearMemoryCache() {
|
|
912
1631
|
this.memoryCache.clear();
|
|
913
1632
|
}
|
|
@@ -915,11 +1634,11 @@ class W extends Ee {
|
|
|
915
1634
|
typeof caches < "u" && await caches.delete("u-space-loader-cache");
|
|
916
1635
|
}
|
|
917
1636
|
}
|
|
918
|
-
class
|
|
1637
|
+
class Ws extends $ {
|
|
919
1638
|
isSphereMesh = !0;
|
|
920
1639
|
type = "SphereMesh";
|
|
921
1640
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
922
|
-
super(), this.geometry = new
|
|
1641
|
+
super(), this.geometry = new At(
|
|
923
1642
|
e?.radius,
|
|
924
1643
|
e?.widthSegments,
|
|
925
1644
|
e?.heightSegments,
|
|
@@ -927,23 +1646,23 @@ class Vt extends j {
|
|
|
927
1646
|
e?.phiLength,
|
|
928
1647
|
e?.thetaStart,
|
|
929
1648
|
e?.thetaLength
|
|
930
|
-
), this.material = new
|
|
1649
|
+
), this.material = new R(t);
|
|
931
1650
|
}
|
|
932
1651
|
}
|
|
933
|
-
class
|
|
1652
|
+
class Pe extends $ {
|
|
934
1653
|
isTubeMesh = !0;
|
|
935
1654
|
type = "TubeMesh";
|
|
936
1655
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
937
|
-
super(), this.geometry = new
|
|
1656
|
+
super(), this.geometry = new Bt(
|
|
938
1657
|
e?.path,
|
|
939
1658
|
e?.tubularSegments,
|
|
940
1659
|
e?.radius,
|
|
941
1660
|
e?.radialSegments,
|
|
942
1661
|
e?.closed
|
|
943
|
-
), this.material = new
|
|
1662
|
+
), this.material = new R(t);
|
|
944
1663
|
}
|
|
945
1664
|
}
|
|
946
|
-
class
|
|
1665
|
+
class _n extends We {
|
|
947
1666
|
isTopology = !0;
|
|
948
1667
|
type = "Topology";
|
|
949
1668
|
// Visuals
|
|
@@ -994,8 +1713,8 @@ class Ms extends Ee {
|
|
|
994
1713
|
console.error(`[Topology] Cannot add edge. One or both nodes not found: ${e}, ${t}`);
|
|
995
1714
|
return;
|
|
996
1715
|
}
|
|
997
|
-
const
|
|
998
|
-
this.getNeighbors(e)?.set(t,
|
|
1716
|
+
const o = s ?? i.distanceTo(r);
|
|
1717
|
+
this.getNeighbors(e)?.set(t, o), n && this.getNeighbors(t)?.set(e, o);
|
|
999
1718
|
}
|
|
1000
1719
|
/**
|
|
1001
1720
|
* Remove an edge between two nodes.
|
|
@@ -1013,32 +1732,32 @@ class Ms extends Ee {
|
|
|
1013
1732
|
if (!this.nodes.has(e) || !this.nodes.has(t))
|
|
1014
1733
|
return console.warn("[Topology] Start or End node not found."), [];
|
|
1015
1734
|
const s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
1016
|
-
for (const [
|
|
1017
|
-
s.set(
|
|
1735
|
+
for (const [a] of this.nodes)
|
|
1736
|
+
s.set(a, 1 / 0), n.set(a, null), i.add(a);
|
|
1018
1737
|
for (s.set(e, 0); i.size > 0; ) {
|
|
1019
|
-
let
|
|
1020
|
-
for (const
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1738
|
+
let a = null, c = 1 / 0;
|
|
1739
|
+
for (const d of i) {
|
|
1740
|
+
const p = s.get(d);
|
|
1741
|
+
p < c && (c = p, a = d);
|
|
1023
1742
|
}
|
|
1024
|
-
if (
|
|
1743
|
+
if (a === null || a === t || c === 1 / 0)
|
|
1025
1744
|
break;
|
|
1026
|
-
i.delete(
|
|
1027
|
-
const
|
|
1028
|
-
if (
|
|
1029
|
-
for (const [
|
|
1030
|
-
if (!i.has(
|
|
1031
|
-
const u = s.get(
|
|
1032
|
-
u < s.get(
|
|
1745
|
+
i.delete(a);
|
|
1746
|
+
const h = this.adjacencyMap?.get(a);
|
|
1747
|
+
if (h)
|
|
1748
|
+
for (const [d, p] of h) {
|
|
1749
|
+
if (!i.has(d)) continue;
|
|
1750
|
+
const u = s.get(a) + p;
|
|
1751
|
+
u < s.get(d) && (s.set(d, u), n.set(d, a));
|
|
1033
1752
|
}
|
|
1034
1753
|
}
|
|
1035
1754
|
const r = [];
|
|
1036
|
-
let
|
|
1755
|
+
let o = t;
|
|
1037
1756
|
if (n.get(t) === null && e !== t)
|
|
1038
1757
|
return [];
|
|
1039
|
-
for (;
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1758
|
+
for (; o !== null; ) {
|
|
1759
|
+
const a = this.nodes.get(o);
|
|
1760
|
+
a && r.unshift(a), o = n.get(o) || null;
|
|
1042
1761
|
}
|
|
1043
1762
|
return r;
|
|
1044
1763
|
}
|
|
@@ -1046,8 +1765,8 @@ class Ms extends Ee {
|
|
|
1046
1765
|
* Renders the entire topology graph structure using TubeGeometry and Spheres.
|
|
1047
1766
|
*/
|
|
1048
1767
|
renderGraph() {
|
|
1049
|
-
this.clearGraph(), this.graphGroup = new
|
|
1050
|
-
const e = new
|
|
1768
|
+
this.clearGraph(), this.graphGroup = new I();
|
|
1769
|
+
const e = new Ws({
|
|
1051
1770
|
geometryParameters: {
|
|
1052
1771
|
radius: this.parameters.nodeRadius,
|
|
1053
1772
|
widthSegments: 16,
|
|
@@ -1064,14 +1783,14 @@ class Ms extends Ee {
|
|
|
1064
1783
|
const t = /* @__PURE__ */ new Set();
|
|
1065
1784
|
this.adjacencyMap.forEach((s, n) => {
|
|
1066
1785
|
s.forEach((i, r) => {
|
|
1067
|
-
const
|
|
1068
|
-
if (t.has(
|
|
1069
|
-
t.add(
|
|
1070
|
-
const
|
|
1071
|
-
if (
|
|
1072
|
-
const
|
|
1786
|
+
const o = [n, r].sort().join("-");
|
|
1787
|
+
if (t.has(o)) return;
|
|
1788
|
+
t.add(o);
|
|
1789
|
+
const a = this.nodes.get(n), c = this.nodes.get(r);
|
|
1790
|
+
if (a && c) {
|
|
1791
|
+
const h = new Lt(a, c), d = new Pe({
|
|
1073
1792
|
geometryParameters: {
|
|
1074
|
-
path:
|
|
1793
|
+
path: h,
|
|
1075
1794
|
tubularSegments: 1,
|
|
1076
1795
|
radius: this.parameters.edgeRadius,
|
|
1077
1796
|
radialSegments: 8,
|
|
@@ -1081,14 +1800,14 @@ class Ms extends Ee {
|
|
|
1081
1800
|
color: this.parameters.edgeColor
|
|
1082
1801
|
}
|
|
1083
1802
|
});
|
|
1084
|
-
Object.assign(
|
|
1803
|
+
Object.assign(d.userData, { from: n, to: r, weight: i, type: "edge" }), this.graphGroup.add(d);
|
|
1085
1804
|
}
|
|
1086
1805
|
});
|
|
1087
1806
|
}), this.add(this.graphGroup);
|
|
1088
1807
|
}
|
|
1089
1808
|
clearGraph() {
|
|
1090
1809
|
this.graphGroup && (this.remove(this.graphGroup), this.graphGroup.traverse((e) => {
|
|
1091
|
-
e instanceof
|
|
1810
|
+
e instanceof G && (e.geometry.dispose(), e.material.dispose());
|
|
1092
1811
|
}), this.graphGroup = null);
|
|
1093
1812
|
}
|
|
1094
1813
|
/**
|
|
@@ -1096,7 +1815,7 @@ class Ms extends Ee {
|
|
|
1096
1815
|
*/
|
|
1097
1816
|
renderPath(e, t = this.parameters.pathColor) {
|
|
1098
1817
|
if (e.length < 2) return;
|
|
1099
|
-
const s = new
|
|
1818
|
+
const s = new It(e, !1, "catmullrom", 0), n = new Pe({
|
|
1100
1819
|
geometryParameters: {
|
|
1101
1820
|
path: s,
|
|
1102
1821
|
tubularSegments: e.length * 10,
|
|
@@ -1122,9 +1841,9 @@ class Ms extends Ee {
|
|
|
1122
1841
|
});
|
|
1123
1842
|
const t = [], s = /* @__PURE__ */ new Set();
|
|
1124
1843
|
return this.adjacencyMap.forEach((n, i) => {
|
|
1125
|
-
n.forEach((r,
|
|
1126
|
-
const
|
|
1127
|
-
s.has(
|
|
1844
|
+
n.forEach((r, o) => {
|
|
1845
|
+
const a = [i, o].sort().join("-");
|
|
1846
|
+
s.has(a) || (s.add(a), t.push({ from: i, to: o, weight: r }));
|
|
1128
1847
|
});
|
|
1129
1848
|
}), { nodes: e, edges: t };
|
|
1130
1849
|
}
|
|
@@ -1134,7 +1853,7 @@ class Ms extends Ee {
|
|
|
1134
1853
|
*/
|
|
1135
1854
|
importData(e) {
|
|
1136
1855
|
this.clearGraph(), this.clearPaths(), this.nodes.clear(), this.adjacencyMap.clear(), Object.entries(e.nodes).forEach(([t, s]) => {
|
|
1137
|
-
this.addNode(t, new
|
|
1856
|
+
this.addNode(t, new w(s.x, s.y, s.z));
|
|
1138
1857
|
}), e.edges.forEach(({ from: t, to: s, weight: n }) => {
|
|
1139
1858
|
this.addEdge(t, s, n);
|
|
1140
1859
|
}), this.renderGraph();
|
|
@@ -1146,7 +1865,7 @@ class Ms extends Ee {
|
|
|
1146
1865
|
return this.adjacencyMap.get(e);
|
|
1147
1866
|
}
|
|
1148
1867
|
}
|
|
1149
|
-
class
|
|
1868
|
+
class Mn extends $s {
|
|
1150
1869
|
isPoi = !0;
|
|
1151
1870
|
type = "Poi";
|
|
1152
1871
|
parameters = {
|
|
@@ -1165,7 +1884,7 @@ class Es extends Zt {
|
|
|
1165
1884
|
_canvas = document.createElement("canvas");
|
|
1166
1885
|
_lastParametersJSON = "";
|
|
1167
1886
|
constructor(e = {}) {
|
|
1168
|
-
super(new
|
|
1887
|
+
super(new Rt()), Object.assign(this.parameters, e), this.updateAsync();
|
|
1169
1888
|
}
|
|
1170
1889
|
/**
|
|
1171
1890
|
* Update the POI with new parameters
|
|
@@ -1181,33 +1900,33 @@ class Es extends Zt {
|
|
|
1181
1900
|
n.font = `${this.parameters.fontSize}px ${this.parameters.fontFamily}`;
|
|
1182
1901
|
let i = null;
|
|
1183
1902
|
this.parameters.img && (i = await this._loadImage(this.parameters.img));
|
|
1184
|
-
const { text: r, fontSize:
|
|
1185
|
-
let
|
|
1186
|
-
const
|
|
1187
|
-
if (
|
|
1903
|
+
const { text: r, fontSize: o, color: a, iconSize: c, padding: h, backgroundColor: d, borderRadius: p, textPosition: u, scaleFactor: g } = this.parameters, b = n.measureText(r), _ = r ? b.width : 0, x = r ? o : 0;
|
|
1904
|
+
let y = 0, M = 0, E = 0, O = 0, T = 0, f = 0;
|
|
1905
|
+
const v = !!i, z = !!r;
|
|
1906
|
+
if (v && z)
|
|
1188
1907
|
switch (u) {
|
|
1189
1908
|
case "top":
|
|
1190
|
-
|
|
1909
|
+
y = Math.max(c, _), M = c + h + x, T = (y - _) / 2, f = x / 2, E = (y - c) / 2, O = x + h;
|
|
1191
1910
|
break;
|
|
1192
1911
|
case "bottom":
|
|
1193
|
-
|
|
1912
|
+
y = Math.max(c, _), M = c + h + x, E = (y - c) / 2, O = 0, T = (y - _) / 2, f = c + h + x / 2;
|
|
1194
1913
|
break;
|
|
1195
1914
|
case "left":
|
|
1196
|
-
|
|
1915
|
+
y = c + h + _, M = Math.max(c, x), T = 0, f = M / 2, E = _ + h, O = (M - c) / 2;
|
|
1197
1916
|
break;
|
|
1198
1917
|
default:
|
|
1199
|
-
|
|
1918
|
+
y = c + h + _, M = Math.max(c, x), E = 0, O = (M - c) / 2, T = c + h, f = M / 2;
|
|
1200
1919
|
break;
|
|
1201
1920
|
}
|
|
1202
|
-
else
|
|
1203
|
-
const
|
|
1204
|
-
if (s.width =
|
|
1205
|
-
n.fillStyle =
|
|
1206
|
-
const
|
|
1207
|
-
n.textBaseline = "alphabetic", n.fillText(r,
|
|
1921
|
+
else v ? (y = c, M = c, E = 0, O = 0) : z && (y = _, M = x, T = 0, f = x / 2);
|
|
1922
|
+
const N = y + h * 2, P = M + h * 2;
|
|
1923
|
+
if (s.width = N, s.height = P, n.font = `${o}px ${this.parameters.fontFamily}`, d && (n.fillStyle = d, this._drawRoundedRect(n, 0, 0, N, P, p), n.fill()), v && n.drawImage(i, E + h, O + h, c, c), z) {
|
|
1924
|
+
n.fillStyle = a;
|
|
1925
|
+
const D = n.measureText(r), k = D.actualBoundingBoxAscent + D.actualBoundingBoxDescent, et = D.actualBoundingBoxAscent - k / 2;
|
|
1926
|
+
n.textBaseline = "alphabetic", n.fillText(r, T + h, f + h + et);
|
|
1208
1927
|
}
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1928
|
+
const X = this.material.map, W = new zt(s);
|
|
1929
|
+
W.colorSpace = De, this.material.map = W, X?.dispose(), this.scale.set(N * g, P * g, 1);
|
|
1211
1930
|
}
|
|
1212
1931
|
_loadImage(e) {
|
|
1213
1932
|
return new Promise((t, s) => {
|
|
@@ -1225,80 +1944,80 @@ class Es extends Zt {
|
|
|
1225
1944
|
this.material.map?.dispose(), this.material.dispose();
|
|
1226
1945
|
}
|
|
1227
1946
|
}
|
|
1228
|
-
class
|
|
1947
|
+
class Ke extends $ {
|
|
1229
1948
|
isShapeMesh = !0;
|
|
1230
1949
|
type = "ShapeMesh";
|
|
1231
1950
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1232
|
-
super(), this.geometry = new
|
|
1951
|
+
super(), this.geometry = new Nt(e?.shape, e?.curveSegments), this.material = new R(t), this.geometry.rotateX(-Math.PI / 2);
|
|
1233
1952
|
}
|
|
1234
1953
|
static createFromPoints(e, t = {}) {
|
|
1235
|
-
return new
|
|
1954
|
+
return new Ke({
|
|
1236
1955
|
...t,
|
|
1237
1956
|
geometryParameters: {
|
|
1238
1957
|
...t.geometryParameters,
|
|
1239
|
-
shape: new
|
|
1958
|
+
shape: new ke(e.map((s) => new S(s.x, -s.z)))
|
|
1240
1959
|
}
|
|
1241
1960
|
});
|
|
1242
1961
|
}
|
|
1243
1962
|
}
|
|
1244
|
-
class
|
|
1963
|
+
class Qe extends $ {
|
|
1245
1964
|
isExtrudeMesh = !0;
|
|
1246
1965
|
type = "ExtrudeMesh";
|
|
1247
1966
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1248
|
-
super(), this.geometry = new
|
|
1967
|
+
super(), this.geometry = new jt(e?.shape, e?.options), this.material = new R(t), this.geometry.rotateX(-Math.PI / 2);
|
|
1249
1968
|
}
|
|
1250
1969
|
static createFromPoints(e, t = {}) {
|
|
1251
|
-
return new
|
|
1970
|
+
return new Qe({
|
|
1252
1971
|
...t,
|
|
1253
1972
|
geometryParameters: {
|
|
1254
1973
|
...t.geometryParameters,
|
|
1255
|
-
shape: new
|
|
1974
|
+
shape: new ke(e.map((s) => new S(s.x, -s.z)))
|
|
1256
1975
|
}
|
|
1257
1976
|
});
|
|
1258
1977
|
}
|
|
1259
1978
|
}
|
|
1260
|
-
class
|
|
1979
|
+
class Tn extends $ {
|
|
1261
1980
|
isPlaneMesh = !0;
|
|
1262
1981
|
type = "PlaneMesh";
|
|
1263
1982
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1264
|
-
super(), this.geometry = new
|
|
1983
|
+
super(), this.geometry = new Dt(
|
|
1265
1984
|
e?.width,
|
|
1266
1985
|
e?.height,
|
|
1267
1986
|
e?.widthSegments,
|
|
1268
1987
|
e?.heightSegments
|
|
1269
|
-
), this.material = new
|
|
1988
|
+
), this.material = new R(t);
|
|
1270
1989
|
}
|
|
1271
1990
|
}
|
|
1272
|
-
class
|
|
1991
|
+
class Pn extends $ {
|
|
1273
1992
|
isCircleMesh = !0;
|
|
1274
1993
|
type = "CircleMesh";
|
|
1275
1994
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1276
1995
|
super(
|
|
1277
|
-
new
|
|
1996
|
+
new kt(
|
|
1278
1997
|
e?.radius,
|
|
1279
1998
|
e?.segments,
|
|
1280
1999
|
e?.thetaStart,
|
|
1281
2000
|
e?.thetaLength
|
|
1282
2001
|
),
|
|
1283
|
-
new
|
|
2002
|
+
new R(t)
|
|
1284
2003
|
), this.geometry.rotateX(-Math.PI / 2);
|
|
1285
2004
|
}
|
|
1286
2005
|
}
|
|
1287
|
-
class
|
|
2006
|
+
class F {
|
|
1288
2007
|
static traverseMeshes(e, t) {
|
|
1289
2008
|
e.traverse((s) => {
|
|
1290
|
-
s instanceof
|
|
2009
|
+
s instanceof G && t(s);
|
|
1291
2010
|
});
|
|
1292
2011
|
}
|
|
1293
2012
|
}
|
|
1294
|
-
class
|
|
2013
|
+
class En {
|
|
1295
2014
|
static flow(e = {}) {
|
|
1296
|
-
const { baseColor: t = 16777215, flowColor: s = 65280, speed: n = 1, scale: i = 3, intensity: r = 4 } = e,
|
|
1297
|
-
return
|
|
2015
|
+
const { baseColor: t = 16777215, flowColor: s = 65280, speed: n = 1, scale: i = 3, intensity: r = 4 } = e, o = H(new U(t)), a = H(new U(s)), c = xe().x.mul(i).sub(te.mul(n)), h = se(pe(c).add(1).mul(0.5), r);
|
|
2016
|
+
return ne(o, a, h);
|
|
1298
2017
|
}
|
|
1299
2018
|
static breathe(e = {}) {
|
|
1300
|
-
const { baseColor: t = 16777215, breathColor: s = 65280, speed: n = 1, intensity: i = 2 } = e, r =
|
|
1301
|
-
return
|
|
2019
|
+
const { baseColor: t = 16777215, breathColor: s = 65280, speed: n = 1, intensity: i = 2 } = e, r = H(new U(t)), o = H(new U(s)), a = pe(te.mul(n)).add(1).mul(0.5), c = se(a, i);
|
|
2020
|
+
return ne(r, o, c);
|
|
1302
2021
|
}
|
|
1303
2022
|
static fluid(e = {}) {
|
|
1304
2023
|
const {
|
|
@@ -1307,43 +2026,149 @@ class Ss {
|
|
|
1307
2026
|
speed: n = 1,
|
|
1308
2027
|
scale: i = 1,
|
|
1309
2028
|
intensity: r = 1,
|
|
1310
|
-
distortion:
|
|
1311
|
-
} = e,
|
|
1312
|
-
return
|
|
2029
|
+
distortion: o = 0.5
|
|
2030
|
+
} = e, a = H(new U(t)), c = H(new U(s)), h = xe().mul(i), d = te.mul(n), p = Se(h.add(d), 1, 0), u = h.add(p.mul(o)), g = Se(u, 1, 0).add(1).mul(0.5), b = se(g, r);
|
|
2031
|
+
return ne(a, c, b);
|
|
1313
2032
|
}
|
|
1314
2033
|
}
|
|
1315
|
-
function
|
|
2034
|
+
function On(l) {
|
|
1316
2035
|
}
|
|
1317
|
-
const
|
|
1318
|
-
const
|
|
1319
|
-
return
|
|
1320
|
-
})(),
|
|
1321
|
-
const
|
|
1322
|
-
return
|
|
2036
|
+
const he = "uSpaceHighlight", Q = `${he}/enabled`, qe = `${he}/opacity`, Xe = `${he}/color`, Ye = `${he}/overwrite`, le = "uSpaceBreathe", ae = `${le}/enabled`, Je = `${le}/color`, Ve = `${le}/speed`, Ze = `${le}/intensity`, ce = /* @__PURE__ */ new WeakMap(), Ks = He(() => {
|
|
2037
|
+
const l = A(Q, "uint"), e = A(Xe, "uint"), t = A(Ye, "uint"), s = Ae(e), n = Ce.mul(s), i = ie(t.greaterThan(0), s, n), r = ie(l.greaterThan(0), i, Ce), o = A(ae, "uint"), a = A(Je, "uint"), c = A(Ve, "float"), h = A(Ze, "float"), d = Ae(a), p = pe(te.mul(c)).add(1).mul(0.5), u = se(p, h), g = ne(r, d, u);
|
|
2038
|
+
return ie(o.greaterThan(0), g, r);
|
|
2039
|
+
})(), Qs = He(() => {
|
|
2040
|
+
const l = A(Q, "uint"), e = A(qe, "float");
|
|
2041
|
+
return ie(l.greaterThan(0), e, Xt);
|
|
1323
2042
|
})();
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
2043
|
+
function Ee(l) {
|
|
2044
|
+
const e = l.material;
|
|
2045
|
+
if (!e || Array.isArray(e)) return;
|
|
2046
|
+
let t = ce.get(e);
|
|
2047
|
+
t || (t = {
|
|
2048
|
+
colorNode: e.colorNode,
|
|
2049
|
+
opacityNode: e.opacityNode,
|
|
2050
|
+
transparent: e.transparent,
|
|
2051
|
+
depthWrite: e.depthWrite,
|
|
2052
|
+
activeMeshes: /* @__PURE__ */ new Set()
|
|
2053
|
+
}, ce.set(e, t)), t.activeMeshes.add(l), e.transparent = !0, e.colorNode = Ks, e.opacityNode = Qs, e.needsUpdate = !0;
|
|
2054
|
+
}
|
|
2055
|
+
function Oe(l) {
|
|
2056
|
+
const e = l.userData[Q], t = l.userData[ae];
|
|
2057
|
+
if (e || t) return;
|
|
2058
|
+
const s = l.material;
|
|
2059
|
+
if (!s || Array.isArray(s)) return;
|
|
2060
|
+
const n = ce.get(s);
|
|
2061
|
+
n && (n.activeMeshes.delete(l), !(n.activeMeshes.size > 0) && (s.colorNode = n.colorNode, s.opacityNode = n.opacityNode, s.transparent = n.transparent, s.depthWrite = n.depthWrite, s.needsUpdate = !0, ce.delete(s)));
|
|
2062
|
+
}
|
|
2063
|
+
class oe {
|
|
2064
|
+
static highlightColor(e, t = {}) {
|
|
2065
|
+
const s = Array.isArray(e) ? e : [e], { opacity: n = 0.5, color: i = 16711680, overwrite: r = !1, depthWrite: o } = t, a = new B(i).getHex();
|
|
2066
|
+
for (const c of s)
|
|
2067
|
+
F.traverseMeshes(c, (h) => {
|
|
2068
|
+
if (h.userData[Q] = 1, h.userData[qe] = n, h.userData[Xe] = a, h.userData[Ye] = r ? 1 : 0, Ee(h), o !== void 0) {
|
|
2069
|
+
const d = h.material;
|
|
2070
|
+
d && !Array.isArray(d) && (d.depthWrite = o);
|
|
2071
|
+
}
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2074
|
+
static removeHighlightColor(e) {
|
|
2075
|
+
const t = Array.isArray(e) ? e : [e];
|
|
2076
|
+
for (const s of t)
|
|
2077
|
+
F.traverseMeshes(s, (n) => {
|
|
2078
|
+
n.userData[Q] = 0, Oe(n);
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
static breatheColor(e, t = {}) {
|
|
2082
|
+
const s = Array.isArray(e) ? e : [e], n = Object.assign(
|
|
1327
2083
|
{
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
overwrite: !1
|
|
2084
|
+
color: 65280,
|
|
2085
|
+
speed: 1,
|
|
2086
|
+
intensity: 2
|
|
1332
2087
|
},
|
|
1333
2088
|
t
|
|
1334
2089
|
);
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
2090
|
+
n.color = new B(n.color).getHex();
|
|
2091
|
+
for (const i of s)
|
|
2092
|
+
F.traverseMeshes(i, (r) => {
|
|
2093
|
+
r.userData[ae] = 1, r.userData[Je] = n.color, r.userData[Ve] = n.speed, r.userData[Ze] = n.intensity, Ee(r);
|
|
2094
|
+
});
|
|
2095
|
+
}
|
|
2096
|
+
static removeBreatheColor(e) {
|
|
2097
|
+
const t = Array.isArray(e) ? e : [e];
|
|
2098
|
+
for (const s of t)
|
|
2099
|
+
F.traverseMeshes(s, (n) => {
|
|
2100
|
+
n.userData[ae] = 0, Oe(n);
|
|
2101
|
+
});
|
|
2102
|
+
}
|
|
2103
|
+
/**
|
|
2104
|
+
* Enable wireframe mode on object(s).
|
|
2105
|
+
*/
|
|
2106
|
+
static wireframe(e, t = !0) {
|
|
2107
|
+
const s = Array.isArray(e) ? e : [e];
|
|
2108
|
+
for (const n of s)
|
|
2109
|
+
F.traverseMeshes(n, (i) => {
|
|
2110
|
+
const r = i.material;
|
|
2111
|
+
!r || Array.isArray(r) || (r.wireframe = t, r.needsUpdate = !0);
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
/**
|
|
2115
|
+
* Remove wireframe mode.
|
|
2116
|
+
*/
|
|
2117
|
+
static removeWireframe(e) {
|
|
2118
|
+
oe.wireframe(e, !1);
|
|
2119
|
+
}
|
|
2120
|
+
/**
|
|
2121
|
+
* Fade in object(s) from fully transparent to original opacity.
|
|
2122
|
+
* Returns a promise that resolves when animation is complete.
|
|
2123
|
+
*/
|
|
2124
|
+
static fadeIn(e, t = {}) {
|
|
2125
|
+
const { duration: s = 500 } = t;
|
|
2126
|
+
return oe._fade(e, 0, 1, s);
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* Fade out object(s) to fully transparent.
|
|
2130
|
+
* Returns a promise that resolves when animation is complete.
|
|
2131
|
+
*/
|
|
2132
|
+
static fadeOut(e, t = {}) {
|
|
2133
|
+
const { duration: s = 500 } = t;
|
|
2134
|
+
return oe._fade(e, 1, 0, s);
|
|
2135
|
+
}
|
|
2136
|
+
static _fade(e, t, s, n) {
|
|
2137
|
+
const i = Array.isArray(e) ? e : [e], r = [];
|
|
2138
|
+
for (const o of i)
|
|
2139
|
+
F.traverseMeshes(o, (a) => {
|
|
2140
|
+
const c = a.material;
|
|
2141
|
+
!c || Array.isArray(c) || (c.transparent = !0, c.opacity = t, c.needsUpdate = !0, r.push({ material: c, targetOpacity: s }));
|
|
2142
|
+
});
|
|
2143
|
+
return r.length === 0 ? Promise.resolve() : new Promise((o) => {
|
|
2144
|
+
const a = performance.now();
|
|
2145
|
+
let c = 0;
|
|
2146
|
+
const h = () => {
|
|
2147
|
+
const d = performance.now() - a, p = Math.min(d / n, 1);
|
|
2148
|
+
if (!i[0].parent) {
|
|
2149
|
+
cancelAnimationFrame(c), o();
|
|
2150
|
+
return;
|
|
2151
|
+
}
|
|
2152
|
+
for (const { material: g, targetOpacity: b } of r)
|
|
2153
|
+
g.opacity = t + (b - t) * p, g.needsUpdate = !0;
|
|
2154
|
+
if (p < 1)
|
|
2155
|
+
c = requestAnimationFrame(h);
|
|
2156
|
+
else {
|
|
2157
|
+
if (s >= 1)
|
|
2158
|
+
for (const { material: g } of r)
|
|
2159
|
+
g.transparent = !1;
|
|
2160
|
+
o();
|
|
2161
|
+
}
|
|
2162
|
+
};
|
|
2163
|
+
c = requestAnimationFrame(h);
|
|
1339
2164
|
});
|
|
1340
2165
|
}
|
|
1341
2166
|
}
|
|
1342
|
-
const
|
|
1343
|
-
const e =
|
|
1344
|
-
return
|
|
2167
|
+
const Ae = (l) => {
|
|
2168
|
+
const e = l.shiftRight(16).bitAnd(255).toFloat().div(255), t = l.shiftRight(8).bitAnd(255).toFloat().div(255), s = l.bitAnd(255).toFloat().div(255);
|
|
2169
|
+
return Yt(e, t, s);
|
|
1345
2170
|
};
|
|
1346
|
-
class
|
|
2171
|
+
class qs extends ms {
|
|
1347
2172
|
viewer;
|
|
1348
2173
|
constructor(e, t) {
|
|
1349
2174
|
super(t), this.viewer = e;
|
|
@@ -1352,7 +2177,7 @@ class is extends Et {
|
|
|
1352
2177
|
this.update(e) && this.viewer.render();
|
|
1353
2178
|
};
|
|
1354
2179
|
easingByMode(e) {
|
|
1355
|
-
const t =
|
|
2180
|
+
const t = Xs[e];
|
|
1356
2181
|
return super.easing(t);
|
|
1357
2182
|
}
|
|
1358
2183
|
start(e, t) {
|
|
@@ -1362,80 +2187,500 @@ class is extends Et {
|
|
|
1362
2187
|
return this.viewer.removeEventListener("afterControlsUpdate", this._update), super.stop();
|
|
1363
2188
|
}
|
|
1364
2189
|
}
|
|
1365
|
-
function
|
|
1366
|
-
return new Promise((r,
|
|
1367
|
-
const { duration:
|
|
1368
|
-
n?.(
|
|
2190
|
+
function An(l, e, t, s = {}, n, i) {
|
|
2191
|
+
return new Promise((r, o) => {
|
|
2192
|
+
const { duration: a = 1e3, delay: c = 0, repeat: h = !1, mode: d = "Linear.None", yoyo: p = !1 } = s, u = new qs(l, e).to(t, a).easingByMode(d).delay(c).onUpdate((g) => {
|
|
2193
|
+
n?.(g, u);
|
|
1369
2194
|
}).onComplete(() => {
|
|
1370
2195
|
r();
|
|
1371
2196
|
}).onStop(() => {
|
|
1372
|
-
|
|
2197
|
+
o("animation stop");
|
|
1373
2198
|
}).onStart(() => {
|
|
1374
2199
|
i?.(u);
|
|
1375
2200
|
});
|
|
1376
|
-
typeof
|
|
2201
|
+
typeof h == "number" ? u.repeat(h) : typeof h == "boolean" && h && u.repeat(1 / 0), p && u.repeatDelay(20), u.yoyo(p), u.start();
|
|
1377
2202
|
});
|
|
1378
2203
|
}
|
|
1379
|
-
const
|
|
1380
|
-
"Linear.None":
|
|
1381
|
-
"Quadratic.In":
|
|
1382
|
-
"Quadratic.Out":
|
|
1383
|
-
"Quadratic.InOut":
|
|
1384
|
-
"Cubic.In":
|
|
1385
|
-
"Cubic.Out":
|
|
1386
|
-
"Cubic.InOut":
|
|
1387
|
-
"Quartic.In":
|
|
1388
|
-
"Quartic.Out":
|
|
1389
|
-
"Quartic.InOut":
|
|
1390
|
-
"Quintic.In":
|
|
1391
|
-
"Quintic.Out":
|
|
1392
|
-
"Quintic.InOut":
|
|
1393
|
-
"Sinusoidal.In":
|
|
1394
|
-
"Sinusoidal.Out":
|
|
1395
|
-
"Sinusoidal.InOut":
|
|
1396
|
-
"Exponential.In":
|
|
1397
|
-
"Exponential.Out":
|
|
1398
|
-
"Exponential.InOut":
|
|
1399
|
-
"Circular.In":
|
|
1400
|
-
"Circular.Out":
|
|
1401
|
-
"Circular.InOut":
|
|
1402
|
-
"Elastic.In":
|
|
1403
|
-
"Elastic.Out":
|
|
1404
|
-
"Elastic.InOut":
|
|
1405
|
-
"Back.In":
|
|
1406
|
-
"Back.Out":
|
|
1407
|
-
"Back.InOut":
|
|
1408
|
-
"Bounce.In":
|
|
1409
|
-
"Bounce.Out":
|
|
1410
|
-
"Bounce.InOut":
|
|
2204
|
+
const Xs = {
|
|
2205
|
+
"Linear.None": m.Linear.None,
|
|
2206
|
+
"Quadratic.In": m.Quadratic.In,
|
|
2207
|
+
"Quadratic.Out": m.Quadratic.Out,
|
|
2208
|
+
"Quadratic.InOut": m.Quadratic.InOut,
|
|
2209
|
+
"Cubic.In": m.Cubic.In,
|
|
2210
|
+
"Cubic.Out": m.Cubic.Out,
|
|
2211
|
+
"Cubic.InOut": m.Cubic.InOut,
|
|
2212
|
+
"Quartic.In": m.Quartic.In,
|
|
2213
|
+
"Quartic.Out": m.Quartic.Out,
|
|
2214
|
+
"Quartic.InOut": m.Quartic.InOut,
|
|
2215
|
+
"Quintic.In": m.Quintic.In,
|
|
2216
|
+
"Quintic.Out": m.Quintic.Out,
|
|
2217
|
+
"Quintic.InOut": m.Quintic.InOut,
|
|
2218
|
+
"Sinusoidal.In": m.Sinusoidal.In,
|
|
2219
|
+
"Sinusoidal.Out": m.Sinusoidal.Out,
|
|
2220
|
+
"Sinusoidal.InOut": m.Sinusoidal.InOut,
|
|
2221
|
+
"Exponential.In": m.Exponential.In,
|
|
2222
|
+
"Exponential.Out": m.Exponential.Out,
|
|
2223
|
+
"Exponential.InOut": m.Exponential.InOut,
|
|
2224
|
+
"Circular.In": m.Circular.In,
|
|
2225
|
+
"Circular.Out": m.Circular.Out,
|
|
2226
|
+
"Circular.InOut": m.Circular.InOut,
|
|
2227
|
+
"Elastic.In": m.Elastic.In,
|
|
2228
|
+
"Elastic.Out": m.Elastic.Out,
|
|
2229
|
+
"Elastic.InOut": m.Elastic.InOut,
|
|
2230
|
+
"Back.In": m.Back.In,
|
|
2231
|
+
"Back.Out": m.Back.Out,
|
|
2232
|
+
"Back.InOut": m.Back.InOut,
|
|
2233
|
+
"Bounce.In": m.Bounce.In,
|
|
2234
|
+
"Bounce.Out": m.Bounce.Out,
|
|
2235
|
+
"Bounce.InOut": m.Bounce.InOut
|
|
1411
2236
|
};
|
|
2237
|
+
class Bn {
|
|
2238
|
+
scene;
|
|
2239
|
+
planes = /* @__PURE__ */ new Map();
|
|
2240
|
+
helpers = /* @__PURE__ */ new Map();
|
|
2241
|
+
/**
|
|
2242
|
+
* The ClippingGroup node. Objects must be descendants of this group to be clipped.
|
|
2243
|
+
*/
|
|
2244
|
+
group;
|
|
2245
|
+
constructor(e) {
|
|
2246
|
+
this.scene = e, this.group = new Ht(), this.group.name = "__clippingToolGroup", this.scene.add(this.group);
|
|
2247
|
+
}
|
|
2248
|
+
/**
|
|
2249
|
+
* Move all current scene children (except the clipping group itself) into the ClippingGroup,
|
|
2250
|
+
* so they are all subject to clipping.
|
|
2251
|
+
*/
|
|
2252
|
+
attach() {
|
|
2253
|
+
const e = [...this.scene.children];
|
|
2254
|
+
for (const t of e)
|
|
2255
|
+
t !== this.group && this.group.add(t);
|
|
2256
|
+
}
|
|
2257
|
+
/**
|
|
2258
|
+
* Move all children out of the ClippingGroup back to the scene root.
|
|
2259
|
+
*/
|
|
2260
|
+
detach() {
|
|
2261
|
+
const e = [...this.group.children];
|
|
2262
|
+
for (const t of e)
|
|
2263
|
+
this.helpers.has(t.name) || this.scene.add(t);
|
|
2264
|
+
}
|
|
2265
|
+
/**
|
|
2266
|
+
* Enable clipping.
|
|
2267
|
+
*/
|
|
2268
|
+
enable() {
|
|
2269
|
+
this.group.enabled = !0;
|
|
2270
|
+
}
|
|
2271
|
+
/**
|
|
2272
|
+
* Disable clipping.
|
|
2273
|
+
*/
|
|
2274
|
+
disable() {
|
|
2275
|
+
this.group.enabled = !1;
|
|
2276
|
+
}
|
|
2277
|
+
/**
|
|
2278
|
+
* Add a clipping plane.
|
|
2279
|
+
*/
|
|
2280
|
+
addPlane(e, t = {}) {
|
|
2281
|
+
const {
|
|
2282
|
+
normal: s = { x: 0, y: -1, z: 0 },
|
|
2283
|
+
constant: n = 0,
|
|
2284
|
+
showHelper: i = !1,
|
|
2285
|
+
helperSize: r = 5,
|
|
2286
|
+
helperColor: o = 16711680
|
|
2287
|
+
} = t, a = new Ut(new w(s.x, s.y, s.z), n);
|
|
2288
|
+
return this.planes.set(e, a), this._syncPlanes(), i && this.showHelper(e, r, o), a;
|
|
2289
|
+
}
|
|
2290
|
+
/**
|
|
2291
|
+
* Add six clipping planes that form a box around a Box3.
|
|
2292
|
+
* Returns the six plane ids: `${id}_+x`, `${id}_-x`, etc.
|
|
2293
|
+
*/
|
|
2294
|
+
addBox(e, t, s = {}) {
|
|
2295
|
+
const { showHelpers: n = !1, helperColor: i = 16711680 } = s, r = t.min, o = t.max, a = [
|
|
2296
|
+
{ suffix: "+x", normal: { x: -1, y: 0, z: 0 }, constant: o.x },
|
|
2297
|
+
{ suffix: "-x", normal: { x: 1, y: 0, z: 0 }, constant: -r.x },
|
|
2298
|
+
{ suffix: "+y", normal: { x: 0, y: -1, z: 0 }, constant: o.y },
|
|
2299
|
+
{ suffix: "-y", normal: { x: 0, y: 1, z: 0 }, constant: -r.y },
|
|
2300
|
+
{ suffix: "+z", normal: { x: 0, y: 0, z: -1 }, constant: o.z },
|
|
2301
|
+
{ suffix: "-z", normal: { x: 0, y: 0, z: 1 }, constant: -r.z }
|
|
2302
|
+
], c = [];
|
|
2303
|
+
for (const h of a) {
|
|
2304
|
+
const d = `${e}_${h.suffix}`;
|
|
2305
|
+
this.addPlane(d, { normal: h.normal, constant: h.constant, showHelper: n, helperColor: i }), c.push(d);
|
|
2306
|
+
}
|
|
2307
|
+
return c;
|
|
2308
|
+
}
|
|
2309
|
+
/**
|
|
2310
|
+
* Add a clipping box from an object's bounding box with optional padding.
|
|
2311
|
+
*/
|
|
2312
|
+
addBoxFromObject(e, t, s = 0, n = {}) {
|
|
2313
|
+
const i = new q().setFromObject(t);
|
|
2314
|
+
return i.expandByScalar(s), this.addBox(e, i, n);
|
|
2315
|
+
}
|
|
2316
|
+
/**
|
|
2317
|
+
* Update a plane's constant (distance from origin).
|
|
2318
|
+
*/
|
|
2319
|
+
setPlaneConstant(e, t) {
|
|
2320
|
+
const s = this.planes.get(e);
|
|
2321
|
+
s && (s.constant = t);
|
|
2322
|
+
}
|
|
2323
|
+
/**
|
|
2324
|
+
* Remove a clipping plane.
|
|
2325
|
+
*/
|
|
2326
|
+
removePlane(e) {
|
|
2327
|
+
this.planes.delete(e), this.hideHelper(e), this._syncPlanes();
|
|
2328
|
+
}
|
|
2329
|
+
/**
|
|
2330
|
+
* Remove a clipping box (all 6 associated planes).
|
|
2331
|
+
*/
|
|
2332
|
+
removeBox(e) {
|
|
2333
|
+
const t = ["+x", "-x", "+y", "-y", "+z", "-z"];
|
|
2334
|
+
for (const s of t)
|
|
2335
|
+
this.removePlane(`${e}_${s}`);
|
|
2336
|
+
}
|
|
2337
|
+
/**
|
|
2338
|
+
* Remove all clipping planes.
|
|
2339
|
+
*/
|
|
2340
|
+
removeAll() {
|
|
2341
|
+
const e = Array.from(this.helpers.keys());
|
|
2342
|
+
for (const t of e)
|
|
2343
|
+
this.hideHelper(t);
|
|
2344
|
+
this.planes.clear(), this._syncPlanes();
|
|
2345
|
+
}
|
|
2346
|
+
/**
|
|
2347
|
+
* Show a helper visualization for a clipping plane.
|
|
2348
|
+
*/
|
|
2349
|
+
showHelper(e, t = 5, s = 16711680) {
|
|
2350
|
+
this.hideHelper(e);
|
|
2351
|
+
const n = this.planes.get(e);
|
|
2352
|
+
if (!n) return;
|
|
2353
|
+
const i = new Ft(n, t, new B(s).getHex());
|
|
2354
|
+
i.name = e, this.helpers.set(e, i), this.scene.add(i);
|
|
2355
|
+
}
|
|
2356
|
+
/**
|
|
2357
|
+
* Hide a plane helper.
|
|
2358
|
+
*/
|
|
2359
|
+
hideHelper(e) {
|
|
2360
|
+
const t = this.helpers.get(e);
|
|
2361
|
+
t && (this.scene.remove(t), t.dispose(), this.helpers.delete(e));
|
|
2362
|
+
}
|
|
2363
|
+
/**
|
|
2364
|
+
* Get a plane by id.
|
|
2365
|
+
*/
|
|
2366
|
+
get(e) {
|
|
2367
|
+
return this.planes.get(e);
|
|
2368
|
+
}
|
|
2369
|
+
/**
|
|
2370
|
+
* Sync the planes map into the ClippingGroup's clippingPlanes array.
|
|
2371
|
+
*/
|
|
2372
|
+
_syncPlanes() {
|
|
2373
|
+
this.group.clippingPlanes = Array.from(this.planes.values());
|
|
2374
|
+
}
|
|
2375
|
+
dispose() {
|
|
2376
|
+
this.detach(), this.removeAll(), this.scene.remove(this.group);
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
class Ln {
|
|
2380
|
+
scene;
|
|
2381
|
+
measurements = /* @__PURE__ */ new Map();
|
|
2382
|
+
_idCounter = 0;
|
|
2383
|
+
constructor(e) {
|
|
2384
|
+
this.scene = e;
|
|
2385
|
+
}
|
|
2386
|
+
/**
|
|
2387
|
+
* Measure distance between two points.
|
|
2388
|
+
*/
|
|
2389
|
+
measureDistance(e, t, s = {}) {
|
|
2390
|
+
const { lineColor: n = 16776960 } = s, i = new w(e.x, e.y, e.z), r = new w(t.x, t.y, t.z), o = i.distanceTo(r), a = `measure_dist_${this._idCounter++}`, c = new I();
|
|
2391
|
+
c.name = a;
|
|
2392
|
+
const h = new K().setFromPoints([i, r]), d = new Z({ color: n }), p = new ee(h, d);
|
|
2393
|
+
c.add(p), this.scene.add(c);
|
|
2394
|
+
const u = {
|
|
2395
|
+
id: a,
|
|
2396
|
+
type: "distance",
|
|
2397
|
+
value: o,
|
|
2398
|
+
unit: "m",
|
|
2399
|
+
points: [i, r],
|
|
2400
|
+
object: c
|
|
2401
|
+
};
|
|
2402
|
+
return this.measurements.set(a, u), u;
|
|
2403
|
+
}
|
|
2404
|
+
/**
|
|
2405
|
+
* Measure the area of a polygon defined by 3+ coplanar points.
|
|
2406
|
+
*/
|
|
2407
|
+
measureArea(e, t = {}) {
|
|
2408
|
+
const { lineColor: s = 65280 } = t;
|
|
2409
|
+
if (e.length < 3)
|
|
2410
|
+
throw new Error("MeasureTool.measureArea requires at least 3 points");
|
|
2411
|
+
const n = e.map((u) => new w(u.x, u.y, u.z)), i = this._calculatePolygonArea(n), r = `measure_area_${this._idCounter++}`, o = new I();
|
|
2412
|
+
o.name = r;
|
|
2413
|
+
const a = [...n, n[0]], c = new K().setFromPoints(a), h = new Z({ color: s }), d = new ee(c, h);
|
|
2414
|
+
o.add(d), this.scene.add(o);
|
|
2415
|
+
const p = {
|
|
2416
|
+
id: r,
|
|
2417
|
+
type: "area",
|
|
2418
|
+
value: i,
|
|
2419
|
+
unit: "m²",
|
|
2420
|
+
points: n,
|
|
2421
|
+
object: o
|
|
2422
|
+
};
|
|
2423
|
+
return this.measurements.set(r, p), p;
|
|
2424
|
+
}
|
|
2425
|
+
/**
|
|
2426
|
+
* Measure the angle between three points (vertex at the middle point).
|
|
2427
|
+
*/
|
|
2428
|
+
measureAngle(e, t, s, n = {}) {
|
|
2429
|
+
const { lineColor: i = 16746496 } = n, r = new w(e.x, e.y, e.z), o = new w(t.x, t.y, t.z), a = new w(s.x, s.y, s.z), c = r.clone().sub(o).normalize(), h = a.clone().sub(o).normalize(), p = Math.acos(Math.max(-1, Math.min(1, c.dot(h)))) * 180 / Math.PI, u = `measure_angle_${this._idCounter++}`, g = new I();
|
|
2430
|
+
g.name = u;
|
|
2431
|
+
const b = new K().setFromPoints([r, o, a]), _ = new Z({ color: i }), x = new ee(b, _);
|
|
2432
|
+
g.add(x), this.scene.add(g);
|
|
2433
|
+
const y = {
|
|
2434
|
+
id: u,
|
|
2435
|
+
type: "angle",
|
|
2436
|
+
value: p,
|
|
2437
|
+
unit: "°",
|
|
2438
|
+
points: [r, o, a],
|
|
2439
|
+
object: g
|
|
2440
|
+
};
|
|
2441
|
+
return this.measurements.set(u, y), y;
|
|
2442
|
+
}
|
|
2443
|
+
/**
|
|
2444
|
+
* Get a measurement result by id.
|
|
2445
|
+
*/
|
|
2446
|
+
get(e) {
|
|
2447
|
+
return this.measurements.get(e);
|
|
2448
|
+
}
|
|
2449
|
+
/**
|
|
2450
|
+
* Remove a measurement by id.
|
|
2451
|
+
*/
|
|
2452
|
+
remove(e) {
|
|
2453
|
+
const t = this.measurements.get(e);
|
|
2454
|
+
t && (this.scene.remove(t.object), t.object.traverse((s) => {
|
|
2455
|
+
s.geometry?.dispose(), s.material?.dispose();
|
|
2456
|
+
}), this.measurements.delete(e));
|
|
2457
|
+
}
|
|
2458
|
+
/**
|
|
2459
|
+
* Remove all measurements.
|
|
2460
|
+
*/
|
|
2461
|
+
removeAll() {
|
|
2462
|
+
const e = Array.from(this.measurements.keys());
|
|
2463
|
+
for (const t of e)
|
|
2464
|
+
this.remove(t);
|
|
2465
|
+
}
|
|
2466
|
+
/**
|
|
2467
|
+
* Get all measurement results.
|
|
2468
|
+
*/
|
|
2469
|
+
getAll() {
|
|
2470
|
+
return Array.from(this.measurements.values());
|
|
2471
|
+
}
|
|
2472
|
+
/**
|
|
2473
|
+
* Calculate polygon area using cross product method (Newell's method).
|
|
2474
|
+
*/
|
|
2475
|
+
_calculatePolygonArea(e) {
|
|
2476
|
+
const t = e.length, s = new w();
|
|
2477
|
+
for (let i = 0; i < t; i++) {
|
|
2478
|
+
const r = e[i], o = e[(i + 1) % t], a = new w().crossVectors(r, o);
|
|
2479
|
+
s.add(a);
|
|
2480
|
+
}
|
|
2481
|
+
const n = new w();
|
|
2482
|
+
if (t >= 3) {
|
|
2483
|
+
const i = e[1].clone().sub(e[0]), r = e[2].clone().sub(e[0]);
|
|
2484
|
+
n.crossVectors(i, r).normalize();
|
|
2485
|
+
}
|
|
2486
|
+
return Math.abs(s.dot(n)) / 2;
|
|
2487
|
+
}
|
|
2488
|
+
dispose() {
|
|
2489
|
+
this.removeAll();
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
class In {
|
|
2493
|
+
scene;
|
|
2494
|
+
annotations = /* @__PURE__ */ new Map();
|
|
2495
|
+
_idCounter = 0;
|
|
2496
|
+
_createCSSObject = null;
|
|
2497
|
+
constructor(e) {
|
|
2498
|
+
this.scene = e;
|
|
2499
|
+
}
|
|
2500
|
+
/**
|
|
2501
|
+
* Set the CSS object factory function (from CSSRenderer).
|
|
2502
|
+
* This allows annotations to be rendered as CSS2D/CSS2.5D objects.
|
|
2503
|
+
*/
|
|
2504
|
+
setCSSObjectFactory(e) {
|
|
2505
|
+
this._createCSSObject = e;
|
|
2506
|
+
}
|
|
2507
|
+
/**
|
|
2508
|
+
* Add an annotation.
|
|
2509
|
+
*/
|
|
2510
|
+
add(e, t) {
|
|
2511
|
+
this.annotations.has(e) && this.remove(e);
|
|
2512
|
+
const s = new I();
|
|
2513
|
+
s.name = `annotation_${e}`;
|
|
2514
|
+
const n = new w(t.position.x, t.position.y, t.position.z);
|
|
2515
|
+
s.position.copy(n);
|
|
2516
|
+
const i = document.createElement("div");
|
|
2517
|
+
if (i.innerHTML = t.content, i.style.cssText = `
|
|
2518
|
+
padding: 4px 8px;
|
|
2519
|
+
background: rgba(0, 0, 0, 0.75);
|
|
2520
|
+
color: #fff;
|
|
2521
|
+
font-size: 12px;
|
|
2522
|
+
border-radius: 4px;
|
|
2523
|
+
pointer-events: auto;
|
|
2524
|
+
white-space: nowrap;
|
|
2525
|
+
`, t.labelStyle)
|
|
2526
|
+
for (const [c, h] of Object.entries(t.labelStyle))
|
|
2527
|
+
h !== void 0 && (i.style[c] = h);
|
|
2528
|
+
let r = null;
|
|
2529
|
+
const o = t.labelOffset || { x: 0, y: 2, z: 0 };
|
|
2530
|
+
if (t.showLeaderLine !== !1) {
|
|
2531
|
+
const { lineColor: c = 16777215 } = t, h = new K().setFromPoints([
|
|
2532
|
+
new w(0, 0, 0),
|
|
2533
|
+
new w(o.x, o.y, o.z)
|
|
2534
|
+
]), d = new Z({ color: c });
|
|
2535
|
+
r = new ee(h, d), s.add(r);
|
|
2536
|
+
}
|
|
2537
|
+
if (this._createCSSObject) {
|
|
2538
|
+
const c = this._createCSSObject(i);
|
|
2539
|
+
c.position.set(o.x, o.y, o.z), s.add(c);
|
|
2540
|
+
}
|
|
2541
|
+
this.scene.add(s);
|
|
2542
|
+
const a = {
|
|
2543
|
+
id: e,
|
|
2544
|
+
options: t,
|
|
2545
|
+
group: s,
|
|
2546
|
+
labelElement: i,
|
|
2547
|
+
line: r
|
|
2548
|
+
};
|
|
2549
|
+
return this.annotations.set(e, a), a;
|
|
2550
|
+
}
|
|
2551
|
+
/**
|
|
2552
|
+
* Quick-add a text annotation.
|
|
2553
|
+
*/
|
|
2554
|
+
addText(e, t, s = {}) {
|
|
2555
|
+
const n = `annotation_${this._idCounter++}`;
|
|
2556
|
+
return this.add(n, {
|
|
2557
|
+
position: t,
|
|
2558
|
+
content: e,
|
|
2559
|
+
...s
|
|
2560
|
+
});
|
|
2561
|
+
}
|
|
2562
|
+
/**
|
|
2563
|
+
* Update an annotation's content.
|
|
2564
|
+
*/
|
|
2565
|
+
updateContent(e, t) {
|
|
2566
|
+
const s = this.annotations.get(e);
|
|
2567
|
+
s && (s.labelElement.innerHTML = t, s.options.content = t);
|
|
2568
|
+
}
|
|
2569
|
+
/**
|
|
2570
|
+
* Update an annotation's position.
|
|
2571
|
+
*/
|
|
2572
|
+
updatePosition(e, t) {
|
|
2573
|
+
const s = this.annotations.get(e);
|
|
2574
|
+
s && (s.group.position.set(t.x, t.y, t.z), s.options.position = t);
|
|
2575
|
+
}
|
|
2576
|
+
/**
|
|
2577
|
+
* Show an annotation.
|
|
2578
|
+
*/
|
|
2579
|
+
show(e) {
|
|
2580
|
+
const t = this.annotations.get(e);
|
|
2581
|
+
t && (t.group.visible = !0);
|
|
2582
|
+
}
|
|
2583
|
+
/**
|
|
2584
|
+
* Hide an annotation.
|
|
2585
|
+
*/
|
|
2586
|
+
hide(e) {
|
|
2587
|
+
const t = this.annotations.get(e);
|
|
2588
|
+
t && (t.group.visible = !1);
|
|
2589
|
+
}
|
|
2590
|
+
/**
|
|
2591
|
+
* Get an annotation by id.
|
|
2592
|
+
*/
|
|
2593
|
+
get(e) {
|
|
2594
|
+
return this.annotations.get(e);
|
|
2595
|
+
}
|
|
2596
|
+
/**
|
|
2597
|
+
* Remove an annotation.
|
|
2598
|
+
*/
|
|
2599
|
+
remove(e) {
|
|
2600
|
+
const t = this.annotations.get(e);
|
|
2601
|
+
if (t) {
|
|
2602
|
+
const s = [...t.group.children];
|
|
2603
|
+
for (const n of s)
|
|
2604
|
+
t.group.remove(n), n.geometry?.dispose(), n.material?.dispose();
|
|
2605
|
+
this.scene.remove(t.group), this.annotations.delete(e);
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
/**
|
|
2609
|
+
* Remove all annotations.
|
|
2610
|
+
*/
|
|
2611
|
+
removeAll() {
|
|
2612
|
+
const e = Array.from(this.annotations.keys());
|
|
2613
|
+
for (const t of e)
|
|
2614
|
+
this.remove(t);
|
|
2615
|
+
}
|
|
2616
|
+
/**
|
|
2617
|
+
* Show all annotations.
|
|
2618
|
+
*/
|
|
2619
|
+
showAll() {
|
|
2620
|
+
for (const e of this.annotations.values())
|
|
2621
|
+
e.group.visible = !0;
|
|
2622
|
+
}
|
|
2623
|
+
/**
|
|
2624
|
+
* Hide all annotations.
|
|
2625
|
+
*/
|
|
2626
|
+
hideAll() {
|
|
2627
|
+
for (const e of this.annotations.values())
|
|
2628
|
+
e.group.visible = !1;
|
|
2629
|
+
}
|
|
2630
|
+
/**
|
|
2631
|
+
* Get all annotation ids.
|
|
2632
|
+
*/
|
|
2633
|
+
keys() {
|
|
2634
|
+
return Array.from(this.annotations.keys());
|
|
2635
|
+
}
|
|
2636
|
+
get size() {
|
|
2637
|
+
return this.annotations.size;
|
|
2638
|
+
}
|
|
2639
|
+
dispose() {
|
|
2640
|
+
this.removeAll();
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
const Ys = "0.0.8";
|
|
2644
|
+
window.__USPACE__ = { version: Ys };
|
|
1412
2645
|
export {
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
2646
|
+
In as AnnotationManager,
|
|
2647
|
+
We as BaseGroup,
|
|
2648
|
+
$ as BaseMesh,
|
|
2649
|
+
$s as BaseSprite,
|
|
2650
|
+
Nn as CSS2DObject,
|
|
2651
|
+
Dn as CSS3DObject,
|
|
2652
|
+
kn as CSS3DSprite,
|
|
2653
|
+
Ts as CSSRenderer,
|
|
2654
|
+
vs as CameraControls,
|
|
2655
|
+
Pn as CircleMesh,
|
|
2656
|
+
Bn as ClippingTool,
|
|
2657
|
+
Qe as ExtrudeMesh,
|
|
2658
|
+
gs as InteractionEvent,
|
|
2659
|
+
fs as InteractionManager,
|
|
2660
|
+
xn as LightManager,
|
|
2661
|
+
oe as MaterialEffects,
|
|
2662
|
+
Ln as MeasureTool,
|
|
2663
|
+
re as Model,
|
|
2664
|
+
j as ModelLoaderManager,
|
|
2665
|
+
ys as ObjectManager,
|
|
2666
|
+
F as ObjectUtils,
|
|
2667
|
+
Tn as PlaneMesh,
|
|
2668
|
+
Mn as Poi,
|
|
2669
|
+
ws as RenderPipeline,
|
|
2670
|
+
Ss as RoomEnvironment,
|
|
2671
|
+
Gs as SBMLoader,
|
|
2672
|
+
Es as SBMXLoader,
|
|
2673
|
+
vn as SceneManager,
|
|
2674
|
+
bn as Selection,
|
|
2675
|
+
Ke as ShapeMesh,
|
|
2676
|
+
Ws as SphereMesh,
|
|
2677
|
+
En as TSLEffects,
|
|
2678
|
+
Cn as TextureLoaderManager,
|
|
2679
|
+
_n as Topology,
|
|
2680
|
+
Pe as TubeMesh,
|
|
2681
|
+
qs as Tween,
|
|
2682
|
+
Sn as Viewer,
|
|
2683
|
+
On as reinterpretType,
|
|
2684
|
+
An as tweenAnimation,
|
|
2685
|
+
Ys as version
|
|
1441
2686
|
};
|