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