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