u-space 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +682 -481
- package/dist/plugins/u-manager/flows/ComponentFlowParser.d.ts +8 -0
- package/dist/plugins/u-manager/flows/FlowParser.d.ts +48 -0
- package/dist/plugins/u-manager/flows/edges/index.d.ts +9 -0
- package/dist/plugins/u-manager/flows/index.d.ts +4 -0
- package/dist/plugins/u-manager/flows/nodes/ColorNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/ConditionNode.d.ts +9 -0
- package/dist/plugins/u-manager/flows/nodes/DataExtractionNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/DataFilterNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/DelayNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/EmissiveNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/FlyToNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/HideNode.d.ts +10 -0
- package/dist/plugins/u-manager/flows/nodes/HighlightNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/MeshNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/MeshesNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/ModelNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/ModelsNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/Node.d.ts +52 -0
- package/dist/plugins/u-manager/flows/nodes/NumberNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/OpacityNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/POINode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/POISNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/PathNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/PathsNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/RotateNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/ScaleNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/ShowNode.d.ts +10 -0
- package/dist/plugins/u-manager/flows/nodes/SpaceNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/SpacesNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/StartNode.d.ts +7 -0
- package/dist/plugins/u-manager/flows/nodes/TranslateNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/UnEmissiveNode.d.ts +10 -0
- package/dist/plugins/u-manager/flows/nodes/UnHighlightNode.d.ts +10 -0
- package/dist/plugins/u-manager/flows/nodes/UnOpacityNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/UserDataNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/clip-animation/ClipAnimationNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/clip-animation/UnClipAnimationNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/clip-animation/index.d.ts +2 -0
- package/dist/plugins/u-manager/flows/nodes/component-tween-animation/ComponentTweenAnimationNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/component-tween-animation/UnComponentTweenAnimationNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/component-tween-animation/index.d.ts +2 -0
- package/dist/plugins/u-manager/flows/nodes/component-tween-animation/utils.d.ts +5 -0
- package/dist/plugins/u-manager/flows/nodes/index.d.ts +34 -0
- package/dist/plugins/u-manager/flows/nodes/tween-animation/TweenAnimationNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/tween-animation/UnTweenAnimationNode.d.ts +8 -0
- package/dist/plugins/u-manager/flows/nodes/tween-animation/index.d.ts +2 -0
- package/dist/plugins/u-manager/flows/nodes/tween-animation/utils.d.ts +5 -0
- package/dist/plugins/u-manager/flows/types.d.ts +81 -0
- package/dist/plugins/u-manager/flows/utils.d.ts +14 -0
- package/dist/plugins/u-manager/index.cjs +59 -59
- package/dist/plugins/u-manager/index.d.ts +1 -0
- package/dist/plugins/u-manager/index.js +9692 -8601
- package/dist/src/effects/MaterialEffects.d.ts +10 -3
- package/dist/src/index.d.ts +8 -0
- package/dist/src/viewers/CSSRenderer.d.ts +19 -0
- package/dist/src/viewers/CameraControls.d.ts +7 -0
- package/dist/src/viewers/RenderPipeline.d.ts +30 -2
- package/dist/src/viewers/Viewer.d.ts +2 -0
- package/dist/src/viewers/index.d.ts +2 -0
- package/docs/api-css-renderer.md +43 -0
- package/docs/api-effects.md +49 -11
- package/docs/api-render-pipeline.md +114 -0
- package/docs/api-viewer.md +31 -0
- package/docs/examples-guide.md +26 -0
- package/docs/getting-started.md +12 -0
- package/docs/index.md +6 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
import { Raycaster as
|
|
2
|
-
import { pass as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
1
|
+
import { Raycaster as Te, Vector2 as R, RenderPipeline as $e, PerspectiveCamera as K, Sphere as Se, Box3 as xe, Spherical as C, Matrix4 as We, Quaternion as Ke, Vector4 as Qe, Vector3 as oe, MathUtils as Xe, PMREMGenerator as qe, OrthographicCamera as Q, TimestampQuery as Ye, Cache as Je, EventDispatcher as Ze, Timer as Ve, WebGPURenderer as et, PCFShadowMap as tt, AgXToneMapping as st, Scene as it, Color as V, MeshStandardNodeMaterial as L, Loader as nt, LoaderUtils as I, FileLoader as Ee, TextureLoader as Me, Group as ee, SRGBColorSpace as Pe, RepeatWrapping as ce, BufferGeometry as rt, BufferAttribute as he, Mesh as z, FrontSide as at, BackSide as ot, DoubleSide as ct, REVISION as le, CubeTextureLoader as ht, EquirectangularReflectionMapping as lt, Sprite as dt, AnimationMixer as pt, LoopRepeat as ut, LoopOnce as mt, SphereGeometry as gt, TubeGeometry as ft, LineCurve3 as yt, CatmullRomCurve3 as wt, SpriteNodeMaterial as vt, CanvasTexture as bt, ShapeGeometry as Ct, Shape as Oe, ExtrudeGeometry as Tt, PlaneGeometry as St, CircleGeometry as xt } from "three/webgpu";
|
|
2
|
+
import { pass as re, mrt as Et, output as Mt, add as de, blendColor as Pt, emissive as Ot, normalView as Rt, velocity as It, color as j, uv as pe, time as X, pow as q, sin as ae, mix as Y, mx_noise_float as ue, Fn as Re, userData as O, materialColor as me, select as J, materialOpacity as Lt, vec3 as At } from "three/tsl";
|
|
3
|
+
import { bloom as Nt } from "three/addons/tsl/display/BloomNode.js";
|
|
4
|
+
import { ssgi as Bt } from "three/addons/tsl/display/SSGINode.js";
|
|
5
|
+
import { traa as _t } from "three/addons/tsl/display/TRAANode.js";
|
|
6
|
+
import Ie from "camera-controls";
|
|
7
|
+
import { RoomEnvironment as Dt } from "three/addons/environments/RoomEnvironment.js";
|
|
8
|
+
import { ViewHelper as jt } from "three/addons/helpers/ViewHelper.js";
|
|
9
|
+
import { CSS2DRenderer as Ut, CSS2DObject as kt } from "three/addons/renderers/CSS2DRenderer.js";
|
|
10
|
+
import { CSS2DObject as pi } from "three/addons/renderers/CSS2DRenderer.js";
|
|
11
|
+
import { CSS3DRenderer as Gt, CSS3DSprite as Ft, CSS3DObject as zt } from "three/addons/renderers/CSS3DRenderer.js";
|
|
12
|
+
import { CSS3DObject as mi, CSS3DSprite as gi } from "three/addons/renderers/CSS3DRenderer.js";
|
|
13
|
+
import { GLTFLoader as Le } from "three/addons/loaders/GLTFLoader.js";
|
|
14
|
+
import { FBXLoader as Ht } from "three/addons/loaders/FBXLoader.js";
|
|
15
|
+
import { OBJLoader as $t } from "three/addons/loaders/OBJLoader.js";
|
|
16
|
+
import { STLLoader as Wt } from "three/addons/loaders/STLLoader.js";
|
|
17
|
+
import { DRACOLoader as Kt } from "three/addons/loaders/DRACOLoader.js";
|
|
18
|
+
import { KTX2Loader as Qt } from "three/addons/loaders/KTX2Loader.js";
|
|
19
|
+
import { MeshoptDecoder as ge } from "three/addons/libs/meshopt_decoder.module.js";
|
|
20
|
+
import { HDRLoader as Xt } from "three/addons/loaders/HDRLoader.js";
|
|
21
|
+
import { clone as qt } from "three/addons/utils/SkeletonUtils.js";
|
|
22
|
+
import { Color as U } from "three";
|
|
23
|
+
import { Easing as u, Tween as Yt } from "three/addons/libs/tween.module.js";
|
|
24
|
+
class Jt {
|
|
18
25
|
/** The type of event (e.g., 'click', 'pointerdown'). */
|
|
19
26
|
type;
|
|
20
27
|
/** The original 3D object that triggered the event. */
|
|
@@ -42,15 +49,15 @@ class Ot {
|
|
|
42
49
|
return this._propagationStopped;
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
|
-
class
|
|
52
|
+
class Zt {
|
|
46
53
|
domElement;
|
|
47
54
|
scene;
|
|
48
55
|
camera;
|
|
49
|
-
raycaster = new
|
|
50
|
-
pointer = new
|
|
56
|
+
raycaster = new Te();
|
|
57
|
+
pointer = new R();
|
|
51
58
|
hoveredObject = null;
|
|
52
59
|
pointerDownTime = 0;
|
|
53
|
-
pointerDownPos = new
|
|
60
|
+
pointerDownPos = new R();
|
|
54
61
|
clickTimer = null;
|
|
55
62
|
longPressThreshold = 500;
|
|
56
63
|
moveThreshold = 0.01;
|
|
@@ -85,16 +92,16 @@ class Pt {
|
|
|
85
92
|
/**
|
|
86
93
|
* Dispatches an event to the target object and bubbles up the parent chain.
|
|
87
94
|
*/
|
|
88
|
-
_dispatchToTarget(e, t, s,
|
|
89
|
-
const
|
|
95
|
+
_dispatchToTarget(e, t, s, i) {
|
|
96
|
+
const n = new Jt({
|
|
90
97
|
type: e,
|
|
91
98
|
target: t,
|
|
92
99
|
intersect: s,
|
|
93
|
-
originalEvent:
|
|
100
|
+
originalEvent: i
|
|
94
101
|
});
|
|
95
102
|
let r = t;
|
|
96
|
-
for (; r && !
|
|
97
|
-
|
|
103
|
+
for (; r && !n.propagationStopped; )
|
|
104
|
+
n.currentTarget = r, r.dispatchEvent({ type: e, event: n }), r = r.parent;
|
|
98
105
|
}
|
|
99
106
|
/**
|
|
100
107
|
* Handles a DOM event by raycasting and dispatching to the first intersected object.
|
|
@@ -103,8 +110,8 @@ class Pt {
|
|
|
103
110
|
this._updatePointer(t);
|
|
104
111
|
const s = this._getIntersects();
|
|
105
112
|
if (s.length === 0) return;
|
|
106
|
-
const
|
|
107
|
-
this._dispatchToTarget(e,
|
|
113
|
+
const i = s[0];
|
|
114
|
+
this._dispatchToTarget(e, i.object, i, t);
|
|
108
115
|
}
|
|
109
116
|
_onClick = (e) => {
|
|
110
117
|
const t = Date.now() - this.pointerDownTime, s = this.pointer.distanceTo(this.pointerDownPos);
|
|
@@ -137,8 +144,8 @@ class Pt {
|
|
|
137
144
|
_onPointerMove = (e) => {
|
|
138
145
|
if (!this.pointerMoveEventsEnabled) return;
|
|
139
146
|
this._updatePointer(e);
|
|
140
|
-
const t = this._getIntersects(), s = t.length > 0 ? t[0].object : null,
|
|
141
|
-
this.hoveredObject !== s && (this.hoveredObject && this._dispatchToTarget("pointerleave", this.hoveredObject, null, e), this.hoveredObject = s, s &&
|
|
147
|
+
const t = this._getIntersects(), s = t.length > 0 ? t[0].object : null, i = t.length > 0 ? t[0] : null;
|
|
148
|
+
this.hoveredObject !== s && (this.hoveredObject && this._dispatchToTarget("pointerleave", this.hoveredObject, null, e), this.hoveredObject = s, s && i && this._dispatchToTarget("pointerenter", s, i, e)), s && i && this._dispatchToTarget("pointermove", s, i, e);
|
|
142
149
|
};
|
|
143
150
|
/**
|
|
144
151
|
* Cleans up event listeners.
|
|
@@ -147,7 +154,7 @@ class Pt {
|
|
|
147
154
|
this.domElement.removeEventListener("click", this._onClick), this.domElement.removeEventListener("dblclick", this._onDblClick), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.hoveredObject = null;
|
|
148
155
|
}
|
|
149
156
|
}
|
|
150
|
-
class
|
|
157
|
+
class Vt {
|
|
151
158
|
idMap = /* @__PURE__ */ new Map();
|
|
152
159
|
nameMap = /* @__PURE__ */ new Map();
|
|
153
160
|
typeMap = /* @__PURE__ */ new Map();
|
|
@@ -250,54 +257,151 @@ class St {
|
|
|
250
257
|
return this.allObjects.size;
|
|
251
258
|
}
|
|
252
259
|
}
|
|
253
|
-
class
|
|
260
|
+
class es extends $e {
|
|
254
261
|
scene;
|
|
255
262
|
camera;
|
|
256
|
-
|
|
263
|
+
scenePass;
|
|
257
264
|
needsUpdateOutputNode;
|
|
258
|
-
#
|
|
265
|
+
#r;
|
|
266
|
+
#t;
|
|
267
|
+
#s = !1;
|
|
268
|
+
#a = { strength: 1, radius: 0, threshold: 0 };
|
|
269
|
+
#c = null;
|
|
270
|
+
#n = !1;
|
|
271
|
+
#e = {
|
|
272
|
+
sliceCount: 1,
|
|
273
|
+
stepCount: 12,
|
|
274
|
+
aoIntensity: 1,
|
|
275
|
+
giIntensity: 10,
|
|
276
|
+
radius: 12,
|
|
277
|
+
thickness: 1
|
|
278
|
+
};
|
|
279
|
+
#h = null;
|
|
280
|
+
#o = !1;
|
|
281
|
+
#l = null;
|
|
282
|
+
#d = null;
|
|
259
283
|
constructor(...e) {
|
|
260
|
-
const [t, s,
|
|
261
|
-
super(t), this.scene = s, this.camera =
|
|
284
|
+
const [t, s, i] = e;
|
|
285
|
+
super(t), this.scene = s, this.camera = i, this.scenePass = re(s, i), this.needsUpdateOutputNode = !0, this.#r = /* @__PURE__ */ new Set(), this.#t = [], this.#p();
|
|
286
|
+
}
|
|
287
|
+
/** @deprecated Use `scenePass` instead */
|
|
288
|
+
get currentOutputNode() {
|
|
289
|
+
return this.scenePass;
|
|
262
290
|
}
|
|
263
291
|
addOverlayPass(e) {
|
|
264
|
-
this.#
|
|
292
|
+
this.#r.add(e), this.needsUpdateOutputNode = !0;
|
|
265
293
|
}
|
|
266
294
|
removeOverlayPass(e) {
|
|
267
|
-
this.#
|
|
295
|
+
this.#r.delete(e), this.needsUpdateOutputNode = !0;
|
|
268
296
|
}
|
|
269
297
|
setCamera(e) {
|
|
270
|
-
this.camera = e, this
|
|
298
|
+
this.camera = e, this.#i();
|
|
271
299
|
}
|
|
300
|
+
/** @deprecated Use `setOutputComposer` instead */
|
|
272
301
|
setCurrentOutputNode(e) {
|
|
273
|
-
this.
|
|
302
|
+
this.setOutputComposer(() => e);
|
|
274
303
|
}
|
|
304
|
+
/** @deprecated Use `setOutputComposer(null)` instead */
|
|
275
305
|
resetCurrentOutputNode() {
|
|
276
|
-
this.
|
|
306
|
+
this.setOutputComposer(null);
|
|
307
|
+
}
|
|
308
|
+
setOutputComposer(e) {
|
|
309
|
+
this.#d = e, this.needsUpdateOutputNode = !0;
|
|
310
|
+
}
|
|
311
|
+
enableBloom(e) {
|
|
312
|
+
e && Object.assign(this.#a, e), this.#s = !0, this.#i();
|
|
313
|
+
}
|
|
314
|
+
disableBloom() {
|
|
315
|
+
this.#s = !1, this.#c = null, this.#i();
|
|
316
|
+
}
|
|
317
|
+
updateBloom(e) {
|
|
318
|
+
Object.assign(this.#a, e), this.#s && (this.needsUpdateOutputNode = !0);
|
|
319
|
+
}
|
|
320
|
+
enableSSGI(e) {
|
|
321
|
+
e && Object.assign(this.#e, e), this.#n = !0, this.#i();
|
|
322
|
+
}
|
|
323
|
+
disableSSGI() {
|
|
324
|
+
this.#n = !1, this.#h = null, this.#i();
|
|
325
|
+
}
|
|
326
|
+
updateSSGI(e) {
|
|
327
|
+
if (Object.assign(this.#e, e), this.#h) {
|
|
328
|
+
const t = this.#h;
|
|
329
|
+
e.sliceCount !== void 0 && (t.sliceCount.value = e.sliceCount), e.stepCount !== void 0 && (t.stepCount.value = e.stepCount), e.aoIntensity !== void 0 && (t.aoIntensity.value = e.aoIntensity), e.giIntensity !== void 0 && (t.giIntensity.value = e.giIntensity), e.radius !== void 0 && (t.radius.value = e.radius), e.thickness !== void 0 && (t.thickness.value = e.thickness);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
enableTRAA() {
|
|
333
|
+
this.#o = !0, this.#i();
|
|
334
|
+
}
|
|
335
|
+
disableTRAA() {
|
|
336
|
+
this.#o = !1, this.#l = null, this.#i();
|
|
337
|
+
}
|
|
338
|
+
#i() {
|
|
339
|
+
const e = this.scenePass;
|
|
340
|
+
this.scenePass = re(this.scene, this.camera), this.#p(), this.needsUpdateOutputNode = !0, e.dispose();
|
|
341
|
+
}
|
|
342
|
+
#p() {
|
|
343
|
+
if (this.#s || this.#n || this.#o) {
|
|
344
|
+
const t = { output: Mt };
|
|
345
|
+
this.#s && (t.emissive = Ot), this.#n && (t.normal = Rt), this.#o && (t.velocity = It), this.scenePass.setMRT(Et(t));
|
|
346
|
+
}
|
|
277
347
|
}
|
|
278
|
-
#
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
348
|
+
#u() {
|
|
349
|
+
for (const e of this.#t)
|
|
350
|
+
e.dispose();
|
|
351
|
+
this.#t = [];
|
|
352
|
+
}
|
|
353
|
+
#m() {
|
|
354
|
+
let e = this.scenePass.getTextureNode();
|
|
355
|
+
if (this.#n)
|
|
356
|
+
if (!(this.camera instanceof K))
|
|
357
|
+
console.warn("RenderPipeline: SSGI requires a PerspectiveCamera, skipping.");
|
|
358
|
+
else {
|
|
359
|
+
const t = this.scenePass.getTextureNode(), s = this.scenePass.getTextureNode("depth"), i = this.scenePass.getTextureNode("normal"), n = Bt(t, s, i, this.camera);
|
|
360
|
+
n.sliceCount.value = this.#e.sliceCount, n.stepCount.value = this.#e.stepCount, n.aoIntensity.value = this.#e.aoIntensity, n.giIntensity.value = this.#e.giIntensity, n.radius.value = this.#e.radius, n.thickness.value = this.#e.thickness, this.#h = n, e = de(e, n), this.#t.push(n);
|
|
361
|
+
}
|
|
362
|
+
if (this.#s) {
|
|
363
|
+
const t = this.scenePass.getTextureNode("emissive");
|
|
364
|
+
this.#c = Nt(
|
|
365
|
+
t,
|
|
366
|
+
this.#a.strength,
|
|
367
|
+
this.#a.radius,
|
|
368
|
+
this.#a.threshold
|
|
369
|
+
), e = de(e, this.#c), this.#t.push(this.#c);
|
|
370
|
+
}
|
|
371
|
+
return e;
|
|
372
|
+
}
|
|
373
|
+
#g() {
|
|
374
|
+
this.#u();
|
|
375
|
+
let e;
|
|
376
|
+
if (this.#d ? e = this.#d(this.scenePass) : this.#s || this.#n ? e = this.#m() : e = this.scenePass, this.#o) {
|
|
377
|
+
const t = this.scenePass.getTextureNode("depth"), s = this.scenePass.getTextureNode("velocity");
|
|
378
|
+
this.#l = _t(e, t, s, this.camera), this.#t.push(this.#l), e = this.#l;
|
|
379
|
+
}
|
|
380
|
+
this.#r.size > 0 && this.#r.forEach((t) => {
|
|
381
|
+
const s = Pt(e, t);
|
|
382
|
+
this.#t.push(s), e = s;
|
|
282
383
|
}), this.outputNode = e, this.needsUpdate = !0;
|
|
283
384
|
}
|
|
284
385
|
render() {
|
|
285
|
-
this.needsUpdateOutputNode && (this.#
|
|
386
|
+
this.needsUpdateOutputNode && (this.#g(), this.needsUpdateOutputNode = !1), super.render();
|
|
387
|
+
}
|
|
388
|
+
dispose() {
|
|
389
|
+
this.#u(), this.scenePass.dispose(), super.dispose();
|
|
286
390
|
}
|
|
287
391
|
}
|
|
288
|
-
const
|
|
289
|
-
Vector2:
|
|
290
|
-
Vector3:
|
|
291
|
-
Vector4:
|
|
292
|
-
Quaternion:
|
|
293
|
-
Matrix4:
|
|
294
|
-
Spherical:
|
|
295
|
-
Box3:
|
|
296
|
-
Sphere:
|
|
297
|
-
Raycaster:
|
|
392
|
+
const ts = {
|
|
393
|
+
Vector2: R,
|
|
394
|
+
Vector3: oe,
|
|
395
|
+
Vector4: Qe,
|
|
396
|
+
Quaternion: Ke,
|
|
397
|
+
Matrix4: We,
|
|
398
|
+
Spherical: C,
|
|
399
|
+
Box3: xe,
|
|
400
|
+
Sphere: Se,
|
|
401
|
+
Raycaster: Te
|
|
298
402
|
};
|
|
299
|
-
|
|
300
|
-
class
|
|
403
|
+
Ie.install({ THREE: ts });
|
|
404
|
+
class ss extends Ie {
|
|
301
405
|
constructor(...e) {
|
|
302
406
|
super(...e), this.minDistance = 0.2, this.smoothTime = 0.2, this.dollySpeed = 0.2;
|
|
303
407
|
}
|
|
@@ -305,62 +409,69 @@ class Bt extends Ce {
|
|
|
305
409
|
* Set absolute angle for azimuth to avoid spinning
|
|
306
410
|
*/
|
|
307
411
|
absoluteRotations() {
|
|
308
|
-
this.azimuthAngle =
|
|
412
|
+
this.azimuthAngle = is(this.azimuthAngle, 0);
|
|
309
413
|
}
|
|
310
414
|
async flyToBox(e, t = {}) {
|
|
311
415
|
if (e.isEmpty())
|
|
312
416
|
return console.warn("CameraControls.flyToBox: The provided Box3 is empty."), !1;
|
|
313
417
|
this.absoluteRotations();
|
|
314
|
-
const { viewpoint: s = "frontTop", enableTransition:
|
|
418
|
+
const { viewpoint: s = "frontTop", enableTransition: i = !0, padding: n = 0.1, cover: r = !1 } = t, o = [];
|
|
315
419
|
if (s !== "current") {
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
this.fitToBox(e,
|
|
319
|
-
paddingLeft:
|
|
320
|
-
paddingRight:
|
|
321
|
-
paddingTop:
|
|
322
|
-
paddingBottom:
|
|
420
|
+
const c = fe[s.toUpperCase()] ?? fe.FRONTTOP, h = c.theta, l = c.phi;
|
|
421
|
+
o.push(
|
|
422
|
+
this.fitToBox(e, i, {
|
|
423
|
+
paddingLeft: n,
|
|
424
|
+
paddingRight: n,
|
|
425
|
+
paddingTop: n,
|
|
426
|
+
paddingBottom: n,
|
|
323
427
|
cover: r
|
|
324
428
|
})
|
|
325
|
-
),
|
|
429
|
+
), o.push(this.rotateTo(h, l, i));
|
|
326
430
|
} else {
|
|
327
|
-
const
|
|
328
|
-
e.getBoundingSphere(
|
|
431
|
+
const c = new Se();
|
|
432
|
+
e.getBoundingSphere(c), c.radius += n, o.push(this.fitToSphere(c, i));
|
|
329
433
|
}
|
|
330
|
-
return await Promise.all(
|
|
434
|
+
return await Promise.all(o), !0;
|
|
331
435
|
}
|
|
332
436
|
async flyToObject(e, t = {}) {
|
|
333
|
-
const s = new
|
|
437
|
+
const s = new xe().setFromObject(e);
|
|
334
438
|
return this.flyToBox(s, t);
|
|
335
439
|
}
|
|
440
|
+
async setCameraViewpoint(e, t = !0) {
|
|
441
|
+
const { position: s, target: i, zoom: n = this.camera.zoom } = e;
|
|
442
|
+
return Promise.all([
|
|
443
|
+
this.zoomTo(n, t),
|
|
444
|
+
this.setLookAt(s.x, s.y, s.z, i.x, i.y, i.z, t)
|
|
445
|
+
]);
|
|
446
|
+
}
|
|
336
447
|
}
|
|
337
|
-
const
|
|
338
|
-
LEFT: new
|
|
339
|
-
RIGHT: new
|
|
340
|
-
FRONT: new
|
|
341
|
-
BACK: new
|
|
342
|
-
TOP: new
|
|
343
|
-
BOTTOM: new
|
|
344
|
-
FRONTTOP: new
|
|
345
|
-
BACKTOP: new
|
|
346
|
-
LEFTTOP: new
|
|
347
|
-
RIGHTTOP: new
|
|
348
|
-
LEFTFRONTTOP: new
|
|
349
|
-
RIGHTFRONTTOP: new
|
|
350
|
-
LEFTBACKTOP: new
|
|
351
|
-
RIGHTBACKTOP: new
|
|
448
|
+
const fe = {
|
|
449
|
+
LEFT: new C(0, Math.PI / 2, -Math.PI / 2),
|
|
450
|
+
RIGHT: new C(0, Math.PI / 2, Math.PI / 2),
|
|
451
|
+
FRONT: new C(0, Math.PI / 2, 0),
|
|
452
|
+
BACK: new C(0, Math.PI / 2, Math.PI),
|
|
453
|
+
TOP: new C(0, 0, 0),
|
|
454
|
+
BOTTOM: new C(0, Math.PI, 0),
|
|
455
|
+
FRONTTOP: new C(0, Math.PI / 4, 0),
|
|
456
|
+
BACKTOP: new C(0, Math.PI / 4, Math.PI),
|
|
457
|
+
LEFTTOP: new C(0, Math.PI / 4, -Math.PI / 2),
|
|
458
|
+
RIGHTTOP: new C(0, Math.PI / 4, Math.PI / 2),
|
|
459
|
+
LEFTFRONTTOP: new C(0, Math.PI / 4, -Math.PI / 4),
|
|
460
|
+
RIGHTFRONTTOP: new C(0, Math.PI / 4, Math.PI / 4),
|
|
461
|
+
LEFTBACKTOP: new C(0, Math.PI / 4, -Math.PI / 4 * 3),
|
|
462
|
+
RIGHTBACKTOP: new C(0, Math.PI / 4, Math.PI / 4 * 3)
|
|
352
463
|
};
|
|
353
|
-
function
|
|
354
|
-
const t =
|
|
355
|
-
return
|
|
464
|
+
function is(a, e) {
|
|
465
|
+
const t = a - e;
|
|
466
|
+
return Xe.euclideanModulo(t + Math.PI, Math.PI * 2) - Math.PI;
|
|
356
467
|
}
|
|
357
|
-
class
|
|
358
|
-
environment = new
|
|
468
|
+
class ns {
|
|
469
|
+
environment = new Dt();
|
|
359
470
|
renderer;
|
|
360
471
|
pmremGenerator;
|
|
361
472
|
envMap = null;
|
|
362
473
|
constructor(e) {
|
|
363
|
-
this.renderer = e, this.pmremGenerator = new
|
|
474
|
+
this.renderer = e, this.pmremGenerator = new qe(e);
|
|
364
475
|
}
|
|
365
476
|
update() {
|
|
366
477
|
this.envMap || (this.envMap = this.pmremGenerator.fromScene(this.environment).texture);
|
|
@@ -369,20 +480,20 @@ class Rt {
|
|
|
369
480
|
this.pmremGenerator.dispose(), this.envMap?.dispose();
|
|
370
481
|
}
|
|
371
482
|
}
|
|
372
|
-
const
|
|
373
|
-
class
|
|
483
|
+
const $ = 128;
|
|
484
|
+
class rs extends jt {
|
|
374
485
|
viewer;
|
|
375
486
|
overlayPass;
|
|
376
487
|
constructor(e) {
|
|
377
488
|
super(e.camera, e.el), this.viewer = e;
|
|
378
|
-
const t = new
|
|
379
|
-
t.position.set(0, 0, 2), this.overlayPass =
|
|
489
|
+
const t = new Q(-2, 2, 2, -2, 0, 4);
|
|
490
|
+
t.position.set(0, 0, 2), this.overlayPass = re(this, t), this.setLabels("x", "y", "z");
|
|
380
491
|
}
|
|
381
492
|
_update = () => {
|
|
382
493
|
this.quaternion.copy(this.viewer.camera.quaternion).invert();
|
|
383
494
|
const e = this.location;
|
|
384
495
|
let t, s;
|
|
385
|
-
e.left !== null ? t = e.left : t = this.viewer.el.offsetWidth -
|
|
496
|
+
e.left !== null ? t = e.left : t = this.viewer.el.offsetWidth - $ - e.right, e.top !== null ? s = e.top : s = this.viewer.el.offsetHeight - $ - e.bottom, this.overlayPass.setViewport(t, s, $, $);
|
|
386
497
|
};
|
|
387
498
|
enable() {
|
|
388
499
|
return this.viewer.renderPipeline.addOverlayPass(this.overlayPass), this.viewer.addEventListener("beforeRender", this._update), this.viewer.render(), this;
|
|
@@ -391,7 +502,42 @@ class _t extends wt {
|
|
|
391
502
|
return this.viewer.renderPipeline.removeOverlayPass(this.overlayPass), this.viewer.removeEventListener("beforeRender", this._update), this.viewer.render(), this;
|
|
392
503
|
}
|
|
393
504
|
}
|
|
394
|
-
|
|
505
|
+
const Ae = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;overflow:hidden;", as = Ae + "z-index:0;", os = Ae + "z-index:1;";
|
|
506
|
+
class cs {
|
|
507
|
+
el;
|
|
508
|
+
css2dRenderer = null;
|
|
509
|
+
css3dRenderer = null;
|
|
510
|
+
constructor(e) {
|
|
511
|
+
this.el = e, getComputedStyle(e).position === "static" && (e.style.position = "relative");
|
|
512
|
+
}
|
|
513
|
+
initCSS2DRenderer() {
|
|
514
|
+
const e = new Ut();
|
|
515
|
+
return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = os, this.el.appendChild(e.domElement), this.css2dRenderer = e, e;
|
|
516
|
+
}
|
|
517
|
+
initCSS3DRenderer() {
|
|
518
|
+
const e = new Gt();
|
|
519
|
+
return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = as, this.el.appendChild(e.domElement), this.css3dRenderer = e, e;
|
|
520
|
+
}
|
|
521
|
+
createCSS2DObject(e) {
|
|
522
|
+
return this.css2dRenderer || this.initCSS2DRenderer(), new kt(e);
|
|
523
|
+
}
|
|
524
|
+
createCSS25DObject(e) {
|
|
525
|
+
return this.css3dRenderer || this.initCSS3DRenderer(), new Ft(e);
|
|
526
|
+
}
|
|
527
|
+
createCSS3DObject(e) {
|
|
528
|
+
return this.css3dRenderer || this.initCSS3DRenderer(), new zt(e);
|
|
529
|
+
}
|
|
530
|
+
render(e, t) {
|
|
531
|
+
this.css2dRenderer && this.css2dRenderer.render(e, t), this.css3dRenderer && this.css3dRenderer.render(e, t);
|
|
532
|
+
}
|
|
533
|
+
resize(e, t) {
|
|
534
|
+
this.css2dRenderer && this.css2dRenderer.setSize(e, t), this.css3dRenderer && this.css3dRenderer.setSize(e, t);
|
|
535
|
+
}
|
|
536
|
+
dispose() {
|
|
537
|
+
this.css2dRenderer && (this.el.removeChild(this.css2dRenderer.domElement), this.css2dRenderer = null), this.css3dRenderer && (this.el.removeChild(this.css3dRenderer.domElement), this.css3dRenderer = null);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
class hs {
|
|
395
541
|
el;
|
|
396
542
|
renderer;
|
|
397
543
|
container;
|
|
@@ -406,19 +552,19 @@ class Nt {
|
|
|
406
552
|
this.el = e, this.renderer = t;
|
|
407
553
|
const s = document.createElement("div");
|
|
408
554
|
s.style.position = "absolute", s.style.left = "12px", s.style.bottom = "12px", s.style.fontSize = "12px", s.style.color = "#fff", s.style.pointerEvents = "none", this.container = s;
|
|
409
|
-
function
|
|
410
|
-
const
|
|
411
|
-
return
|
|
555
|
+
function i(r, o = !0) {
|
|
556
|
+
const c = document.createElement("span");
|
|
557
|
+
return o && (c.style.marginLeft = "6px"), c.innerText = r, c;
|
|
412
558
|
}
|
|
413
|
-
function
|
|
559
|
+
function n() {
|
|
414
560
|
return document.createElement("br");
|
|
415
561
|
}
|
|
416
|
-
this.drawCallsText =
|
|
562
|
+
this.drawCallsText = i("0"), this.frameCallsText = i("0"), this.trianglesText = i("0"), this.linesText = i("0"), this.pointsText = i("0"), this.timestampText = i("0"), this.container.appendChild(i("draw calls", !1)), this.container.appendChild(this.drawCallsText), this.container.appendChild(n()), this.container.appendChild(i("frame calls", !1)), this.container.appendChild(this.frameCallsText), this.container.appendChild(n()), this.container.appendChild(i("triangles", !1)), this.container.appendChild(this.trianglesText), this.container.appendChild(n()), this.container.appendChild(i("points", !1)), this.container.appendChild(this.pointsText), this.container.appendChild(n()), this.container.appendChild(i("lines", !1)), this.container.appendChild(this.linesText), this.container.appendChild(n()), this.container.appendChild(i("timestamp", !1)), this.container.appendChild(this.timestampText), this.container.appendChild(n());
|
|
417
563
|
}
|
|
418
564
|
update() {
|
|
419
565
|
if (this._enabled) {
|
|
420
566
|
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(
|
|
567
|
+
this.drawCallsText.innerText = e.drawCalls.toString(), this.frameCallsText.innerText = e.frameCalls.toString(), this.trianglesText.innerText = e.triangles.toString(), this.pointsText.innerText = e.points.toString(), this.linesText.innerText = e.lines.toString(), this.renderer.resolveTimestampsAsync(Ye.RENDER).then((t) => {
|
|
422
568
|
this.timestampText.innerText = t?.toFixed(2) ?? "0";
|
|
423
569
|
});
|
|
424
570
|
}
|
|
@@ -433,8 +579,8 @@ class Nt {
|
|
|
433
579
|
this.disable();
|
|
434
580
|
}
|
|
435
581
|
}
|
|
436
|
-
|
|
437
|
-
class
|
|
582
|
+
Je.enabled = !0;
|
|
583
|
+
class ei extends Ze {
|
|
438
584
|
el;
|
|
439
585
|
renderer;
|
|
440
586
|
scene;
|
|
@@ -447,14 +593,15 @@ class Cs extends Ge {
|
|
|
447
593
|
interactionManager;
|
|
448
594
|
objectManager;
|
|
449
595
|
viewerHelper;
|
|
596
|
+
cssRenderer;
|
|
450
597
|
frameCount = 1;
|
|
451
598
|
frameloop = "demand";
|
|
452
599
|
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
|
|
600
|
+
super(), this.el = e, this.renderer = this._initRenderer(t), this.scene = this.createScene(), this.camera = this.createPerspectiveCamera(), this.info = new hs(this.el, this.renderer), this.controls = new ss(this.camera, this.renderer.domElement), this.renderPipeline = new es(this.renderer, this.scene, this.camera), this.timer = new Ve(), this.roomEnvironment = new ns(this.renderer), this.interactionManager = new Zt(this.renderer.domElement, this.scene, this.camera), this.objectManager = new Vt(), this.viewerHelper = new rs(this), this.cssRenderer = new cs(this.el), window.addEventListener("resize", this.onWindowResize);
|
|
454
601
|
}
|
|
455
602
|
onWindowResize = () => {
|
|
456
603
|
const e = this.el.clientWidth, t = this.el.clientHeight;
|
|
457
|
-
this.camera instanceof
|
|
604
|
+
this.camera instanceof K ? (this.camera.aspect = e / t, this.camera.updateProjectionMatrix()) : this.camera instanceof Q && (this.camera.left = -e / 2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = -t / 2, this.camera.updateProjectionMatrix()), this.renderer.setSize(e, t), this.cssRenderer.resize(e, t), this.render();
|
|
458
605
|
};
|
|
459
606
|
async init() {
|
|
460
607
|
await this.renderer.init(), this.roomEnvironment.update(), this.scene.environment = this.roomEnvironment.envMap;
|
|
@@ -463,7 +610,7 @@ class Cs extends Ge {
|
|
|
463
610
|
this.camera = e, this.controls.camera = e, this.interactionManager.setCamera(e), this.renderPipeline.setCamera(e), this.onWindowResize(), this.dispatchEvent({ type: "cameraChange", camera: e });
|
|
464
611
|
}
|
|
465
612
|
setCameraByType(e) {
|
|
466
|
-
e === "perspective" && !(this.camera instanceof
|
|
613
|
+
e === "perspective" && !(this.camera instanceof K) ? this.setCamera(this.createPerspectiveCamera()) : e === "orthographic" && !(this.camera instanceof Q) && this.setCamera(this.createOrthographicCamera());
|
|
467
614
|
}
|
|
468
615
|
render(e = 1) {
|
|
469
616
|
return this.frameCount += e, new Promise((t) => {
|
|
@@ -478,28 +625,28 @@ class Cs extends Ge {
|
|
|
478
625
|
const t = this.timer.getDelta();
|
|
479
626
|
this.dispatchEvent({ type: "beforeControlsUpdate", time: e, delta: t });
|
|
480
627
|
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 }));
|
|
628
|
+
this.dispatchEvent({ type: "afterControlsUpdate", time: e, delta: t }), this.frameCount > 0 && (this.frameCount--, s = !0), this.frameloop === "always" && (s = !0), s && (this.dispatchEvent({ type: "beforeRender", time: e, delta: t }), this.renderer.info.reset(), this.renderPipeline.render(), this.cssRenderer.render(this.scene, this.camera), this.info.update(), this.dispatchEvent({ type: "afterRender", time: e, delta: t }));
|
|
482
629
|
};
|
|
483
630
|
_initRenderer(e) {
|
|
484
|
-
const t = new
|
|
631
|
+
const t = new et({
|
|
485
632
|
logarithmicDepthBuffer: !0,
|
|
486
633
|
antialias: !1,
|
|
487
634
|
depth: !1,
|
|
488
635
|
trackTimestamp: !0,
|
|
489
636
|
...e
|
|
490
637
|
});
|
|
491
|
-
return t.setSize(this.el.clientWidth, this.el.clientHeight), t.shadowMap.enabled = !0, t.shadowMap.type =
|
|
638
|
+
return t.setSize(this.el.clientWidth, this.el.clientHeight), t.shadowMap.enabled = !0, t.shadowMap.type = tt, t.toneMapping = st, t.toneMappingExposure = 1, t.info.autoReset = !1, t.setPixelRatio(window.devicePixelRatio), t.setAnimationLoop(this.animate), this.el.appendChild(t.domElement), t;
|
|
492
639
|
}
|
|
493
640
|
createScene() {
|
|
494
|
-
const e = new
|
|
495
|
-
return e.background = new
|
|
641
|
+
const e = new it();
|
|
642
|
+
return e.background = new V(0), e;
|
|
496
643
|
}
|
|
497
644
|
createPerspectiveCamera() {
|
|
498
|
-
const e = new
|
|
645
|
+
const e = new K(50, this.el.clientWidth / this.el.clientHeight, 0.1, 1e5);
|
|
499
646
|
return e.position.setScalar(5), e;
|
|
500
647
|
}
|
|
501
648
|
createOrthographicCamera() {
|
|
502
|
-
const e = new
|
|
649
|
+
const e = new Q(
|
|
503
650
|
-this.el.clientWidth / 2,
|
|
504
651
|
this.el.clientWidth / 2,
|
|
505
652
|
this.el.clientHeight / 2,
|
|
@@ -510,194 +657,194 @@ class Cs extends Ge {
|
|
|
510
657
|
return e.position.setScalar(5), e;
|
|
511
658
|
}
|
|
512
659
|
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();
|
|
660
|
+
this.el.removeChild(this.renderer.domElement), window.removeEventListener("resize", this.onWindowResize), this.info.dispose(), this.interactionManager.dispose(), this.roomEnvironment.dispose(), this.cssRenderer.dispose(), this.renderPipeline.dispose(), this.renderer.dispose();
|
|
514
661
|
}
|
|
515
662
|
}
|
|
516
|
-
class
|
|
663
|
+
class ls extends Le {
|
|
517
664
|
constructor(e) {
|
|
518
665
|
super(e);
|
|
519
666
|
}
|
|
520
|
-
parse(e, t, s,
|
|
521
|
-
if (
|
|
522
|
-
const r =
|
|
523
|
-
return super.parse(r, t, s,
|
|
667
|
+
parse(e, t, s, i) {
|
|
668
|
+
if (ds(e.slice(0, 8)) === "SBMG----") {
|
|
669
|
+
const r = ps(e.slice(8));
|
|
670
|
+
return super.parse(r, t, s, i);
|
|
524
671
|
} else
|
|
525
|
-
return super.parse(e, t, s,
|
|
672
|
+
return super.parse(e, t, s, i);
|
|
526
673
|
}
|
|
527
674
|
}
|
|
528
|
-
function
|
|
529
|
-
return new TextDecoder().decode(new Uint8Array(
|
|
675
|
+
function ds(a) {
|
|
676
|
+
return new TextDecoder().decode(new Uint8Array(a));
|
|
530
677
|
}
|
|
531
|
-
function
|
|
532
|
-
const e = new DataView(
|
|
678
|
+
function ps(a) {
|
|
679
|
+
const e = new DataView(a);
|
|
533
680
|
for (let t = 0; t < e.byteLength; t++) {
|
|
534
|
-
const s = e.getUint8(t),
|
|
535
|
-
e.setUint8(t,
|
|
681
|
+
const s = e.getUint8(t), i = (s >> 4 & 15) + (s << 4 & 240);
|
|
682
|
+
e.setUint8(t, i);
|
|
536
683
|
}
|
|
537
684
|
return e.buffer;
|
|
538
685
|
}
|
|
539
|
-
const
|
|
540
|
-
function
|
|
541
|
-
let e =
|
|
542
|
-
const t = new Uint8Array(
|
|
543
|
-
if (
|
|
544
|
-
return
|
|
545
|
-
e +=
|
|
546
|
-
const
|
|
547
|
-
if (
|
|
548
|
-
const r =
|
|
549
|
-
let l =
|
|
550
|
-
const
|
|
686
|
+
const us = 8, ms = 130, ye = 66, gs = "SBK-----", fs = "SBM-----", Ne = new TextDecoder(), ys = new TextEncoder();
|
|
687
|
+
function ws(a) {
|
|
688
|
+
let e = us;
|
|
689
|
+
const t = new Uint8Array(a, 0, e);
|
|
690
|
+
if (Ne.decode(t) !== gs)
|
|
691
|
+
return a;
|
|
692
|
+
e += ms;
|
|
693
|
+
const i = new Uint8Array(a, 0, e);
|
|
694
|
+
if (i[40] === 1) {
|
|
695
|
+
const r = ys.encode(fs), o = new Uint8Array([i[41]]), c = vs(i), h = bs(c);
|
|
696
|
+
let l = ye % h.length;
|
|
697
|
+
const d = e + ye, g = new Uint8Array(a, d), p = new Uint8Array(g.length);
|
|
551
698
|
for (let v = 0; v < g.length; v++)
|
|
552
|
-
|
|
553
|
-
const
|
|
554
|
-
return
|
|
699
|
+
p[v] = g[v] ^ h[l], l = (l + 1) % h.length;
|
|
700
|
+
const y = new Uint8Array(r.length + o.length + p.length);
|
|
701
|
+
return y.set(r), y.set(o, r.length), y.set(p, r.length + o.length), y.buffer;
|
|
555
702
|
}
|
|
556
703
|
}
|
|
557
|
-
function
|
|
704
|
+
function vs(a) {
|
|
558
705
|
const e = new Uint8Array(128);
|
|
559
|
-
return e.set(
|
|
706
|
+
return e.set(a.slice(42, 74), 0), e.set(a.slice(74, 138), 32), e.set(a.slice(8, 40), 96), e;
|
|
560
707
|
}
|
|
561
|
-
function
|
|
708
|
+
function bs(a) {
|
|
562
709
|
const e = new Uint8Array(64);
|
|
563
|
-
return e.set(
|
|
710
|
+
return e.set(a.slice(0, 8), 0), e.set(a.slice(24, 32), 8), e.set(a.slice(40, 56), 16), e.set(a.slice(64, 88), 32), e.set(a.slice(96, 104), 56), e;
|
|
564
711
|
}
|
|
565
|
-
const
|
|
566
|
-
const s =
|
|
567
|
-
let
|
|
568
|
-
return
|
|
569
|
-
},
|
|
570
|
-
const [s,
|
|
571
|
-
return new
|
|
572
|
-
name:
|
|
573
|
-
color: new
|
|
712
|
+
const Cs = (a, e, t) => {
|
|
713
|
+
const s = a.buffer.slice(t, t + e);
|
|
714
|
+
let i = Ne.decode(s);
|
|
715
|
+
return i = i.replace("\\", "/"), i.startsWith("Maps/") || (i = `Maps/${i}`), i;
|
|
716
|
+
}, Ts = (a, e, t) => {
|
|
717
|
+
const [s, i, n, r, o] = e, c = t || r < 1;
|
|
718
|
+
return new L({
|
|
719
|
+
name: a,
|
|
720
|
+
color: new V(s, i, n),
|
|
574
721
|
opacity: r,
|
|
575
|
-
transparent:
|
|
722
|
+
transparent: c,
|
|
576
723
|
alphaTest: 0.01,
|
|
577
|
-
side:
|
|
724
|
+
side: o
|
|
578
725
|
});
|
|
579
|
-
},
|
|
580
|
-
class
|
|
726
|
+
}, Ss = (a) => a?.toLowerCase().endsWith(".png") ?? !1;
|
|
727
|
+
class xs {
|
|
581
728
|
data;
|
|
582
729
|
options;
|
|
583
730
|
textureLoader;
|
|
584
731
|
littleEndian = !0;
|
|
585
732
|
materials = /* @__PURE__ */ new Map();
|
|
586
733
|
constructor(e, t) {
|
|
587
|
-
this.data = e, this.options = t, this.textureLoader = new
|
|
734
|
+
this.data = e, this.options = t, this.textureLoader = new Me(t.manager), this.textureLoader.setCrossOrigin(t.crossOrigin), this.textureLoader.setRequestHeader(t.requestHeader);
|
|
588
735
|
}
|
|
589
736
|
parse(e, t) {
|
|
590
737
|
let s = this.data;
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
const
|
|
738
|
+
const i = ws(this.data);
|
|
739
|
+
i && (s = i);
|
|
740
|
+
const n = new DataView(s);
|
|
594
741
|
let r = 8;
|
|
595
|
-
const
|
|
596
|
-
r += 1,
|
|
742
|
+
const o = n.getUint8(r);
|
|
743
|
+
r += 1, o === 1 ? this._parseV2(n, r, e) : o === 2 ? this._parseV2(n, r, e) : o === 3 ? this._parseV3(n, r, e) : t?.(new Error(`SBMLoader: Unsupported SBM version: ${o}`));
|
|
597
744
|
}
|
|
598
745
|
_parseV2(e, t, s) {
|
|
599
|
-
const
|
|
746
|
+
const i = new ee(), n = e.getUint16(t, this.littleEndian);
|
|
600
747
|
t += 2;
|
|
601
748
|
const r = e.getUint16(t, this.littleEndian);
|
|
602
749
|
t += 2;
|
|
603
|
-
for (let
|
|
604
|
-
const
|
|
750
|
+
for (let o = 0; o < n; ++o) {
|
|
751
|
+
const c = e.getUint16(t, this.littleEndian).toString();
|
|
605
752
|
t += 2, t += 4, t += 4, t += 4, t += 4;
|
|
606
753
|
const h = e.getFloat32(t, this.littleEndian);
|
|
607
754
|
t += 4;
|
|
608
755
|
const l = e.getFloat32(t, this.littleEndian);
|
|
609
756
|
t += 4;
|
|
610
|
-
const
|
|
757
|
+
const d = e.getFloat32(t, this.littleEndian);
|
|
611
758
|
t += 4;
|
|
612
759
|
const g = e.getFloat32(t, this.littleEndian);
|
|
613
760
|
t += 4, t += 4, t += 4, t += 4, t += 4;
|
|
614
|
-
let
|
|
615
|
-
t += 1,
|
|
616
|
-
const
|
|
761
|
+
let p = e.getUint8(t);
|
|
762
|
+
t += 1, p === 0 ? p = at : p === 1 ? p = ot : p === 2 && (p = ct);
|
|
763
|
+
const y = e.getUint16(t, this.littleEndian);
|
|
617
764
|
t += 2;
|
|
618
|
-
const v =
|
|
619
|
-
if (t +=
|
|
620
|
-
const b =
|
|
621
|
-
this.materials.set(
|
|
622
|
-
f.colorSpace =
|
|
765
|
+
const v = y > 0 ? Cs(e, y, t) : "";
|
|
766
|
+
if (t += y, !this.materials.has(c)) {
|
|
767
|
+
const b = Ts(c, [h, l, d, g, p], Ss(v));
|
|
768
|
+
this.materials.set(c, b), v && this.options.path && this.textureLoader.load(I.resolveURL(v, this.options.path), (f) => {
|
|
769
|
+
f.colorSpace = Pe, f.wrapS = ce, f.wrapT = ce, f.flipY = !1, f.anisotropy = 16, b.map = f;
|
|
623
770
|
});
|
|
624
771
|
}
|
|
625
772
|
}
|
|
626
|
-
for (let
|
|
627
|
-
const
|
|
773
|
+
for (let o = 0; o < r; ++o) {
|
|
774
|
+
const c = e.getUint16(t, this.littleEndian).toString();
|
|
628
775
|
t += 2;
|
|
629
776
|
const h = e.getUint16(t, this.littleEndian).toString();
|
|
630
777
|
t += 2;
|
|
631
|
-
const l = [],
|
|
632
|
-
if (t += 2,
|
|
633
|
-
for (let m = 0; m <
|
|
634
|
-
const
|
|
635
|
-
|
|
778
|
+
const l = [], d = [], g = [], p = [], y = e.getUint16(t, this.littleEndian);
|
|
779
|
+
if (t += 2, y > 0)
|
|
780
|
+
for (let m = 0; m < y; m++) {
|
|
781
|
+
const w = new oe();
|
|
782
|
+
w.setX(e.getFloat32(t, this.littleEndian)), t += 4, w.setY(e.getFloat32(t, this.littleEndian)), t += 4, w.setZ(e.getFloat32(t, this.littleEndian)), t += 4, l.push(w);
|
|
636
783
|
}
|
|
637
784
|
const v = e.getUint16(t, this.littleEndian);
|
|
638
785
|
if (t += 2, v > 0)
|
|
639
786
|
for (let m = 0; m < v; m++)
|
|
640
787
|
t += 4, t += 4, t += 4;
|
|
641
|
-
const
|
|
642
|
-
if (t += 2,
|
|
643
|
-
for (let m = 0; m <
|
|
644
|
-
const
|
|
645
|
-
|
|
788
|
+
const S = e.getUint16(t, this.littleEndian);
|
|
789
|
+
if (t += 2, S > 0)
|
|
790
|
+
for (let m = 0; m < S; m++) {
|
|
791
|
+
const w = new R();
|
|
792
|
+
w.setX(e.getFloat32(t, this.littleEndian)), t += 4, w.setY(e.getFloat32(t, this.littleEndian)), t += 4, d.push(w);
|
|
646
793
|
}
|
|
647
794
|
const b = e.getUint16(t, this.littleEndian);
|
|
648
795
|
if (t += 2, b > 0)
|
|
649
796
|
for (let m = 0; m < b; m++) {
|
|
650
|
-
const
|
|
651
|
-
t += 2;
|
|
652
|
-
const B = e.getUint16(t, this.littleEndian);
|
|
797
|
+
const w = e.getUint16(t, this.littleEndian);
|
|
653
798
|
t += 2;
|
|
654
799
|
const A = e.getUint16(t, this.littleEndian);
|
|
655
800
|
t += 2;
|
|
656
|
-
const
|
|
657
|
-
|
|
801
|
+
const N = e.getUint16(t, this.littleEndian);
|
|
802
|
+
t += 2;
|
|
803
|
+
const E = [w, A, N];
|
|
804
|
+
g.push(E), d.length > 0 && p.push([d[E[0]], d[E[1]], d[E[2]]]);
|
|
658
805
|
}
|
|
659
|
-
const f = [],
|
|
806
|
+
const f = [], T = [];
|
|
660
807
|
for (let m = 0; m < g.length; m++) {
|
|
661
|
-
const
|
|
662
|
-
f.push(...
|
|
663
|
-
let H = new
|
|
664
|
-
const
|
|
665
|
-
|
|
808
|
+
const w = g[m], A = l[w[0]], N = l[w[1]], E = l[w[2]];
|
|
809
|
+
f.push(...A.toArray(), ...N.toArray(), ...E.toArray());
|
|
810
|
+
let H = new R(), G = new R(), _ = new R();
|
|
811
|
+
const D = p[m];
|
|
812
|
+
D !== void 0 && (H = D[0], G = D[1], _ = D[2]), T.push(...H.toArray(), ...G.toArray(), ..._.toArray());
|
|
666
813
|
}
|
|
667
|
-
const
|
|
668
|
-
if (
|
|
669
|
-
const m = new
|
|
670
|
-
m.name =
|
|
814
|
+
const M = new Float32Array(f), P = new Float32Array(T), x = new rt();
|
|
815
|
+
if (M.length > 0 && x.setAttribute("position", new he(M, 3)), P.length > 0 && x.setAttribute("uv", new he(P, 2)), x.computeVertexNormals(), this.materials.has(h)) {
|
|
816
|
+
const m = new z(x, this.materials.get(h));
|
|
817
|
+
m.name = c, m.castShadow = !0, m.receiveShadow = !0, i.add(m);
|
|
671
818
|
}
|
|
672
819
|
}
|
|
673
|
-
s(
|
|
820
|
+
s(i);
|
|
674
821
|
}
|
|
675
822
|
_parseV3(e, t, s) {
|
|
676
|
-
const
|
|
677
|
-
console.warn("SBMLoader: SBM version 3 is not supported yet."), s(
|
|
823
|
+
const i = new ee();
|
|
824
|
+
console.warn("SBMLoader: SBM version 3 is not supported yet."), s(i);
|
|
678
825
|
}
|
|
679
826
|
}
|
|
680
|
-
class
|
|
681
|
-
load(e, t, s,
|
|
682
|
-
let
|
|
827
|
+
class Es extends nt {
|
|
828
|
+
load(e, t, s, i) {
|
|
829
|
+
let n;
|
|
683
830
|
if (this.resourcePath !== "")
|
|
684
|
-
|
|
831
|
+
n = this.resourcePath;
|
|
685
832
|
else if (this.path !== "") {
|
|
686
|
-
const
|
|
687
|
-
|
|
833
|
+
const c = I.extractUrlBase(e);
|
|
834
|
+
n = I.resolveURL(c, this.path);
|
|
688
835
|
} else
|
|
689
|
-
|
|
836
|
+
n = I.extractUrlBase(e);
|
|
690
837
|
this.manager.itemStart(e);
|
|
691
|
-
const r = (
|
|
692
|
-
|
|
693
|
-
},
|
|
694
|
-
|
|
838
|
+
const r = (c) => {
|
|
839
|
+
i ? i(c) : console.error(c), this.manager.itemError(e), this.manager.itemEnd(e);
|
|
840
|
+
}, o = new Ee(this.manager);
|
|
841
|
+
o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(
|
|
695
842
|
e,
|
|
696
|
-
(
|
|
843
|
+
(c) => {
|
|
697
844
|
try {
|
|
698
845
|
this.parse(
|
|
699
|
-
|
|
700
|
-
|
|
846
|
+
c,
|
|
847
|
+
n,
|
|
701
848
|
(h) => {
|
|
702
849
|
t(h), this.manager.itemEnd(e);
|
|
703
850
|
},
|
|
@@ -711,49 +858,49 @@ class Jt extends Qe {
|
|
|
711
858
|
r
|
|
712
859
|
);
|
|
713
860
|
}
|
|
714
|
-
parse(e, t, s,
|
|
715
|
-
const
|
|
716
|
-
if (
|
|
717
|
-
|
|
861
|
+
parse(e, t, s, i) {
|
|
862
|
+
const n = new TextDecoder().decode(e.slice(0, 8));
|
|
863
|
+
if (n !== "SBK-----" && n !== "SBM-----") {
|
|
864
|
+
i?.(new Error(`SBMLoader: Invalid SBM format: ${n}`));
|
|
718
865
|
return;
|
|
719
866
|
}
|
|
720
|
-
new
|
|
867
|
+
new xs(e, {
|
|
721
868
|
path: t,
|
|
722
869
|
crossOrigin: this.crossOrigin,
|
|
723
870
|
requestHeader: this.requestHeader,
|
|
724
871
|
manager: this.manager
|
|
725
|
-
}).parse(s,
|
|
872
|
+
}).parse(s, i);
|
|
726
873
|
}
|
|
727
874
|
parseAsync(e, t) {
|
|
728
|
-
return new Promise((s,
|
|
875
|
+
return new Promise((s, i) => {
|
|
729
876
|
this.parse(
|
|
730
877
|
e,
|
|
731
878
|
t,
|
|
732
|
-
(
|
|
733
|
-
s(
|
|
879
|
+
(n) => {
|
|
880
|
+
s(n);
|
|
734
881
|
},
|
|
735
|
-
(
|
|
736
|
-
n
|
|
882
|
+
(n) => {
|
|
883
|
+
i(n);
|
|
737
884
|
}
|
|
738
885
|
);
|
|
739
886
|
});
|
|
740
887
|
}
|
|
741
888
|
}
|
|
742
|
-
class
|
|
889
|
+
class B {
|
|
743
890
|
static CACHE_NAME = "u-space-model-loader-cache";
|
|
744
|
-
static fileLoader = new
|
|
745
|
-
static dracoLoader = new
|
|
746
|
-
`https://cdn.jsdelivr.net/npm/three@0.${
|
|
891
|
+
static fileLoader = new Ee().setResponseType("arraybuffer");
|
|
892
|
+
static dracoLoader = new Kt().setDecoderPath(
|
|
893
|
+
`https://cdn.jsdelivr.net/npm/three@0.${le}.0/examples/jsm/libs/draco/`
|
|
747
894
|
);
|
|
748
|
-
static ktx2Loader = new
|
|
749
|
-
`https://cdn.jsdelivr.net/npm/three@0.${
|
|
895
|
+
static ktx2Loader = new Qt().setTranscoderPath(
|
|
896
|
+
`https://cdn.jsdelivr.net/npm/three@0.${le}.0/examples/jsm/libs/basis/`
|
|
750
897
|
);
|
|
751
|
-
static gltfLoader = new
|
|
752
|
-
static sbmxLoader = new
|
|
753
|
-
static sbmLoader = new
|
|
754
|
-
static fbxLoader = new
|
|
755
|
-
static objLoader = new
|
|
756
|
-
static stlLoader = new
|
|
898
|
+
static gltfLoader = new Le().setDRACOLoader(B.dracoLoader).setKTX2Loader(B.ktx2Loader).setMeshoptDecoder(ge);
|
|
899
|
+
static sbmxLoader = new ls().setDRACOLoader(B.dracoLoader).setKTX2Loader(B.ktx2Loader).setMeshoptDecoder(ge);
|
|
900
|
+
static sbmLoader = new Es();
|
|
901
|
+
static fbxLoader = new Ht();
|
|
902
|
+
static objLoader = new $t();
|
|
903
|
+
static stlLoader = new Wt();
|
|
757
904
|
static setLoadingManager(e) {
|
|
758
905
|
this.fileLoader.manager = e, this.dracoLoader.manager = e, this.ktx2Loader.manager = e, this.gltfLoader.manager = e, this.sbmxLoader.manager = e, this.sbmLoader.manager = e, this.fbxLoader.manager = e, this.objLoader.manager = e, this.stlLoader.manager = e;
|
|
759
906
|
}
|
|
@@ -777,25 +924,25 @@ class R {
|
|
|
777
924
|
}
|
|
778
925
|
static async loadAsync(e, t = { persistent: !0 }) {
|
|
779
926
|
const s = e.split(".").pop()?.split("?")[0].toLowerCase();
|
|
780
|
-
let
|
|
781
|
-
switch (t.persistent && typeof caches < "u" ?
|
|
927
|
+
let i;
|
|
928
|
+
switch (t.persistent && typeof caches < "u" ? i = await this.getPersistentData(e) : i = await this.fileLoader.loadAsync(e), s) {
|
|
782
929
|
case "gltf":
|
|
783
930
|
case "glb":
|
|
784
|
-
const
|
|
785
|
-
return
|
|
931
|
+
const n = await this.gltfLoader.parseAsync(i, I.extractUrlBase(e));
|
|
932
|
+
return n.scene.animations = n.animations, n.scene;
|
|
786
933
|
case "sbmx":
|
|
787
|
-
const r = await this.sbmxLoader.parseAsync(
|
|
934
|
+
const r = await this.sbmxLoader.parseAsync(i, I.extractUrlBase(e));
|
|
788
935
|
return r.scene.animations = r.animations, r.scene;
|
|
789
936
|
case "sbm":
|
|
790
|
-
return await this.sbmLoader.parseAsync(
|
|
937
|
+
return await this.sbmLoader.parseAsync(i, I.extractUrlBase(e));
|
|
791
938
|
case "fbx":
|
|
792
|
-
return this.fbxLoader.parse(
|
|
939
|
+
return this.fbxLoader.parse(i, I.extractUrlBase(e));
|
|
793
940
|
case "obj":
|
|
794
|
-
const h = new TextDecoder().decode(
|
|
941
|
+
const h = new TextDecoder().decode(i);
|
|
795
942
|
return this.objLoader.parse(h);
|
|
796
943
|
case "stl":
|
|
797
|
-
const
|
|
798
|
-
return new
|
|
944
|
+
const d = this.stlLoader.parse(i);
|
|
945
|
+
return new z(d, new L());
|
|
799
946
|
default:
|
|
800
947
|
throw new Error(`Unsupported model format: ${s}`);
|
|
801
948
|
}
|
|
@@ -805,17 +952,17 @@ class R {
|
|
|
805
952
|
const t = await caches.open(this.CACHE_NAME), s = await t.match(e);
|
|
806
953
|
if (s)
|
|
807
954
|
return await s.arrayBuffer();
|
|
808
|
-
const
|
|
809
|
-
return await t.put(e,
|
|
955
|
+
const i = await this.fileLoader.loadAsync(e), n = new Response(i);
|
|
956
|
+
return await t.put(e, n), i;
|
|
810
957
|
} catch (t) {
|
|
811
958
|
return console.warn(`[LoaderManager] Failed to use Cache API for ${e}:`, t), await this.fileLoader.loadAsync(e);
|
|
812
959
|
}
|
|
813
960
|
}
|
|
814
961
|
}
|
|
815
|
-
class
|
|
816
|
-
static textureLoader = new
|
|
817
|
-
static hdrLoader = new
|
|
818
|
-
static cubeTextureLoader = new
|
|
962
|
+
class ti {
|
|
963
|
+
static textureLoader = new Me();
|
|
964
|
+
static hdrLoader = new Xt();
|
|
965
|
+
static cubeTextureLoader = new ht();
|
|
819
966
|
static setLoadingManager(e) {
|
|
820
967
|
this.textureLoader.manager = e, this.hdrLoader.manager = e, this.cubeTextureLoader.manager = e;
|
|
821
968
|
}
|
|
@@ -824,13 +971,13 @@ class xs {
|
|
|
824
971
|
}
|
|
825
972
|
static async loadAsyncHDR(e) {
|
|
826
973
|
const t = await this.hdrLoader.loadAsync(e);
|
|
827
|
-
return t.mapping =
|
|
974
|
+
return t.mapping = lt, t;
|
|
828
975
|
}
|
|
829
976
|
static async loadAsyncCubeTexture(e, t) {
|
|
830
977
|
return this.cubeTextureLoader.setPath(e), await this.cubeTextureLoader.loadAsync(t);
|
|
831
978
|
}
|
|
832
979
|
}
|
|
833
|
-
class
|
|
980
|
+
class k extends z {
|
|
834
981
|
isBaseMesh = !0;
|
|
835
982
|
type = "BaseMesh";
|
|
836
983
|
ignoreInvisibleWhenRaycast = !0;
|
|
@@ -841,7 +988,7 @@ class j extends F {
|
|
|
841
988
|
return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
|
|
842
989
|
}
|
|
843
990
|
}
|
|
844
|
-
class
|
|
991
|
+
class Be extends ee {
|
|
845
992
|
isBaseGroup = !0;
|
|
846
993
|
type = "BaseGroup";
|
|
847
994
|
ignoreInvisibleWhenRaycast = !0;
|
|
@@ -852,7 +999,7 @@ class Ee extends Q {
|
|
|
852
999
|
return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
|
|
853
1000
|
}
|
|
854
1001
|
}
|
|
855
|
-
class
|
|
1002
|
+
class Ms extends dt {
|
|
856
1003
|
isBaseSprite = !0;
|
|
857
1004
|
type = "BaseSprite";
|
|
858
1005
|
ignoreInvisibleWhenRaycast = !0;
|
|
@@ -863,7 +1010,7 @@ class Zt extends Ve {
|
|
|
863
1010
|
return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
|
|
864
1011
|
}
|
|
865
1012
|
}
|
|
866
|
-
class
|
|
1013
|
+
class Z extends Be {
|
|
867
1014
|
isModel = !0;
|
|
868
1015
|
type = "Model";
|
|
869
1016
|
static memoryCache = /* @__PURE__ */ new Map();
|
|
@@ -874,24 +1021,24 @@ class W extends Ee {
|
|
|
874
1021
|
super();
|
|
875
1022
|
}
|
|
876
1023
|
async loadAsync(e) {
|
|
877
|
-
const { url: t, cache: s = !0, persistent:
|
|
1024
|
+
const { url: t, cache: s = !0, persistent: i = !0 } = e;
|
|
878
1025
|
try {
|
|
879
|
-
let
|
|
880
|
-
s ?
|
|
881
|
-
const r = await
|
|
882
|
-
return this.add(
|
|
883
|
-
} catch (
|
|
884
|
-
return console.error(`[Model] Failed to load model from ${t}:`,
|
|
1026
|
+
let n;
|
|
1027
|
+
s ? Z.memoryCache.has(t) ? n = Z.memoryCache.get(t) : (n = B.loadAsync(t, { persistent: i }), Z.memoryCache.set(t, n)) : n = B.loadAsync(t, { persistent: i });
|
|
1028
|
+
const r = await n, o = qt(r);
|
|
1029
|
+
return this.add(o), o.animations && o.animations.length > 0 && (this.animations = o.animations, this.mixer = new pt(o)), o;
|
|
1030
|
+
} catch (n) {
|
|
1031
|
+
return console.error(`[Model] Failed to load model from ${t}:`, n), null;
|
|
885
1032
|
}
|
|
886
1033
|
}
|
|
887
1034
|
playAnimation(e, t = {}) {
|
|
888
1035
|
if (!this.mixer || this.animations.length === 0) return null;
|
|
889
|
-
const { loop: s = !0, repetitions:
|
|
890
|
-
let
|
|
891
|
-
if (e === void 0 ?
|
|
1036
|
+
const { loop: s = !0, repetitions: i = 1 / 0, timeScale: n = 1, clampWhenFinished: r = !1 } = t;
|
|
1037
|
+
let o;
|
|
1038
|
+
if (e === void 0 ? o = this.animations[0] : typeof e == "number" ? o = this.animations[e] : o = this.animations.find((h) => h.name === e), !o)
|
|
892
1039
|
return console.warn(`[Model] Animation not found: ${e}`), null;
|
|
893
|
-
let
|
|
894
|
-
return
|
|
1040
|
+
let c = this.actions.get(o.name);
|
|
1041
|
+
return c || (c = this.mixer.clipAction(o), this.actions.set(o.name, c)), c.setLoop(s ? ut : mt, i), c.clampWhenFinished = r, c.timeScale = n, c.reset().play(), c;
|
|
895
1042
|
}
|
|
896
1043
|
playAllAnimations(e = {}) {
|
|
897
1044
|
return this.animations.map((t, s) => this.playAnimation(s, e)).filter((t) => t !== null);
|
|
@@ -915,11 +1062,11 @@ class W extends Ee {
|
|
|
915
1062
|
typeof caches < "u" && await caches.delete("u-space-loader-cache");
|
|
916
1063
|
}
|
|
917
1064
|
}
|
|
918
|
-
class
|
|
1065
|
+
class Ps extends k {
|
|
919
1066
|
isSphereMesh = !0;
|
|
920
1067
|
type = "SphereMesh";
|
|
921
1068
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
922
|
-
super(), this.geometry = new
|
|
1069
|
+
super(), this.geometry = new gt(
|
|
923
1070
|
e?.radius,
|
|
924
1071
|
e?.widthSegments,
|
|
925
1072
|
e?.heightSegments,
|
|
@@ -927,23 +1074,23 @@ class Vt extends j {
|
|
|
927
1074
|
e?.phiLength,
|
|
928
1075
|
e?.thetaStart,
|
|
929
1076
|
e?.thetaLength
|
|
930
|
-
), this.material = new
|
|
1077
|
+
), this.material = new L(t);
|
|
931
1078
|
}
|
|
932
1079
|
}
|
|
933
|
-
class
|
|
1080
|
+
class we extends k {
|
|
934
1081
|
isTubeMesh = !0;
|
|
935
1082
|
type = "TubeMesh";
|
|
936
1083
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
937
|
-
super(), this.geometry = new
|
|
1084
|
+
super(), this.geometry = new ft(
|
|
938
1085
|
e?.path,
|
|
939
1086
|
e?.tubularSegments,
|
|
940
1087
|
e?.radius,
|
|
941
1088
|
e?.radialSegments,
|
|
942
1089
|
e?.closed
|
|
943
|
-
), this.material = new
|
|
1090
|
+
), this.material = new L(t);
|
|
944
1091
|
}
|
|
945
1092
|
}
|
|
946
|
-
class
|
|
1093
|
+
class si extends Be {
|
|
947
1094
|
isTopology = !0;
|
|
948
1095
|
type = "Topology";
|
|
949
1096
|
// Visuals
|
|
@@ -988,14 +1135,14 @@ class Ms extends Ee {
|
|
|
988
1135
|
* @param weight Cost of the edge. Defaults to Euclidean distance.
|
|
989
1136
|
* @param bidirectional If true, adds the reverse edge as well. Default true.
|
|
990
1137
|
*/
|
|
991
|
-
addEdge(e, t, s,
|
|
992
|
-
const
|
|
993
|
-
if (!
|
|
1138
|
+
addEdge(e, t, s, i = !0) {
|
|
1139
|
+
const n = this.nodes.get(e), r = this.nodes.get(t);
|
|
1140
|
+
if (!n || !r) {
|
|
994
1141
|
console.error(`[Topology] Cannot add edge. One or both nodes not found: ${e}, ${t}`);
|
|
995
1142
|
return;
|
|
996
1143
|
}
|
|
997
|
-
const
|
|
998
|
-
this.getNeighbors(e)?.set(t,
|
|
1144
|
+
const o = s ?? n.distanceTo(r);
|
|
1145
|
+
this.getNeighbors(e)?.set(t, o), i && this.getNeighbors(t)?.set(e, o);
|
|
999
1146
|
}
|
|
1000
1147
|
/**
|
|
1001
1148
|
* Remove an edge between two nodes.
|
|
@@ -1012,33 +1159,33 @@ class Ms extends Ee {
|
|
|
1012
1159
|
getShortestPath(e, t) {
|
|
1013
1160
|
if (!this.nodes.has(e) || !this.nodes.has(t))
|
|
1014
1161
|
return console.warn("[Topology] Start or End node not found."), [];
|
|
1015
|
-
const s = /* @__PURE__ */ new Map(),
|
|
1016
|
-
for (const [
|
|
1017
|
-
s.set(
|
|
1018
|
-
for (s.set(e, 0);
|
|
1019
|
-
let
|
|
1020
|
-
for (const
|
|
1021
|
-
const g = s.get(
|
|
1022
|
-
g < h && (h = g,
|
|
1162
|
+
const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
1163
|
+
for (const [c] of this.nodes)
|
|
1164
|
+
s.set(c, 1 / 0), i.set(c, null), n.add(c);
|
|
1165
|
+
for (s.set(e, 0); n.size > 0; ) {
|
|
1166
|
+
let c = null, h = 1 / 0;
|
|
1167
|
+
for (const d of n) {
|
|
1168
|
+
const g = s.get(d);
|
|
1169
|
+
g < h && (h = g, c = d);
|
|
1023
1170
|
}
|
|
1024
|
-
if (
|
|
1171
|
+
if (c === null || c === t || h === 1 / 0)
|
|
1025
1172
|
break;
|
|
1026
|
-
|
|
1027
|
-
const l = this.adjacencyMap?.get(
|
|
1173
|
+
n.delete(c);
|
|
1174
|
+
const l = this.adjacencyMap?.get(c);
|
|
1028
1175
|
if (l)
|
|
1029
|
-
for (const [
|
|
1030
|
-
if (!
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1176
|
+
for (const [d, g] of l) {
|
|
1177
|
+
if (!n.has(d)) continue;
|
|
1178
|
+
const p = s.get(c) + g;
|
|
1179
|
+
p < s.get(d) && (s.set(d, p), i.set(d, c));
|
|
1033
1180
|
}
|
|
1034
1181
|
}
|
|
1035
1182
|
const r = [];
|
|
1036
|
-
let
|
|
1037
|
-
if (
|
|
1183
|
+
let o = t;
|
|
1184
|
+
if (i.get(t) === null && e !== t)
|
|
1038
1185
|
return [];
|
|
1039
|
-
for (;
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1186
|
+
for (; o !== null; ) {
|
|
1187
|
+
const c = this.nodes.get(o);
|
|
1188
|
+
c && r.unshift(c), o = i.get(o) || null;
|
|
1042
1189
|
}
|
|
1043
1190
|
return r;
|
|
1044
1191
|
}
|
|
@@ -1046,8 +1193,8 @@ class Ms extends Ee {
|
|
|
1046
1193
|
* Renders the entire topology graph structure using TubeGeometry and Spheres.
|
|
1047
1194
|
*/
|
|
1048
1195
|
renderGraph() {
|
|
1049
|
-
this.clearGraph(), this.graphGroup = new
|
|
1050
|
-
const e = new
|
|
1196
|
+
this.clearGraph(), this.graphGroup = new ee();
|
|
1197
|
+
const e = new Ps({
|
|
1051
1198
|
geometryParameters: {
|
|
1052
1199
|
radius: this.parameters.nodeRadius,
|
|
1053
1200
|
widthSegments: 16,
|
|
@@ -1057,19 +1204,19 @@ class Ms extends Ee {
|
|
|
1057
1204
|
color: this.parameters.nodeColor
|
|
1058
1205
|
}
|
|
1059
1206
|
});
|
|
1060
|
-
this.nodes.forEach((s,
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1207
|
+
this.nodes.forEach((s, i) => {
|
|
1208
|
+
const n = e.clone();
|
|
1209
|
+
n.position.copy(s), Object.assign(n.userData, { id: i, type: "node" }), this.graphGroup.add(n);
|
|
1063
1210
|
});
|
|
1064
1211
|
const t = /* @__PURE__ */ new Set();
|
|
1065
|
-
this.adjacencyMap.forEach((s,
|
|
1066
|
-
s.forEach((
|
|
1067
|
-
const
|
|
1068
|
-
if (t.has(
|
|
1069
|
-
t.add(
|
|
1070
|
-
const
|
|
1071
|
-
if (
|
|
1072
|
-
const l = new
|
|
1212
|
+
this.adjacencyMap.forEach((s, i) => {
|
|
1213
|
+
s.forEach((n, r) => {
|
|
1214
|
+
const o = [i, r].sort().join("-");
|
|
1215
|
+
if (t.has(o)) return;
|
|
1216
|
+
t.add(o);
|
|
1217
|
+
const c = this.nodes.get(i), h = this.nodes.get(r);
|
|
1218
|
+
if (c && h) {
|
|
1219
|
+
const l = new yt(c, h), d = new we({
|
|
1073
1220
|
geometryParameters: {
|
|
1074
1221
|
path: l,
|
|
1075
1222
|
tubularSegments: 1,
|
|
@@ -1081,14 +1228,14 @@ class Ms extends Ee {
|
|
|
1081
1228
|
color: this.parameters.edgeColor
|
|
1082
1229
|
}
|
|
1083
1230
|
});
|
|
1084
|
-
Object.assign(
|
|
1231
|
+
Object.assign(d.userData, { from: i, to: r, weight: n, type: "edge" }), this.graphGroup.add(d);
|
|
1085
1232
|
}
|
|
1086
1233
|
});
|
|
1087
1234
|
}), this.add(this.graphGroup);
|
|
1088
1235
|
}
|
|
1089
1236
|
clearGraph() {
|
|
1090
1237
|
this.graphGroup && (this.remove(this.graphGroup), this.graphGroup.traverse((e) => {
|
|
1091
|
-
e instanceof
|
|
1238
|
+
e instanceof z && (e.geometry.dispose(), e.material.dispose());
|
|
1092
1239
|
}), this.graphGroup = null);
|
|
1093
1240
|
}
|
|
1094
1241
|
/**
|
|
@@ -1096,7 +1243,7 @@ class Ms extends Ee {
|
|
|
1096
1243
|
*/
|
|
1097
1244
|
renderPath(e, t = this.parameters.pathColor) {
|
|
1098
1245
|
if (e.length < 2) return;
|
|
1099
|
-
const s = new
|
|
1246
|
+
const s = new wt(e, !1, "catmullrom", 0), i = new we({
|
|
1100
1247
|
geometryParameters: {
|
|
1101
1248
|
path: s,
|
|
1102
1249
|
tubularSegments: e.length * 10,
|
|
@@ -1107,7 +1254,7 @@ class Ms extends Ee {
|
|
|
1107
1254
|
color: t
|
|
1108
1255
|
}
|
|
1109
1256
|
});
|
|
1110
|
-
return this.add(
|
|
1257
|
+
return this.add(i), this.pathMeshes.push(i), i;
|
|
1111
1258
|
}
|
|
1112
1259
|
clearPaths() {
|
|
1113
1260
|
this.pathMeshes.forEach((e) => {
|
|
@@ -1117,14 +1264,14 @@ class Ms extends Ee {
|
|
|
1117
1264
|
/** Export nodes and edges as a JSON-serializable object. */
|
|
1118
1265
|
exportData() {
|
|
1119
1266
|
const e = {};
|
|
1120
|
-
this.nodes.forEach((
|
|
1121
|
-
e[
|
|
1267
|
+
this.nodes.forEach((i, n) => {
|
|
1268
|
+
e[n] = { x: i.x, y: i.y, z: i.z };
|
|
1122
1269
|
});
|
|
1123
1270
|
const t = [], s = /* @__PURE__ */ new Set();
|
|
1124
|
-
return this.adjacencyMap.forEach((
|
|
1125
|
-
|
|
1126
|
-
const
|
|
1127
|
-
s.has(
|
|
1271
|
+
return this.adjacencyMap.forEach((i, n) => {
|
|
1272
|
+
i.forEach((r, o) => {
|
|
1273
|
+
const c = [n, o].sort().join("-");
|
|
1274
|
+
s.has(c) || (s.add(c), t.push({ from: n, to: o, weight: r }));
|
|
1128
1275
|
});
|
|
1129
1276
|
}), { nodes: e, edges: t };
|
|
1130
1277
|
}
|
|
@@ -1134,9 +1281,9 @@ class Ms extends Ee {
|
|
|
1134
1281
|
*/
|
|
1135
1282
|
importData(e) {
|
|
1136
1283
|
this.clearGraph(), this.clearPaths(), this.nodes.clear(), this.adjacencyMap.clear(), Object.entries(e.nodes).forEach(([t, s]) => {
|
|
1137
|
-
this.addNode(t, new
|
|
1138
|
-
}), e.edges.forEach(({ from: t, to: s, weight:
|
|
1139
|
-
this.addEdge(t, s,
|
|
1284
|
+
this.addNode(t, new oe(s.x, s.y, s.z));
|
|
1285
|
+
}), e.edges.forEach(({ from: t, to: s, weight: i }) => {
|
|
1286
|
+
this.addEdge(t, s, i);
|
|
1140
1287
|
}), this.renderGraph();
|
|
1141
1288
|
}
|
|
1142
1289
|
dispose() {
|
|
@@ -1146,7 +1293,7 @@ class Ms extends Ee {
|
|
|
1146
1293
|
return this.adjacencyMap.get(e);
|
|
1147
1294
|
}
|
|
1148
1295
|
}
|
|
1149
|
-
class
|
|
1296
|
+
class ii extends Ms {
|
|
1150
1297
|
isPoi = !0;
|
|
1151
1298
|
type = "Poi";
|
|
1152
1299
|
parameters = {
|
|
@@ -1165,7 +1312,7 @@ class Es extends Zt {
|
|
|
1165
1312
|
_canvas = document.createElement("canvas");
|
|
1166
1313
|
_lastParametersJSON = "";
|
|
1167
1314
|
constructor(e = {}) {
|
|
1168
|
-
super(new
|
|
1315
|
+
super(new vt()), Object.assign(this.parameters, e), this.updateAsync();
|
|
1169
1316
|
}
|
|
1170
1317
|
/**
|
|
1171
1318
|
* Update the POI with new parameters
|
|
@@ -1176,174 +1323,221 @@ class Es extends Zt {
|
|
|
1176
1323
|
const t = JSON.stringify(this.parameters);
|
|
1177
1324
|
if (t === this._lastParametersJSON) return;
|
|
1178
1325
|
this._lastParametersJSON = t;
|
|
1179
|
-
const s = this._canvas,
|
|
1180
|
-
if (!
|
|
1181
|
-
|
|
1182
|
-
let
|
|
1183
|
-
this.parameters.img && (
|
|
1184
|
-
const { text: r, fontSize:
|
|
1185
|
-
let f = 0,
|
|
1186
|
-
const
|
|
1187
|
-
if (
|
|
1188
|
-
switch (
|
|
1326
|
+
const s = this._canvas, i = s.getContext("2d");
|
|
1327
|
+
if (!i) return;
|
|
1328
|
+
i.font = `${this.parameters.fontSize}px ${this.parameters.fontFamily}`;
|
|
1329
|
+
let n = null;
|
|
1330
|
+
this.parameters.img && (n = await this._loadImage(this.parameters.img));
|
|
1331
|
+
const { text: r, fontSize: o, color: c, iconSize: h, padding: l, backgroundColor: d, borderRadius: g, textPosition: p, scaleFactor: y } = this.parameters, v = i.measureText(r), S = r ? v.width : 0, b = r ? o : 0;
|
|
1332
|
+
let f = 0, T = 0, M = 0, P = 0, x = 0, m = 0;
|
|
1333
|
+
const w = !!n, A = !!r;
|
|
1334
|
+
if (w && A)
|
|
1335
|
+
switch (p) {
|
|
1189
1336
|
case "top":
|
|
1190
|
-
f = Math.max(h,
|
|
1337
|
+
f = Math.max(h, S), T = h + l + b, x = (f - S) / 2, m = b / 2, M = (f - h) / 2, P = b + l;
|
|
1191
1338
|
break;
|
|
1192
1339
|
case "bottom":
|
|
1193
|
-
f = Math.max(h,
|
|
1340
|
+
f = Math.max(h, S), T = h + l + b, M = (f - h) / 2, P = 0, x = (f - S) / 2, m = h + l + b / 2;
|
|
1194
1341
|
break;
|
|
1195
1342
|
case "left":
|
|
1196
|
-
f = h + l +
|
|
1343
|
+
f = h + l + S, T = Math.max(h, b), x = 0, m = T / 2, M = S + l, P = (T - h) / 2;
|
|
1197
1344
|
break;
|
|
1198
1345
|
default:
|
|
1199
|
-
f = h + l +
|
|
1346
|
+
f = h + l + S, T = Math.max(h, b), M = 0, P = (T - h) / 2, x = h + l, m = T / 2;
|
|
1200
1347
|
break;
|
|
1201
1348
|
}
|
|
1202
|
-
else
|
|
1203
|
-
const
|
|
1204
|
-
if (s.width =
|
|
1205
|
-
|
|
1206
|
-
const _ =
|
|
1207
|
-
|
|
1349
|
+
else w ? (f = h, T = h, M = 0, P = 0) : A && (f = S, T = b, x = 0, m = b / 2);
|
|
1350
|
+
const N = f + l * 2, E = T + l * 2;
|
|
1351
|
+
if (s.width = N, s.height = E, i.font = `${o}px ${this.parameters.fontFamily}`, d && (i.fillStyle = d, this._drawRoundedRect(i, 0, 0, N, E, g), i.fill()), w && i.drawImage(n, M + l, P + l, h, h), A) {
|
|
1352
|
+
i.fillStyle = c;
|
|
1353
|
+
const _ = i.measureText(r), D = _.actualBoundingBoxAscent + _.actualBoundingBoxDescent, He = _.actualBoundingBoxAscent - D / 2;
|
|
1354
|
+
i.textBaseline = "alphabetic", i.fillText(r, x + l, m + l + He);
|
|
1208
1355
|
}
|
|
1209
|
-
const H = this.material.map,
|
|
1210
|
-
|
|
1356
|
+
const H = this.material.map, G = new bt(s);
|
|
1357
|
+
G.colorSpace = Pe, this.material.map = G, H?.dispose(), this.scale.set(N * y, E * y, 1);
|
|
1211
1358
|
}
|
|
1212
1359
|
_loadImage(e) {
|
|
1213
1360
|
return new Promise((t, s) => {
|
|
1214
1361
|
if (typeof e == "string") {
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1362
|
+
const i = new Image();
|
|
1363
|
+
i.crossOrigin = "Anonymous", i.onload = () => t(i), i.onerror = () => s(new Error(`Failed to load image: ${e}`)), i.src = e;
|
|
1217
1364
|
} else
|
|
1218
1365
|
t(e);
|
|
1219
1366
|
});
|
|
1220
1367
|
}
|
|
1221
|
-
_drawRoundedRect(e, t, s,
|
|
1222
|
-
e.beginPath(), e.moveTo(t + r, s), e.lineTo(t +
|
|
1368
|
+
_drawRoundedRect(e, t, s, i, n, r) {
|
|
1369
|
+
e.beginPath(), e.moveTo(t + r, s), e.lineTo(t + i - r, s), e.quadraticCurveTo(t + i, s, t + i, s + r), e.lineTo(t + i, s + n - r), e.quadraticCurveTo(t + i, s + n, t + i - r, s + n), e.lineTo(t + r, s + n), e.quadraticCurveTo(t, s + n, t, s + n - r), e.lineTo(t, s + r), e.quadraticCurveTo(t, s, t + r, s), e.closePath();
|
|
1223
1370
|
}
|
|
1224
1371
|
dispose() {
|
|
1225
1372
|
this.material.map?.dispose(), this.material.dispose();
|
|
1226
1373
|
}
|
|
1227
1374
|
}
|
|
1228
|
-
class
|
|
1375
|
+
class _e extends k {
|
|
1229
1376
|
isShapeMesh = !0;
|
|
1230
1377
|
type = "ShapeMesh";
|
|
1231
1378
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1232
|
-
super(), this.geometry = new
|
|
1379
|
+
super(), this.geometry = new Ct(e?.shape, e?.curveSegments), this.material = new L(t), this.geometry.rotateX(-Math.PI / 2);
|
|
1233
1380
|
}
|
|
1234
1381
|
static createFromPoints(e, t = {}) {
|
|
1235
|
-
return new
|
|
1382
|
+
return new _e({
|
|
1236
1383
|
...t,
|
|
1237
1384
|
geometryParameters: {
|
|
1238
1385
|
...t.geometryParameters,
|
|
1239
|
-
shape: new
|
|
1386
|
+
shape: new Oe(e.map((s) => new R(s.x, -s.z)))
|
|
1240
1387
|
}
|
|
1241
1388
|
});
|
|
1242
1389
|
}
|
|
1243
1390
|
}
|
|
1244
|
-
class
|
|
1391
|
+
class De extends k {
|
|
1245
1392
|
isExtrudeMesh = !0;
|
|
1246
1393
|
type = "ExtrudeMesh";
|
|
1247
1394
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1248
|
-
super(), this.geometry = new
|
|
1395
|
+
super(), this.geometry = new Tt(e?.shape, e?.options), this.material = new L(t), this.geometry.rotateX(-Math.PI / 2);
|
|
1249
1396
|
}
|
|
1250
1397
|
static createFromPoints(e, t = {}) {
|
|
1251
|
-
return new
|
|
1398
|
+
return new De({
|
|
1252
1399
|
...t,
|
|
1253
1400
|
geometryParameters: {
|
|
1254
1401
|
...t.geometryParameters,
|
|
1255
|
-
shape: new
|
|
1402
|
+
shape: new Oe(e.map((s) => new R(s.x, -s.z)))
|
|
1256
1403
|
}
|
|
1257
1404
|
});
|
|
1258
1405
|
}
|
|
1259
1406
|
}
|
|
1260
|
-
class
|
|
1407
|
+
class ni extends k {
|
|
1261
1408
|
isPlaneMesh = !0;
|
|
1262
1409
|
type = "PlaneMesh";
|
|
1263
1410
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1264
|
-
super(), this.geometry = new
|
|
1411
|
+
super(), this.geometry = new St(
|
|
1265
1412
|
e?.width,
|
|
1266
1413
|
e?.height,
|
|
1267
1414
|
e?.widthSegments,
|
|
1268
1415
|
e?.heightSegments
|
|
1269
|
-
), this.material = new
|
|
1416
|
+
), this.material = new L(t);
|
|
1270
1417
|
}
|
|
1271
1418
|
}
|
|
1272
|
-
class
|
|
1419
|
+
class ri extends k {
|
|
1273
1420
|
isCircleMesh = !0;
|
|
1274
1421
|
type = "CircleMesh";
|
|
1275
1422
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1276
1423
|
super(
|
|
1277
|
-
new
|
|
1424
|
+
new xt(
|
|
1278
1425
|
e?.radius,
|
|
1279
1426
|
e?.segments,
|
|
1280
1427
|
e?.thetaStart,
|
|
1281
1428
|
e?.thetaLength
|
|
1282
1429
|
),
|
|
1283
|
-
new
|
|
1430
|
+
new L(t)
|
|
1284
1431
|
), this.geometry.rotateX(-Math.PI / 2);
|
|
1285
1432
|
}
|
|
1286
1433
|
}
|
|
1287
|
-
class
|
|
1434
|
+
class W {
|
|
1288
1435
|
static traverseMeshes(e, t) {
|
|
1289
1436
|
e.traverse((s) => {
|
|
1290
|
-
s instanceof
|
|
1437
|
+
s instanceof z && t(s);
|
|
1291
1438
|
});
|
|
1292
1439
|
}
|
|
1293
1440
|
}
|
|
1294
|
-
class
|
|
1441
|
+
class ai {
|
|
1295
1442
|
static flow(e = {}) {
|
|
1296
|
-
const { baseColor: t = 16777215, flowColor: s = 65280, speed:
|
|
1297
|
-
return
|
|
1443
|
+
const { baseColor: t = 16777215, flowColor: s = 65280, speed: i = 1, scale: n = 3, intensity: r = 4 } = e, o = j(new U(t)), c = j(new U(s)), h = pe().x.mul(n).sub(X.mul(i)), l = q(ae(h).add(1).mul(0.5), r);
|
|
1444
|
+
return Y(o, c, l);
|
|
1298
1445
|
}
|
|
1299
1446
|
static breathe(e = {}) {
|
|
1300
|
-
const { baseColor: t = 16777215, breathColor: s = 65280, speed:
|
|
1301
|
-
return
|
|
1447
|
+
const { baseColor: t = 16777215, breathColor: s = 65280, speed: i = 1, intensity: n = 2 } = e, r = j(new U(t)), o = j(new U(s)), c = ae(X.mul(i)).add(1).mul(0.5), h = q(c, n);
|
|
1448
|
+
return Y(r, o, h);
|
|
1302
1449
|
}
|
|
1303
1450
|
static fluid(e = {}) {
|
|
1304
1451
|
const {
|
|
1305
1452
|
baseColor: t = 16777215,
|
|
1306
1453
|
flowColor: s = 255,
|
|
1307
|
-
speed:
|
|
1308
|
-
scale:
|
|
1454
|
+
speed: i = 1,
|
|
1455
|
+
scale: n = 1,
|
|
1309
1456
|
intensity: r = 1,
|
|
1310
|
-
distortion:
|
|
1311
|
-
} = e,
|
|
1312
|
-
return
|
|
1457
|
+
distortion: o = 0.5
|
|
1458
|
+
} = e, c = j(new U(t)), h = j(new U(s)), l = pe().mul(n), d = X.mul(i), g = ue(l.add(d), 1, 0), p = l.add(g.mul(o)), y = ue(p, 1, 0).add(1).mul(0.5), v = q(y, r);
|
|
1459
|
+
return Y(c, h, v);
|
|
1313
1460
|
}
|
|
1314
1461
|
}
|
|
1315
|
-
function
|
|
1462
|
+
function oi(a) {
|
|
1316
1463
|
}
|
|
1317
|
-
const
|
|
1318
|
-
const
|
|
1319
|
-
return
|
|
1320
|
-
})(),
|
|
1321
|
-
const
|
|
1322
|
-
return
|
|
1464
|
+
const ie = "uSpaceHighlight", F = `${ie}/enabled`, je = `${ie}/opacity`, Ue = `${ie}/color`, ke = `${ie}/overwrite`, ne = "uSpaceBreathe", te = `${ne}/enabled`, Ge = `${ne}/color`, Fe = `${ne}/speed`, ze = `${ne}/intensity`, se = /* @__PURE__ */ new WeakMap(), Os = Re(() => {
|
|
1465
|
+
const a = O(F, "uint"), e = O(Ue, "uint"), t = O(ke, "uint"), s = Ce(e), i = me.mul(s), n = J(t.greaterThan(0), s, i), r = J(a.greaterThan(0), n, me), o = O(te, "uint"), c = O(Ge, "uint"), h = O(Fe, "float"), l = O(ze, "float"), d = Ce(c), g = ae(X.mul(h)).add(1).mul(0.5), p = q(g, l), y = Y(r, d, p);
|
|
1466
|
+
return J(o.greaterThan(0), y, r);
|
|
1467
|
+
})(), Rs = Re(() => {
|
|
1468
|
+
const a = O(F, "uint"), e = O(je, "float");
|
|
1469
|
+
return J(a.greaterThan(0), e, Lt);
|
|
1323
1470
|
})();
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1471
|
+
function ve(a) {
|
|
1472
|
+
const e = a.material;
|
|
1473
|
+
if (!e || Array.isArray(e)) return;
|
|
1474
|
+
let t = se.get(e);
|
|
1475
|
+
t || (t = {
|
|
1476
|
+
colorNode: e.colorNode,
|
|
1477
|
+
opacityNode: e.opacityNode,
|
|
1478
|
+
transparent: e.transparent,
|
|
1479
|
+
activeMeshes: /* @__PURE__ */ new Set()
|
|
1480
|
+
}, se.set(e, t)), t.activeMeshes.add(a), e.transparent = !0, e.colorNode = Os, e.opacityNode = Rs, e.needsUpdate = !0;
|
|
1481
|
+
}
|
|
1482
|
+
function be(a) {
|
|
1483
|
+
const e = a.userData[F], t = a.userData[te];
|
|
1484
|
+
if (e || t) return;
|
|
1485
|
+
const s = a.material;
|
|
1486
|
+
if (!s || Array.isArray(s)) return;
|
|
1487
|
+
const i = se.get(s);
|
|
1488
|
+
i && (i.activeMeshes.delete(a), !(i.activeMeshes.size > 0) && (s.colorNode = i.colorNode, s.opacityNode = i.opacityNode, s.transparent = i.transparent, s.needsUpdate = !0, se.delete(s)));
|
|
1489
|
+
}
|
|
1490
|
+
class ci {
|
|
1491
|
+
static highlightColor(e, t = {}) {
|
|
1492
|
+
const s = Array.isArray(e) ? e : [e], i = Object.assign(
|
|
1327
1493
|
{
|
|
1328
|
-
enabled: !0,
|
|
1329
1494
|
opacity: 0.5,
|
|
1330
1495
|
color: 16711680,
|
|
1331
1496
|
overwrite: !1
|
|
1332
1497
|
},
|
|
1333
1498
|
t
|
|
1334
1499
|
);
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1500
|
+
i.color = new V(i.color).getHex();
|
|
1501
|
+
for (const n of s)
|
|
1502
|
+
W.traverseMeshes(n, (r) => {
|
|
1503
|
+
r.userData[F] = 1, r.userData[je] = i.opacity, r.userData[Ue] = i.color, r.userData[ke] = i.overwrite ? 1 : 0, ve(r);
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
static removeHighlightColor(e) {
|
|
1507
|
+
const t = Array.isArray(e) ? e : [e];
|
|
1508
|
+
for (const s of t)
|
|
1509
|
+
W.traverseMeshes(s, (i) => {
|
|
1510
|
+
i.userData[F] = 0, be(i);
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
static breatheColor(e, t = {}) {
|
|
1514
|
+
const s = Array.isArray(e) ? e : [e], i = Object.assign(
|
|
1515
|
+
{
|
|
1516
|
+
color: 65280,
|
|
1517
|
+
speed: 1,
|
|
1518
|
+
intensity: 2
|
|
1519
|
+
},
|
|
1520
|
+
t
|
|
1521
|
+
);
|
|
1522
|
+
i.color = new V(i.color).getHex();
|
|
1523
|
+
for (const n of s)
|
|
1524
|
+
W.traverseMeshes(n, (r) => {
|
|
1525
|
+
r.userData[te] = 1, r.userData[Ge] = i.color, r.userData[Fe] = i.speed, r.userData[ze] = i.intensity, ve(r);
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
static removeBreatheColor(e) {
|
|
1529
|
+
const t = Array.isArray(e) ? e : [e];
|
|
1530
|
+
for (const s of t)
|
|
1531
|
+
W.traverseMeshes(s, (i) => {
|
|
1532
|
+
i.userData[te] = 0, be(i);
|
|
1533
|
+
});
|
|
1340
1534
|
}
|
|
1341
1535
|
}
|
|
1342
|
-
const
|
|
1343
|
-
const e =
|
|
1344
|
-
return
|
|
1536
|
+
const Ce = (a) => {
|
|
1537
|
+
const e = a.shiftRight(16).bitAnd(255).toFloat().div(255), t = a.shiftRight(8).bitAnd(255).toFloat().div(255), s = a.bitAnd(255).toFloat().div(255);
|
|
1538
|
+
return At(e, t, s);
|
|
1345
1539
|
};
|
|
1346
|
-
class
|
|
1540
|
+
class Is extends Yt {
|
|
1347
1541
|
viewer;
|
|
1348
1542
|
constructor(e, t) {
|
|
1349
1543
|
super(t), this.viewer = e;
|
|
@@ -1352,7 +1546,7 @@ class is extends Et {
|
|
|
1352
1546
|
this.update(e) && this.viewer.render();
|
|
1353
1547
|
};
|
|
1354
1548
|
easingByMode(e) {
|
|
1355
|
-
const t =
|
|
1549
|
+
const t = Ls[e];
|
|
1356
1550
|
return super.easing(t);
|
|
1357
1551
|
}
|
|
1358
1552
|
start(e, t) {
|
|
@@ -1362,80 +1556,87 @@ class is extends Et {
|
|
|
1362
1556
|
return this.viewer.removeEventListener("afterControlsUpdate", this._update), super.stop();
|
|
1363
1557
|
}
|
|
1364
1558
|
}
|
|
1365
|
-
function
|
|
1366
|
-
return new Promise((r,
|
|
1367
|
-
const { duration:
|
|
1368
|
-
|
|
1559
|
+
function hi(a, e, t, s = {}, i, n) {
|
|
1560
|
+
return new Promise((r, o) => {
|
|
1561
|
+
const { duration: c = 1e3, delay: h = 0, repeat: l = !1, mode: d = "Linear.None", yoyo: g = !1 } = s, p = new Is(a, e).to(t, c).easingByMode(d).delay(h).onUpdate((y) => {
|
|
1562
|
+
i?.(y, p);
|
|
1369
1563
|
}).onComplete(() => {
|
|
1370
1564
|
r();
|
|
1371
1565
|
}).onStop(() => {
|
|
1372
|
-
|
|
1566
|
+
o("animation stop");
|
|
1373
1567
|
}).onStart(() => {
|
|
1374
|
-
|
|
1568
|
+
n?.(p);
|
|
1375
1569
|
});
|
|
1376
|
-
typeof l == "number" ?
|
|
1570
|
+
typeof l == "number" ? p.repeat(l) : typeof l == "boolean" && l && p.repeat(1 / 0), g && p.repeatDelay(20), p.yoyo(g), p.start();
|
|
1377
1571
|
});
|
|
1378
1572
|
}
|
|
1379
|
-
const
|
|
1380
|
-
"Linear.None":
|
|
1381
|
-
"Quadratic.In":
|
|
1382
|
-
"Quadratic.Out":
|
|
1383
|
-
"Quadratic.InOut":
|
|
1384
|
-
"Cubic.In":
|
|
1385
|
-
"Cubic.Out":
|
|
1386
|
-
"Cubic.InOut":
|
|
1387
|
-
"Quartic.In":
|
|
1388
|
-
"Quartic.Out":
|
|
1389
|
-
"Quartic.InOut":
|
|
1390
|
-
"Quintic.In":
|
|
1391
|
-
"Quintic.Out":
|
|
1392
|
-
"Quintic.InOut":
|
|
1393
|
-
"Sinusoidal.In":
|
|
1394
|
-
"Sinusoidal.Out":
|
|
1395
|
-
"Sinusoidal.InOut":
|
|
1396
|
-
"Exponential.In":
|
|
1397
|
-
"Exponential.Out":
|
|
1398
|
-
"Exponential.InOut":
|
|
1399
|
-
"Circular.In":
|
|
1400
|
-
"Circular.Out":
|
|
1401
|
-
"Circular.InOut":
|
|
1402
|
-
"Elastic.In":
|
|
1403
|
-
"Elastic.Out":
|
|
1404
|
-
"Elastic.InOut":
|
|
1405
|
-
"Back.In":
|
|
1406
|
-
"Back.Out":
|
|
1407
|
-
"Back.InOut":
|
|
1408
|
-
"Bounce.In":
|
|
1409
|
-
"Bounce.Out":
|
|
1410
|
-
"Bounce.InOut":
|
|
1411
|
-
};
|
|
1573
|
+
const Ls = {
|
|
1574
|
+
"Linear.None": u.Linear.None,
|
|
1575
|
+
"Quadratic.In": u.Quadratic.In,
|
|
1576
|
+
"Quadratic.Out": u.Quadratic.Out,
|
|
1577
|
+
"Quadratic.InOut": u.Quadratic.InOut,
|
|
1578
|
+
"Cubic.In": u.Cubic.In,
|
|
1579
|
+
"Cubic.Out": u.Cubic.Out,
|
|
1580
|
+
"Cubic.InOut": u.Cubic.InOut,
|
|
1581
|
+
"Quartic.In": u.Quartic.In,
|
|
1582
|
+
"Quartic.Out": u.Quartic.Out,
|
|
1583
|
+
"Quartic.InOut": u.Quartic.InOut,
|
|
1584
|
+
"Quintic.In": u.Quintic.In,
|
|
1585
|
+
"Quintic.Out": u.Quintic.Out,
|
|
1586
|
+
"Quintic.InOut": u.Quintic.InOut,
|
|
1587
|
+
"Sinusoidal.In": u.Sinusoidal.In,
|
|
1588
|
+
"Sinusoidal.Out": u.Sinusoidal.Out,
|
|
1589
|
+
"Sinusoidal.InOut": u.Sinusoidal.InOut,
|
|
1590
|
+
"Exponential.In": u.Exponential.In,
|
|
1591
|
+
"Exponential.Out": u.Exponential.Out,
|
|
1592
|
+
"Exponential.InOut": u.Exponential.InOut,
|
|
1593
|
+
"Circular.In": u.Circular.In,
|
|
1594
|
+
"Circular.Out": u.Circular.Out,
|
|
1595
|
+
"Circular.InOut": u.Circular.InOut,
|
|
1596
|
+
"Elastic.In": u.Elastic.In,
|
|
1597
|
+
"Elastic.Out": u.Elastic.Out,
|
|
1598
|
+
"Elastic.InOut": u.Elastic.InOut,
|
|
1599
|
+
"Back.In": u.Back.In,
|
|
1600
|
+
"Back.Out": u.Back.Out,
|
|
1601
|
+
"Back.InOut": u.Back.InOut,
|
|
1602
|
+
"Bounce.In": u.Bounce.In,
|
|
1603
|
+
"Bounce.Out": u.Bounce.Out,
|
|
1604
|
+
"Bounce.InOut": u.Bounce.InOut
|
|
1605
|
+
}, As = "0.0.5";
|
|
1606
|
+
window.__USPACE__ = { version: As };
|
|
1412
1607
|
export {
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1608
|
+
Be as BaseGroup,
|
|
1609
|
+
k as BaseMesh,
|
|
1610
|
+
Ms as BaseSprite,
|
|
1611
|
+
pi as CSS2DObject,
|
|
1612
|
+
mi as CSS3DObject,
|
|
1613
|
+
gi as CSS3DSprite,
|
|
1614
|
+
cs as CSSRenderer,
|
|
1615
|
+
ss as CameraControls,
|
|
1616
|
+
ri as CircleMesh,
|
|
1617
|
+
De as ExtrudeMesh,
|
|
1618
|
+
Jt as InteractionEvent,
|
|
1619
|
+
Zt as InteractionManager,
|
|
1620
|
+
ci as MaterialEffects,
|
|
1621
|
+
Z as Model,
|
|
1622
|
+
B as ModelLoaderManager,
|
|
1623
|
+
Vt as ObjectManager,
|
|
1624
|
+
W as ObjectUtils,
|
|
1625
|
+
ni as PlaneMesh,
|
|
1626
|
+
ii as Poi,
|
|
1627
|
+
es as RenderPipeline,
|
|
1628
|
+
ns as RoomEnvironment,
|
|
1629
|
+
Es as SBMLoader,
|
|
1630
|
+
ls as SBMXLoader,
|
|
1631
|
+
_e as ShapeMesh,
|
|
1632
|
+
Ps as SphereMesh,
|
|
1633
|
+
ai as TSLEffects,
|
|
1634
|
+
ti as TextureLoaderManager,
|
|
1635
|
+
si as Topology,
|
|
1636
|
+
we as TubeMesh,
|
|
1637
|
+
Is as Tween,
|
|
1638
|
+
ei as Viewer,
|
|
1639
|
+
oi as reinterpretType,
|
|
1640
|
+
hi as tweenAnimation,
|
|
1641
|
+
As as version
|
|
1441
1642
|
};
|