u-space 0.0.29 → 0.0.31
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/README.md +9 -0
- package/dist/Viewer-BKNV67Jj.cjs +1 -0
- package/dist/Viewer-Cs_y7IiH.js +1256 -0
- package/dist/getTransferables-C97JPUVf.cjs +1 -0
- package/dist/getTransferables-DrzSmiCR.js +43 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +2280 -1542
- package/dist/modelDecodeProtocol-D1Apm9iG.cjs +1 -0
- package/dist/modelDecodeProtocol-wDB7ksYw.js +56 -0
- package/dist/plugins/atmosphere/AgxToneMapping.d.ts +1 -1
- package/dist/plugins/atmosphere/index.cjs +1 -1
- package/dist/plugins/atmosphere/index.js +4 -4
- package/dist/plugins/curve-movement/index.cjs +1 -1
- package/dist/plugins/curve-movement/index.js +1 -1
- package/dist/plugins/fire/index.cjs +1 -1
- package/dist/plugins/fire/index.js +5 -5
- package/dist/plugins/object-controls/index.cjs +1 -1
- package/dist/plugins/object-controls/index.js +4 -4
- package/dist/plugins/tiles/index.cjs +1 -1
- package/dist/plugins/tiles/index.js +5 -5
- package/dist/plugins/u-manager/index.cjs +48 -48
- package/dist/plugins/u-manager/index.d.ts +1 -1
- package/dist/plugins/u-manager/index.js +8126 -8660
- package/dist/plugins/u-manager/loaders/SceneEditableBatchLayer.d.ts +17 -0
- package/dist/plugins/u-manager/loaders/SceneInstancedLayer.d.ts +3 -3
- package/dist/plugins/u-manager/loaders/SceneLoader.d.ts +11 -3
- package/dist/plugins/u-manager/semantics/objects/BuildingGroup.d.ts +4 -5
- package/dist/plugins/u-manager/semantics/objects/FacilityInstancedLayer.d.ts +4 -4
- package/dist/plugins/u-manager/semantics/objects/FloorMesh.d.ts +20 -22
- package/dist/plugins/u-manager/semantics/objects/SemanticGroup.d.ts +2 -3
- package/dist/protocol-C-OMPz15.js +10 -0
- package/dist/protocol-IUAzx0lk.cjs +1 -0
- package/dist/src/batches/EditableGeometryBatchLayer.d.ts +50 -0
- package/dist/src/batches/ModelInstancedLayer.d.ts +42 -0
- package/dist/src/batches/index.d.ts +2 -0
- package/dist/src/effects/TSLEffects.d.ts +24 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/instances/InstanceObject.d.ts +57 -0
- package/dist/src/instances/index.d.ts +1 -0
- package/dist/src/interactions/MeshBVHRaycast.d.ts +9 -0
- package/dist/src/interactions/index.d.ts +1 -0
- package/dist/src/loaders/ModelDecodeWorkerClient.d.ts +31 -0
- package/dist/src/loaders/ModelLoaderManager.d.ts +15 -2
- package/dist/src/loaders/buildDecodedGltfModel.d.ts +4 -0
- package/dist/src/loaders/index.d.ts +1 -0
- package/dist/src/objects/Model.d.ts +1 -0
- package/dist/src/viewers/RenderPipeline.d.ts +37 -0
- package/dist/src/viewers/ReversedDepthSSGICompat.d.ts +10 -0
- package/dist/src/viewers/ReversedDepthSSRCompat.d.ts +20 -0
- package/dist/src/viewers/Viewer.d.ts +3 -1
- package/dist/src/viewers/renderInvalidation.d.ts +2 -0
- package/dist/src/worker/FrameTimingWindow.d.ts +16 -0
- package/dist/src/worker/OffscreenViewerHost.d.ts +20 -0
- package/dist/src/worker/WorkerDomTarget.d.ts +44 -0
- package/dist/src/worker/createWorkerViewer.d.ts +18 -0
- package/dist/src/worker/decodeGltfModel.d.ts +10 -0
- package/dist/src/worker/getTransferables.d.ts +1 -0
- package/dist/src/worker/index.d.ts +3 -0
- package/dist/src/worker/installWorkerImageLoader.d.ts +8 -0
- package/dist/src/worker/model-decoder.d.ts +13 -0
- package/dist/src/worker/modelDecodeProtocol.d.ts +205 -0
- package/dist/src/worker/protocol.d.ts +102 -0
- package/dist/src/worker/runtime.d.ts +2 -0
- package/dist/src/worker/workerImageUtils.d.ts +8 -0
- package/dist/worker/index.cjs +1 -0
- package/dist/worker/index.js +226 -0
- package/dist/worker/model-decoder.cjs +1 -0
- package/dist/worker/model-decoder.js +339 -0
- package/dist/worker/runtime.cjs +1 -0
- package/dist/worker/runtime.js +412 -0
- package/dist/workerImageUtils-lmOMyTQN.cjs +1 -0
- package/dist/workerImageUtils-mQD3TQ1N.js +105 -0
- package/docs/api-batches.md +112 -0
- package/docs/api-effects.md +2 -2
- package/docs/api-interactions.md +8 -0
- package/docs/api-managers.md +1 -1
- package/docs/api-objects.md +207 -0
- package/docs/api-plugin-u-manager.md +193 -102
- package/docs/api-render-pipeline.md +103 -5
- package/docs/api-viewer.md +232 -1
- package/docs/changelog.md +68 -12
- package/docs/examples-guide.md +104 -20
- package/docs/getting-started.md +1 -1
- package/docs/index.md +11 -4
- package/docs/mcp.md +30 -14
- package/docs/release.md +97 -0
- package/package.json +35 -4
- package/dist/plugins/u-manager/instances/SemanticInstanceObject.d.ts +0 -51
- package/dist/plugins/u-manager/instances/SemanticModelInstancedLayer.d.ts +0 -42
- package/dist/plugins/u-manager/instances/index.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -1,211 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
import { clone as ys } from "three/addons/utils/SkeletonUtils.js";
|
|
22
|
-
import { Easing as f, Tween as ws } from "three/addons/libs/tween.module.js";
|
|
23
|
-
class vs {
|
|
24
|
-
/** The type of event (e.g., 'click', 'pointerdown'). */
|
|
25
|
-
type;
|
|
26
|
-
/** The original 3D object that triggered the event. */
|
|
27
|
-
target;
|
|
28
|
-
/** The current 3D object during the bubbling phase. */
|
|
29
|
-
currentTarget;
|
|
30
|
-
/** The intersection data from raycasting, or null if not applicable. */
|
|
31
|
-
intersect;
|
|
32
|
-
/** The original DOM event, or undefined if not applicable. */
|
|
33
|
-
originalEvent;
|
|
34
|
-
_propagationStopped = !1;
|
|
35
|
-
constructor(e) {
|
|
36
|
-
this.type = e.type, this.target = e.target, this.currentTarget = e.target, this.intersect = e.intersect, this.originalEvent = e.originalEvent;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Stops the event from bubbling up the parent chain.
|
|
40
|
-
*/
|
|
41
|
-
stopPropagation() {
|
|
42
|
-
this._propagationStopped = !0;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Returns true if `stopPropagation()` has been called.
|
|
46
|
-
*/
|
|
47
|
-
get propagationStopped() {
|
|
48
|
-
return this._propagationStopped;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
class bs {
|
|
52
|
-
domElement;
|
|
53
|
-
scene;
|
|
54
|
-
camera;
|
|
55
|
-
raycaster = new De();
|
|
56
|
-
pointer = new C();
|
|
57
|
-
hoveredObject = null;
|
|
58
|
-
pointerDownTime = 0;
|
|
59
|
-
pointerDownPos = new C();
|
|
60
|
-
clickTimer = null;
|
|
61
|
-
longPressThreshold = 500;
|
|
62
|
-
moveThreshold = 0.01;
|
|
63
|
-
/**
|
|
64
|
-
* The objects to check for intersections. default to all children of the scene (including nested).
|
|
65
|
-
*/
|
|
66
|
-
targetObjects;
|
|
67
|
-
/**
|
|
68
|
-
* Whether to enable pointer move events (pointermove, pointerenter, pointerleave).
|
|
69
|
-
* Disabled by default for performance optimization.
|
|
70
|
-
*/
|
|
71
|
-
pointerMoveEventsEnabled = !1;
|
|
72
|
-
/**
|
|
73
|
-
* Whether interaction is enabled globally.
|
|
74
|
-
*/
|
|
75
|
-
_enabled = !0;
|
|
76
|
-
/**
|
|
77
|
-
* Objects excluded from raycasting (via addIgnore or setInteractable(false)).
|
|
78
|
-
*/
|
|
79
|
-
_excludeSet = /* @__PURE__ */ new Set();
|
|
80
|
-
constructor(e, t, s) {
|
|
81
|
-
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();
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Updates the camera reference (useful when switching cameras).
|
|
85
|
-
*/
|
|
86
|
-
setCamera(e) {
|
|
87
|
-
this.camera = e;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Enable all interactions.
|
|
91
|
-
*/
|
|
92
|
-
enable() {
|
|
93
|
-
this._enabled = !0;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Disable all interactions.
|
|
97
|
-
*/
|
|
98
|
-
disable() {
|
|
99
|
-
this._enabled = !1;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Set whether a specific object is interactable.
|
|
103
|
-
* When set to false, the object and its children are excluded from raycasting.
|
|
104
|
-
*/
|
|
105
|
-
setInteractable(e, t) {
|
|
106
|
-
t ? this._excludeSet.delete(e) : this._excludeSet.add(e);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Add an object to the exclude list (will not receive any events).
|
|
110
|
-
* Alias for `setInteractable(object, false)`.
|
|
111
|
-
*/
|
|
112
|
-
addIgnore(e) {
|
|
113
|
-
this._excludeSet.add(e);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Remove an object from the exclude list.
|
|
117
|
-
* Alias for `setInteractable(object, true)`.
|
|
118
|
-
*/
|
|
119
|
-
removeIgnore(e) {
|
|
120
|
-
this._excludeSet.delete(e);
|
|
121
|
-
}
|
|
122
|
-
_bindEvents() {
|
|
123
|
-
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);
|
|
124
|
-
}
|
|
125
|
-
_updatePointer(e) {
|
|
126
|
-
const t = this.domElement.getBoundingClientRect();
|
|
127
|
-
this.pointer.x = (e.clientX - t.left) / t.width * 2 - 1, this.pointer.y = -((e.clientY - t.top) / t.height) * 2 + 1;
|
|
128
|
-
}
|
|
129
|
-
_getIntersects() {
|
|
130
|
-
this.raycaster.setFromCamera(this.pointer, this.camera);
|
|
131
|
-
const e = this.raycaster.intersectObjects(this.targetObjects, !0);
|
|
132
|
-
return this._excludeSet.size > 0 ? e.filter((t) => {
|
|
133
|
-
let s = t.object;
|
|
134
|
-
for (; s; ) {
|
|
135
|
-
if (this._excludeSet.has(s))
|
|
136
|
-
return !1;
|
|
137
|
-
s = s.parent;
|
|
138
|
-
}
|
|
139
|
-
return !0;
|
|
140
|
-
}) : e;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Dispatches an event to the target object and bubbles up the parent chain.
|
|
144
|
-
*/
|
|
145
|
-
_dispatchToTarget(e, t, s, n) {
|
|
146
|
-
const i = new vs({
|
|
147
|
-
type: e,
|
|
148
|
-
target: t,
|
|
149
|
-
intersect: s,
|
|
150
|
-
originalEvent: n
|
|
151
|
-
});
|
|
152
|
-
let r = t;
|
|
153
|
-
for (; r && !i.propagationStopped; )
|
|
154
|
-
i.currentTarget = r, r.dispatchEvent({ type: e, event: i }), r = r.parent;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Handles a DOM event by raycasting and dispatching to the first intersected object.
|
|
158
|
-
*/
|
|
159
|
-
_handleEvent(e, t) {
|
|
160
|
-
if (!this._enabled) return;
|
|
161
|
-
this._updatePointer(t);
|
|
162
|
-
const s = this._getIntersects();
|
|
163
|
-
if (s.length === 0) return;
|
|
164
|
-
const n = s[0];
|
|
165
|
-
this._dispatchToTarget(e, n.object, n, t);
|
|
166
|
-
}
|
|
167
|
-
_onClick = (e) => {
|
|
168
|
-
const t = Date.now() - this.pointerDownTime, s = this.pointer.distanceTo(this.pointerDownPos);
|
|
169
|
-
if (!(t > this.longPressThreshold || s > this.moveThreshold)) {
|
|
170
|
-
if (this.clickTimer) {
|
|
171
|
-
clearTimeout(this.clickTimer), this.clickTimer = null;
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
this.clickTimer = setTimeout(() => {
|
|
175
|
-
this._handleEvent("click", e), this.clickTimer = null;
|
|
176
|
-
}, 200);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
_onDblClick = (e) => {
|
|
180
|
-
this.clickTimer && (clearTimeout(this.clickTimer), this.clickTimer = null), this._handleEvent("dblclick", e);
|
|
181
|
-
};
|
|
182
|
-
_onContextMenu = (e) => {
|
|
183
|
-
e.preventDefault();
|
|
184
|
-
};
|
|
185
|
-
_onPointerDown = (e) => {
|
|
186
|
-
this.pointerDownTime = Date.now(), this._updatePointer(e), this.pointerDownPos.copy(this.pointer), this._handleEvent("pointerdown", e);
|
|
187
|
-
};
|
|
188
|
-
_onPointerUp = (e) => {
|
|
189
|
-
if (this._updatePointer(e), e.button === 2) {
|
|
190
|
-
const t = Date.now() - this.pointerDownTime, s = this.pointer.distanceTo(this.pointerDownPos);
|
|
191
|
-
t <= this.longPressThreshold && s <= this.moveThreshold && this._handleEvent("rightclick", e);
|
|
192
|
-
}
|
|
193
|
-
this._handleEvent("pointerup", e);
|
|
194
|
-
};
|
|
195
|
-
_onPointerMove = (e) => {
|
|
196
|
-
if (!this._enabled || !this.pointerMoveEventsEnabled) return;
|
|
197
|
-
this._updatePointer(e);
|
|
198
|
-
const t = this._getIntersects(), s = t.length > 0 ? t[0].object : null, n = t.length > 0 ? t[0] : null;
|
|
199
|
-
this.hoveredObject !== s && (this.hoveredObject && this._dispatchToTarget("pointerleave", this.hoveredObject, null, e), this.hoveredObject = s, s && n && this._dispatchToTarget("pointerenter", s, n, e)), s && n && this._dispatchToTarget("pointermove", s, n, e);
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* Cleans up event listeners.
|
|
203
|
-
*/
|
|
204
|
-
dispose() {
|
|
205
|
-
this.domElement.removeEventListener("click", this._onClick), this.domElement.removeEventListener("dblclick", this._onDblClick), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.clickTimer && (clearTimeout(this.clickTimer), this.clickTimer = null), this.hoveredObject = null, this._excludeSet.clear();
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
class En extends ke {
|
|
1
|
+
import { g as jt } from "./Viewer-Cs_y7IiH.js";
|
|
2
|
+
import { C as vi, a as Si, I as Ii, b as Ei, O as Ci, R as Ai, c as Oi, V as Bi, e as _i } from "./Viewer-Cs_y7IiH.js";
|
|
3
|
+
import { EventDispatcher as hs, Vector2 as j, Box2 as ds, Matrix4 as R, Vector3 as D, Scene as us, Color as P, AmbientLight as ps, DirectionalLight as Fe, PointLight as He, SpotLight as $e, HemisphereLight as Ge, DirectionalLightHelper as fs, PointLightHelper as ms, SpotLightHelper as gs, HemisphereLightHelper as ys, MeshStandardNodeMaterial as q, Loader as bs, LoaderUtils as he, FileLoader as Wt, TextureLoader as Ft, Group as W, SRGBColorSpace as Se, RepeatWrapping as Ie, BufferGeometry as G, BufferAttribute as Pe, Mesh as k, FrontSide as ws, BackSide as xs, DoubleSide as Ht, InterleavedBufferAttribute as Ke, MeshStandardMaterial as Ms, LinearSRGBColorSpace as qe, InterleavedBuffer as vs, Texture as $t, NearestFilter as Ee, LinearFilter as Ve, LinearMipmapLinearFilter as Ss, NearestMipmapLinearFilter as Is, LinearMipmapNearestFilter as Es, NearestMipmapNearestFilter as Cs, MirroredRepeatWrapping as Xe, ClampToEdgeWrapping as Ye, NoColorSpace as fe, REVISION as Qe, LoadingManager as As, CubeTextureLoader as Os, EquirectangularReflectionMapping as Bs, Sprite as _s, AnimationMixer as Ts, LoopRepeat as Ls, LoopOnce as Ns, Box3 as K, SphereGeometry as Ds, TubeGeometry as Ps, LineCurve3 as Rs, CatmullRomCurve3 as ks, SpriteNodeMaterial as zs, CanvasTexture as Us, ShapeGeometry as js, Shape as Gt, ExtrudeGeometry as Ws, PlaneGeometry as Fs, CircleGeometry as Hs, Quaternion as $s, BoxGeometry as Gs, MeshBasicNodeMaterial as Ks, ClippingGroup as qs, Plane as Vs, PlaneHelper as Xs, LineBasicMaterial as ye, Line as be, Object3D as Ys, Sphere as ne, Float32BufferAttribute as Qs, SkinnedMesh as Js, DataTexture as Zs, RGBAFormat as en, FloatType as tn, Frustum as sn, InstancedBufferAttribute as Je, DynamicDrawUsage as Te, InstancedMesh as nn, StorageInstancedBufferAttribute as rn } from "three/webgpu";
|
|
4
|
+
import { GLTFLoader as Re } from "three/addons/loaders/GLTFLoader.js";
|
|
5
|
+
import { FBXLoader as Ze } from "three/addons/loaders/FBXLoader.js";
|
|
6
|
+
import { OBJLoader as an } from "three/addons/loaders/OBJLoader.js";
|
|
7
|
+
import { STLLoader as on } from "three/addons/loaders/STLLoader.js";
|
|
8
|
+
import { DRACOLoader as cn } from "three/addons/loaders/DRACOLoader.js";
|
|
9
|
+
import { KTX2Loader as ln } from "three/addons/loaders/KTX2Loader.js";
|
|
10
|
+
import { MeshoptDecoder as Le } from "three/addons/libs/meshopt_decoder.module.js";
|
|
11
|
+
import { M as et, v as hn, U as Kt } from "./modelDecodeProtocol-wDB7ksYw.js";
|
|
12
|
+
import { HDRLoader as dn } from "three/addons/loaders/HDRLoader.js";
|
|
13
|
+
import { clone as We } from "three/addons/utils/SkeletonUtils.js";
|
|
14
|
+
import { color as Y, uv as tt, time as we, pow as xe, sin as ke, mix as Me, mx_noise_float as st, uniform as ae, add as un, vec4 as pn, Fn as qt, userData as F, materialColor as Ce, select as $, materialOpacity as ze, vec3 as fn, attribute as mn, int as nt, textureSize as gn, textureLoad as rt, ivec2 as yn, instancedBufferAttribute as it, float as bn } from "three/tsl";
|
|
15
|
+
import { outline as wn } from "three/addons/tsl/display/OutlineNode.js";
|
|
16
|
+
import { Easing as T, Tween as xn } from "three/addons/libs/tween.module.js";
|
|
17
|
+
import { mergeGeometries as Mn } from "three/addons/utils/BufferGeometryUtils.js";
|
|
18
|
+
import { CSS2DObject as Li } from "three/addons/renderers/CSS2DRenderer.js";
|
|
19
|
+
import { CSS3DObject as Di, CSS3DSprite as Pi } from "three/addons/renderers/CSS3DRenderer.js";
|
|
20
|
+
class si extends hs {
|
|
209
21
|
scene;
|
|
210
22
|
camera;
|
|
211
23
|
domElement;
|
|
@@ -215,8 +27,8 @@ class En extends ke {
|
|
|
215
27
|
// Box selection state
|
|
216
28
|
_boxSelectionEnabled = !1;
|
|
217
29
|
_isSelecting = !1;
|
|
218
|
-
_startPoint = new
|
|
219
|
-
_endPoint = new
|
|
30
|
+
_startPoint = new j();
|
|
31
|
+
_endPoint = new j();
|
|
220
32
|
_selectionBox = null;
|
|
221
33
|
_deep = !0;
|
|
222
34
|
/**
|
|
@@ -315,226 +127,33 @@ class En extends ke {
|
|
|
315
127
|
this._selectionBox.style.left = `${e}px`, this._selectionBox.style.top = `${t}px`, this._selectionBox.style.width = `${s}px`, this._selectionBox.style.height = `${n}px`;
|
|
316
128
|
}
|
|
317
129
|
_getObjectsInBox() {
|
|
318
|
-
const e = this._container.getBoundingClientRect(), t = e.width, s = e.height, n = new
|
|
130
|
+
const e = this._container.getBoundingClientRect(), t = e.width, s = e.height, n = new j(
|
|
319
131
|
this._startPoint.x / t * 2 - 1,
|
|
320
132
|
-(this._startPoint.y / s) * 2 + 1
|
|
321
|
-
),
|
|
133
|
+
), r = new j(
|
|
322
134
|
this._endPoint.x / t * 2 - 1,
|
|
323
135
|
-(this._endPoint.y / s) * 2 + 1
|
|
324
|
-
),
|
|
325
|
-
new
|
|
326
|
-
new
|
|
327
|
-
), o = this.targetObjects || this.scene.children,
|
|
328
|
-
|
|
329
|
-
const
|
|
136
|
+
), a = new ds(
|
|
137
|
+
new j(Math.min(n.x, r.x), Math.min(n.y, r.y)),
|
|
138
|
+
new j(Math.max(n.x, r.x), Math.max(n.y, r.y))
|
|
139
|
+
), o = this.targetObjects || this.scene.children, c = [], l = new R();
|
|
140
|
+
l.multiplyMatrices(this.camera.projectionMatrix, this.camera.matrixWorldInverse);
|
|
141
|
+
const h = (d) => {
|
|
330
142
|
if (!d.visible) return;
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
333
|
-
for (const
|
|
334
|
-
|
|
143
|
+
const u = new D();
|
|
144
|
+
if (u.setFromMatrixPosition(d.matrixWorld), u.applyMatrix4(l), u.z > -1 && u.z < 1 && a.containsPoint(new j(u.x, u.y)) && c.push(d), this._deep)
|
|
145
|
+
for (const p of d.children)
|
|
146
|
+
h(p);
|
|
335
147
|
};
|
|
336
148
|
for (const d of o)
|
|
337
|
-
|
|
338
|
-
return
|
|
149
|
+
h(d);
|
|
150
|
+
return c;
|
|
339
151
|
}
|
|
340
152
|
dispose() {
|
|
341
153
|
this.disableBoxSelection(), this._selected.clear();
|
|
342
154
|
}
|
|
343
155
|
}
|
|
344
|
-
|
|
345
|
-
const t = h;
|
|
346
|
-
if (t.setSemanticVisible) {
|
|
347
|
-
t.setSemanticVisible(e);
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
h.visible = e, t.markSemanticRenderDirty?.();
|
|
351
|
-
}
|
|
352
|
-
class xs {
|
|
353
|
-
idMap = /* @__PURE__ */ new Map();
|
|
354
|
-
nameMap = /* @__PURE__ */ new Map();
|
|
355
|
-
typeMap = /* @__PURE__ */ new Map();
|
|
356
|
-
objectIds = /* @__PURE__ */ new Map();
|
|
357
|
-
allObjects = /* @__PURE__ */ new Set();
|
|
358
|
-
/**
|
|
359
|
-
* Add an object with a custom id.
|
|
360
|
-
* One object can have multiple ids.
|
|
361
|
-
*/
|
|
362
|
-
add(e, t) {
|
|
363
|
-
if (this.idMap.has(e)) {
|
|
364
|
-
console.warn(`ObjectManager: Object with id ${e} already exists.`);
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
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));
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Get an object by its custom id.
|
|
371
|
-
*/
|
|
372
|
-
getById(e) {
|
|
373
|
-
return this.idMap.get(e);
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Get all objects with a given name.
|
|
377
|
-
*/
|
|
378
|
-
getByName(e) {
|
|
379
|
-
return this.nameMap.get(e) || /* @__PURE__ */ new Set();
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Get all objects with a given type.
|
|
383
|
-
*/
|
|
384
|
-
getByType(e) {
|
|
385
|
-
return this.typeMap.get(e) || /* @__PURE__ */ new Set();
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Get all ids associated with an object.
|
|
389
|
-
*/
|
|
390
|
-
getObjectIds(e) {
|
|
391
|
-
return this.objectIds.get(e) || /* @__PURE__ */ new Set();
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Remove an object and all its associated ids.
|
|
395
|
-
*/
|
|
396
|
-
remove(e) {
|
|
397
|
-
const t = this.objectIds.get(e);
|
|
398
|
-
if (t) {
|
|
399
|
-
for (const s of t)
|
|
400
|
-
this.idMap.delete(s);
|
|
401
|
-
this.objectIds.delete(e);
|
|
402
|
-
}
|
|
403
|
-
if (e.name && this.nameMap.has(e.name)) {
|
|
404
|
-
const s = this.nameMap.get(e.name);
|
|
405
|
-
s.delete(e), s.size === 0 && this.nameMap.delete(e.name);
|
|
406
|
-
}
|
|
407
|
-
if (e.type && this.typeMap.has(e.type)) {
|
|
408
|
-
const s = this.typeMap.get(e.type);
|
|
409
|
-
s.delete(e), s.size === 0 && this.typeMap.delete(e.type);
|
|
410
|
-
}
|
|
411
|
-
this.allObjects.delete(e);
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Remove an object by its id.
|
|
415
|
-
*/
|
|
416
|
-
removeById(e) {
|
|
417
|
-
const t = this.idMap.get(e);
|
|
418
|
-
t && this.remove(t);
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Remove all objects with a given name.
|
|
422
|
-
*/
|
|
423
|
-
removeByName(e) {
|
|
424
|
-
const t = this.getByName(e);
|
|
425
|
-
for (const s of t)
|
|
426
|
-
this.remove(s);
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* Remove all objects with a given type.
|
|
430
|
-
*/
|
|
431
|
-
removeByType(e) {
|
|
432
|
-
const t = this.getByType(e);
|
|
433
|
-
for (const s of t)
|
|
434
|
-
this.remove(s);
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* Clear all cached objects.
|
|
438
|
-
*/
|
|
439
|
-
clear() {
|
|
440
|
-
this.idMap.clear(), this.nameMap.clear(), this.typeMap.clear(), this.objectIds.clear(), this.allObjects.clear();
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* Get all cached objects as a Set.
|
|
444
|
-
*/
|
|
445
|
-
getAll() {
|
|
446
|
-
return this.allObjects;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Get the number of unique cached objects.
|
|
450
|
-
*/
|
|
451
|
-
get size() {
|
|
452
|
-
return this.allObjects.size;
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* Show an object by id.
|
|
456
|
-
*/
|
|
457
|
-
show(e) {
|
|
458
|
-
const t = this.idMap.get(e);
|
|
459
|
-
t && ee(t, !0);
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Hide an object by id.
|
|
463
|
-
*/
|
|
464
|
-
hide(e) {
|
|
465
|
-
const t = this.idMap.get(e);
|
|
466
|
-
t && ee(t, !1);
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* Show only the specified objects, hide all others.
|
|
470
|
-
*/
|
|
471
|
-
isolate(e) {
|
|
472
|
-
const t = new Set(e);
|
|
473
|
-
for (const s of this.allObjects) {
|
|
474
|
-
const n = this.objectIds.get(s) ?? /* @__PURE__ */ new Set();
|
|
475
|
-
ee(s, [...n].some((i) => t.has(i)));
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Set the opacity of an object's materials.
|
|
480
|
-
*/
|
|
481
|
-
setOpacity(e, t) {
|
|
482
|
-
const s = this.idMap.get(e);
|
|
483
|
-
if (!s) return;
|
|
484
|
-
const n = s;
|
|
485
|
-
if (n.setSemanticOpacity) {
|
|
486
|
-
n.setSemanticOpacity(t);
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
s.traverse((i) => {
|
|
490
|
-
if (!i.isMesh) return;
|
|
491
|
-
const r = i.material;
|
|
492
|
-
if (!r) return;
|
|
493
|
-
const o = Array.isArray(r) ? r : [r];
|
|
494
|
-
for (const a of o)
|
|
495
|
-
a.transparent = t < 1, a.opacity = t, a.needsUpdate = !0;
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Get the bounding box of an object by id, or all objects if no id provided.
|
|
500
|
-
*/
|
|
501
|
-
getBoundingBox(e) {
|
|
502
|
-
const t = new V();
|
|
503
|
-
if (e) {
|
|
504
|
-
const s = this.idMap.get(e);
|
|
505
|
-
s && t.setFromObject(s);
|
|
506
|
-
} else
|
|
507
|
-
for (const s of this.allObjects)
|
|
508
|
-
t.expandByObject(s);
|
|
509
|
-
return t;
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* Iterate over all managed objects.
|
|
513
|
-
*/
|
|
514
|
-
forEach(e) {
|
|
515
|
-
for (const t of this.allObjects) {
|
|
516
|
-
const s = this.objectIds.get(t) || /* @__PURE__ */ new Set();
|
|
517
|
-
e(t, s);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Filter objects by a predicate.
|
|
522
|
-
*/
|
|
523
|
-
filter(e) {
|
|
524
|
-
const t = [];
|
|
525
|
-
for (const s of this.allObjects)
|
|
526
|
-
e(s) && t.push(s);
|
|
527
|
-
return t;
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Show all managed objects.
|
|
531
|
-
*/
|
|
532
|
-
showAll() {
|
|
533
|
-
for (const e of this.allObjects)
|
|
534
|
-
ee(e, !0);
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
class Pn {
|
|
156
|
+
class ni {
|
|
538
157
|
scenes = /* @__PURE__ */ new Map();
|
|
539
158
|
_activeSceneKey = null;
|
|
540
159
|
/**
|
|
@@ -547,8 +166,8 @@ class Pn {
|
|
|
547
166
|
* Create and register a new scene.
|
|
548
167
|
*/
|
|
549
168
|
create(e, t = {}) {
|
|
550
|
-
const s = new
|
|
551
|
-
return t.background !== void 0 && (s.background = new
|
|
169
|
+
const s = new us();
|
|
170
|
+
return t.background !== void 0 && (s.background = new P(t.background)), this.scenes.set(e, s), s;
|
|
552
171
|
}
|
|
553
172
|
/**
|
|
554
173
|
* Get a scene by key.
|
|
@@ -587,7 +206,7 @@ class Pn {
|
|
|
587
206
|
const t = this.scenes.get(e);
|
|
588
207
|
if (!t) return null;
|
|
589
208
|
let s = null;
|
|
590
|
-
return t.background instanceof
|
|
209
|
+
return t.background instanceof P && (s = `#${t.background.getHexString()}`), {
|
|
591
210
|
name: t.name || e,
|
|
592
211
|
background: s,
|
|
593
212
|
environmentRotation: {
|
|
@@ -608,7 +227,7 @@ class Pn {
|
|
|
608
227
|
return this.scenes.size;
|
|
609
228
|
}
|
|
610
229
|
}
|
|
611
|
-
class
|
|
230
|
+
class ri {
|
|
612
231
|
scene;
|
|
613
232
|
lights = /* @__PURE__ */ new Map();
|
|
614
233
|
helpers = /* @__PURE__ */ new Map();
|
|
@@ -616,34 +235,34 @@ class On {
|
|
|
616
235
|
this.scene = e;
|
|
617
236
|
}
|
|
618
237
|
addAmbient(e, t = {}) {
|
|
619
|
-
const { color: s = 16777215, intensity: n = 0.5 } = t,
|
|
620
|
-
return
|
|
238
|
+
const { color: s = 16777215, intensity: n = 0.5 } = t, r = new ps(s, n);
|
|
239
|
+
return r.name = e, this._register(e, r), r;
|
|
621
240
|
}
|
|
622
241
|
addDirectional(e, t = {}) {
|
|
623
|
-
const { color: s = 16777215, intensity: n = 1, position:
|
|
624
|
-
return
|
|
242
|
+
const { color: s = 16777215, intensity: n = 1, position: r = { x: 5, y: 10, z: 5 }, castShadow: a = !1, shadowMapSize: o = 1024 } = t, c = new Fe(s, n);
|
|
243
|
+
return c.position.set(r.x, r.y, r.z), c.castShadow = a, a && c.shadow.mapSize.setScalar(o), c.name = e, this._register(e, c), c;
|
|
625
244
|
}
|
|
626
245
|
addPoint(e, t = {}) {
|
|
627
|
-
const { color: s = 16777215, intensity: n = 1, distance:
|
|
628
|
-
return
|
|
246
|
+
const { color: s = 16777215, intensity: n = 1, distance: r = 0, decay: a = 2, position: o = { x: 0, y: 5, z: 0 }, castShadow: c = !1 } = t, l = new He(s, n, r, a);
|
|
247
|
+
return l.position.set(o.x, o.y, o.z), l.castShadow = c, l.name = e, this._register(e, l), l;
|
|
629
248
|
}
|
|
630
249
|
addSpot(e, t = {}) {
|
|
631
250
|
const {
|
|
632
251
|
color: s = 16777215,
|
|
633
252
|
intensity: n = 1,
|
|
634
|
-
distance:
|
|
635
|
-
angle:
|
|
253
|
+
distance: r = 0,
|
|
254
|
+
angle: a = Math.PI / 6,
|
|
636
255
|
penumbra: o = 0.1,
|
|
637
|
-
decay:
|
|
638
|
-
position:
|
|
639
|
-
target:
|
|
256
|
+
decay: c = 2,
|
|
257
|
+
position: l = { x: 0, y: 10, z: 0 },
|
|
258
|
+
target: h,
|
|
640
259
|
castShadow: d = !1
|
|
641
|
-
} = t,
|
|
642
|
-
return
|
|
260
|
+
} = t, u = new $e(s, n, r, a, o, c);
|
|
261
|
+
return u.position.set(l.x, l.y, l.z), h && u.target.position.set(h.x, h.y, h.z), u.castShadow = d, u.name = e, this._register(e, u), u;
|
|
643
262
|
}
|
|
644
263
|
addHemisphere(e, t = {}) {
|
|
645
|
-
const { skyColor: s = 8900331, groundColor: n = 3549447, intensity:
|
|
646
|
-
return
|
|
264
|
+
const { skyColor: s = 8900331, groundColor: n = 3549447, intensity: r = 0.6 } = t, a = new Ge(s, n, r);
|
|
265
|
+
return a.name = e, this._register(e, a), a;
|
|
647
266
|
}
|
|
648
267
|
/**
|
|
649
268
|
* Apply a lighting preset to the scene.
|
|
@@ -693,7 +312,7 @@ class On {
|
|
|
693
312
|
const t = this.lights.get(e);
|
|
694
313
|
if (!t) return;
|
|
695
314
|
let s = null;
|
|
696
|
-
t instanceof
|
|
315
|
+
t instanceof Fe ? s = new fs(t, 1) : t instanceof He ? s = new ms(t, 0.5) : t instanceof $e ? s = new gs(t) : t instanceof Ge && (s = new ys(t, 1)), s && (this.scene.add(s), this.helpers.set(e, s));
|
|
697
316
|
}
|
|
698
317
|
/**
|
|
699
318
|
* Hide (remove) the helper for a light.
|
|
@@ -724,795 +343,643 @@ class On {
|
|
|
724
343
|
this.removeAll(), this.hideAllHelpers();
|
|
725
344
|
}
|
|
726
345
|
}
|
|
727
|
-
class
|
|
728
|
-
scene;
|
|
729
|
-
camera;
|
|
730
|
-
scenePass;
|
|
731
|
-
needsUpdateOutputNode;
|
|
732
|
-
#t;
|
|
733
|
-
#e;
|
|
734
|
-
#s = !1;
|
|
735
|
-
#r = { strength: 1, radius: 0, threshold: 0 };
|
|
736
|
-
#n = null;
|
|
737
|
-
#o = !1;
|
|
738
|
-
#a = {
|
|
739
|
-
sliceCount: 1,
|
|
740
|
-
stepCount: 12,
|
|
741
|
-
aoIntensity: 1,
|
|
742
|
-
giIntensity: 10,
|
|
743
|
-
radius: 12,
|
|
744
|
-
thickness: 1
|
|
745
|
-
};
|
|
746
|
-
#p = null;
|
|
747
|
-
#h = !1;
|
|
748
|
-
#l = null;
|
|
749
|
-
#u = null;
|
|
750
|
-
#d;
|
|
751
|
-
#c;
|
|
752
|
-
#m = !1;
|
|
753
|
-
#f = !0;
|
|
754
|
-
constructor(...e) {
|
|
755
|
-
const [t, s, n] = e;
|
|
756
|
-
super(t), this.scene = s, this.camera = n, this.scenePass = ge(s, n), this.needsUpdateOutputNode = !0, this.#t = /* @__PURE__ */ new Set(), this.#e = [], this.#d = /* @__PURE__ */ new Set(), this.#c = /* @__PURE__ */ new Map(), this.#g();
|
|
757
|
-
}
|
|
758
|
-
/** @deprecated Use `scenePass` instead */
|
|
759
|
-
get currentOutputNode() {
|
|
760
|
-
return this.scenePass;
|
|
761
|
-
}
|
|
762
|
-
addOverlayPass(e) {
|
|
763
|
-
this.#t.add(e), this.needsUpdateOutputNode = !0;
|
|
764
|
-
}
|
|
765
|
-
removeOverlayPass(e) {
|
|
766
|
-
this.#t.delete(e), this.needsUpdateOutputNode = !0;
|
|
767
|
-
}
|
|
768
|
-
setCamera(e) {
|
|
769
|
-
this.camera = e, this.#i();
|
|
770
|
-
}
|
|
771
|
-
/** @deprecated Use `setOutputComposer` instead */
|
|
772
|
-
setCurrentOutputNode(e) {
|
|
773
|
-
this.setOutputComposer(() => e);
|
|
774
|
-
}
|
|
775
|
-
/** @deprecated Use `setOutputComposer(null)` instead */
|
|
776
|
-
resetCurrentOutputNode() {
|
|
777
|
-
this.setOutputComposer(null);
|
|
778
|
-
}
|
|
779
|
-
setOutputComposer(e) {
|
|
780
|
-
this.#u = e, this.needsUpdateOutputNode = !0;
|
|
781
|
-
}
|
|
782
|
-
addOutputEffect(e) {
|
|
783
|
-
return this.#d.add(e), this.needsUpdateOutputNode = !0, this;
|
|
784
|
-
}
|
|
785
|
-
removeOutputEffect(e) {
|
|
786
|
-
return this.#d.delete(e), this.needsUpdateOutputNode = !0, this;
|
|
787
|
-
}
|
|
788
|
-
addMRTChannel(e, t) {
|
|
789
|
-
return this.#c.get(e) === t ? this : (this.#c.set(e, t), this.#i(), this);
|
|
790
|
-
}
|
|
791
|
-
removeMRTChannel(e) {
|
|
792
|
-
return this.#c.delete(e) && this.#i(), this;
|
|
793
|
-
}
|
|
794
|
-
enableBloom(e) {
|
|
795
|
-
e && Object.assign(this.#r, e), this.#s = !0, this.#i();
|
|
796
|
-
}
|
|
797
|
-
disableBloom() {
|
|
798
|
-
this.#s = !1, this.#n = null, this.#i();
|
|
799
|
-
}
|
|
800
|
-
updateBloom(e) {
|
|
801
|
-
Object.assign(this.#r, e), this.#s && (this.needsUpdateOutputNode = !0);
|
|
802
|
-
}
|
|
803
|
-
enableSSGI(e) {
|
|
804
|
-
e && Object.assign(this.#a, e), this.#o = !0, this.#i();
|
|
805
|
-
}
|
|
806
|
-
disableSSGI() {
|
|
807
|
-
this.#o = !1, this.#p = null, this.#i();
|
|
808
|
-
}
|
|
809
|
-
updateSSGI(e) {
|
|
810
|
-
if (Object.assign(this.#a, e), this.#p) {
|
|
811
|
-
const t = this.#p;
|
|
812
|
-
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);
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
enableTRAA() {
|
|
816
|
-
this.#h = !0, this.#i();
|
|
817
|
-
}
|
|
818
|
-
disableTRAA() {
|
|
819
|
-
this.#h = !1, this.#l = null, this.#i();
|
|
820
|
-
}
|
|
821
|
-
#i() {
|
|
822
|
-
const e = this.scenePass;
|
|
823
|
-
this.scenePass = ge(this.scene, this.camera), this.#g(), this.needsUpdateOutputNode = !0, e.dispose();
|
|
824
|
-
}
|
|
825
|
-
#g() {
|
|
826
|
-
if (this.#s || this.#o || this.#h || this.#c.size > 0) {
|
|
827
|
-
const t = { output: Xt };
|
|
828
|
-
this.#c.forEach((s, n) => {
|
|
829
|
-
n !== "output" && (t[n] = s);
|
|
830
|
-
}), this.#s && (t.emissive = Vt), this.#o && (t.normal = Jt), this.#h && (t.velocity = Zt), this.scenePass.setMRT(qt(t));
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
#y() {
|
|
834
|
-
for (const e of this.#e)
|
|
835
|
-
e.dispose();
|
|
836
|
-
this.#e = [];
|
|
837
|
-
}
|
|
838
|
-
#w() {
|
|
839
|
-
let e = this.scenePass.getTextureNode();
|
|
840
|
-
if (this.#o)
|
|
841
|
-
if (!(this.camera instanceof se))
|
|
842
|
-
console.warn("RenderPipeline: SSGI requires a PerspectiveCamera, skipping.");
|
|
843
|
-
else {
|
|
844
|
-
const t = this.scenePass.getTextureNode(), s = this.scenePass.getTextureNode("depth"), n = this.scenePass.getTextureNode("normal"), i = ss(t, s, n, this.camera);
|
|
845
|
-
i.sliceCount.value = this.#a.sliceCount, i.stepCount.value = this.#a.stepCount, i.aoIntensity.value = this.#a.aoIntensity, i.giIntensity.value = this.#a.giIntensity, i.radius.value = this.#a.radius, i.thickness.value = this.#a.thickness, this.#p = i, e = Me(e, i), this.#e.push(i);
|
|
846
|
-
}
|
|
847
|
-
if (this.#s) {
|
|
848
|
-
const t = this.scenePass.getTextureNode("emissive");
|
|
849
|
-
this.#n = ts(
|
|
850
|
-
t,
|
|
851
|
-
this.#r.strength,
|
|
852
|
-
this.#r.radius,
|
|
853
|
-
this.#r.threshold
|
|
854
|
-
), e = Me(e, this.#n), this.#e.push(this.#n);
|
|
855
|
-
}
|
|
856
|
-
return e;
|
|
857
|
-
}
|
|
858
|
-
#v(e) {
|
|
859
|
-
e ? (this.#m || (this.#f = this.outputColorTransform), this.outputColorTransform = !1) : this.#m && (this.outputColorTransform = this.#f), this.#m = e;
|
|
860
|
-
}
|
|
861
|
-
#b() {
|
|
862
|
-
this.#y();
|
|
863
|
-
let e, t = !1, s = !1;
|
|
864
|
-
const n = this.#u !== null;
|
|
865
|
-
if (n ? e = this.#u(this.scenePass) : this.#s || this.#o ? e = this.#w() : e = this.#d.size > 0 ? this.scenePass.getTextureNode() : this.scenePass, n || this.#d.forEach((i) => {
|
|
866
|
-
t ||= i.includesTemporalAntialias === !0, s ||= i.includesOutputTransform === !0, e = i(this.scenePass, e);
|
|
867
|
-
}), this.#v(s), this.#h && !t) {
|
|
868
|
-
const i = this.scenePass.getTextureNode("depth"), r = this.scenePass.getTextureNode("velocity");
|
|
869
|
-
this.#l = ns(e, i, r, this.camera), this.#e.push(this.#l), e = this.#l;
|
|
870
|
-
} else
|
|
871
|
-
this.#l = null;
|
|
872
|
-
this.#t.size > 0 && this.#t.forEach((i) => {
|
|
873
|
-
const r = Yt(e, i);
|
|
874
|
-
this.#e.push(r), e = r;
|
|
875
|
-
}), this.outputNode = e, this.needsUpdate = !0;
|
|
876
|
-
}
|
|
877
|
-
render() {
|
|
878
|
-
this.needsUpdateOutputNode && (this.#b(), this.needsUpdateOutputNode = !1), super.render();
|
|
879
|
-
}
|
|
880
|
-
dispose() {
|
|
881
|
-
this.#y(), this.scenePass.dispose(), super.dispose();
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
const Cs = {
|
|
885
|
-
Vector2: C,
|
|
886
|
-
Vector3: v,
|
|
887
|
-
Vector4: ft,
|
|
888
|
-
Quaternion: mt,
|
|
889
|
-
Matrix4: je,
|
|
890
|
-
Spherical: M,
|
|
891
|
-
Box3: V,
|
|
892
|
-
Sphere: fe,
|
|
893
|
-
Raycaster: De
|
|
894
|
-
};
|
|
895
|
-
Ke.install({ THREE: Cs });
|
|
896
|
-
class Ts extends Ke {
|
|
897
|
-
constructor(...e) {
|
|
898
|
-
super(...e), this.minDistance = 0.2, this.smoothTime = 0.2, this.dollySpeed = 0.2;
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* Set absolute angle for azimuth to avoid spinning
|
|
902
|
-
*/
|
|
903
|
-
absoluteRotations() {
|
|
904
|
-
this.azimuthAngle = _s(this.azimuthAngle, 0);
|
|
905
|
-
}
|
|
906
|
-
async flyToBox(e, t = {}) {
|
|
907
|
-
if (e.isEmpty())
|
|
908
|
-
return console.warn("CameraControls.flyToBox: The provided Box3 is empty."), !1;
|
|
909
|
-
this.absoluteRotations();
|
|
910
|
-
const { viewpoint: s = "frontTop", enableTransition: n = !0, padding: i = 0.1, cover: r = !1 } = t;
|
|
911
|
-
if (s !== "current") {
|
|
912
|
-
const o = s.toUpperCase(), a = Be[o] ?? Be.FRONTTOP, c = a.theta, l = a.phi;
|
|
913
|
-
if (await this.rotateTo(c, l, n), Ms.has(o))
|
|
914
|
-
await this.fitToBox(e, n, {
|
|
915
|
-
paddingLeft: i,
|
|
916
|
-
paddingRight: i,
|
|
917
|
-
paddingTop: i,
|
|
918
|
-
paddingBottom: i,
|
|
919
|
-
cover: r
|
|
920
|
-
});
|
|
921
|
-
else {
|
|
922
|
-
const d = new fe();
|
|
923
|
-
e.getBoundingSphere(d), d.radius += i, await this.fitToSphere(d, n);
|
|
924
|
-
}
|
|
925
|
-
} else {
|
|
926
|
-
const o = new fe();
|
|
927
|
-
e.getBoundingSphere(o), o.radius += i, await this.fitToSphere(o, n);
|
|
928
|
-
}
|
|
929
|
-
return !0;
|
|
930
|
-
}
|
|
931
|
-
async flyToObject(e, t = {}) {
|
|
932
|
-
const s = new V().setFromObject(e);
|
|
933
|
-
return this.flyToBox(s, t);
|
|
934
|
-
}
|
|
935
|
-
/**
|
|
936
|
-
* Fly camera to a specific position and look-at target.
|
|
937
|
-
*/
|
|
938
|
-
async flyTo(e, t, s = {}) {
|
|
939
|
-
const { enableTransition: n = !0 } = s;
|
|
940
|
-
return this.absoluteRotations(), this.setLookAt(e.x, e.y, e.z, t.x, t.y, t.z, n);
|
|
941
|
-
}
|
|
942
|
-
/**
|
|
943
|
-
* Get the current camera viewpoint data (position, target, zoom).
|
|
944
|
-
*/
|
|
945
|
-
getCameraViewpoint() {
|
|
946
|
-
const e = new v(), t = new v();
|
|
947
|
-
return this.getPosition(e), this.getTarget(t), {
|
|
948
|
-
position: { x: e.x, y: e.y, z: e.z },
|
|
949
|
-
target: { x: t.x, y: t.y, z: t.z },
|
|
950
|
-
zoom: this.camera.zoom
|
|
951
|
-
};
|
|
952
|
-
}
|
|
953
|
-
/**
|
|
954
|
-
* Lock camera controls (disable all user interaction).
|
|
955
|
-
*/
|
|
956
|
-
lock() {
|
|
957
|
-
this.enabled = !1;
|
|
958
|
-
}
|
|
959
|
-
/**
|
|
960
|
-
* Unlock camera controls (re-enable user interaction).
|
|
961
|
-
*/
|
|
962
|
-
unlock() {
|
|
963
|
-
this.enabled = !0;
|
|
964
|
-
}
|
|
965
|
-
/**
|
|
966
|
-
* Switch between 2D top-down and 3D perspective views.
|
|
967
|
-
*/
|
|
968
|
-
async setViewMode(e, t = !0) {
|
|
969
|
-
if (e === "2d") {
|
|
970
|
-
const s = new v();
|
|
971
|
-
this.getTarget(s), await this.rotateTo(0, 0, t), this.minPolarAngle = 0, this.maxPolarAngle = 0;
|
|
972
|
-
} else
|
|
973
|
-
this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, await this.rotateTo(0, Math.PI / 4, t);
|
|
974
|
-
}
|
|
975
|
-
async setCameraViewpoint(e, t = !0) {
|
|
976
|
-
const { position: s, target: n, zoom: i = this.camera.zoom } = e;
|
|
977
|
-
return Promise.all([
|
|
978
|
-
this.zoomTo(i, t),
|
|
979
|
-
this.setLookAt(s.x, s.y, s.z, n.x, n.y, n.z, t)
|
|
980
|
-
]);
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
const Be = {
|
|
984
|
-
LEFT: new M(0, Math.PI / 2, -Math.PI / 2),
|
|
985
|
-
RIGHT: new M(0, Math.PI / 2, Math.PI / 2),
|
|
986
|
-
FRONT: new M(0, Math.PI / 2, 0),
|
|
987
|
-
BACK: new M(0, Math.PI / 2, Math.PI),
|
|
988
|
-
TOP: new M(0, 0, 0),
|
|
989
|
-
BOTTOM: new M(0, Math.PI, 0),
|
|
990
|
-
FRONTTOP: new M(0, Math.PI / 4, 0),
|
|
991
|
-
BACKTOP: new M(0, Math.PI / 4, Math.PI),
|
|
992
|
-
LEFTTOP: new M(0, Math.PI / 4, -Math.PI / 2),
|
|
993
|
-
RIGHTTOP: new M(0, Math.PI / 4, Math.PI / 2),
|
|
994
|
-
LEFTFRONTTOP: new M(0, Math.PI / 4, -Math.PI / 4),
|
|
995
|
-
RIGHTFRONTTOP: new M(0, Math.PI / 4, Math.PI / 4),
|
|
996
|
-
LEFTBACKTOP: new M(0, Math.PI / 4, -Math.PI / 4 * 3),
|
|
997
|
-
RIGHTBACKTOP: new M(0, Math.PI / 4, Math.PI / 4 * 3)
|
|
998
|
-
}, Ms = /* @__PURE__ */ new Set(["LEFT", "RIGHT", "FRONT", "BACK", "TOP", "BOTTOM"]);
|
|
999
|
-
function _s(h, e) {
|
|
1000
|
-
const t = h - e;
|
|
1001
|
-
return gt.euclideanModulo(t + Math.PI, Math.PI * 2) - Math.PI;
|
|
1002
|
-
}
|
|
1003
|
-
class Es {
|
|
1004
|
-
environment = new is();
|
|
1005
|
-
renderer;
|
|
1006
|
-
pmremGenerator;
|
|
1007
|
-
envMap = null;
|
|
1008
|
-
constructor(e) {
|
|
1009
|
-
this.renderer = e, this.pmremGenerator = new yt(e);
|
|
1010
|
-
}
|
|
1011
|
-
update() {
|
|
1012
|
-
this.envMap || (this.envMap = this.pmremGenerator.fromScene(this.environment).texture);
|
|
1013
|
-
}
|
|
1014
|
-
dispose() {
|
|
1015
|
-
this.pmremGenerator.dispose(), this.envMap?.dispose();
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
const te = 128;
|
|
1019
|
-
class Ps extends rs {
|
|
1020
|
-
viewer;
|
|
1021
|
-
overlayPass;
|
|
1022
|
-
constructor(e) {
|
|
1023
|
-
super(e.camera, e.el), this.viewer = e;
|
|
1024
|
-
const t = new ne(-2, 2, 2, -2, 0, 4);
|
|
1025
|
-
t.position.set(0, 0, 2), this.overlayPass = ge(this, t), this.setLabels("x", "y", "z");
|
|
1026
|
-
}
|
|
1027
|
-
_update = () => {
|
|
1028
|
-
this.quaternion.copy(this.viewer.camera.quaternion).invert();
|
|
1029
|
-
const e = this.location;
|
|
1030
|
-
let t, s;
|
|
1031
|
-
e.left !== null ? t = e.left : t = this.viewer.el.offsetWidth - te - e.right, e.top !== null ? s = e.top : s = this.viewer.el.offsetHeight - te - e.bottom, this.overlayPass.setViewport(t, s, te, te);
|
|
1032
|
-
};
|
|
1033
|
-
enable() {
|
|
1034
|
-
return this.viewer.renderPipeline.addOverlayPass(this.overlayPass), this.viewer.addEventListener("beforeRender", this._update), this.viewer.render(), this;
|
|
1035
|
-
}
|
|
1036
|
-
disable() {
|
|
1037
|
-
return this.viewer.renderPipeline.removeOverlayPass(this.overlayPass), this.viewer.removeEventListener("beforeRender", this._update), this.viewer.render(), this;
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
const qe = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;overflow:hidden;", Os = qe + "z-index:0;", As = qe + "z-index:1;";
|
|
1041
|
-
class Bs {
|
|
1042
|
-
el;
|
|
1043
|
-
css2dRenderer = null;
|
|
1044
|
-
css3dRenderer = null;
|
|
1045
|
-
constructor(e) {
|
|
1046
|
-
this.el = e, getComputedStyle(e).position === "static" && (e.style.position = "relative");
|
|
1047
|
-
}
|
|
1048
|
-
initCSS2DRenderer() {
|
|
1049
|
-
const e = new os();
|
|
1050
|
-
return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = As, this.el.appendChild(e.domElement), this.css2dRenderer = e, e;
|
|
1051
|
-
}
|
|
1052
|
-
initCSS3DRenderer() {
|
|
1053
|
-
const e = new cs();
|
|
1054
|
-
return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = Os, this.el.appendChild(e.domElement), this.css3dRenderer = e, e;
|
|
1055
|
-
}
|
|
1056
|
-
createCSS2DObject(e) {
|
|
1057
|
-
return this.css2dRenderer || this.initCSS2DRenderer(), new as(e);
|
|
1058
|
-
}
|
|
1059
|
-
createCSS25DObject(e) {
|
|
1060
|
-
return this.css3dRenderer || this.initCSS3DRenderer(), new hs(e);
|
|
1061
|
-
}
|
|
1062
|
-
createCSS3DObject(e) {
|
|
1063
|
-
return this.css3dRenderer || this.initCSS3DRenderer(), new ls(e);
|
|
1064
|
-
}
|
|
1065
|
-
render(e, t) {
|
|
1066
|
-
this.css2dRenderer && this.css2dRenderer.render(e, t), this.css3dRenderer && this.css3dRenderer.render(e, t);
|
|
1067
|
-
}
|
|
1068
|
-
resize(e, t) {
|
|
1069
|
-
this.css2dRenderer && this.css2dRenderer.setSize(e, t), this.css3dRenderer && this.css3dRenderer.setSize(e, t);
|
|
1070
|
-
}
|
|
1071
|
-
dispose() {
|
|
1072
|
-
this.css2dRenderer && (this.el.removeChild(this.css2dRenderer.domElement), this.css2dRenderer = null), this.css3dRenderer && (this.el.removeChild(this.css3dRenderer.domElement), this.css3dRenderer = null);
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
const Rs = "timestamp-query";
|
|
1076
|
-
class Is {
|
|
1077
|
-
el;
|
|
1078
|
-
renderer;
|
|
1079
|
-
container;
|
|
1080
|
-
drawCallsText;
|
|
1081
|
-
frameCallsText;
|
|
1082
|
-
trianglesText;
|
|
1083
|
-
pointsText;
|
|
1084
|
-
linesText;
|
|
1085
|
-
timestampText;
|
|
1086
|
-
_enabled = !1;
|
|
1087
|
-
#t = !1;
|
|
1088
|
-
constructor(e, t) {
|
|
1089
|
-
this.el = e, this.renderer = t;
|
|
1090
|
-
const s = document.createElement("div");
|
|
1091
|
-
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;
|
|
1092
|
-
function n(r, o = !0) {
|
|
1093
|
-
const a = document.createElement("span");
|
|
1094
|
-
return o && (a.style.marginLeft = "6px"), a.innerText = r, a;
|
|
1095
|
-
}
|
|
1096
|
-
function i() {
|
|
1097
|
-
return document.createElement("br");
|
|
1098
|
-
}
|
|
1099
|
-
this.drawCallsText = n("0"), this.frameCallsText = n("0"), this.trianglesText = n("0"), this.linesText = n("0"), this.pointsText = n("0"), this.timestampText = n("0"), this.container.appendChild(n("draw calls", !1)), this.container.appendChild(this.drawCallsText), this.container.appendChild(i()), this.container.appendChild(n("frame calls", !1)), this.container.appendChild(this.frameCallsText), this.container.appendChild(i()), this.container.appendChild(n("triangles", !1)), this.container.appendChild(this.trianglesText), this.container.appendChild(i()), this.container.appendChild(n("points", !1)), this.container.appendChild(this.pointsText), this.container.appendChild(i()), this.container.appendChild(n("lines", !1)), this.container.appendChild(this.linesText), this.container.appendChild(i()), this.container.appendChild(n("timestamp", !1)), this.container.appendChild(this.timestampText), this.container.appendChild(i());
|
|
1100
|
-
}
|
|
1101
|
-
update() {
|
|
1102
|
-
if (this._enabled) {
|
|
1103
|
-
const { render: e } = this.renderer.info;
|
|
1104
|
-
if (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.#t) {
|
|
1105
|
-
this.timestampText.innerText = "0";
|
|
1106
|
-
return;
|
|
1107
|
-
}
|
|
1108
|
-
this.#n(Z.RENDER).then((t) => {
|
|
1109
|
-
this._enabled && (this.timestampText.innerText = t?.toFixed(2) ?? "0");
|
|
1110
|
-
}), this.#n(Z.COMPUTE);
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
enable() {
|
|
1114
|
-
this._enabled = !0, this.#r(!0), this.el.appendChild(this.container);
|
|
1115
|
-
}
|
|
1116
|
-
disable() {
|
|
1117
|
-
this._enabled = !1, this.#r(!1), this.#o(), this.container.remove();
|
|
1118
|
-
}
|
|
1119
|
-
dispose() {
|
|
1120
|
-
this.disable();
|
|
1121
|
-
}
|
|
1122
|
-
#e() {
|
|
1123
|
-
return this.renderer.backend;
|
|
1124
|
-
}
|
|
1125
|
-
#s() {
|
|
1126
|
-
try {
|
|
1127
|
-
return this.renderer.hasFeature(Rs);
|
|
1128
|
-
} catch {
|
|
1129
|
-
return !0;
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
#r(e) {
|
|
1133
|
-
const t = this.#e();
|
|
1134
|
-
if (!t) {
|
|
1135
|
-
this.#t = !1;
|
|
1136
|
-
return;
|
|
1137
|
-
}
|
|
1138
|
-
t.trackTimestamp = e && this.#s(), this.#t = t.trackTimestamp === !0;
|
|
1139
|
-
}
|
|
1140
|
-
#n(e) {
|
|
1141
|
-
const t = this.#e()?.timestampQueryPool?.[e];
|
|
1142
|
-
return t?.resolveQueriesAsync ? Promise.resolve(t.resolveQueriesAsync()).catch(() => {
|
|
1143
|
-
}) : Promise.resolve(void 0);
|
|
1144
|
-
}
|
|
1145
|
-
#o() {
|
|
1146
|
-
this.#n(Z.RENDER), this.#n(Z.COMPUTE);
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
wt.enabled = !0;
|
|
1150
|
-
class An extends ke {
|
|
1151
|
-
el;
|
|
1152
|
-
renderer;
|
|
1153
|
-
scene;
|
|
1154
|
-
camera;
|
|
1155
|
-
info;
|
|
1156
|
-
controls;
|
|
1157
|
-
renderPipeline;
|
|
1158
|
-
timer;
|
|
1159
|
-
roomEnvironment;
|
|
1160
|
-
interactionManager;
|
|
1161
|
-
objectManager;
|
|
1162
|
-
viewerHelper;
|
|
1163
|
-
cssRenderer;
|
|
1164
|
-
frameCount = 1;
|
|
1165
|
-
frameloop = "demand";
|
|
1166
|
-
constructor({ el: e, rendererOptions: t }) {
|
|
1167
|
-
super(), this.el = e, this.renderer = this._initRenderer(t), this.scene = this.createScene(), this.camera = this.createPerspectiveCamera(), this.info = new Is(this.el, this.renderer), this.controls = new Ts(this.camera, this.renderer.domElement), this.renderPipeline = new Ss(this.renderer, this.scene, this.camera), this.timer = new vt(), this.roomEnvironment = new Es(this.renderer), this.interactionManager = new bs(this.renderer.domElement, this.scene, this.camera), this.objectManager = new xs(), this.viewerHelper = new Ps(this), this.cssRenderer = new Bs(this.el), window.addEventListener("resize", this.onWindowResize);
|
|
1168
|
-
}
|
|
1169
|
-
onWindowResize = () => {
|
|
1170
|
-
const e = this.el.clientWidth, t = this.el.clientHeight;
|
|
1171
|
-
this.camera instanceof se ? (this.camera.aspect = e / t, this.camera.updateProjectionMatrix()) : this.camera instanceof ne && (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();
|
|
1172
|
-
};
|
|
1173
|
-
async init() {
|
|
1174
|
-
await this.renderer.init(), this.roomEnvironment.update(), this.scene.environment = this.roomEnvironment.envMap;
|
|
1175
|
-
}
|
|
1176
|
-
setCamera(e) {
|
|
1177
|
-
this.camera = e, this.controls.camera = e, this.interactionManager.setCamera(e), this.renderPipeline.setCamera(e), this.onWindowResize(), this.dispatchEvent({ type: "cameraChange", camera: e });
|
|
1178
|
-
}
|
|
1179
|
-
setCameraByType(e) {
|
|
1180
|
-
e === "perspective" && !(this.camera instanceof se) ? this.setCamera(this.createPerspectiveCamera()) : e === "orthographic" && !(this.camera instanceof ne) && this.setCamera(this.createOrthographicCamera());
|
|
1181
|
-
}
|
|
1182
|
-
render(e = 1) {
|
|
1183
|
-
return this.frameCount += e, new Promise((t) => {
|
|
1184
|
-
const s = () => {
|
|
1185
|
-
this.removeEventListener("afterRender", s), t();
|
|
1186
|
-
};
|
|
1187
|
-
this.addEventListener("afterRender", s);
|
|
1188
|
-
});
|
|
1189
|
-
}
|
|
1190
|
-
animate = (e) => {
|
|
1191
|
-
this.timer.update(e);
|
|
1192
|
-
const t = this.timer.getDelta();
|
|
1193
|
-
this.dispatchEvent({ type: "beforeControlsUpdate", time: e, delta: t });
|
|
1194
|
-
let s = this.controls.update(t);
|
|
1195
|
-
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 }));
|
|
1196
|
-
};
|
|
1197
|
-
_initRenderer(e) {
|
|
1198
|
-
const t = new bt({
|
|
1199
|
-
reversedDepthBuffer: !0,
|
|
1200
|
-
antialias: !1,
|
|
1201
|
-
depth: !1,
|
|
1202
|
-
trackTimestamp: !1,
|
|
1203
|
-
...e
|
|
1204
|
-
});
|
|
1205
|
-
return t.setSize(this.el.clientWidth, this.el.clientHeight), t.shadowMap.enabled = !0, t.shadowMap.type = xt, t.toneMapping = St, t.toneMappingExposure = 1, t.info.autoReset = !1, t.setPixelRatio(Math.min(window.devicePixelRatio, 1.5)), t.setAnimationLoop(this.animate), this.el.appendChild(t.domElement), t;
|
|
1206
|
-
}
|
|
1207
|
-
createScene() {
|
|
1208
|
-
const e = new Ue();
|
|
1209
|
-
return e.background = new T(0), e;
|
|
1210
|
-
}
|
|
1211
|
-
createPerspectiveCamera() {
|
|
1212
|
-
const e = new se(50, this.el.clientWidth / this.el.clientHeight, 0.1, 1e5);
|
|
1213
|
-
return e.position.setScalar(5), e;
|
|
1214
|
-
}
|
|
1215
|
-
createOrthographicCamera() {
|
|
1216
|
-
const e = new ne(
|
|
1217
|
-
-this.el.clientWidth / 2,
|
|
1218
|
-
this.el.clientWidth / 2,
|
|
1219
|
-
this.el.clientHeight / 2,
|
|
1220
|
-
-this.el.clientHeight / 2,
|
|
1221
|
-
0.1,
|
|
1222
|
-
1e5
|
|
1223
|
-
);
|
|
1224
|
-
return e.position.setScalar(5), e;
|
|
1225
|
-
}
|
|
1226
|
-
/**
|
|
1227
|
-
* Manually trigger a resize update.
|
|
1228
|
-
*/
|
|
1229
|
-
resize(e, t) {
|
|
1230
|
-
e !== void 0 && t !== void 0 && (this.el.style.width = `${e}px`, this.el.style.height = `${t}px`), this.onWindowResize();
|
|
1231
|
-
}
|
|
1232
|
-
/**
|
|
1233
|
-
* Capture a screenshot of the current render.
|
|
1234
|
-
*/
|
|
1235
|
-
async screenshot(e = {}) {
|
|
1236
|
-
const { type: t = "image/png", quality: s = 1 } = e, n = this.el.clientWidth, i = this.el.clientHeight, r = e.width && e.height;
|
|
1237
|
-
r && this.renderer.setSize(e.width, e.height), await this.render();
|
|
1238
|
-
const o = this.renderer.domElement.toDataURL(t, s);
|
|
1239
|
-
return r && (this.renderer.setSize(n, i), this.onWindowResize()), o;
|
|
1240
|
-
}
|
|
1241
|
-
/**
|
|
1242
|
-
* Set the scene background color, texture, or null.
|
|
1243
|
-
*/
|
|
1244
|
-
setBackground(e) {
|
|
1245
|
-
e === null ? this.scene.background = null : e instanceof T || typeof e == "number" || typeof e == "string" ? this.scene.background = new T(e) : this.scene.background = e, this.render();
|
|
1246
|
-
}
|
|
1247
|
-
/**
|
|
1248
|
-
* Set the scene environment map for reflections / IBL.
|
|
1249
|
-
*/
|
|
1250
|
-
setEnvironment(e) {
|
|
1251
|
-
this.scene.environment = e, this.render();
|
|
1252
|
-
}
|
|
1253
|
-
/**
|
|
1254
|
-
* Enable shadow rendering.
|
|
1255
|
-
*/
|
|
1256
|
-
enableShadow() {
|
|
1257
|
-
this.renderer.shadowMap.enabled = !0, this.render();
|
|
1258
|
-
}
|
|
1259
|
-
/**
|
|
1260
|
-
* Disable shadow rendering.
|
|
1261
|
-
*/
|
|
1262
|
-
disableShadow() {
|
|
1263
|
-
this.renderer.shadowMap.enabled = !1, this.render();
|
|
1264
|
-
}
|
|
1265
|
-
/**
|
|
1266
|
-
* Enable linear fog.
|
|
1267
|
-
*/
|
|
1268
|
-
enableFog(e = {}) {
|
|
1269
|
-
const { color: t = 13421772, near: s = 10, far: n = 100 } = e;
|
|
1270
|
-
this.scene.fog = new Ct(t, s, n), this.render();
|
|
1271
|
-
}
|
|
1272
|
-
/**
|
|
1273
|
-
* Enable exponential fog.
|
|
1274
|
-
*/
|
|
1275
|
-
enableFogExp2(e = {}) {
|
|
1276
|
-
const { color: t = 13421772, density: s = 0.01 } = e;
|
|
1277
|
-
this.scene.fog = new Tt(t, s), this.render();
|
|
1278
|
-
}
|
|
1279
|
-
/**
|
|
1280
|
-
* Disable fog.
|
|
1281
|
-
*/
|
|
1282
|
-
disableFog() {
|
|
1283
|
-
this.scene.fog = null, this.render();
|
|
1284
|
-
}
|
|
1285
|
-
dispose() {
|
|
1286
|
-
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();
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
class Ls extends Qe {
|
|
346
|
+
class at extends Re {
|
|
1290
347
|
constructor(e) {
|
|
1291
348
|
super(e);
|
|
1292
349
|
}
|
|
1293
350
|
parse(e, t, s, n) {
|
|
1294
|
-
if (
|
|
1295
|
-
const
|
|
1296
|
-
return super.parse(
|
|
351
|
+
if (vn(e.slice(0, 8)) === "SBMG----") {
|
|
352
|
+
const a = Sn(e.slice(8));
|
|
353
|
+
return super.parse(a, t, s, n);
|
|
1297
354
|
} else
|
|
1298
355
|
return super.parse(e, t, s, n);
|
|
1299
356
|
}
|
|
1300
357
|
}
|
|
1301
|
-
function
|
|
1302
|
-
return new TextDecoder().decode(new Uint8Array(
|
|
358
|
+
function vn(i) {
|
|
359
|
+
return new TextDecoder().decode(new Uint8Array(i));
|
|
1303
360
|
}
|
|
1304
|
-
function
|
|
1305
|
-
const e = new DataView(
|
|
361
|
+
function Sn(i) {
|
|
362
|
+
const e = new DataView(i);
|
|
1306
363
|
for (let t = 0; t < e.byteLength; t++) {
|
|
1307
364
|
const s = e.getUint8(t), n = (s >> 4 & 15) + (s << 4 & 240);
|
|
1308
365
|
e.setUint8(t, n);
|
|
1309
366
|
}
|
|
1310
367
|
return e.buffer;
|
|
1311
368
|
}
|
|
1312
|
-
const
|
|
1313
|
-
function
|
|
1314
|
-
let e =
|
|
1315
|
-
const t = new Uint8Array(
|
|
1316
|
-
if (
|
|
1317
|
-
return
|
|
1318
|
-
e +=
|
|
1319
|
-
const n = new Uint8Array(
|
|
369
|
+
const In = 8, En = 130, ot = 66, Cn = "SBK-----", An = "SBM-----", Vt = new TextDecoder(), On = new TextEncoder();
|
|
370
|
+
function Bn(i) {
|
|
371
|
+
let e = In;
|
|
372
|
+
const t = new Uint8Array(i, 0, e);
|
|
373
|
+
if (Vt.decode(t) !== Cn)
|
|
374
|
+
return i;
|
|
375
|
+
e += En;
|
|
376
|
+
const n = new Uint8Array(i, 0, e);
|
|
1320
377
|
if (n[40] === 1) {
|
|
1321
|
-
const
|
|
1322
|
-
let
|
|
1323
|
-
const d = e +
|
|
1324
|
-
for (let
|
|
1325
|
-
|
|
1326
|
-
const
|
|
1327
|
-
return
|
|
378
|
+
const a = On.encode(An), o = new Uint8Array([n[41]]), c = _n(n), l = Tn(c);
|
|
379
|
+
let h = ot % l.length;
|
|
380
|
+
const d = e + ot, u = new Uint8Array(i, d), p = new Uint8Array(u.length);
|
|
381
|
+
for (let I = 0; I < u.length; I++)
|
|
382
|
+
p[I] = u[I] ^ l[h], h = (h + 1) % l.length;
|
|
383
|
+
const x = new Uint8Array(a.length + o.length + p.length);
|
|
384
|
+
return x.set(a), x.set(o, a.length), x.set(p, a.length + o.length), x.buffer;
|
|
1328
385
|
}
|
|
1329
386
|
}
|
|
1330
|
-
function
|
|
387
|
+
function _n(i) {
|
|
1331
388
|
const e = new Uint8Array(128);
|
|
1332
|
-
return e.set(
|
|
389
|
+
return e.set(i.slice(42, 74), 0), e.set(i.slice(74, 138), 32), e.set(i.slice(8, 40), 96), e;
|
|
1333
390
|
}
|
|
1334
|
-
function
|
|
391
|
+
function Tn(i) {
|
|
1335
392
|
const e = new Uint8Array(64);
|
|
1336
|
-
return e.set(
|
|
393
|
+
return e.set(i.slice(0, 8), 0), e.set(i.slice(24, 32), 8), e.set(i.slice(40, 56), 16), e.set(i.slice(64, 88), 32), e.set(i.slice(96, 104), 56), e;
|
|
1337
394
|
}
|
|
1338
|
-
const
|
|
1339
|
-
const s =
|
|
1340
|
-
let n =
|
|
395
|
+
const Ln = (i, e, t) => {
|
|
396
|
+
const s = i.buffer.slice(t, t + e);
|
|
397
|
+
let n = Vt.decode(s);
|
|
1341
398
|
return n = n.replace("\\", "/"), n.startsWith("Maps/") || (n = `Maps/${n}`), n;
|
|
1342
|
-
},
|
|
1343
|
-
const [s, n,
|
|
1344
|
-
return new
|
|
1345
|
-
name:
|
|
1346
|
-
color: new
|
|
1347
|
-
opacity:
|
|
1348
|
-
transparent:
|
|
399
|
+
}, Nn = (i, e, t) => {
|
|
400
|
+
const [s, n, r, a, o] = e, c = t || a < 1;
|
|
401
|
+
return new q({
|
|
402
|
+
name: i,
|
|
403
|
+
color: new P(s, n, r),
|
|
404
|
+
opacity: a,
|
|
405
|
+
transparent: c,
|
|
1349
406
|
alphaTest: 0.01,
|
|
1350
407
|
side: o
|
|
1351
408
|
});
|
|
1352
|
-
},
|
|
1353
|
-
class
|
|
409
|
+
}, Dn = (i) => i?.toLowerCase().endsWith(".png") ?? !1;
|
|
410
|
+
class Pn {
|
|
1354
411
|
data;
|
|
1355
412
|
options;
|
|
1356
413
|
textureLoader;
|
|
1357
414
|
littleEndian = !0;
|
|
1358
415
|
materials = /* @__PURE__ */ new Map();
|
|
1359
416
|
constructor(e, t) {
|
|
1360
|
-
this.data = e, this.options = t, this.textureLoader = new
|
|
417
|
+
this.data = e, this.options = t, this.textureLoader = new Ft(t.manager), this.textureLoader.setCrossOrigin(t.crossOrigin), this.textureLoader.setRequestHeader(t.requestHeader);
|
|
1361
418
|
}
|
|
1362
419
|
parse(e, t) {
|
|
1363
420
|
let s = this.data;
|
|
1364
|
-
const n =
|
|
421
|
+
const n = Bn(this.data);
|
|
1365
422
|
n && (s = n);
|
|
1366
|
-
const
|
|
1367
|
-
let
|
|
1368
|
-
const o =
|
|
1369
|
-
|
|
423
|
+
const r = new DataView(s);
|
|
424
|
+
let a = 8;
|
|
425
|
+
const o = r.getUint8(a);
|
|
426
|
+
a += 1, o === 1 ? this._parseV2(r, a, e) : o === 2 ? this._parseV2(r, a, e) : o === 3 ? this._parseV3(r, a, e) : t?.(new Error(`SBMLoader: Unsupported SBM version: ${o}`));
|
|
1370
427
|
}
|
|
1371
428
|
_parseV2(e, t, s) {
|
|
1372
|
-
const n = new
|
|
429
|
+
const n = new W(), r = e.getUint16(t, this.littleEndian);
|
|
1373
430
|
t += 2;
|
|
1374
|
-
const
|
|
431
|
+
const a = e.getUint16(t, this.littleEndian);
|
|
1375
432
|
t += 2;
|
|
1376
|
-
for (let o = 0; o <
|
|
1377
|
-
const
|
|
433
|
+
for (let o = 0; o < r; ++o) {
|
|
434
|
+
const c = e.getUint16(t, this.littleEndian).toString();
|
|
1378
435
|
t += 2, t += 4, t += 4, t += 4, t += 4;
|
|
1379
|
-
const c = e.getFloat32(t, this.littleEndian);
|
|
1380
|
-
t += 4;
|
|
1381
436
|
const l = e.getFloat32(t, this.littleEndian);
|
|
1382
437
|
t += 4;
|
|
438
|
+
const h = e.getFloat32(t, this.littleEndian);
|
|
439
|
+
t += 4;
|
|
1383
440
|
const d = e.getFloat32(t, this.littleEndian);
|
|
1384
441
|
t += 4;
|
|
1385
|
-
const
|
|
442
|
+
const u = e.getFloat32(t, this.littleEndian);
|
|
1386
443
|
t += 4, t += 4, t += 4, t += 4, t += 4;
|
|
1387
|
-
let
|
|
1388
|
-
t += 1,
|
|
1389
|
-
const
|
|
444
|
+
let p = e.getUint8(t);
|
|
445
|
+
t += 1, p === 0 ? p = ws : p === 1 ? p = xs : p === 2 && (p = Ht);
|
|
446
|
+
const x = e.getUint16(t, this.littleEndian);
|
|
1390
447
|
t += 2;
|
|
1391
|
-
const
|
|
1392
|
-
if (t +=
|
|
1393
|
-
const
|
|
1394
|
-
this.materials.set(
|
|
1395
|
-
y.colorSpace =
|
|
448
|
+
const I = x > 0 ? Ln(e, x, t) : "";
|
|
449
|
+
if (t += x, !this.materials.has(c)) {
|
|
450
|
+
const C = Nn(c, [l, h, d, u, p], Dn(I));
|
|
451
|
+
this.materials.set(c, C), I && this.options.path && this.textureLoader.load(he.resolveURL(I, this.options.path), (y) => {
|
|
452
|
+
y.colorSpace = Se, y.wrapS = Ie, y.wrapT = Ie, y.flipY = !1, y.anisotropy = 16, C.map = y;
|
|
1396
453
|
});
|
|
1397
454
|
}
|
|
1398
455
|
}
|
|
1399
|
-
for (let o = 0; o <
|
|
1400
|
-
const a = e.getUint16(t, this.littleEndian).toString();
|
|
1401
|
-
t += 2;
|
|
456
|
+
for (let o = 0; o < a; ++o) {
|
|
1402
457
|
const c = e.getUint16(t, this.littleEndian).toString();
|
|
1403
458
|
t += 2;
|
|
1404
|
-
const l =
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
459
|
+
const l = e.getUint16(t, this.littleEndian).toString();
|
|
460
|
+
t += 2;
|
|
461
|
+
const h = [], d = [], u = [], p = [], x = e.getUint16(t, this.littleEndian);
|
|
462
|
+
if (t += 2, x > 0)
|
|
463
|
+
for (let b = 0; b < x; b++) {
|
|
464
|
+
const S = new D();
|
|
465
|
+
S.setX(e.getFloat32(t, this.littleEndian)), t += 4, S.setY(e.getFloat32(t, this.littleEndian)), t += 4, S.setZ(e.getFloat32(t, this.littleEndian)), t += 4, h.push(S);
|
|
1409
466
|
}
|
|
1410
|
-
const
|
|
1411
|
-
if (t += 2,
|
|
1412
|
-
for (let
|
|
467
|
+
const I = e.getUint16(t, this.littleEndian);
|
|
468
|
+
if (t += 2, I > 0)
|
|
469
|
+
for (let b = 0; b < I; b++)
|
|
1413
470
|
t += 4, t += 4, t += 4;
|
|
1414
|
-
const
|
|
1415
|
-
if (t += 2,
|
|
1416
|
-
for (let
|
|
1417
|
-
const
|
|
1418
|
-
|
|
471
|
+
const _ = e.getUint16(t, this.littleEndian);
|
|
472
|
+
if (t += 2, _ > 0)
|
|
473
|
+
for (let b = 0; b < _; b++) {
|
|
474
|
+
const S = new j();
|
|
475
|
+
S.setX(e.getFloat32(t, this.littleEndian)), t += 4, S.setY(e.getFloat32(t, this.littleEndian)), t += 4, d.push(S);
|
|
1419
476
|
}
|
|
1420
|
-
const
|
|
1421
|
-
if (t += 2,
|
|
1422
|
-
for (let
|
|
1423
|
-
const
|
|
477
|
+
const C = e.getUint16(t, this.littleEndian);
|
|
478
|
+
if (t += 2, C > 0)
|
|
479
|
+
for (let b = 0; b < C; b++) {
|
|
480
|
+
const S = e.getUint16(t, this.littleEndian);
|
|
1424
481
|
t += 2;
|
|
1425
|
-
const
|
|
482
|
+
const A = e.getUint16(t, this.littleEndian);
|
|
1426
483
|
t += 2;
|
|
1427
|
-
const
|
|
484
|
+
const v = e.getUint16(t, this.littleEndian);
|
|
1428
485
|
t += 2;
|
|
1429
|
-
const
|
|
1430
|
-
|
|
486
|
+
const E = [S, A, v];
|
|
487
|
+
u.push(E), d.length > 0 && p.push([d[E[0]], d[E[1]], d[E[2]]]);
|
|
1431
488
|
}
|
|
1432
|
-
const y = [],
|
|
1433
|
-
for (let
|
|
1434
|
-
const
|
|
1435
|
-
y.push(...
|
|
1436
|
-
let
|
|
1437
|
-
const
|
|
1438
|
-
|
|
489
|
+
const y = [], w = [];
|
|
490
|
+
for (let b = 0; b < u.length; b++) {
|
|
491
|
+
const S = u[b], A = h[S[0]], v = h[S[1]], E = h[S[2]];
|
|
492
|
+
y.push(...A.toArray(), ...v.toArray(), ...E.toArray());
|
|
493
|
+
let z = new j(), N = new j(), f = new j();
|
|
494
|
+
const L = p[b];
|
|
495
|
+
L !== void 0 && (z = L[0], N = L[1], f = L[2]), w.push(...z.toArray(), ...N.toArray(), ...f.toArray());
|
|
1439
496
|
}
|
|
1440
|
-
const
|
|
1441
|
-
if (
|
|
1442
|
-
const
|
|
1443
|
-
|
|
497
|
+
const g = new Float32Array(y), m = new Float32Array(w), M = new G();
|
|
498
|
+
if (g.length > 0 && M.setAttribute("position", new Pe(g, 3)), m.length > 0 && M.setAttribute("uv", new Pe(m, 2)), M.computeVertexNormals(), this.materials.has(l)) {
|
|
499
|
+
const b = new k(M, this.materials.get(l));
|
|
500
|
+
b.name = c, b.castShadow = !0, b.receiveShadow = !0, n.add(b);
|
|
1444
501
|
}
|
|
1445
502
|
}
|
|
1446
503
|
s(n);
|
|
1447
504
|
}
|
|
1448
505
|
_parseV3(e, t, s) {
|
|
1449
|
-
const n = new
|
|
506
|
+
const n = new W();
|
|
1450
507
|
console.warn("SBMLoader: SBM version 3 is not supported yet."), s(n);
|
|
1451
508
|
}
|
|
1452
509
|
}
|
|
1453
|
-
class
|
|
510
|
+
class ct extends bs {
|
|
1454
511
|
load(e, t, s, n) {
|
|
1455
|
-
let
|
|
512
|
+
let r;
|
|
1456
513
|
if (this.resourcePath !== "")
|
|
1457
|
-
|
|
514
|
+
r = this.resourcePath;
|
|
1458
515
|
else if (this.path !== "") {
|
|
1459
|
-
const
|
|
1460
|
-
|
|
516
|
+
const c = he.extractUrlBase(e);
|
|
517
|
+
r = he.resolveURL(c, this.path);
|
|
1461
518
|
} else
|
|
1462
|
-
|
|
519
|
+
r = he.extractUrlBase(e);
|
|
1463
520
|
this.manager.itemStart(e);
|
|
1464
|
-
const
|
|
1465
|
-
n ? n(
|
|
1466
|
-
}, o = new
|
|
521
|
+
const a = (c) => {
|
|
522
|
+
n ? n(c) : console.error(c), this.manager.itemError(e), this.manager.itemEnd(e);
|
|
523
|
+
}, o = new Wt(this.manager);
|
|
1467
524
|
o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(
|
|
1468
525
|
e,
|
|
1469
|
-
(
|
|
526
|
+
(c) => {
|
|
1470
527
|
try {
|
|
1471
528
|
this.parse(
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
(
|
|
1475
|
-
t(
|
|
529
|
+
c,
|
|
530
|
+
r,
|
|
531
|
+
(l) => {
|
|
532
|
+
t(l), this.manager.itemEnd(e);
|
|
1476
533
|
},
|
|
1477
|
-
|
|
534
|
+
a
|
|
1478
535
|
);
|
|
1479
|
-
} catch (
|
|
1480
|
-
|
|
536
|
+
} catch (l) {
|
|
537
|
+
a(l);
|
|
1481
538
|
}
|
|
1482
539
|
},
|
|
1483
540
|
s,
|
|
1484
|
-
|
|
541
|
+
a
|
|
1485
542
|
);
|
|
1486
543
|
}
|
|
1487
544
|
parse(e, t, s, n) {
|
|
1488
|
-
const
|
|
1489
|
-
if (
|
|
1490
|
-
n?.(new Error(`SBMLoader: Invalid SBM format: ${
|
|
545
|
+
const r = new TextDecoder().decode(e.slice(0, 8));
|
|
546
|
+
if (r !== "SBK-----" && r !== "SBM-----") {
|
|
547
|
+
n?.(new Error(`SBMLoader: Invalid SBM format: ${r}`));
|
|
1491
548
|
return;
|
|
1492
549
|
}
|
|
1493
|
-
new
|
|
550
|
+
new Pn(e, {
|
|
1494
551
|
path: t,
|
|
1495
552
|
crossOrigin: this.crossOrigin,
|
|
1496
553
|
requestHeader: this.requestHeader,
|
|
1497
554
|
manager: this.manager
|
|
1498
555
|
}).parse(s, n);
|
|
1499
556
|
}
|
|
1500
|
-
parseAsync(e, t) {
|
|
1501
|
-
return new Promise((s, n) => {
|
|
1502
|
-
this.parse(
|
|
1503
|
-
e,
|
|
1504
|
-
t,
|
|
1505
|
-
(
|
|
1506
|
-
s(
|
|
1507
|
-
},
|
|
1508
|
-
(
|
|
1509
|
-
n(
|
|
1510
|
-
}
|
|
1511
|
-
);
|
|
1512
|
-
});
|
|
557
|
+
parseAsync(e, t) {
|
|
558
|
+
return new Promise((s, n) => {
|
|
559
|
+
this.parse(
|
|
560
|
+
e,
|
|
561
|
+
t,
|
|
562
|
+
(r) => {
|
|
563
|
+
s(r);
|
|
564
|
+
},
|
|
565
|
+
(r) => {
|
|
566
|
+
n(r);
|
|
567
|
+
}
|
|
568
|
+
);
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
const Rn = {
|
|
573
|
+
5120: Int8Array,
|
|
574
|
+
5121: Uint8Array,
|
|
575
|
+
5122: Int16Array,
|
|
576
|
+
5123: Uint16Array,
|
|
577
|
+
5125: Uint32Array,
|
|
578
|
+
5126: Float32Array
|
|
579
|
+
}, kn = {
|
|
580
|
+
SCALAR: 1,
|
|
581
|
+
VEC2: 2,
|
|
582
|
+
VEC3: 3,
|
|
583
|
+
VEC4: 4,
|
|
584
|
+
MAT2: 4,
|
|
585
|
+
MAT3: 9,
|
|
586
|
+
MAT4: 16
|
|
587
|
+
}, zn = {
|
|
588
|
+
POSITION: "position",
|
|
589
|
+
NORMAL: "normal",
|
|
590
|
+
TANGENT: "tangent",
|
|
591
|
+
TEXCOORD_0: "uv",
|
|
592
|
+
TEXCOORD_1: "uv1",
|
|
593
|
+
TEXCOORD_2: "uv2",
|
|
594
|
+
TEXCOORD_3: "uv3",
|
|
595
|
+
COLOR_0: "color"
|
|
596
|
+
};
|
|
597
|
+
function oe(i, e) {
|
|
598
|
+
e && typeof e == "object" && !Array.isArray(e) && Object.assign(i.userData, e);
|
|
599
|
+
}
|
|
600
|
+
function Un(i) {
|
|
601
|
+
if (i.protocolVersion !== et)
|
|
602
|
+
throw new Error(
|
|
603
|
+
`Unsupported model decode protocol ${i.protocolVersion}; expected ${et}.`
|
|
604
|
+
);
|
|
605
|
+
const { document: e, buffers: t, images: s } = i;
|
|
606
|
+
hn(e);
|
|
607
|
+
const n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = (w) => {
|
|
608
|
+
const g = n.get(w);
|
|
609
|
+
if (g) return g;
|
|
610
|
+
const m = e.accessors?.[w];
|
|
611
|
+
if (!m || m.bufferView === void 0)
|
|
612
|
+
throw new Error(`Decoded glTF references missing accessor ${w}.`);
|
|
613
|
+
const M = e.bufferViews?.[m.bufferView];
|
|
614
|
+
if (!M) throw new Error(`Decoded glTF references missing bufferView ${m.bufferView}.`);
|
|
615
|
+
const b = t[M.buffer];
|
|
616
|
+
if (!b) throw new Error(`Decoded glTF references missing buffer ${M.buffer}.`);
|
|
617
|
+
const S = Rn[m.componentType], A = kn[m.type];
|
|
618
|
+
if (!S || !A)
|
|
619
|
+
throw new Error(`Unsupported decoded glTF accessor type ${m.componentType}/${m.type}.`);
|
|
620
|
+
const v = S.BYTES_PER_ELEMENT, E = M.byteOffset ?? 0, z = m.byteOffset ?? 0;
|
|
621
|
+
let N;
|
|
622
|
+
const f = A * v;
|
|
623
|
+
if (M.byteStride && M.byteStride !== f) {
|
|
624
|
+
if (M.byteStride % v !== 0 || z % v !== 0)
|
|
625
|
+
throw new Error(`Decoded glTF accessor ${w} has an invalid interleaved alignment.`);
|
|
626
|
+
const L = Math.floor(z / M.byteStride), O = [
|
|
627
|
+
m.bufferView,
|
|
628
|
+
m.componentType,
|
|
629
|
+
L,
|
|
630
|
+
m.count
|
|
631
|
+
].join(":");
|
|
632
|
+
let B = r.get(O);
|
|
633
|
+
if (!B) {
|
|
634
|
+
const U = new S(
|
|
635
|
+
b,
|
|
636
|
+
E + L * M.byteStride,
|
|
637
|
+
m.count * M.byteStride / v
|
|
638
|
+
);
|
|
639
|
+
B = new vs(U, M.byteStride / v), r.set(O, B);
|
|
640
|
+
}
|
|
641
|
+
N = new Ke(
|
|
642
|
+
B,
|
|
643
|
+
A,
|
|
644
|
+
z % M.byteStride / v,
|
|
645
|
+
m.normalized ?? !1
|
|
646
|
+
);
|
|
647
|
+
} else {
|
|
648
|
+
const L = new S(
|
|
649
|
+
b,
|
|
650
|
+
E + z,
|
|
651
|
+
m.count * A
|
|
652
|
+
);
|
|
653
|
+
N = new Pe(L, A, m.normalized ?? !1);
|
|
654
|
+
}
|
|
655
|
+
return N.name = m.name ?? "", n.set(w, N), N;
|
|
656
|
+
}, h = (w, g, m) => {
|
|
657
|
+
const M = `${w}:${g}:${m}`, b = c.get(M);
|
|
658
|
+
if (b) return b;
|
|
659
|
+
const S = e.textures?.[w];
|
|
660
|
+
if (!S || S.source === void 0)
|
|
661
|
+
throw new Error(`Decoded glTF references missing texture ${w}.`);
|
|
662
|
+
const A = s[S.source];
|
|
663
|
+
if (!A) throw new Error(`Decoded glTF references missing image ${S.source}.`);
|
|
664
|
+
const v = S.sampler === void 0 ? void 0 : e.samplers?.[S.sampler], E = new $t(A);
|
|
665
|
+
return E.name = S.name ?? e.images?.[S.source]?.name ?? "", E.flipY = !1, E.colorSpace = g, E.channel = m, E.magFilter = v?.magFilter === 9728 ? Ee : Ve, E.minFilter = (() => {
|
|
666
|
+
switch (v?.minFilter) {
|
|
667
|
+
case 9728:
|
|
668
|
+
return Ee;
|
|
669
|
+
case 9729:
|
|
670
|
+
return Ve;
|
|
671
|
+
case 9984:
|
|
672
|
+
return Cs;
|
|
673
|
+
case 9985:
|
|
674
|
+
return Es;
|
|
675
|
+
case 9986:
|
|
676
|
+
return Is;
|
|
677
|
+
default:
|
|
678
|
+
return Ss;
|
|
679
|
+
}
|
|
680
|
+
})(), E.wrapS = (() => {
|
|
681
|
+
switch (v?.wrapS) {
|
|
682
|
+
case 33071:
|
|
683
|
+
return Ye;
|
|
684
|
+
case 33648:
|
|
685
|
+
return Xe;
|
|
686
|
+
default:
|
|
687
|
+
return Ie;
|
|
688
|
+
}
|
|
689
|
+
})(), E.wrapT = (() => {
|
|
690
|
+
switch (v?.wrapT) {
|
|
691
|
+
case 33071:
|
|
692
|
+
return Ye;
|
|
693
|
+
case 33648:
|
|
694
|
+
return Xe;
|
|
695
|
+
default:
|
|
696
|
+
return Ie;
|
|
697
|
+
}
|
|
698
|
+
})(), E.needsUpdate = !0, c.set(M, E), E;
|
|
699
|
+
}, d = (w, g, m, M) => {
|
|
700
|
+
m && (w[g] = h(m.index, M, m.texCoord ?? 0));
|
|
701
|
+
}, u = (w, g, m, M) => {
|
|
702
|
+
const b = [
|
|
703
|
+
w ?? "default",
|
|
704
|
+
g ? "derivative-tangents" : "",
|
|
705
|
+
m ? "vertex-colors" : "",
|
|
706
|
+
M ? "flat-shading" : ""
|
|
707
|
+
].join(":"), S = o.get(b);
|
|
708
|
+
if (S) return S;
|
|
709
|
+
const A = w === void 0 ? void 0 : e.materials?.[w];
|
|
710
|
+
if (w !== void 0 && !A)
|
|
711
|
+
throw new Error(`Decoded glTF references missing material ${w}.`);
|
|
712
|
+
const v = A ?? {}, E = v.pbrMetallicRoughness ?? {}, z = E.baseColorFactor ?? [1, 1, 1, 1], N = v.alphaMode ?? "OPAQUE", f = new Ms({
|
|
713
|
+
color: new P().setRGB(
|
|
714
|
+
z[0] ?? 1,
|
|
715
|
+
z[1] ?? 1,
|
|
716
|
+
z[2] ?? 1,
|
|
717
|
+
qe
|
|
718
|
+
),
|
|
719
|
+
opacity: z[3] ?? 1,
|
|
720
|
+
metalness: E.metallicFactor ?? 1,
|
|
721
|
+
roughness: E.roughnessFactor ?? 1,
|
|
722
|
+
transparent: N === "BLEND",
|
|
723
|
+
depthWrite: N !== "BLEND",
|
|
724
|
+
alphaTest: N === "MASK" ? v.alphaCutoff ?? 0.5 : 0
|
|
725
|
+
});
|
|
726
|
+
return v.doubleSided && (f.side = Ht), f.vertexColors = m, f.flatShading = M, f.name = v.name ?? "", d(f, "map", E.baseColorTexture, Se), d(f, "metalnessMap", E.metallicRoughnessTexture, fe), d(f, "roughnessMap", E.metallicRoughnessTexture, fe), d(f, "normalMap", v.normalTexture, fe), d(f, "aoMap", v.occlusionTexture, fe), d(f, "emissiveMap", v.emissiveTexture, Se), v.normalTexture?.scale !== void 0 && (f.normalScale = new j(
|
|
727
|
+
v.normalTexture.scale,
|
|
728
|
+
v.normalTexture.scale
|
|
729
|
+
)), g && (f.normalScale.y *= -1), v.occlusionTexture?.strength !== void 0 && (f.aoMapIntensity = v.occlusionTexture.strength), v.emissiveFactor && f.emissive.setRGB(
|
|
730
|
+
v.emissiveFactor[0] ?? 0,
|
|
731
|
+
v.emissiveFactor[1] ?? 0,
|
|
732
|
+
v.emissiveFactor[2] ?? 0,
|
|
733
|
+
qe
|
|
734
|
+
), oe(f, v.extras), o.set(b, f), f;
|
|
735
|
+
}, p = (w, g) => {
|
|
736
|
+
const m = `${w}:${g}`, M = a.get(m);
|
|
737
|
+
if (M) return M;
|
|
738
|
+
const b = e.meshes?.[w]?.primitives[g];
|
|
739
|
+
if (!b) throw new Error(`Decoded glTF references missing primitive ${m}.`);
|
|
740
|
+
const S = new G();
|
|
741
|
+
for (const [A, v] of Object.entries(b.attributes)) {
|
|
742
|
+
const E = zn[A] ?? A.toLowerCase();
|
|
743
|
+
S.setAttribute(E, l(v));
|
|
744
|
+
}
|
|
745
|
+
if (b.indices !== void 0) {
|
|
746
|
+
const A = l(b.indices);
|
|
747
|
+
if (A instanceof Ke)
|
|
748
|
+
throw new Error(`Decoded glTF index accessor ${b.indices} cannot be interleaved.`);
|
|
749
|
+
S.setIndex(A);
|
|
750
|
+
}
|
|
751
|
+
return a.set(m, S), S;
|
|
752
|
+
}, x = (w) => {
|
|
753
|
+
const g = e.meshes?.[w];
|
|
754
|
+
if (!g) throw new Error(`Decoded glTF references missing mesh ${w}.`);
|
|
755
|
+
const m = g.primitives.map((b, S) => {
|
|
756
|
+
const A = new k(
|
|
757
|
+
p(w, S),
|
|
758
|
+
u(
|
|
759
|
+
b.material,
|
|
760
|
+
b.attributes.TANGENT === void 0,
|
|
761
|
+
b.attributes.COLOR_0 !== void 0,
|
|
762
|
+
b.attributes.NORMAL === void 0
|
|
763
|
+
)
|
|
764
|
+
);
|
|
765
|
+
return A.name = g.name ?? "", A;
|
|
766
|
+
});
|
|
767
|
+
if (m.length === 1)
|
|
768
|
+
return oe(m[0], g.extras), m[0];
|
|
769
|
+
const M = new W();
|
|
770
|
+
return M.name = g.name ?? "", M.add(...m), oe(M, g.extras), M;
|
|
771
|
+
}, I = (w) => {
|
|
772
|
+
const g = e.nodes?.[w];
|
|
773
|
+
if (!g) throw new Error(`Decoded glTF references missing node ${w}.`);
|
|
774
|
+
const m = g.mesh === void 0 ? new W() : x(g.mesh);
|
|
775
|
+
m.name = g.name ?? m.name, g.matrix ? new R().fromArray(g.matrix).decompose(m.position, m.quaternion, m.scale) : (g.translation && m.position.fromArray(g.translation), g.rotation && m.quaternion.fromArray(g.rotation), g.scale && m.scale.fromArray(g.scale)), oe(m, g.extras);
|
|
776
|
+
for (const M of g.children ?? [])
|
|
777
|
+
m.add(I(M));
|
|
778
|
+
return m;
|
|
779
|
+
}, _ = e.scene ?? 0, C = e.scenes?.[_];
|
|
780
|
+
if (!C) throw new Error(`Decoded glTF references missing scene ${_}.`);
|
|
781
|
+
const y = new W();
|
|
782
|
+
y.name = C.name ?? "", oe(y, C.extras);
|
|
783
|
+
for (const w of C.nodes ?? []) y.add(I(w));
|
|
784
|
+
return y.animations = [], y;
|
|
785
|
+
}
|
|
786
|
+
const jn = 256;
|
|
787
|
+
function Wn(i) {
|
|
788
|
+
return i instanceof Error ? { message: i.message, name: i.name, stack: i.stack } : { message: String(i) };
|
|
789
|
+
}
|
|
790
|
+
function Fn(i) {
|
|
791
|
+
const e = new Error(i.message);
|
|
792
|
+
return e.name = i.name ?? "Error", e.stack = i.stack, e;
|
|
793
|
+
}
|
|
794
|
+
class ve extends Error {
|
|
795
|
+
name = "ModelDecodeWorkerUnavailableError";
|
|
796
|
+
constructor(e, t) {
|
|
797
|
+
super(e, t);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
function Hn(i, e, t = jn) {
|
|
801
|
+
if (i.images.length !== i.imageKeys.length)
|
|
802
|
+
throw new Error("Decoded model image identities do not match its image payload.");
|
|
803
|
+
const s = [];
|
|
804
|
+
for (let n = 0; n < i.images.length; n++) {
|
|
805
|
+
const r = i.imageKeys[n], a = i.images[n], o = e.get(r);
|
|
806
|
+
if (o)
|
|
807
|
+
e.delete(r), e.set(r, o), o !== a && a.close(), i.images[n] = o;
|
|
808
|
+
else
|
|
809
|
+
for (e.set(r, a), s.push(r); e.size > Math.max(0, t); ) {
|
|
810
|
+
const c = e.keys().next().value;
|
|
811
|
+
if (c === void 0) break;
|
|
812
|
+
e.delete(c);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return s;
|
|
816
|
+
}
|
|
817
|
+
class $n {
|
|
818
|
+
worker;
|
|
819
|
+
#s;
|
|
820
|
+
#a = 1;
|
|
821
|
+
#t = /* @__PURE__ */ new Map();
|
|
822
|
+
#e = /* @__PURE__ */ new Map();
|
|
823
|
+
#r = !1;
|
|
824
|
+
constructor(e, t = {}) {
|
|
825
|
+
this.worker = e, this.#s = t.onFatal, e.addEventListener("message", this.#o), e.addEventListener("error", this.#l), e.addEventListener("messageerror", this.#d);
|
|
826
|
+
}
|
|
827
|
+
get disposed() {
|
|
828
|
+
return this.#r;
|
|
829
|
+
}
|
|
830
|
+
supports(e) {
|
|
831
|
+
const t = e.split(/[?#]/, 1)[0].split(".").pop()?.toLowerCase();
|
|
832
|
+
return t === "sbmx" || t === "gltf" || t === "glb";
|
|
833
|
+
}
|
|
834
|
+
async loadAsync(e, t = {}) {
|
|
835
|
+
if (this.#r)
|
|
836
|
+
throw new ve("Model decode Worker is unavailable.");
|
|
837
|
+
const s = this.#a++, { signal: n, loadingManager: r, ...a } = t;
|
|
838
|
+
if (n?.aborted) throw n.reason ?? new DOMException("Aborted", "AbortError");
|
|
839
|
+
const o = await new Promise((l, h) => {
|
|
840
|
+
const d = {
|
|
841
|
+
resolve: l,
|
|
842
|
+
reject: h,
|
|
843
|
+
manager: r,
|
|
844
|
+
rootUrl: e,
|
|
845
|
+
resources: /* @__PURE__ */ new Map()
|
|
846
|
+
};
|
|
847
|
+
if (r?.itemStart(e), n) {
|
|
848
|
+
const u = () => {
|
|
849
|
+
this.#t.delete(s), this.#h(d, n.reason ?? new DOMException("Aborted", "AbortError")), h(n.reason ?? new DOMException("Aborted", "AbortError"));
|
|
850
|
+
try {
|
|
851
|
+
this.#n({ type: "cancel", id: s });
|
|
852
|
+
} catch {
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
d.cleanup = () => n.removeEventListener("abort", u), n.addEventListener("abort", u, { once: !0 });
|
|
856
|
+
}
|
|
857
|
+
this.#t.set(s, d);
|
|
858
|
+
try {
|
|
859
|
+
this.#n({ type: "decode", id: s, url: e, options: a });
|
|
860
|
+
} catch (u) {
|
|
861
|
+
this.#t.delete(s), d.cleanup?.();
|
|
862
|
+
const p = u instanceof Error ? u : new Error(String(u));
|
|
863
|
+
this.#h(d, p), h(p);
|
|
864
|
+
}
|
|
865
|
+
}), c = [];
|
|
866
|
+
try {
|
|
867
|
+
return c.push(...Hn(o, this.#e)), Un(o);
|
|
868
|
+
} catch (l) {
|
|
869
|
+
const h = /* @__PURE__ */ new Set();
|
|
870
|
+
for (const d of c) {
|
|
871
|
+
const u = o.imageKeys.indexOf(d), p = this.#e.get(d) ?? o.images[u];
|
|
872
|
+
this.#e.get(d) === p && this.#e.delete(d), p && !h.has(p) && (p.close(), h.add(p));
|
|
873
|
+
}
|
|
874
|
+
throw l;
|
|
875
|
+
} finally {
|
|
876
|
+
try {
|
|
877
|
+
this.#n({ type: "ack", id: s });
|
|
878
|
+
} catch {
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
dispose() {
|
|
883
|
+
if (!this.#r) {
|
|
884
|
+
this.#r = !0;
|
|
885
|
+
try {
|
|
886
|
+
this.#n({ type: "dispose" });
|
|
887
|
+
} catch {
|
|
888
|
+
}
|
|
889
|
+
this.#i(), this.worker.terminate(), this.#p(new ve("Model decode Worker was disposed.")), this.#e.clear();
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
#n(e) {
|
|
893
|
+
this.worker.postMessage(e);
|
|
894
|
+
}
|
|
895
|
+
#o = (e) => {
|
|
896
|
+
const t = e.data;
|
|
897
|
+
if (t.type === "disposed") return;
|
|
898
|
+
if (t.type === "resolve-resource") {
|
|
899
|
+
this.#c(t.id, t.resourceId, t.url);
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
if (t.type === "resource-complete") {
|
|
903
|
+
const n = this.#t.get(t.id), r = n?.resources.get(t.resourceId);
|
|
904
|
+
n && r !== void 0 && (n.resources.delete(t.resourceId), t.ok || n.manager?.itemError(r), n.manager?.itemEnd(r));
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
const s = this.#t.get(t.id);
|
|
908
|
+
if (!s) {
|
|
909
|
+
if (t.type === "decoded") {
|
|
910
|
+
t.packet.images.forEach((n) => n.close());
|
|
911
|
+
try {
|
|
912
|
+
this.#n({ type: "ack", id: t.id });
|
|
913
|
+
} catch {
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
if (this.#t.delete(t.id), s.cleanup?.(), t.type === "decoded")
|
|
919
|
+
this.#h(s), s.resolve(t.packet);
|
|
920
|
+
else if (t.type === "unsupported")
|
|
921
|
+
this.#h(s, void 0, !1), s.reject(new Kt(t.reason));
|
|
922
|
+
else {
|
|
923
|
+
const n = Fn(t.error);
|
|
924
|
+
this.#h(s, n), s.reject(n);
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
#c(e, t, s) {
|
|
928
|
+
const n = this.#t.get(e);
|
|
929
|
+
if (!n) {
|
|
930
|
+
try {
|
|
931
|
+
this.#n({
|
|
932
|
+
type: "resource-resolved",
|
|
933
|
+
id: e,
|
|
934
|
+
resourceId: t,
|
|
935
|
+
error: { message: "The model decode request is no longer active.", name: "AbortError" }
|
|
936
|
+
});
|
|
937
|
+
} catch {
|
|
938
|
+
}
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
let r;
|
|
942
|
+
try {
|
|
943
|
+
r = n.manager?.resolveURL(s) ?? s, n.manager?.itemStart(r), n.manager && n.resources.set(t, r), this.#n({ type: "resource-resolved", id: e, resourceId: t, url: r });
|
|
944
|
+
} catch (a) {
|
|
945
|
+
r !== void 0 && n.resources.delete(t) && (n.manager?.itemError(r), n.manager?.itemEnd(r));
|
|
946
|
+
try {
|
|
947
|
+
this.#n({ type: "resource-resolved", id: e, resourceId: t, error: Wn(a) });
|
|
948
|
+
} catch (o) {
|
|
949
|
+
this.#u(o instanceof Error ? o : new Error(String(o)));
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
#l = (e) => {
|
|
954
|
+
this.#u(e.error instanceof Error ? e.error : new Error(e.message));
|
|
955
|
+
};
|
|
956
|
+
#d = () => {
|
|
957
|
+
this.#u(new Error("Failed to deserialize a model decode Worker response."));
|
|
958
|
+
};
|
|
959
|
+
#u(e) {
|
|
960
|
+
if (this.#r) return;
|
|
961
|
+
this.#r = !0, this.#i(), this.worker.terminate();
|
|
962
|
+
const t = new ve(
|
|
963
|
+
`Model decode Worker failed: ${e.message}`,
|
|
964
|
+
{ cause: e }
|
|
965
|
+
);
|
|
966
|
+
this.#p(t), this.#e.clear(), this.#s?.(t);
|
|
967
|
+
}
|
|
968
|
+
#i() {
|
|
969
|
+
this.worker.removeEventListener("message", this.#o), this.worker.removeEventListener("error", this.#l), this.worker.removeEventListener("messageerror", this.#d);
|
|
970
|
+
}
|
|
971
|
+
#h(e, t, s = t !== void 0) {
|
|
972
|
+
for (const n of e.resources.values())
|
|
973
|
+
t && e.manager?.itemError(n), e.manager?.itemEnd(n);
|
|
974
|
+
e.resources.clear(), s && e.manager?.itemError(e.rootUrl), e.manager?.itemEnd(e.rootUrl);
|
|
975
|
+
}
|
|
976
|
+
#p(e) {
|
|
977
|
+
for (const t of this.#t.values())
|
|
978
|
+
t.cleanup?.(), this.#h(t, e), t.reject(e);
|
|
979
|
+
this.#t.clear();
|
|
1513
980
|
}
|
|
1514
981
|
}
|
|
1515
|
-
const
|
|
982
|
+
const Gn = [
|
|
1516
983
|
"map",
|
|
1517
984
|
"alphaMap",
|
|
1518
985
|
"aoMap",
|
|
@@ -1539,36 +1006,59 @@ const Ys = [
|
|
|
1539
1006
|
"thicknessMap",
|
|
1540
1007
|
"transmissionMap"
|
|
1541
1008
|
];
|
|
1542
|
-
function
|
|
1543
|
-
return
|
|
1009
|
+
function ce(i) {
|
|
1010
|
+
return i.traverse((e) => {
|
|
1544
1011
|
if (!(e instanceof k)) return;
|
|
1545
1012
|
const t = Array.isArray(e.material) ? e.material : [e.material];
|
|
1546
1013
|
for (const s of t) {
|
|
1547
1014
|
if (!s) continue;
|
|
1548
1015
|
let n = !1;
|
|
1549
|
-
for (const
|
|
1550
|
-
const
|
|
1551
|
-
|
|
1016
|
+
for (const r of Gn) {
|
|
1017
|
+
const a = s[r];
|
|
1018
|
+
a?.isTexture && a.image == null && (a.dispose(), s[r] = null, n = !0);
|
|
1552
1019
|
}
|
|
1553
1020
|
n && (s.needsUpdate = !0);
|
|
1554
1021
|
}
|
|
1555
|
-
}),
|
|
1022
|
+
}), i;
|
|
1556
1023
|
}
|
|
1557
|
-
class
|
|
1024
|
+
class V {
|
|
1558
1025
|
static CACHE_NAME = "u-space-model-loader-cache";
|
|
1559
|
-
static fileLoader = new
|
|
1560
|
-
static dracoLoader = new
|
|
1561
|
-
`https://cdn.jsdelivr.net/npm/three@0.${
|
|
1026
|
+
static fileLoader = new Wt().setResponseType("arraybuffer");
|
|
1027
|
+
static dracoLoader = new cn().setDecoderPath(
|
|
1028
|
+
`https://cdn.jsdelivr.net/npm/three@0.${Qe}.0/examples/jsm/libs/draco/`
|
|
1562
1029
|
);
|
|
1563
|
-
static ktx2Loader = new
|
|
1564
|
-
`https://cdn.jsdelivr.net/npm/three@0.${
|
|
1030
|
+
static ktx2Loader = new ln().setTranscoderPath(
|
|
1031
|
+
`https://cdn.jsdelivr.net/npm/three@0.${Qe}.0/examples/jsm/libs/basis/`
|
|
1565
1032
|
);
|
|
1566
|
-
static gltfLoader = new
|
|
1567
|
-
static sbmxLoader = new
|
|
1568
|
-
static sbmLoader = new
|
|
1569
|
-
static fbxLoader = new
|
|
1570
|
-
static objLoader = new
|
|
1571
|
-
static stlLoader = new
|
|
1033
|
+
static gltfLoader = new Re().setDRACOLoader(V.dracoLoader).setKTX2Loader(V.ktx2Loader).setMeshoptDecoder(Le);
|
|
1034
|
+
static sbmxLoader = new at().setDRACOLoader(V.dracoLoader).setKTX2Loader(V.ktx2Loader).setMeshoptDecoder(Le);
|
|
1035
|
+
static sbmLoader = new ct();
|
|
1036
|
+
static fbxLoader = new Ze();
|
|
1037
|
+
static objLoader = new an();
|
|
1038
|
+
static stlLoader = new on();
|
|
1039
|
+
static decodeWorkerClient = null;
|
|
1040
|
+
/**
|
|
1041
|
+
* Routes supported static glTF/GLB/SBMX models through a dedicated decoder
|
|
1042
|
+
* Worker. ModelLoaderManager owns the supplied Worker and terminates it when
|
|
1043
|
+
* replaced or cleared. The returned disposer only clears this specific
|
|
1044
|
+
* Worker, so a late owner cleanup cannot terminate a newer replacement.
|
|
1045
|
+
*/
|
|
1046
|
+
static setDecodeWorker(e) {
|
|
1047
|
+
const t = this.decodeWorkerClient;
|
|
1048
|
+
if (this.decodeWorkerClient = null, t?.dispose(), !e) return () => {
|
|
1049
|
+
};
|
|
1050
|
+
let s;
|
|
1051
|
+
return s = new $n(e, {
|
|
1052
|
+
onFatal: () => {
|
|
1053
|
+
this.decodeWorkerClient === s && (this.decodeWorkerClient = null);
|
|
1054
|
+
}
|
|
1055
|
+
}), this.decodeWorkerClient = s, () => {
|
|
1056
|
+
this.decodeWorkerClient === s && (this.decodeWorkerClient = null, s.dispose());
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
static get decodeWorkerEnabled() {
|
|
1060
|
+
return this.decodeWorkerClient !== null && !this.decodeWorkerClient.disposed;
|
|
1061
|
+
}
|
|
1572
1062
|
static setLoadingManager(e) {
|
|
1573
1063
|
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;
|
|
1574
1064
|
}
|
|
@@ -1591,48 +1081,124 @@ class D {
|
|
|
1591
1081
|
this.ktx2Loader.setTranscoderPath(e);
|
|
1592
1082
|
}
|
|
1593
1083
|
static async loadAsync(e, t = { persistent: !0 }) {
|
|
1594
|
-
const s = e.split(".").pop()?.
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
return
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1084
|
+
const s = e.split(/[?#]/, 1)[0].split(".").pop()?.toLowerCase(), n = t.persistent ?? !0, r = t.signal;
|
|
1085
|
+
this.throwIfAborted(r);
|
|
1086
|
+
const a = this.decodeWorkerClient;
|
|
1087
|
+
if (a?.supports(e)) {
|
|
1088
|
+
const h = this.fileLoader.manager.resolveURL(e), d = typeof location > "u" ? e : new URL(e, location.href).href, u = typeof location > "u" ? h : new URL(h, location.href).href;
|
|
1089
|
+
try {
|
|
1090
|
+
return await a.loadAsync(u, {
|
|
1091
|
+
persistent: n,
|
|
1092
|
+
headers: this.fileLoader.requestHeader,
|
|
1093
|
+
credentials: this.fileLoader.withCredentials ? "include" : "same-origin",
|
|
1094
|
+
resourceBaseUrl: d,
|
|
1095
|
+
signal: r,
|
|
1096
|
+
loadingManager: this.fileLoader.manager
|
|
1097
|
+
});
|
|
1098
|
+
} catch (p) {
|
|
1099
|
+
if (this.throwIfAborted(r), !(p instanceof Kt) && !(p instanceof ve)) throw p;
|
|
1100
|
+
console.info(`[ModelLoaderManager] Decode Worker fallback for ${e}: ${p.message}`);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
const o = await this.loadSourceBuffer(e, n, r);
|
|
1104
|
+
this.throwIfAborted(r);
|
|
1105
|
+
const c = he.extractUrlBase(e), l = this.createParseLoadingManager(r);
|
|
1106
|
+
try {
|
|
1107
|
+
switch (s) {
|
|
1108
|
+
case "gltf":
|
|
1109
|
+
case "glb": {
|
|
1110
|
+
const d = await this.configureGltfLoader(new Re(l.manager)).parseAsync(o, c);
|
|
1111
|
+
return this.throwIfAborted(r), d.scene.animations = d.animations, ce(d.scene);
|
|
1112
|
+
}
|
|
1113
|
+
case "sbmx": {
|
|
1114
|
+
const d = await this.configureGltfLoader(new at(l.manager)).parseAsync(o, c);
|
|
1115
|
+
return this.throwIfAborted(r), d.scene.animations = d.animations, ce(d.scene);
|
|
1116
|
+
}
|
|
1117
|
+
case "sbm": {
|
|
1118
|
+
const d = await new ct(l.manager).setCrossOrigin(this.sbmLoader.crossOrigin).setRequestHeader(this.sbmLoader.requestHeader).setWithCredentials(this.sbmLoader.withCredentials).parseAsync(o, c);
|
|
1119
|
+
return this.throwIfAborted(r), ce(d);
|
|
1120
|
+
}
|
|
1121
|
+
case "fbx": {
|
|
1122
|
+
const d = new Ze(l.manager).setCrossOrigin(this.fbxLoader.crossOrigin).setRequestHeader(this.fbxLoader.requestHeader).setWithCredentials(this.fbxLoader.withCredentials).parse(o, c);
|
|
1123
|
+
return this.throwIfAborted(r), ce(d);
|
|
1124
|
+
}
|
|
1125
|
+
case "obj": {
|
|
1126
|
+
const h = new TextDecoder().decode(o), d = this.objLoader.parse(h);
|
|
1127
|
+
return this.throwIfAborted(r), ce(d);
|
|
1128
|
+
}
|
|
1129
|
+
case "stl": {
|
|
1130
|
+
const h = this.stlLoader.parse(o);
|
|
1131
|
+
return this.throwIfAborted(r), new k(h, new q());
|
|
1132
|
+
}
|
|
1133
|
+
default:
|
|
1134
|
+
throw new Error(`Unsupported model format: ${s}`);
|
|
1135
|
+
}
|
|
1136
|
+
} finally {
|
|
1137
|
+
l.cleanup();
|
|
1618
1138
|
}
|
|
1619
1139
|
}
|
|
1620
|
-
static
|
|
1140
|
+
static configureGltfLoader(e) {
|
|
1141
|
+
return e.setDRACOLoader(this.dracoLoader).setKTX2Loader(this.ktx2Loader).setMeshoptDecoder(Le).setCrossOrigin(this.gltfLoader.crossOrigin).setRequestHeader(this.gltfLoader.requestHeader).setWithCredentials(this.gltfLoader.withCredentials), e;
|
|
1142
|
+
}
|
|
1143
|
+
static createParseLoadingManager(e) {
|
|
1144
|
+
this.throwIfAborted(e);
|
|
1145
|
+
const t = this.fileLoader.manager, s = new As();
|
|
1146
|
+
s.setURLModifier((r) => t.resolveURL(r)), s.itemStart = (r) => t.itemStart(r), s.itemEnd = (r) => t.itemEnd(r), s.itemError = (r) => t.itemError(r);
|
|
1147
|
+
const n = () => s.abort();
|
|
1148
|
+
return e?.addEventListener("abort", n, { once: !0 }), {
|
|
1149
|
+
manager: s,
|
|
1150
|
+
cleanup: () => e?.removeEventListener("abort", n)
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
static async loadSourceBuffer(e, t, s) {
|
|
1154
|
+
this.throwIfAborted(s);
|
|
1155
|
+
const n = this.fileLoader.manager, r = n.resolveURL(e);
|
|
1156
|
+
n.itemStart(r);
|
|
1621
1157
|
try {
|
|
1622
|
-
|
|
1623
|
-
if (
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1158
|
+
let a;
|
|
1159
|
+
if (t && typeof caches < "u")
|
|
1160
|
+
try {
|
|
1161
|
+
a = await caches.open(this.CACHE_NAME);
|
|
1162
|
+
const d = await a.match(r);
|
|
1163
|
+
if (this.throwIfAborted(s), d) {
|
|
1164
|
+
const u = await d.arrayBuffer();
|
|
1165
|
+
return this.throwIfAborted(s), u;
|
|
1166
|
+
}
|
|
1167
|
+
} catch (d) {
|
|
1168
|
+
this.throwIfAborted(s), console.warn(`[ModelLoaderManager] Failed to read Cache Storage for ${r}:`, d);
|
|
1169
|
+
}
|
|
1170
|
+
const o = n.abortController.signal, c = s && typeof AbortSignal.any == "function" ? AbortSignal.any([s, o]) : s ?? o, l = await fetch(r, {
|
|
1171
|
+
headers: this.fileLoader.requestHeader,
|
|
1172
|
+
credentials: this.fileLoader.withCredentials ? "include" : "same-origin",
|
|
1173
|
+
signal: c
|
|
1174
|
+
});
|
|
1175
|
+
if (!l.ok)
|
|
1176
|
+
throw new Error(
|
|
1177
|
+
`Failed to load model ${r}: ${l.status} ${l.statusText}`
|
|
1178
|
+
);
|
|
1179
|
+
const h = await l.arrayBuffer();
|
|
1180
|
+
if (this.throwIfAborted(s), a)
|
|
1181
|
+
try {
|
|
1182
|
+
await a.put(r, new Response(h.slice(0)));
|
|
1183
|
+
} catch (d) {
|
|
1184
|
+
this.throwIfAborted(s), console.warn(`[ModelLoaderManager] Failed to write Cache Storage for ${r}:`, d);
|
|
1185
|
+
}
|
|
1186
|
+
return h;
|
|
1187
|
+
} catch (a) {
|
|
1188
|
+
throw n.itemError(r), a;
|
|
1189
|
+
} finally {
|
|
1190
|
+
n.itemEnd(r);
|
|
1629
1191
|
}
|
|
1630
1192
|
}
|
|
1193
|
+
static throwIfAborted(e) {
|
|
1194
|
+
if (e?.aborted)
|
|
1195
|
+
throw e.reason ?? new DOMException("Aborted", "AbortError");
|
|
1196
|
+
}
|
|
1631
1197
|
}
|
|
1632
|
-
class
|
|
1633
|
-
static textureLoader = new
|
|
1634
|
-
static hdrLoader = new
|
|
1635
|
-
static cubeTextureLoader = new
|
|
1198
|
+
class ii {
|
|
1199
|
+
static textureLoader = new Ft();
|
|
1200
|
+
static hdrLoader = new dn();
|
|
1201
|
+
static cubeTextureLoader = new Os();
|
|
1636
1202
|
static setLoadingManager(e) {
|
|
1637
1203
|
this.textureLoader.manager = e, this.hdrLoader.manager = e, this.cubeTextureLoader.manager = e;
|
|
1638
1204
|
}
|
|
@@ -1641,13 +1207,13 @@ class Bn {
|
|
|
1641
1207
|
}
|
|
1642
1208
|
static async loadAsyncHDR(e) {
|
|
1643
1209
|
const t = await this.hdrLoader.loadAsync(e);
|
|
1644
|
-
return t.mapping =
|
|
1210
|
+
return t.mapping = Bs, t;
|
|
1645
1211
|
}
|
|
1646
1212
|
static async loadAsyncCubeTexture(e, t) {
|
|
1647
1213
|
return this.cubeTextureLoader.setPath(e), await this.cubeTextureLoader.loadAsync(t);
|
|
1648
1214
|
}
|
|
1649
1215
|
}
|
|
1650
|
-
class
|
|
1216
|
+
class X extends k {
|
|
1651
1217
|
isBaseMesh = !0;
|
|
1652
1218
|
type = "BaseMesh";
|
|
1653
1219
|
castShadow = !0;
|
|
@@ -1660,7 +1226,7 @@ class G extends k {
|
|
|
1660
1226
|
return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
|
|
1661
1227
|
}
|
|
1662
1228
|
}
|
|
1663
|
-
class
|
|
1229
|
+
class pe extends W {
|
|
1664
1230
|
isBaseGroup = !0;
|
|
1665
1231
|
type = "BaseGroup";
|
|
1666
1232
|
ignoreInvisibleWhenRaycast = !0;
|
|
@@ -1671,7 +1237,7 @@ class Ye extends I {
|
|
|
1671
1237
|
return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
|
|
1672
1238
|
}
|
|
1673
1239
|
}
|
|
1674
|
-
class
|
|
1240
|
+
class Kn extends _s {
|
|
1675
1241
|
isBaseSprite = !0;
|
|
1676
1242
|
type = "BaseSprite";
|
|
1677
1243
|
ignoreInvisibleWhenRaycast = !0;
|
|
@@ -1682,7 +1248,7 @@ class Vs extends Bt {
|
|
|
1682
1248
|
return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
|
|
1683
1249
|
}
|
|
1684
1250
|
}
|
|
1685
|
-
class
|
|
1251
|
+
class te extends pe {
|
|
1686
1252
|
isModel = !0;
|
|
1687
1253
|
type = "Model";
|
|
1688
1254
|
static memoryCache = /* @__PURE__ */ new Map();
|
|
@@ -1693,24 +1259,34 @@ class he extends Ye {
|
|
|
1693
1259
|
super();
|
|
1694
1260
|
}
|
|
1695
1261
|
async loadAsync(e) {
|
|
1696
|
-
const { url: t, cache: s = !0, persistent: n = !0 } = e;
|
|
1262
|
+
const { url: t, cache: s = !0, persistent: n = !0, signal: r } = e;
|
|
1697
1263
|
try {
|
|
1698
|
-
let
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1264
|
+
let a;
|
|
1265
|
+
if (s && !r)
|
|
1266
|
+
if (te.memoryCache.has(t))
|
|
1267
|
+
a = te.memoryCache.get(t);
|
|
1268
|
+
else {
|
|
1269
|
+
const h = V.loadAsync(t, { persistent: n, signal: r }).catch((d) => {
|
|
1270
|
+
throw te.memoryCache.get(t) === h && te.memoryCache.delete(t), d;
|
|
1271
|
+
});
|
|
1272
|
+
te.memoryCache.set(t, h), a = h;
|
|
1273
|
+
}
|
|
1274
|
+
else
|
|
1275
|
+
a = V.loadAsync(t, { persistent: n, signal: r });
|
|
1276
|
+
const o = await a, c = We(o);
|
|
1277
|
+
return this.add(c), c.animations && c.animations.length > 0 && (this.animations = c.animations, this.mixer = new Ts(c)), c;
|
|
1278
|
+
} catch (a) {
|
|
1279
|
+
return console.error(`[Model] Failed to load model from ${t}:`, a), null;
|
|
1704
1280
|
}
|
|
1705
1281
|
}
|
|
1706
1282
|
playAnimation(e, t = {}) {
|
|
1707
1283
|
if (!this.mixer || this.animations.length === 0) return null;
|
|
1708
|
-
const { loop: s = !0, repetitions: n = 1 / 0, timeScale:
|
|
1284
|
+
const { loop: s = !0, repetitions: n = 1 / 0, timeScale: r = 1, clampWhenFinished: a = !1 } = t;
|
|
1709
1285
|
let o;
|
|
1710
|
-
if (e === void 0 ? o = this.animations[0] : typeof e == "number" ? o = this.animations[e] : o = this.animations.find((
|
|
1286
|
+
if (e === void 0 ? o = this.animations[0] : typeof e == "number" ? o = this.animations[e] : o = this.animations.find((l) => l.name === e), !o)
|
|
1711
1287
|
return console.warn(`[Model] Animation not found: ${e}`), null;
|
|
1712
|
-
let
|
|
1713
|
-
return
|
|
1288
|
+
let c = this.actions.get(o.name);
|
|
1289
|
+
return c || (c = this.mixer.clipAction(o), this.actions.set(o.name, c)), c.setLoop(s ? Ls : Ns, n), c.clampWhenFinished = a, c.timeScale = r, c.reset().play(), c;
|
|
1714
1290
|
}
|
|
1715
1291
|
playAllAnimations(e = {}) {
|
|
1716
1292
|
return this.animations.map((t, s) => this.playAnimation(s, e)).filter((t) => t !== null);
|
|
@@ -1731,13 +1307,13 @@ class he extends Ye {
|
|
|
1731
1307
|
* Get the axis-aligned bounding box of this model.
|
|
1732
1308
|
*/
|
|
1733
1309
|
getBoundingBox() {
|
|
1734
|
-
return new
|
|
1310
|
+
return new K().setFromObject(this);
|
|
1735
1311
|
}
|
|
1736
1312
|
/**
|
|
1737
1313
|
* Get the center point of this model's bounding box.
|
|
1738
1314
|
*/
|
|
1739
1315
|
getCenter() {
|
|
1740
|
-
const e = new
|
|
1316
|
+
const e = new D();
|
|
1741
1317
|
return this.getBoundingBox().getCenter(e), e;
|
|
1742
1318
|
}
|
|
1743
1319
|
/**
|
|
@@ -1752,14 +1328,14 @@ class he extends Ye {
|
|
|
1752
1328
|
this.memoryCache.clear();
|
|
1753
1329
|
}
|
|
1754
1330
|
static async clearPersistentCache() {
|
|
1755
|
-
typeof caches < "u" && await caches.delete("u-space-loader-cache");
|
|
1331
|
+
typeof caches < "u" && await caches.delete("u-space-model-loader-cache");
|
|
1756
1332
|
}
|
|
1757
1333
|
}
|
|
1758
|
-
class
|
|
1334
|
+
class qn extends X {
|
|
1759
1335
|
isSphereMesh = !0;
|
|
1760
1336
|
type = "SphereMesh";
|
|
1761
1337
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1762
|
-
super(), this.geometry = new
|
|
1338
|
+
super(), this.geometry = new Ds(
|
|
1763
1339
|
e?.radius,
|
|
1764
1340
|
e?.widthSegments,
|
|
1765
1341
|
e?.heightSegments,
|
|
@@ -1767,23 +1343,23 @@ class Js extends G {
|
|
|
1767
1343
|
e?.phiLength,
|
|
1768
1344
|
e?.thetaStart,
|
|
1769
1345
|
e?.thetaLength
|
|
1770
|
-
), this.material = new
|
|
1346
|
+
), this.material = new q(t);
|
|
1771
1347
|
}
|
|
1772
1348
|
}
|
|
1773
|
-
class
|
|
1349
|
+
class lt extends X {
|
|
1774
1350
|
isTubeMesh = !0;
|
|
1775
1351
|
type = "TubeMesh";
|
|
1776
1352
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1777
|
-
super(), this.geometry = new
|
|
1353
|
+
super(), this.geometry = new Ps(
|
|
1778
1354
|
e?.path,
|
|
1779
1355
|
e?.tubularSegments,
|
|
1780
1356
|
e?.radius,
|
|
1781
1357
|
e?.radialSegments,
|
|
1782
1358
|
e?.closed
|
|
1783
|
-
), this.material = new
|
|
1359
|
+
), this.material = new q(t);
|
|
1784
1360
|
}
|
|
1785
1361
|
}
|
|
1786
|
-
class
|
|
1362
|
+
class ai extends pe {
|
|
1787
1363
|
isTopology = !0;
|
|
1788
1364
|
type = "Topology";
|
|
1789
1365
|
// Visuals
|
|
@@ -1829,12 +1405,12 @@ class Rn extends Ye {
|
|
|
1829
1405
|
* @param bidirectional If true, adds the reverse edge as well. Default true.
|
|
1830
1406
|
*/
|
|
1831
1407
|
addEdge(e, t, s, n = !0) {
|
|
1832
|
-
const
|
|
1833
|
-
if (!
|
|
1408
|
+
const r = this.nodes.get(e), a = this.nodes.get(t);
|
|
1409
|
+
if (!r || !a) {
|
|
1834
1410
|
console.error(`[Topology] Cannot add edge. One or both nodes not found: ${e}, ${t}`);
|
|
1835
1411
|
return;
|
|
1836
1412
|
}
|
|
1837
|
-
const o = s ??
|
|
1413
|
+
const o = s ?? r.distanceTo(a);
|
|
1838
1414
|
this.getNeighbors(e)?.set(t, o), n && this.getNeighbors(t)?.set(e, o);
|
|
1839
1415
|
}
|
|
1840
1416
|
/**
|
|
@@ -1852,42 +1428,42 @@ class Rn extends Ye {
|
|
|
1852
1428
|
getShortestPath(e, t) {
|
|
1853
1429
|
if (!this.nodes.has(e) || !this.nodes.has(t))
|
|
1854
1430
|
return console.warn("[Topology] Start or End node not found."), [];
|
|
1855
|
-
const s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(),
|
|
1856
|
-
for (const [
|
|
1857
|
-
s.set(
|
|
1858
|
-
for (s.set(e, 0);
|
|
1859
|
-
let
|
|
1860
|
-
for (const d of
|
|
1861
|
-
const
|
|
1862
|
-
|
|
1431
|
+
const s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
1432
|
+
for (const [c] of this.nodes)
|
|
1433
|
+
s.set(c, 1 / 0), n.set(c, null), r.add(c);
|
|
1434
|
+
for (s.set(e, 0); r.size > 0; ) {
|
|
1435
|
+
let c = null, l = 1 / 0;
|
|
1436
|
+
for (const d of r) {
|
|
1437
|
+
const u = s.get(d);
|
|
1438
|
+
u < l && (l = u, c = d);
|
|
1863
1439
|
}
|
|
1864
|
-
if (
|
|
1440
|
+
if (c === null || c === t || l === 1 / 0)
|
|
1865
1441
|
break;
|
|
1866
|
-
|
|
1867
|
-
const
|
|
1868
|
-
if (
|
|
1869
|
-
for (const [d,
|
|
1870
|
-
if (!
|
|
1871
|
-
const
|
|
1872
|
-
|
|
1442
|
+
r.delete(c);
|
|
1443
|
+
const h = this.adjacencyMap?.get(c);
|
|
1444
|
+
if (h)
|
|
1445
|
+
for (const [d, u] of h) {
|
|
1446
|
+
if (!r.has(d)) continue;
|
|
1447
|
+
const p = s.get(c) + u;
|
|
1448
|
+
p < s.get(d) && (s.set(d, p), n.set(d, c));
|
|
1873
1449
|
}
|
|
1874
1450
|
}
|
|
1875
|
-
const
|
|
1451
|
+
const a = [];
|
|
1876
1452
|
let o = t;
|
|
1877
1453
|
if (n.get(t) === null && e !== t)
|
|
1878
1454
|
return [];
|
|
1879
1455
|
for (; o !== null; ) {
|
|
1880
|
-
const
|
|
1881
|
-
|
|
1456
|
+
const c = this.nodes.get(o);
|
|
1457
|
+
c && a.unshift(c), o = n.get(o) || null;
|
|
1882
1458
|
}
|
|
1883
|
-
return
|
|
1459
|
+
return a;
|
|
1884
1460
|
}
|
|
1885
1461
|
/**
|
|
1886
1462
|
* Renders the entire topology graph structure using TubeGeometry and Spheres.
|
|
1887
1463
|
*/
|
|
1888
1464
|
renderGraph() {
|
|
1889
|
-
this.clearGraph(), this.graphGroup = new
|
|
1890
|
-
const e = new
|
|
1465
|
+
this.clearGraph(), this.graphGroup = new W();
|
|
1466
|
+
const e = new qn({
|
|
1891
1467
|
geometryParameters: {
|
|
1892
1468
|
radius: this.parameters.nodeRadius,
|
|
1893
1469
|
widthSegments: 16,
|
|
@@ -1898,20 +1474,20 @@ class Rn extends Ye {
|
|
|
1898
1474
|
}
|
|
1899
1475
|
});
|
|
1900
1476
|
this.nodes.forEach((s, n) => {
|
|
1901
|
-
const
|
|
1902
|
-
|
|
1477
|
+
const r = e.clone();
|
|
1478
|
+
r.position.copy(s), Object.assign(r.userData, { id: n, type: "node" }), this.graphGroup.add(r);
|
|
1903
1479
|
});
|
|
1904
1480
|
const t = /* @__PURE__ */ new Set();
|
|
1905
1481
|
this.adjacencyMap.forEach((s, n) => {
|
|
1906
|
-
s.forEach((
|
|
1907
|
-
const o = [n,
|
|
1482
|
+
s.forEach((r, a) => {
|
|
1483
|
+
const o = [n, a].sort().join("-");
|
|
1908
1484
|
if (t.has(o)) return;
|
|
1909
1485
|
t.add(o);
|
|
1910
|
-
const
|
|
1911
|
-
if (
|
|
1912
|
-
const
|
|
1486
|
+
const c = this.nodes.get(n), l = this.nodes.get(a);
|
|
1487
|
+
if (c && l) {
|
|
1488
|
+
const h = new Rs(c, l), d = new lt({
|
|
1913
1489
|
geometryParameters: {
|
|
1914
|
-
path:
|
|
1490
|
+
path: h,
|
|
1915
1491
|
tubularSegments: 1,
|
|
1916
1492
|
radius: this.parameters.edgeRadius,
|
|
1917
1493
|
radialSegments: 8,
|
|
@@ -1921,7 +1497,7 @@ class Rn extends Ye {
|
|
|
1921
1497
|
color: this.parameters.edgeColor
|
|
1922
1498
|
}
|
|
1923
1499
|
});
|
|
1924
|
-
Object.assign(d.userData, { from: n, to:
|
|
1500
|
+
Object.assign(d.userData, { from: n, to: a, weight: r, type: "edge" }), this.graphGroup.add(d);
|
|
1925
1501
|
}
|
|
1926
1502
|
});
|
|
1927
1503
|
}), this.add(this.graphGroup);
|
|
@@ -1936,7 +1512,7 @@ class Rn extends Ye {
|
|
|
1936
1512
|
*/
|
|
1937
1513
|
renderPath(e, t = this.parameters.pathColor) {
|
|
1938
1514
|
if (e.length < 2) return;
|
|
1939
|
-
const s = new
|
|
1515
|
+
const s = new ks(e, !1, "catmullrom", 0), n = new lt({
|
|
1940
1516
|
geometryParameters: {
|
|
1941
1517
|
path: s,
|
|
1942
1518
|
tubularSegments: e.length * 10,
|
|
@@ -1957,14 +1533,14 @@ class Rn extends Ye {
|
|
|
1957
1533
|
/** Export nodes and edges as a JSON-serializable object. */
|
|
1958
1534
|
exportData() {
|
|
1959
1535
|
const e = {};
|
|
1960
|
-
this.nodes.forEach((n,
|
|
1961
|
-
e[
|
|
1536
|
+
this.nodes.forEach((n, r) => {
|
|
1537
|
+
e[r] = { x: n.x, y: n.y, z: n.z };
|
|
1962
1538
|
});
|
|
1963
1539
|
const t = [], s = /* @__PURE__ */ new Set();
|
|
1964
|
-
return this.adjacencyMap.forEach((n,
|
|
1965
|
-
n.forEach((
|
|
1966
|
-
const
|
|
1967
|
-
s.has(
|
|
1540
|
+
return this.adjacencyMap.forEach((n, r) => {
|
|
1541
|
+
n.forEach((a, o) => {
|
|
1542
|
+
const c = [r, o].sort().join("-");
|
|
1543
|
+
s.has(c) || (s.add(c), t.push({ from: r, to: o, weight: a }));
|
|
1968
1544
|
});
|
|
1969
1545
|
}), { nodes: e, edges: t };
|
|
1970
1546
|
}
|
|
@@ -1974,7 +1550,7 @@ class Rn extends Ye {
|
|
|
1974
1550
|
*/
|
|
1975
1551
|
importData(e) {
|
|
1976
1552
|
this.clearGraph(), this.clearPaths(), this.nodes.clear(), this.adjacencyMap.clear(), Object.entries(e.nodes).forEach(([t, s]) => {
|
|
1977
|
-
this.addNode(t, new
|
|
1553
|
+
this.addNode(t, new D(s.x, s.y, s.z));
|
|
1978
1554
|
}), e.edges.forEach(({ from: t, to: s, weight: n }) => {
|
|
1979
1555
|
this.addEdge(t, s, n);
|
|
1980
1556
|
}), this.renderGraph();
|
|
@@ -1986,7 +1562,7 @@ class Rn extends Ye {
|
|
|
1986
1562
|
return this.adjacencyMap.get(e);
|
|
1987
1563
|
}
|
|
1988
1564
|
}
|
|
1989
|
-
class
|
|
1565
|
+
class oi extends Kn {
|
|
1990
1566
|
isPoi = !0;
|
|
1991
1567
|
type = "Poi";
|
|
1992
1568
|
parameters = {
|
|
@@ -2005,7 +1581,7 @@ class In extends Vs {
|
|
|
2005
1581
|
_canvas = document.createElement("canvas");
|
|
2006
1582
|
_lastParametersJSON = "";
|
|
2007
1583
|
constructor(e = {}) {
|
|
2008
|
-
super(new
|
|
1584
|
+
super(new zs()), Object.assign(this.parameters, e), this.updateAsync();
|
|
2009
1585
|
}
|
|
2010
1586
|
/**
|
|
2011
1587
|
* Update the POI with new parameters
|
|
@@ -2019,35 +1595,35 @@ class In extends Vs {
|
|
|
2019
1595
|
const s = this._canvas, n = s.getContext("2d");
|
|
2020
1596
|
if (!n) return;
|
|
2021
1597
|
n.font = `${this.parameters.fontSize}px ${this.parameters.fontFamily}`;
|
|
2022
|
-
let
|
|
2023
|
-
this.parameters.img && (
|
|
2024
|
-
const { text:
|
|
2025
|
-
let y = 0,
|
|
2026
|
-
const
|
|
2027
|
-
if (
|
|
2028
|
-
switch (
|
|
1598
|
+
let r = null;
|
|
1599
|
+
this.parameters.img && (r = await this._loadImage(this.parameters.img));
|
|
1600
|
+
const { text: a, fontSize: o, color: c, iconSize: l, padding: h, backgroundColor: d, borderRadius: u, textPosition: p, scaleFactor: x } = this.parameters, I = n.measureText(a), _ = a ? I.width : 0, C = a ? o : 0;
|
|
1601
|
+
let y = 0, w = 0, g = 0, m = 0, M = 0, b = 0;
|
|
1602
|
+
const S = !!r, A = !!a;
|
|
1603
|
+
if (S && A)
|
|
1604
|
+
switch (p) {
|
|
2029
1605
|
case "top":
|
|
2030
|
-
y = Math.max(
|
|
1606
|
+
y = Math.max(l, _), w = l + h + C, M = (y - _) / 2, b = C / 2, g = (y - l) / 2, m = C + h;
|
|
2031
1607
|
break;
|
|
2032
1608
|
case "bottom":
|
|
2033
|
-
y = Math.max(
|
|
1609
|
+
y = Math.max(l, _), w = l + h + C, g = (y - l) / 2, m = 0, M = (y - _) / 2, b = l + h + C / 2;
|
|
2034
1610
|
break;
|
|
2035
1611
|
case "left":
|
|
2036
|
-
y =
|
|
1612
|
+
y = l + h + _, w = Math.max(l, C), M = 0, b = w / 2, g = _ + h, m = (w - l) / 2;
|
|
2037
1613
|
break;
|
|
2038
1614
|
default:
|
|
2039
|
-
y =
|
|
1615
|
+
y = l + h + _, w = Math.max(l, C), g = 0, m = (w - l) / 2, M = l + h, b = w / 2;
|
|
2040
1616
|
break;
|
|
2041
1617
|
}
|
|
2042
|
-
else
|
|
2043
|
-
const
|
|
2044
|
-
if (s.width =
|
|
2045
|
-
n.fillStyle =
|
|
2046
|
-
const
|
|
2047
|
-
n.textBaseline = "alphabetic", n.fillText(
|
|
1618
|
+
else S ? (y = l, w = l, g = 0, m = 0) : A && (y = _, w = C, M = 0, b = C / 2);
|
|
1619
|
+
const v = y + h * 2, E = w + h * 2;
|
|
1620
|
+
if (s.width = v, s.height = E, n.font = `${o}px ${this.parameters.fontFamily}`, d && (n.fillStyle = d, this._drawRoundedRect(n, 0, 0, v, E, u), n.fill()), S && n.drawImage(r, g + h, m + h, l, l), A) {
|
|
1621
|
+
n.fillStyle = c;
|
|
1622
|
+
const f = n.measureText(a), L = f.actualBoundingBoxAscent + f.actualBoundingBoxDescent, O = f.actualBoundingBoxAscent - L / 2;
|
|
1623
|
+
n.textBaseline = "alphabetic", n.fillText(a, M + h, b + h + O);
|
|
2048
1624
|
}
|
|
2049
|
-
const
|
|
2050
|
-
|
|
1625
|
+
const z = this.material.map, N = new Us(s);
|
|
1626
|
+
N.colorSpace = Se, this.material.map = N, z?.dispose(), this.scale.set(v * x, E * x, 1);
|
|
2051
1627
|
}
|
|
2052
1628
|
_loadImage(e) {
|
|
2053
1629
|
return new Promise((t, s) => {
|
|
@@ -2058,169 +1634,265 @@ class In extends Vs {
|
|
|
2058
1634
|
t(e);
|
|
2059
1635
|
});
|
|
2060
1636
|
}
|
|
2061
|
-
_drawRoundedRect(e, t, s, n,
|
|
2062
|
-
e.beginPath(), e.moveTo(t +
|
|
1637
|
+
_drawRoundedRect(e, t, s, n, r, a) {
|
|
1638
|
+
e.beginPath(), e.moveTo(t + a, s), e.lineTo(t + n - a, s), e.quadraticCurveTo(t + n, s, t + n, s + a), e.lineTo(t + n, s + r - a), e.quadraticCurveTo(t + n, s + r, t + n - a, s + r), e.lineTo(t + a, s + r), e.quadraticCurveTo(t, s + r, t, s + r - a), e.lineTo(t, s + a), e.quadraticCurveTo(t, s, t + a, s), e.closePath();
|
|
2063
1639
|
}
|
|
2064
1640
|
dispose() {
|
|
2065
1641
|
this.material.map?.dispose(), this.material.dispose();
|
|
2066
1642
|
}
|
|
2067
1643
|
}
|
|
2068
|
-
class
|
|
1644
|
+
class Xt extends X {
|
|
2069
1645
|
isShapeMesh = !0;
|
|
2070
1646
|
type = "ShapeMesh";
|
|
2071
1647
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
2072
|
-
super(), this.geometry = new
|
|
1648
|
+
super(), this.geometry = new js(e?.shape, e?.curveSegments), this.material = new q(t), this.geometry.rotateX(-Math.PI / 2);
|
|
2073
1649
|
}
|
|
2074
1650
|
static createFromPoints(e, t = {}) {
|
|
2075
|
-
return new
|
|
1651
|
+
return new Xt({
|
|
2076
1652
|
...t,
|
|
2077
1653
|
geometryParameters: {
|
|
2078
1654
|
...t.geometryParameters,
|
|
2079
|
-
shape: new
|
|
1655
|
+
shape: new Gt(e.map((s) => new j(s.x, -s.z)))
|
|
2080
1656
|
}
|
|
2081
1657
|
});
|
|
2082
1658
|
}
|
|
2083
1659
|
}
|
|
2084
|
-
class
|
|
1660
|
+
class Yt extends X {
|
|
2085
1661
|
isExtrudeMesh = !0;
|
|
2086
1662
|
type = "ExtrudeMesh";
|
|
2087
1663
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
2088
|
-
super(), this.geometry = new
|
|
1664
|
+
super(), this.geometry = new Ws(e?.shape, e?.options), this.material = new q(t), this.geometry.rotateX(-Math.PI / 2);
|
|
2089
1665
|
}
|
|
2090
1666
|
static createFromPoints(e, t = {}) {
|
|
2091
|
-
return e && e.length === 0 && (e = void 0), new
|
|
1667
|
+
return e && e.length === 0 && (e = void 0), new Yt({
|
|
2092
1668
|
...t,
|
|
2093
1669
|
geometryParameters: {
|
|
2094
1670
|
...t.geometryParameters,
|
|
2095
|
-
shape: new
|
|
1671
|
+
shape: new Gt(e?.map((s) => new j(s.x, -s.z)))
|
|
2096
1672
|
}
|
|
2097
1673
|
});
|
|
2098
1674
|
}
|
|
2099
1675
|
}
|
|
2100
|
-
class
|
|
1676
|
+
class ci extends X {
|
|
2101
1677
|
isPlaneMesh = !0;
|
|
2102
1678
|
type = "PlaneMesh";
|
|
2103
1679
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
2104
|
-
super(), this.geometry = new
|
|
1680
|
+
super(), this.geometry = new Fs(
|
|
2105
1681
|
e?.width,
|
|
2106
1682
|
e?.height,
|
|
2107
1683
|
e?.widthSegments,
|
|
2108
1684
|
e?.heightSegments
|
|
2109
|
-
), this.material = new
|
|
1685
|
+
), this.material = new q(t);
|
|
2110
1686
|
}
|
|
2111
1687
|
}
|
|
2112
|
-
class
|
|
1688
|
+
class li extends X {
|
|
2113
1689
|
isCircleMesh = !0;
|
|
2114
1690
|
type = "CircleMesh";
|
|
2115
1691
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
2116
1692
|
super(
|
|
2117
|
-
new
|
|
1693
|
+
new Hs(
|
|
2118
1694
|
e?.radius,
|
|
2119
1695
|
e?.segments,
|
|
2120
1696
|
e?.thetaStart,
|
|
2121
1697
|
e?.thetaLength
|
|
2122
1698
|
),
|
|
2123
|
-
new
|
|
1699
|
+
new q(t)
|
|
2124
1700
|
), this.geometry.rotateX(-Math.PI / 2);
|
|
2125
1701
|
}
|
|
2126
1702
|
}
|
|
2127
|
-
class
|
|
1703
|
+
class Q {
|
|
2128
1704
|
static traverseMeshes(e, t) {
|
|
2129
1705
|
e.traverse((s) => {
|
|
2130
1706
|
s instanceof k && t(s);
|
|
2131
1707
|
});
|
|
2132
1708
|
}
|
|
2133
1709
|
}
|
|
2134
|
-
|
|
1710
|
+
const Vn = 3, Xn = 1, Yn = 0, Qn = 2, Jn = 1e-3, ht = new D(), J = new D(), Zn = new $s();
|
|
1711
|
+
function dt(i) {
|
|
1712
|
+
return i.isInstanceObject === !0;
|
|
1713
|
+
}
|
|
1714
|
+
function ut(i) {
|
|
1715
|
+
let e = !1;
|
|
1716
|
+
return i.traverse((t) => {
|
|
1717
|
+
if (e) return;
|
|
1718
|
+
const s = t;
|
|
1719
|
+
e = s.isMesh === !0 || s.isSprite === !0;
|
|
1720
|
+
}), e;
|
|
1721
|
+
}
|
|
1722
|
+
function er(i) {
|
|
1723
|
+
let e = i;
|
|
1724
|
+
for (; e; ) {
|
|
1725
|
+
if (!e.visible) return !1;
|
|
1726
|
+
e = e.parent;
|
|
1727
|
+
}
|
|
1728
|
+
return !0;
|
|
1729
|
+
}
|
|
1730
|
+
function pt(i) {
|
|
1731
|
+
return i === void 0 || !Number.isFinite(i) || i <= 0 ? Qn : i;
|
|
1732
|
+
}
|
|
1733
|
+
class hi {
|
|
2135
1734
|
static flow(e = {}) {
|
|
2136
|
-
const { baseColor: t = 16777215, flowColor: s = 65280, speed: n = 1, scale:
|
|
2137
|
-
return
|
|
1735
|
+
const { baseColor: t = 16777215, flowColor: s = 65280, speed: n = 1, scale: r = 3, intensity: a = 4 } = e, o = Y(new P(t)), c = Y(new P(s)), l = tt().x.mul(r).sub(we.mul(n)), h = xe(ke(l).add(1).mul(0.5), a);
|
|
1736
|
+
return Me(o, c, h);
|
|
2138
1737
|
}
|
|
2139
1738
|
static breathe(e = {}) {
|
|
2140
|
-
const { baseColor: t = 16777215, breathColor: s = 65280, speed: n = 1, intensity:
|
|
2141
|
-
return
|
|
1739
|
+
const { baseColor: t = 16777215, breathColor: s = 65280, speed: n = 1, intensity: r = 2 } = e, a = Y(new P(t)), o = Y(new P(s)), c = ke(we.mul(n)).add(1).mul(0.5), l = xe(c, r);
|
|
1740
|
+
return Me(a, o, l);
|
|
2142
1741
|
}
|
|
2143
1742
|
static fluid(e = {}) {
|
|
2144
1743
|
const {
|
|
2145
1744
|
baseColor: t = 16777215,
|
|
2146
1745
|
flowColor: s = 255,
|
|
2147
1746
|
speed: n = 1,
|
|
2148
|
-
scale:
|
|
2149
|
-
intensity:
|
|
1747
|
+
scale: r = 1,
|
|
1748
|
+
intensity: a = 1,
|
|
2150
1749
|
distortion: o = 0.5
|
|
2151
|
-
} = e,
|
|
2152
|
-
return
|
|
1750
|
+
} = e, c = Y(new P(t)), l = Y(new P(s)), h = tt().mul(r), d = we.mul(n), u = st(h.add(d), 1, 0), p = h.add(u.mul(o)), x = st(p, 1, 0).add(1).mul(0.5), I = xe(x, a);
|
|
1751
|
+
return Me(c, l, I);
|
|
1752
|
+
}
|
|
1753
|
+
static outline(e = {}) {
|
|
1754
|
+
let t = [...e.selectedObjects ?? []];
|
|
1755
|
+
const s = [], n = /* @__PURE__ */ new Map(), r = new K();
|
|
1756
|
+
let a = null, o = null, c = null, l = null, h = null, d = e.instanceBoundsProxy ?? !0, u = e.instanceBoundsPadding ?? 0, p = e.instanceBoundsMinSize ?? Jn, x = pt(e.downSampleRatio);
|
|
1757
|
+
const I = ae(e.edgeStrength ?? Vn), _ = ae(e.edgeThickness ?? Xn), C = ae(e.edgeGlow ?? Yn), y = ae(new P(e.visibleEdgeColor ?? 16777215)), w = ae(new P(e.hiddenEdgeColor ?? 5125686)), g = () => (l ??= new Gs(1, 1, 1), l), m = () => (h || (h = new Ks({ color: 16777215 }), h.colorWrite = !1, h.depthWrite = !1, h.name = "u-space.outline.instanceBoundsProxy"), h), M = (f) => {
|
|
1758
|
+
const { source: L, mesh: O } = f, B = L.getInstanceBoundingBox?.(r, !0);
|
|
1759
|
+
if (!B || B.isEmpty() || !er(L)) {
|
|
1760
|
+
O.visible = !1;
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
B.getCenter(ht), B.getSize(J);
|
|
1764
|
+
const U = Math.max(0, u), ie = Math.max(0, p);
|
|
1765
|
+
J.set(
|
|
1766
|
+
Math.max(J.x + U * 2, ie),
|
|
1767
|
+
Math.max(J.y + U * 2, ie),
|
|
1768
|
+
Math.max(J.z + U * 2, ie)
|
|
1769
|
+
), O.visible = !0, O.layers.mask = L.layers.mask, O.matrix.compose(ht, Zn, J), O.matrixWorldNeedsUpdate = !0;
|
|
1770
|
+
}, b = (f) => {
|
|
1771
|
+
f.unsubscribe?.(), f.mesh.removeFromParent();
|
|
1772
|
+
}, S = (f, L) => {
|
|
1773
|
+
let O = n.get(f);
|
|
1774
|
+
if (!O) {
|
|
1775
|
+
const B = new k(g(), m());
|
|
1776
|
+
B.name = `u-space.outline.instanceBoundsProxy:${f.uuid}`, B.matrixAutoUpdate = !1, B.castShadow = !1, B.receiveShadow = !1, B.frustumCulled = !1, B.raycast = () => {
|
|
1777
|
+
}, B.userData.instanceObject = f, O = {
|
|
1778
|
+
source: f,
|
|
1779
|
+
mesh: B,
|
|
1780
|
+
unsubscribe: f.onInstanceRenderDirty?.(() => M(O)) ?? null
|
|
1781
|
+
}, n.set(f, O);
|
|
1782
|
+
}
|
|
1783
|
+
return O.mesh.parent !== L && (O.mesh.removeFromParent(), L.add(O.mesh)), M(O), O.mesh.visible ? O.mesh : null;
|
|
1784
|
+
}, A = (f, L) => {
|
|
1785
|
+
const O = f.getInstanceRenderObject?.();
|
|
1786
|
+
return O && ut(O) ? O : ut(f) ? f : d && f.getInstanceBoundingBox ? S(f, L) : null;
|
|
1787
|
+
}, v = (f) => {
|
|
1788
|
+
const L = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set();
|
|
1789
|
+
for (const B of t) {
|
|
1790
|
+
const U = dt(B) ? A(B, f) : B;
|
|
1791
|
+
U && (L.add(U), dt(B) && n.get(B)?.mesh === U && O.add(B));
|
|
1792
|
+
}
|
|
1793
|
+
n.forEach((B, U) => {
|
|
1794
|
+
O.has(U) || (b(B), n.delete(U));
|
|
1795
|
+
}), s.length = 0, L.forEach((B) => s.push(B));
|
|
1796
|
+
}, E = () => {
|
|
1797
|
+
a?.dispose(), a = null;
|
|
1798
|
+
}, z = (f, L) => {
|
|
1799
|
+
if (a && o === f && c === L)
|
|
1800
|
+
return a.downSampleRatio = x, a;
|
|
1801
|
+
E(), o = f, c = L, a = wn(f, L, {
|
|
1802
|
+
selectedObjects: s,
|
|
1803
|
+
edgeThickness: _,
|
|
1804
|
+
edgeGlow: C,
|
|
1805
|
+
downSampleRatio: x
|
|
1806
|
+
});
|
|
1807
|
+
const O = a.updateBefore.bind(a);
|
|
1808
|
+
return a.updateBefore = (B) => (v(f), O(B)), a;
|
|
1809
|
+
}, N = ((f, L) => {
|
|
1810
|
+
const O = f.scene, B = f.camera;
|
|
1811
|
+
v(O);
|
|
1812
|
+
const U = z(O, B), ie = U.visibleEdge.mul(y).add(U.hiddenEdge.mul(w)).mul(I);
|
|
1813
|
+
return un(L, pn(ie, 0));
|
|
1814
|
+
});
|
|
1815
|
+
return Object.defineProperties(N, {
|
|
1816
|
+
outlineNode: {
|
|
1817
|
+
get: () => a
|
|
1818
|
+
},
|
|
1819
|
+
selectedObjects: {
|
|
1820
|
+
get: () => t
|
|
1821
|
+
}
|
|
1822
|
+
}), N.setSelectedObjects = (f) => (t = [...f], o && v(o), N), N.update = (f) => (f.edgeStrength !== void 0 && (I.value = f.edgeStrength), f.edgeThickness !== void 0 && (_.value = f.edgeThickness), f.edgeGlow !== void 0 && (C.value = f.edgeGlow), f.visibleEdgeColor !== void 0 && y.value.set(f.visibleEdgeColor), f.hiddenEdgeColor !== void 0 && w.value.set(f.hiddenEdgeColor), f.instanceBoundsProxy !== void 0 && (d = f.instanceBoundsProxy), f.instanceBoundsPadding !== void 0 && (u = f.instanceBoundsPadding), f.instanceBoundsMinSize !== void 0 && (p = f.instanceBoundsMinSize), f.downSampleRatio !== void 0 && (x = pt(f.downSampleRatio), a && (a.downSampleRatio = x)), o && v(o), N), N.dispose = () => {
|
|
1823
|
+
E(), n.forEach(b), n.clear(), l?.dispose(), h?.dispose(), l = null, h = null, t = [], s.length = 0, o = null, c = null;
|
|
1824
|
+
}, N;
|
|
2153
1825
|
}
|
|
2154
1826
|
}
|
|
2155
|
-
function
|
|
1827
|
+
function di(i) {
|
|
2156
1828
|
}
|
|
2157
|
-
const
|
|
2158
|
-
const
|
|
2159
|
-
return
|
|
2160
|
-
})(),
|
|
2161
|
-
const
|
|
2162
|
-
return
|
|
1829
|
+
const re = "uSpaceHighlight", ue = `${re}/enabled`, Qt = `${re}/opacity`, Jt = `${re}/color`, Zt = `${re}/overwrite`, es = `${re}/multiplyOpacity`, Ae = `${re}/instancedOriginalOpacity`, _e = "uSpaceBreathe", Oe = `${_e}/enabled`, ts = `${_e}/color`, ss = `${_e}/speed`, ns = `${_e}/intensity`, Be = /* @__PURE__ */ new WeakMap(), tr = qt(() => {
|
|
1830
|
+
const i = F(ue, "uint"), e = F(Jt, "uint"), t = F(Zt, "uint"), s = gt(e), n = Ce.mul(s), r = $(t.greaterThan(0), s, n), a = $(i.greaterThan(0), r, Ce), o = F(Oe, "uint"), c = F(ts, "uint"), l = F(ss, "float"), h = F(ns, "float"), d = gt(c), u = ke(we.mul(l)).add(1).mul(0.5), p = xe(u, h), x = Me(a, d, p);
|
|
1831
|
+
return $(o.greaterThan(0), x, a);
|
|
1832
|
+
})(), sr = qt(() => {
|
|
1833
|
+
const i = F(ue, "uint"), e = F(Qt, "float"), t = F(es, "uint"), s = $(t.greaterThan(0), ze.mul(e), e);
|
|
1834
|
+
return $(i.greaterThan(0), s, ze);
|
|
2163
1835
|
})();
|
|
2164
|
-
function
|
|
2165
|
-
return Array.isArray(
|
|
1836
|
+
function de(i) {
|
|
1837
|
+
return Array.isArray(i.material) ? i.material : [i.material];
|
|
2166
1838
|
}
|
|
2167
|
-
function
|
|
2168
|
-
|
|
1839
|
+
function ft(i) {
|
|
1840
|
+
de(i).forEach((t) => {
|
|
2169
1841
|
if (!t) return;
|
|
2170
|
-
let s =
|
|
1842
|
+
let s = Be.get(t);
|
|
2171
1843
|
s || (s = {
|
|
2172
1844
|
colorNode: t.colorNode,
|
|
2173
1845
|
opacityNode: t.opacityNode,
|
|
2174
1846
|
transparent: t.transparent,
|
|
2175
1847
|
depthWrite: t.depthWrite,
|
|
2176
1848
|
activeMeshes: /* @__PURE__ */ new Set()
|
|
2177
|
-
},
|
|
1849
|
+
}, Be.set(t, s)), s.activeMeshes.add(i), t.transparent = !0, t.colorNode = tr, t.opacityNode = sr, t.needsUpdate = !0;
|
|
2178
1850
|
});
|
|
2179
1851
|
}
|
|
2180
|
-
function
|
|
2181
|
-
const e =
|
|
1852
|
+
function mt(i) {
|
|
1853
|
+
const e = i.userData[ue], t = i.userData[Oe];
|
|
2182
1854
|
if (e || t) return;
|
|
2183
|
-
|
|
1855
|
+
de(i).forEach((n) => {
|
|
2184
1856
|
if (!n) return;
|
|
2185
|
-
const
|
|
2186
|
-
|
|
1857
|
+
const r = Be.get(n);
|
|
1858
|
+
r && (r.activeMeshes.delete(i), !(r.activeMeshes.size > 0) && (n.colorNode = r.colorNode, n.opacityNode = r.opacityNode, n.transparent = r.transparent, n.depthWrite = r.depthWrite, n.needsUpdate = !0, Be.delete(n)));
|
|
2187
1859
|
});
|
|
2188
1860
|
}
|
|
2189
|
-
function
|
|
2190
|
-
const n =
|
|
2191
|
-
if (
|
|
2192
|
-
return
|
|
2193
|
-
const
|
|
2194
|
-
return !
|
|
2195
|
-
hasColor:
|
|
2196
|
-
color:
|
|
2197
|
-
opacity:
|
|
2198
|
-
}),
|
|
2199
|
-
}
|
|
2200
|
-
function
|
|
2201
|
-
const e =
|
|
1861
|
+
function nr(i, e, t, s) {
|
|
1862
|
+
const n = i, r = n.setInstanceHighlight;
|
|
1863
|
+
if (r)
|
|
1864
|
+
return r.call(i, e, t, s), !0;
|
|
1865
|
+
const a = n.setInstanceColor, o = n.setInstanceOpacity, c = n.getInstanceOpacity, l = n.getInstanceColor, h = n.hasInstanceColor;
|
|
1866
|
+
return !a || !o ? !1 : (i.userData[Ae] === void 0 && (i.userData[Ae] = {
|
|
1867
|
+
hasColor: h?.call(i) ?? !1,
|
|
1868
|
+
color: l?.call(i, new P()).getHex() ?? 16777215,
|
|
1869
|
+
opacity: c?.call(i) ?? 1
|
|
1870
|
+
}), a.call(i, e), o.call(i, t), !0);
|
|
1871
|
+
}
|
|
1872
|
+
function rr(i) {
|
|
1873
|
+
const e = i, t = e.clearInstanceHighlight;
|
|
2202
1874
|
if (t)
|
|
2203
|
-
return t.call(
|
|
2204
|
-
const s = e.
|
|
2205
|
-
if (!s || !
|
|
2206
|
-
const
|
|
2207
|
-
return
|
|
1875
|
+
return t.call(i), !0;
|
|
1876
|
+
const s = e.resetInstanceColor, n = e.setInstanceColor, r = e.setInstanceOpacity;
|
|
1877
|
+
if (!s || !r) return !1;
|
|
1878
|
+
const a = i.userData[Ae];
|
|
1879
|
+
return a && (a.hasColor && n ? n.call(i, a.color) : s.call(i), r.call(i, a.opacity), Reflect.deleteProperty(i.userData, Ae)), !0;
|
|
2208
1880
|
}
|
|
2209
|
-
class
|
|
1881
|
+
class se {
|
|
2210
1882
|
static highlightColor(e, t = {}) {
|
|
2211
|
-
const s = Array.isArray(e) ? e : [e], { opacity: n = 0.5, color:
|
|
2212
|
-
for (const
|
|
2213
|
-
|
|
2214
|
-
d.userData[
|
|
2215
|
-
|
|
1883
|
+
const s = Array.isArray(e) ? e : [e], { opacity: n = 0.5, color: r = 16711680, overwrite: a = !1, depthWrite: o, multiplyOpacity: c = !1 } = t, l = new P(r).getHex();
|
|
1884
|
+
for (const h of s)
|
|
1885
|
+
nr(h, r, n, a) || Q.traverseMeshes(h, (d) => {
|
|
1886
|
+
d.userData[ue] = 1, d.userData[Qt] = n, d.userData[Jt] = l, d.userData[Zt] = a ? 1 : 0, d.userData[es] = c ? 1 : 0, ft(d), o !== void 0 && de(d).forEach((p) => {
|
|
1887
|
+
p && (p.depthWrite = o);
|
|
2216
1888
|
});
|
|
2217
1889
|
});
|
|
2218
1890
|
}
|
|
2219
1891
|
static removeHighlightColor(e) {
|
|
2220
1892
|
const t = Array.isArray(e) ? e : [e];
|
|
2221
1893
|
for (const s of t)
|
|
2222
|
-
|
|
2223
|
-
n.userData[
|
|
1894
|
+
rr(s) || Q.traverseMeshes(s, (n) => {
|
|
1895
|
+
n.userData[ue] = 0, mt(n);
|
|
2224
1896
|
});
|
|
2225
1897
|
}
|
|
2226
1898
|
static breatheColor(e, t = {}) {
|
|
@@ -2232,17 +1904,17 @@ class le {
|
|
|
2232
1904
|
},
|
|
2233
1905
|
t
|
|
2234
1906
|
);
|
|
2235
|
-
n.color = new
|
|
2236
|
-
for (const
|
|
2237
|
-
|
|
2238
|
-
|
|
1907
|
+
n.color = new P(n.color).getHex();
|
|
1908
|
+
for (const r of s)
|
|
1909
|
+
Q.traverseMeshes(r, (a) => {
|
|
1910
|
+
a.userData[Oe] = 1, a.userData[ts] = n.color, a.userData[ss] = n.speed, a.userData[ns] = n.intensity, ft(a);
|
|
2239
1911
|
});
|
|
2240
1912
|
}
|
|
2241
1913
|
static removeBreatheColor(e) {
|
|
2242
1914
|
const t = Array.isArray(e) ? e : [e];
|
|
2243
1915
|
for (const s of t)
|
|
2244
|
-
|
|
2245
|
-
n.userData[
|
|
1916
|
+
Q.traverseMeshes(s, (n) => {
|
|
1917
|
+
n.userData[Oe] = 0, mt(n);
|
|
2246
1918
|
});
|
|
2247
1919
|
}
|
|
2248
1920
|
/**
|
|
@@ -2251,10 +1923,10 @@ class le {
|
|
|
2251
1923
|
static wireframe(e, t = !0) {
|
|
2252
1924
|
const s = Array.isArray(e) ? e : [e];
|
|
2253
1925
|
for (const n of s)
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
if (!
|
|
2257
|
-
const o =
|
|
1926
|
+
Q.traverseMeshes(n, (r) => {
|
|
1927
|
+
de(r).forEach((a) => {
|
|
1928
|
+
if (!a) return;
|
|
1929
|
+
const o = a;
|
|
2258
1930
|
o.wireframe = t, o.needsUpdate = !0;
|
|
2259
1931
|
});
|
|
2260
1932
|
});
|
|
@@ -2263,7 +1935,7 @@ class le {
|
|
|
2263
1935
|
* Remove wireframe mode.
|
|
2264
1936
|
*/
|
|
2265
1937
|
static removeWireframe(e) {
|
|
2266
|
-
|
|
1938
|
+
se.wireframe(e, !1);
|
|
2267
1939
|
}
|
|
2268
1940
|
/**
|
|
2269
1941
|
* Fade in object(s) from fully transparent to original opacity.
|
|
@@ -2271,7 +1943,7 @@ class le {
|
|
|
2271
1943
|
*/
|
|
2272
1944
|
static fadeIn(e, t = {}) {
|
|
2273
1945
|
const { duration: s = 500 } = t;
|
|
2274
|
-
return
|
|
1946
|
+
return se._fade(e, 0, 1, s);
|
|
2275
1947
|
}
|
|
2276
1948
|
/**
|
|
2277
1949
|
* Fade out object(s) to fully transparent.
|
|
@@ -2279,61 +1951,62 @@ class le {
|
|
|
2279
1951
|
*/
|
|
2280
1952
|
static fadeOut(e, t = {}) {
|
|
2281
1953
|
const { duration: s = 500 } = t;
|
|
2282
|
-
return
|
|
1954
|
+
return se._fade(e, 1, 0, s);
|
|
2283
1955
|
}
|
|
2284
1956
|
static _fade(e, t, s, n) {
|
|
2285
|
-
const
|
|
2286
|
-
for (const o of
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
if (!
|
|
2290
|
-
const
|
|
2291
|
-
|
|
2292
|
-
material:
|
|
2293
|
-
targetOpacity:
|
|
2294
|
-
originalOpacity:
|
|
1957
|
+
const r = Array.isArray(e) ? e : [e], a = /* @__PURE__ */ new Map();
|
|
1958
|
+
for (const o of r)
|
|
1959
|
+
Q.traverseMeshes(o, (c) => {
|
|
1960
|
+
de(c).forEach((l) => {
|
|
1961
|
+
if (!l || a.has(l)) return;
|
|
1962
|
+
const h = l.opacity, d = l.transparent, u = s >= 1 ? h : s;
|
|
1963
|
+
a.set(l, {
|
|
1964
|
+
material: l,
|
|
1965
|
+
targetOpacity: u,
|
|
1966
|
+
originalOpacity: h,
|
|
2295
1967
|
originalTransparent: d
|
|
2296
|
-
}),
|
|
1968
|
+
}), l.transparent = !0, l.opacity = t, l.needsUpdate = !0;
|
|
2297
1969
|
});
|
|
2298
1970
|
});
|
|
2299
|
-
return
|
|
2300
|
-
const
|
|
2301
|
-
let
|
|
2302
|
-
const
|
|
2303
|
-
const d = performance.now() -
|
|
2304
|
-
if (!
|
|
2305
|
-
cancelAnimationFrame(
|
|
1971
|
+
return a.size === 0 ? Promise.resolve() : new Promise((o) => {
|
|
1972
|
+
const c = performance.now();
|
|
1973
|
+
let l = 0;
|
|
1974
|
+
const h = () => {
|
|
1975
|
+
const d = performance.now() - c, u = Math.min(d / n, 1);
|
|
1976
|
+
if (!r[0].parent) {
|
|
1977
|
+
cancelAnimationFrame(l), o();
|
|
2306
1978
|
return;
|
|
2307
1979
|
}
|
|
2308
|
-
for (const { material:
|
|
2309
|
-
|
|
2310
|
-
if (
|
|
2311
|
-
|
|
1980
|
+
for (const { material: x, targetOpacity: I } of a.values())
|
|
1981
|
+
x.opacity = t + (I - t) * u, x.needsUpdate = !0;
|
|
1982
|
+
if (u < 1)
|
|
1983
|
+
l = requestAnimationFrame(h);
|
|
2312
1984
|
else {
|
|
2313
1985
|
if (s >= 1)
|
|
2314
|
-
for (const { material:
|
|
2315
|
-
|
|
1986
|
+
for (const { material: x, originalOpacity: I, originalTransparent: _ } of a.values())
|
|
1987
|
+
x.opacity = I, x.transparent = _, x.needsUpdate = !0;
|
|
2316
1988
|
o();
|
|
2317
1989
|
}
|
|
2318
1990
|
};
|
|
2319
|
-
|
|
1991
|
+
l = requestAnimationFrame(h);
|
|
2320
1992
|
});
|
|
2321
1993
|
}
|
|
2322
1994
|
}
|
|
2323
|
-
const
|
|
2324
|
-
const e =
|
|
2325
|
-
return
|
|
1995
|
+
const gt = (i) => {
|
|
1996
|
+
const e = i.shiftRight(16).bitAnd(255).toFloat().div(255), t = i.shiftRight(8).bitAnd(255).toFloat().div(255), s = i.bitAnd(255).toFloat().div(255);
|
|
1997
|
+
return fn(e, t, s);
|
|
2326
1998
|
};
|
|
2327
|
-
class
|
|
1999
|
+
class ir extends xn {
|
|
2328
2000
|
viewer;
|
|
2329
2001
|
constructor(e, t) {
|
|
2330
2002
|
super(t), this.viewer = e;
|
|
2331
2003
|
}
|
|
2332
2004
|
_update = ({ time: e }) => {
|
|
2333
|
-
this.update(e)
|
|
2005
|
+
const t = this.update(e);
|
|
2006
|
+
this.viewer.invalidate(), t || this.viewer.removeEventListener("afterControlsUpdate", this._update);
|
|
2334
2007
|
};
|
|
2335
2008
|
easingByMode(e) {
|
|
2336
|
-
const t =
|
|
2009
|
+
const t = ar[e];
|
|
2337
2010
|
return super.easing(t);
|
|
2338
2011
|
}
|
|
2339
2012
|
start(e, t) {
|
|
@@ -2343,54 +2016,54 @@ class nn extends ws {
|
|
|
2343
2016
|
return this.viewer.removeEventListener("afterControlsUpdate", this._update), super.stop();
|
|
2344
2017
|
}
|
|
2345
2018
|
}
|
|
2346
|
-
function
|
|
2347
|
-
return new Promise((
|
|
2348
|
-
const { duration:
|
|
2349
|
-
n?.(
|
|
2019
|
+
function ui(i, e, t, s = {}, n, r) {
|
|
2020
|
+
return new Promise((a, o) => {
|
|
2021
|
+
const { duration: c = 1e3, delay: l = 0, repeat: h = !1, mode: d = "Linear.None", yoyo: u = !1 } = s, p = new ir(i, e).to(t, c).easingByMode(d).delay(l).onUpdate((x) => {
|
|
2022
|
+
n?.(x, p);
|
|
2350
2023
|
}).onComplete(() => {
|
|
2351
|
-
|
|
2024
|
+
a();
|
|
2352
2025
|
}).onStop(() => {
|
|
2353
2026
|
o("animation stop");
|
|
2354
2027
|
}).onStart(() => {
|
|
2355
|
-
|
|
2028
|
+
r?.(p);
|
|
2356
2029
|
});
|
|
2357
|
-
typeof
|
|
2030
|
+
typeof h == "number" ? p.repeat(h) : typeof h == "boolean" && h && p.repeat(1 / 0), u && p.repeatDelay(20), p.yoyo(u), p.start();
|
|
2358
2031
|
});
|
|
2359
2032
|
}
|
|
2360
|
-
const
|
|
2361
|
-
"Linear.None":
|
|
2362
|
-
"Quadratic.In":
|
|
2363
|
-
"Quadratic.Out":
|
|
2364
|
-
"Quadratic.InOut":
|
|
2365
|
-
"Cubic.In":
|
|
2366
|
-
"Cubic.Out":
|
|
2367
|
-
"Cubic.InOut":
|
|
2368
|
-
"Quartic.In":
|
|
2369
|
-
"Quartic.Out":
|
|
2370
|
-
"Quartic.InOut":
|
|
2371
|
-
"Quintic.In":
|
|
2372
|
-
"Quintic.Out":
|
|
2373
|
-
"Quintic.InOut":
|
|
2374
|
-
"Sinusoidal.In":
|
|
2375
|
-
"Sinusoidal.Out":
|
|
2376
|
-
"Sinusoidal.InOut":
|
|
2377
|
-
"Exponential.In":
|
|
2378
|
-
"Exponential.Out":
|
|
2379
|
-
"Exponential.InOut":
|
|
2380
|
-
"Circular.In":
|
|
2381
|
-
"Circular.Out":
|
|
2382
|
-
"Circular.InOut":
|
|
2383
|
-
"Elastic.In":
|
|
2384
|
-
"Elastic.Out":
|
|
2385
|
-
"Elastic.InOut":
|
|
2386
|
-
"Back.In":
|
|
2387
|
-
"Back.Out":
|
|
2388
|
-
"Back.InOut":
|
|
2389
|
-
"Bounce.In":
|
|
2390
|
-
"Bounce.Out":
|
|
2391
|
-
"Bounce.InOut":
|
|
2033
|
+
const ar = {
|
|
2034
|
+
"Linear.None": T.Linear.None,
|
|
2035
|
+
"Quadratic.In": T.Quadratic.In,
|
|
2036
|
+
"Quadratic.Out": T.Quadratic.Out,
|
|
2037
|
+
"Quadratic.InOut": T.Quadratic.InOut,
|
|
2038
|
+
"Cubic.In": T.Cubic.In,
|
|
2039
|
+
"Cubic.Out": T.Cubic.Out,
|
|
2040
|
+
"Cubic.InOut": T.Cubic.InOut,
|
|
2041
|
+
"Quartic.In": T.Quartic.In,
|
|
2042
|
+
"Quartic.Out": T.Quartic.Out,
|
|
2043
|
+
"Quartic.InOut": T.Quartic.InOut,
|
|
2044
|
+
"Quintic.In": T.Quintic.In,
|
|
2045
|
+
"Quintic.Out": T.Quintic.Out,
|
|
2046
|
+
"Quintic.InOut": T.Quintic.InOut,
|
|
2047
|
+
"Sinusoidal.In": T.Sinusoidal.In,
|
|
2048
|
+
"Sinusoidal.Out": T.Sinusoidal.Out,
|
|
2049
|
+
"Sinusoidal.InOut": T.Sinusoidal.InOut,
|
|
2050
|
+
"Exponential.In": T.Exponential.In,
|
|
2051
|
+
"Exponential.Out": T.Exponential.Out,
|
|
2052
|
+
"Exponential.InOut": T.Exponential.InOut,
|
|
2053
|
+
"Circular.In": T.Circular.In,
|
|
2054
|
+
"Circular.Out": T.Circular.Out,
|
|
2055
|
+
"Circular.InOut": T.Circular.InOut,
|
|
2056
|
+
"Elastic.In": T.Elastic.In,
|
|
2057
|
+
"Elastic.Out": T.Elastic.Out,
|
|
2058
|
+
"Elastic.InOut": T.Elastic.InOut,
|
|
2059
|
+
"Back.In": T.Back.In,
|
|
2060
|
+
"Back.Out": T.Back.Out,
|
|
2061
|
+
"Back.InOut": T.Back.InOut,
|
|
2062
|
+
"Bounce.In": T.Bounce.In,
|
|
2063
|
+
"Bounce.Out": T.Bounce.Out,
|
|
2064
|
+
"Bounce.InOut": T.Bounce.InOut
|
|
2392
2065
|
};
|
|
2393
|
-
class
|
|
2066
|
+
class pi {
|
|
2394
2067
|
scene;
|
|
2395
2068
|
planes = /* @__PURE__ */ new Map();
|
|
2396
2069
|
helpers = /* @__PURE__ */ new Map();
|
|
@@ -2399,7 +2072,7 @@ class jn {
|
|
|
2399
2072
|
*/
|
|
2400
2073
|
group;
|
|
2401
2074
|
constructor(e) {
|
|
2402
|
-
this.scene = e, this.group = new
|
|
2075
|
+
this.scene = e, this.group = new qs(), this.group.name = "__clippingToolGroup", this.scene.add(this.group);
|
|
2403
2076
|
}
|
|
2404
2077
|
/**
|
|
2405
2078
|
* Move all current scene children (except the clipping group itself) into the ClippingGroup,
|
|
@@ -2437,37 +2110,37 @@ class jn {
|
|
|
2437
2110
|
const {
|
|
2438
2111
|
normal: s = { x: 0, y: -1, z: 0 },
|
|
2439
2112
|
constant: n = 0,
|
|
2440
|
-
showHelper:
|
|
2441
|
-
helperSize:
|
|
2113
|
+
showHelper: r = !1,
|
|
2114
|
+
helperSize: a = 5,
|
|
2442
2115
|
helperColor: o = 16711680
|
|
2443
|
-
} = t,
|
|
2444
|
-
return this.planes.set(e,
|
|
2116
|
+
} = t, c = new Vs(new D(s.x, s.y, s.z), n);
|
|
2117
|
+
return this.planes.set(e, c), this._syncPlanes(), r && this.showHelper(e, a, o), c;
|
|
2445
2118
|
}
|
|
2446
2119
|
/**
|
|
2447
2120
|
* Add six clipping planes that form a box around a Box3.
|
|
2448
2121
|
* Returns the six plane ids: `${id}_+x`, `${id}_-x`, etc.
|
|
2449
2122
|
*/
|
|
2450
2123
|
addBox(e, t, s = {}) {
|
|
2451
|
-
const { showHelpers: n = !1, helperColor:
|
|
2124
|
+
const { showHelpers: n = !1, helperColor: r = 16711680 } = s, a = t.min, o = t.max, c = [
|
|
2452
2125
|
{ suffix: "+x", normal: { x: -1, y: 0, z: 0 }, constant: o.x },
|
|
2453
|
-
{ suffix: "-x", normal: { x: 1, y: 0, z: 0 }, constant: -
|
|
2126
|
+
{ suffix: "-x", normal: { x: 1, y: 0, z: 0 }, constant: -a.x },
|
|
2454
2127
|
{ suffix: "+y", normal: { x: 0, y: -1, z: 0 }, constant: o.y },
|
|
2455
|
-
{ suffix: "-y", normal: { x: 0, y: 1, z: 0 }, constant: -
|
|
2128
|
+
{ suffix: "-y", normal: { x: 0, y: 1, z: 0 }, constant: -a.y },
|
|
2456
2129
|
{ suffix: "+z", normal: { x: 0, y: 0, z: -1 }, constant: o.z },
|
|
2457
|
-
{ suffix: "-z", normal: { x: 0, y: 0, z: 1 }, constant: -
|
|
2458
|
-
],
|
|
2459
|
-
for (const
|
|
2460
|
-
const d = `${e}_${
|
|
2461
|
-
this.addPlane(d, { normal:
|
|
2130
|
+
{ suffix: "-z", normal: { x: 0, y: 0, z: 1 }, constant: -a.z }
|
|
2131
|
+
], l = [];
|
|
2132
|
+
for (const h of c) {
|
|
2133
|
+
const d = `${e}_${h.suffix}`;
|
|
2134
|
+
this.addPlane(d, { normal: h.normal, constant: h.constant, showHelper: n, helperColor: r }), l.push(d);
|
|
2462
2135
|
}
|
|
2463
|
-
return
|
|
2136
|
+
return l;
|
|
2464
2137
|
}
|
|
2465
2138
|
/**
|
|
2466
2139
|
* Add a clipping box from an object's bounding box with optional padding.
|
|
2467
2140
|
*/
|
|
2468
2141
|
addBoxFromObject(e, t, s = 0, n = {}) {
|
|
2469
|
-
const
|
|
2470
|
-
return
|
|
2142
|
+
const r = new K().setFromObject(t);
|
|
2143
|
+
return r.expandByScalar(s), this.addBox(e, r, n);
|
|
2471
2144
|
}
|
|
2472
2145
|
/**
|
|
2473
2146
|
* Update a plane's constant (distance from origin).
|
|
@@ -2506,8 +2179,8 @@ class jn {
|
|
|
2506
2179
|
this.hideHelper(e);
|
|
2507
2180
|
const n = this.planes.get(e);
|
|
2508
2181
|
if (!n) return;
|
|
2509
|
-
const
|
|
2510
|
-
|
|
2182
|
+
const r = new Xs(n, t, new P(s).getHex());
|
|
2183
|
+
r.name = e, this.helpers.set(e, r), this.scene.add(r);
|
|
2511
2184
|
}
|
|
2512
2185
|
/**
|
|
2513
2186
|
* Hide a plane helper.
|
|
@@ -2532,7 +2205,7 @@ class jn {
|
|
|
2532
2205
|
this.detach(), this.removeAll(), this.scene.remove(this.group);
|
|
2533
2206
|
}
|
|
2534
2207
|
}
|
|
2535
|
-
class
|
|
2208
|
+
class fi {
|
|
2536
2209
|
scene;
|
|
2537
2210
|
measurements = /* @__PURE__ */ new Map();
|
|
2538
2211
|
_idCounter = 0;
|
|
@@ -2543,19 +2216,19 @@ class Un {
|
|
|
2543
2216
|
* Measure distance between two points.
|
|
2544
2217
|
*/
|
|
2545
2218
|
measureDistance(e, t, s = {}) {
|
|
2546
|
-
const { lineColor: n = 16776960 } = s,
|
|
2547
|
-
|
|
2548
|
-
const
|
|
2549
|
-
|
|
2550
|
-
const
|
|
2551
|
-
id:
|
|
2219
|
+
const { lineColor: n = 16776960 } = s, r = new D(e.x, e.y, e.z), a = new D(t.x, t.y, t.z), o = r.distanceTo(a), c = `measure_dist_${this._idCounter++}`, l = new W();
|
|
2220
|
+
l.name = c;
|
|
2221
|
+
const h = new G().setFromPoints([r, a]), d = new ye({ color: n }), u = new be(h, d);
|
|
2222
|
+
l.add(u), this.scene.add(l);
|
|
2223
|
+
const p = {
|
|
2224
|
+
id: c,
|
|
2552
2225
|
type: "distance",
|
|
2553
2226
|
value: o,
|
|
2554
2227
|
unit: "m",
|
|
2555
|
-
points: [
|
|
2556
|
-
object:
|
|
2228
|
+
points: [r, a],
|
|
2229
|
+
object: l
|
|
2557
2230
|
};
|
|
2558
|
-
return this.measurements.set(
|
|
2231
|
+
return this.measurements.set(c, p), p;
|
|
2559
2232
|
}
|
|
2560
2233
|
/**
|
|
2561
2234
|
* Measure the area of a polygon defined by 3+ coplanar points.
|
|
@@ -2564,37 +2237,37 @@ class Un {
|
|
|
2564
2237
|
const { lineColor: s = 65280 } = t;
|
|
2565
2238
|
if (e.length < 3)
|
|
2566
2239
|
throw new Error("MeasureTool.measureArea requires at least 3 points");
|
|
2567
|
-
const n = e.map((
|
|
2568
|
-
o.name =
|
|
2569
|
-
const
|
|
2240
|
+
const n = e.map((p) => new D(p.x, p.y, p.z)), r = this._calculatePolygonArea(n), a = `measure_area_${this._idCounter++}`, o = new W();
|
|
2241
|
+
o.name = a;
|
|
2242
|
+
const c = [...n, n[0]], l = new G().setFromPoints(c), h = new ye({ color: s }), d = new be(l, h);
|
|
2570
2243
|
o.add(d), this.scene.add(o);
|
|
2571
|
-
const
|
|
2572
|
-
id:
|
|
2244
|
+
const u = {
|
|
2245
|
+
id: a,
|
|
2573
2246
|
type: "area",
|
|
2574
|
-
value:
|
|
2247
|
+
value: r,
|
|
2575
2248
|
unit: "m²",
|
|
2576
2249
|
points: n,
|
|
2577
2250
|
object: o
|
|
2578
2251
|
};
|
|
2579
|
-
return this.measurements.set(
|
|
2252
|
+
return this.measurements.set(a, u), u;
|
|
2580
2253
|
}
|
|
2581
2254
|
/**
|
|
2582
2255
|
* Measure the angle between three points (vertex at the middle point).
|
|
2583
2256
|
*/
|
|
2584
2257
|
measureAngle(e, t, s, n = {}) {
|
|
2585
|
-
const { lineColor:
|
|
2586
|
-
|
|
2587
|
-
const
|
|
2588
|
-
|
|
2258
|
+
const { lineColor: r = 16746496 } = n, a = new D(e.x, e.y, e.z), o = new D(t.x, t.y, t.z), c = new D(s.x, s.y, s.z), l = a.clone().sub(o).normalize(), h = c.clone().sub(o).normalize(), u = Math.acos(Math.max(-1, Math.min(1, l.dot(h)))) * 180 / Math.PI, p = `measure_angle_${this._idCounter++}`, x = new W();
|
|
2259
|
+
x.name = p;
|
|
2260
|
+
const I = new G().setFromPoints([a, o, c]), _ = new ye({ color: r }), C = new be(I, _);
|
|
2261
|
+
x.add(C), this.scene.add(x);
|
|
2589
2262
|
const y = {
|
|
2590
|
-
id:
|
|
2263
|
+
id: p,
|
|
2591
2264
|
type: "angle",
|
|
2592
|
-
value:
|
|
2265
|
+
value: u,
|
|
2593
2266
|
unit: "°",
|
|
2594
|
-
points: [
|
|
2595
|
-
object:
|
|
2267
|
+
points: [a, o, c],
|
|
2268
|
+
object: x
|
|
2596
2269
|
};
|
|
2597
|
-
return this.measurements.set(
|
|
2270
|
+
return this.measurements.set(p, y), y;
|
|
2598
2271
|
}
|
|
2599
2272
|
/**
|
|
2600
2273
|
* Get a measurement result by id.
|
|
@@ -2629,15 +2302,15 @@ class Un {
|
|
|
2629
2302
|
* Calculate polygon area using cross product method (Newell's method).
|
|
2630
2303
|
*/
|
|
2631
2304
|
_calculatePolygonArea(e) {
|
|
2632
|
-
const t = e.length, s = new
|
|
2633
|
-
for (let
|
|
2634
|
-
const
|
|
2635
|
-
s.add(
|
|
2305
|
+
const t = e.length, s = new D();
|
|
2306
|
+
for (let r = 0; r < t; r++) {
|
|
2307
|
+
const a = e[r], o = e[(r + 1) % t], c = new D().crossVectors(a, o);
|
|
2308
|
+
s.add(c);
|
|
2636
2309
|
}
|
|
2637
|
-
const n = new
|
|
2310
|
+
const n = new D();
|
|
2638
2311
|
if (t >= 3) {
|
|
2639
|
-
const
|
|
2640
|
-
n.crossVectors(
|
|
2312
|
+
const r = e[1].clone().sub(e[0]), a = e[2].clone().sub(e[0]);
|
|
2313
|
+
n.crossVectors(r, a).normalize();
|
|
2641
2314
|
}
|
|
2642
2315
|
return Math.abs(s.dot(n)) / 2;
|
|
2643
2316
|
}
|
|
@@ -2645,7 +2318,7 @@ class Un {
|
|
|
2645
2318
|
this.removeAll();
|
|
2646
2319
|
}
|
|
2647
2320
|
}
|
|
2648
|
-
class
|
|
2321
|
+
class mi {
|
|
2649
2322
|
scene;
|
|
2650
2323
|
annotations = /* @__PURE__ */ new Map();
|
|
2651
2324
|
_idCounter = 0;
|
|
@@ -2665,12 +2338,12 @@ class Hn {
|
|
|
2665
2338
|
*/
|
|
2666
2339
|
add(e, t) {
|
|
2667
2340
|
this.annotations.has(e) && this.remove(e);
|
|
2668
|
-
const s = new
|
|
2341
|
+
const s = new W();
|
|
2669
2342
|
s.name = `annotation_${e}`;
|
|
2670
|
-
const n = new
|
|
2343
|
+
const n = new D(t.position.x, t.position.y, t.position.z);
|
|
2671
2344
|
s.position.copy(n);
|
|
2672
|
-
const
|
|
2673
|
-
if (
|
|
2345
|
+
const r = document.createElement("div");
|
|
2346
|
+
if (r.innerHTML = t.content, r.style.cssText = `
|
|
2674
2347
|
padding: 4px 8px;
|
|
2675
2348
|
background: rgba(0, 0, 0, 0.75);
|
|
2676
2349
|
color: #fff;
|
|
@@ -2679,32 +2352,32 @@ class Hn {
|
|
|
2679
2352
|
pointer-events: auto;
|
|
2680
2353
|
white-space: nowrap;
|
|
2681
2354
|
`, t.labelStyle)
|
|
2682
|
-
for (const
|
|
2683
|
-
const
|
|
2684
|
-
|
|
2355
|
+
for (const l of Object.keys(t.labelStyle)) {
|
|
2356
|
+
const h = t.labelStyle[l];
|
|
2357
|
+
h !== void 0 && (r.style[l] = h);
|
|
2685
2358
|
}
|
|
2686
|
-
let
|
|
2359
|
+
let a = null;
|
|
2687
2360
|
const o = t.labelOffset || { x: 0, y: 2, z: 0 };
|
|
2688
2361
|
if (t.showLeaderLine !== !1) {
|
|
2689
|
-
const { lineColor:
|
|
2690
|
-
new
|
|
2691
|
-
new
|
|
2692
|
-
]), d = new
|
|
2693
|
-
|
|
2362
|
+
const { lineColor: l = 16777215 } = t, h = new G().setFromPoints([
|
|
2363
|
+
new D(0, 0, 0),
|
|
2364
|
+
new D(o.x, o.y, o.z)
|
|
2365
|
+
]), d = new ye({ color: l });
|
|
2366
|
+
a = new be(h, d), s.add(a);
|
|
2694
2367
|
}
|
|
2695
2368
|
if (this._createCSSObject) {
|
|
2696
|
-
const
|
|
2697
|
-
|
|
2369
|
+
const l = this._createCSSObject(r);
|
|
2370
|
+
l.position.set(o.x, o.y, o.z), s.add(l);
|
|
2698
2371
|
}
|
|
2699
2372
|
this.scene.add(s);
|
|
2700
|
-
const
|
|
2373
|
+
const c = {
|
|
2701
2374
|
id: e,
|
|
2702
2375
|
options: t,
|
|
2703
2376
|
group: s,
|
|
2704
|
-
labelElement:
|
|
2705
|
-
line:
|
|
2377
|
+
labelElement: r,
|
|
2378
|
+
line: a
|
|
2706
2379
|
};
|
|
2707
|
-
return this.annotations.set(e,
|
|
2380
|
+
return this.annotations.set(e, c), c;
|
|
2708
2381
|
}
|
|
2709
2382
|
/**
|
|
2710
2383
|
* Quick-add a text annotation.
|
|
@@ -2798,47 +2471,1112 @@ class Hn {
|
|
|
2798
2471
|
this.removeAll();
|
|
2799
2472
|
}
|
|
2800
2473
|
}
|
|
2801
|
-
const
|
|
2802
|
-
|
|
2474
|
+
const yt = new R(), or = 1e-6, cr = 1e-6, bt = "uSpaceInstanceOriginalMaterialState", wt = 0, Ne = 1, lr = 2;
|
|
2475
|
+
function hr(i) {
|
|
2476
|
+
let e = i;
|
|
2477
|
+
for (; e; ) {
|
|
2478
|
+
if (!e.visible) return !1;
|
|
2479
|
+
e = e.parent;
|
|
2480
|
+
}
|
|
2481
|
+
return !0;
|
|
2482
|
+
}
|
|
2483
|
+
function dr(i, e) {
|
|
2484
|
+
const t = i.elements, s = e.elements;
|
|
2485
|
+
for (let n = 0; n < 16; n++)
|
|
2486
|
+
if (Math.abs(t[n] - s[n]) > or) return !1;
|
|
2487
|
+
return !0;
|
|
2488
|
+
}
|
|
2489
|
+
function rs(i) {
|
|
2490
|
+
const e = i.material;
|
|
2491
|
+
return Array.isArray(e) ? e : [e];
|
|
2492
|
+
}
|
|
2493
|
+
function is(i) {
|
|
2494
|
+
const e = i.userData, t = e[bt];
|
|
2495
|
+
if (t) return t;
|
|
2496
|
+
const s = {
|
|
2497
|
+
transparent: i.transparent,
|
|
2498
|
+
opacity: i.opacity
|
|
2499
|
+
};
|
|
2500
|
+
return e[bt] = s, s;
|
|
2501
|
+
}
|
|
2502
|
+
function ur(i, e) {
|
|
2503
|
+
i.traverse((t) => {
|
|
2504
|
+
const s = t;
|
|
2505
|
+
s.isMesh && rs(s).forEach((n) => {
|
|
2506
|
+
if (!n) return;
|
|
2507
|
+
const r = n, a = is(r), o = a.opacity * e;
|
|
2508
|
+
r.transparent = a.transparent || o < 1, r.opacity = o, r.needsUpdate = !0;
|
|
2509
|
+
});
|
|
2510
|
+
});
|
|
2511
|
+
}
|
|
2512
|
+
function pr(i) {
|
|
2513
|
+
i.traverse((e) => {
|
|
2514
|
+
const t = e;
|
|
2515
|
+
t.isMesh && rs(t).forEach((s) => {
|
|
2516
|
+
if (!s) return;
|
|
2517
|
+
const n = s, r = is(n);
|
|
2518
|
+
n.transparent = r.transparent, n.opacity = r.opacity, n.needsUpdate = !0;
|
|
2519
|
+
});
|
|
2520
|
+
});
|
|
2521
|
+
}
|
|
2522
|
+
class gi extends pe {
|
|
2523
|
+
isInstanceObject = !0;
|
|
2524
|
+
type = "InstanceObject";
|
|
2525
|
+
instanceId = "";
|
|
2526
|
+
instanceKind = "";
|
|
2527
|
+
instanceName = "";
|
|
2528
|
+
geometry = new G();
|
|
2529
|
+
boundingBox = null;
|
|
2530
|
+
boundingSphere = null;
|
|
2531
|
+
#s = {
|
|
2532
|
+
color: null,
|
|
2533
|
+
colorMode: wt,
|
|
2534
|
+
opacity: 1
|
|
2535
|
+
};
|
|
2536
|
+
#a = null;
|
|
2537
|
+
#t = null;
|
|
2538
|
+
#e = null;
|
|
2539
|
+
#r = null;
|
|
2540
|
+
#n = /* @__PURE__ */ new Set();
|
|
2541
|
+
#o = new R();
|
|
2542
|
+
#c = !1;
|
|
2543
|
+
#l = !0;
|
|
2544
|
+
#d = !1;
|
|
2545
|
+
#u;
|
|
2546
|
+
constructor(e = {}) {
|
|
2547
|
+
super(), this.#u = e.boundsName ?? "InstanceBounds";
|
|
2548
|
+
}
|
|
2549
|
+
setInstanceIdentity(e) {
|
|
2550
|
+
let t = !1;
|
|
2551
|
+
if (e.id !== void 0) {
|
|
2552
|
+
const s = e.id ?? "";
|
|
2553
|
+
this.instanceId !== s && (this.instanceId = s, t = !0);
|
|
2554
|
+
}
|
|
2555
|
+
if (e.kind !== void 0) {
|
|
2556
|
+
const s = e.kind ?? "";
|
|
2557
|
+
this.instanceKind !== s && (this.instanceKind = s, t = !0);
|
|
2558
|
+
}
|
|
2559
|
+
if (e.name !== void 0) {
|
|
2560
|
+
const s = e.name ?? "";
|
|
2561
|
+
this.instanceName !== s && (this.instanceName = s, t = !0);
|
|
2562
|
+
}
|
|
2563
|
+
return t && this.markInstanceRenderDirty(), this;
|
|
2564
|
+
}
|
|
2565
|
+
setInstanceBounds(e) {
|
|
2566
|
+
if (e.isEmpty()) return this;
|
|
2567
|
+
this.#t && this.remove(this.#t);
|
|
2568
|
+
const t = new G();
|
|
2569
|
+
t.boundingBox = e.clone();
|
|
2570
|
+
const s = new Ys();
|
|
2571
|
+
return s.name = this.#u, s.visible = !1, s.geometry = t, s.raycast = () => {
|
|
2572
|
+
}, this.#t = s, this.add(s), this.#h(), this.markInstanceRenderDirty(), this;
|
|
2573
|
+
}
|
|
2574
|
+
setInstanceRenderObject(e) {
|
|
2575
|
+
return this.#e && this.#e !== e && this.#e.parent === this && this.remove(this.#e), this.#e = e, e && e.parent !== this && this.add(e), this.#f(), this.#h(), this.markInstanceRenderDirty(), this;
|
|
2576
|
+
}
|
|
2577
|
+
getInstanceRenderObject() {
|
|
2578
|
+
return this.#e;
|
|
2579
|
+
}
|
|
2580
|
+
setInstanceMaterializer(e) {
|
|
2581
|
+
return this.#r = e, this;
|
|
2582
|
+
}
|
|
2583
|
+
hasInstanceMaterializer(e) {
|
|
2584
|
+
return this.#r === e;
|
|
2585
|
+
}
|
|
2586
|
+
clearInstanceMaterializer(e) {
|
|
2587
|
+
return (e === void 0 || this.#r === e) && (this.#r = null), this;
|
|
2588
|
+
}
|
|
2589
|
+
materialize() {
|
|
2590
|
+
return this.#r?.() ?? this.#e ?? null;
|
|
2591
|
+
}
|
|
2592
|
+
computeBoundingBox() {
|
|
2593
|
+
this.boundingBox === null && (this.boundingBox = new K()), this.getInstanceBoundingBox(this.boundingBox, !1);
|
|
2594
|
+
}
|
|
2595
|
+
computeBoundingSphere() {
|
|
2596
|
+
if (this.boundingSphere === null && (this.boundingSphere = new ne()), this.boundingBox === null && this.computeBoundingBox(), !this.boundingBox || this.boundingBox.isEmpty()) {
|
|
2597
|
+
this.boundingSphere.makeEmpty();
|
|
2598
|
+
return;
|
|
2599
|
+
}
|
|
2600
|
+
this.boundingBox.getBoundingSphere(this.boundingSphere);
|
|
2601
|
+
}
|
|
2602
|
+
getInstanceBoundingBox(e = new K(), t = !1) {
|
|
2603
|
+
const s = this.#t?.geometry?.boundingBox;
|
|
2604
|
+
return s ? (e.copy(s), t && (this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld)), e) : this.#e ? (e.setFromObject(this.#e), t || (this.updateWorldMatrix(!0, !1), yt.copy(this.matrixWorld).invert(), e.applyMatrix4(yt)), e) : e.makeEmpty();
|
|
2605
|
+
}
|
|
2606
|
+
setInstanceVisible(e) {
|
|
2607
|
+
return this.visible === e ? this : (this.visible = e, this.markInstanceRenderDirty(), this);
|
|
2608
|
+
}
|
|
2609
|
+
setInstanceColor(e) {
|
|
2610
|
+
return this.#s.color = new P(e), this.#s.colorMode = Ne, this.#f(), this.markInstanceRenderDirty(), this;
|
|
2611
|
+
}
|
|
2612
|
+
resetInstanceColor() {
|
|
2613
|
+
return this.#s.color === null ? this : (this.#s.color = null, this.#s.colorMode = wt, this.#f(), this.markInstanceRenderDirty(), this);
|
|
2614
|
+
}
|
|
2615
|
+
setInstanceOpacity(e) {
|
|
2616
|
+
const t = Math.max(0, Math.min(1, e));
|
|
2617
|
+
return Math.abs(this.#s.opacity - t) <= cr ? this : (this.#s.opacity = t, this.#f(), this.markInstanceRenderDirty(), this);
|
|
2618
|
+
}
|
|
2619
|
+
getInstanceColor(e = new P()) {
|
|
2620
|
+
const t = this.#p();
|
|
2621
|
+
return t.color ? e.copy(t.color) : e.setRGB(1, 1, 1);
|
|
2622
|
+
}
|
|
2623
|
+
hasInstanceColor() {
|
|
2624
|
+
return this.#p().color !== null;
|
|
2625
|
+
}
|
|
2626
|
+
getInstanceOpacity() {
|
|
2627
|
+
return this.#p().opacity;
|
|
2628
|
+
}
|
|
2629
|
+
setInstanceHighlight(e, t, s = !1) {
|
|
2630
|
+
return this.#a = {
|
|
2631
|
+
color: new P(e),
|
|
2632
|
+
colorMode: s ? Ne : lr,
|
|
2633
|
+
opacity: Math.max(0, Math.min(1, t))
|
|
2634
|
+
}, this.#f(), this.markInstanceRenderDirty(), this;
|
|
2635
|
+
}
|
|
2636
|
+
clearInstanceHighlight() {
|
|
2637
|
+
return this.#a === null ? this : (this.#a = null, this.#f(), this.markInstanceRenderDirty(), this);
|
|
2638
|
+
}
|
|
2639
|
+
getInstanceColorMode() {
|
|
2640
|
+
return this.#p().colorMode;
|
|
2641
|
+
}
|
|
2642
|
+
onInstanceRenderDirty(e) {
|
|
2643
|
+
return this.#n.add(e), () => this.#n.delete(e);
|
|
2644
|
+
}
|
|
2645
|
+
markInstanceRenderDirty() {
|
|
2646
|
+
return this.#n.forEach((e) => e()), this;
|
|
2647
|
+
}
|
|
2648
|
+
updateMatrixWorld(e) {
|
|
2649
|
+
super.updateMatrixWorld(e), this.#i();
|
|
2650
|
+
}
|
|
2651
|
+
updateWorldMatrix(e, t) {
|
|
2652
|
+
super.updateWorldMatrix(e, t), this.#i();
|
|
2653
|
+
}
|
|
2654
|
+
#i() {
|
|
2655
|
+
const e = hr(this);
|
|
2656
|
+
(!this.#c || !dr(this.matrixWorld, this.#o) || !this.#d || e !== this.#l) && (this.#c = !0, this.#d = !0, this.#o.copy(this.matrixWorld), this.#l = e, this.markInstanceRenderDirty());
|
|
2657
|
+
}
|
|
2658
|
+
#h() {
|
|
2659
|
+
this.boundingBox = null, this.boundingSphere = null;
|
|
2660
|
+
}
|
|
2661
|
+
#p() {
|
|
2662
|
+
return this.#a ?? this.#s;
|
|
2663
|
+
}
|
|
2664
|
+
#f() {
|
|
2665
|
+
if (!this.#e) return;
|
|
2666
|
+
const e = this.#p();
|
|
2667
|
+
if (e.color) {
|
|
2668
|
+
pr(this.#e), se.highlightColor(this.#e, {
|
|
2669
|
+
color: e.color,
|
|
2670
|
+
opacity: e.opacity,
|
|
2671
|
+
overwrite: e.colorMode === Ne,
|
|
2672
|
+
multiplyOpacity: !0
|
|
2673
|
+
});
|
|
2674
|
+
return;
|
|
2675
|
+
}
|
|
2676
|
+
se.removeHighlightColor(this.#e), ur(this.#e, e.opacity);
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
function yi(i) {
|
|
2680
|
+
return i.isInstanceObject === !0;
|
|
2681
|
+
}
|
|
2682
|
+
const fr = /* @__PURE__ */ new Set([
|
|
2683
|
+
"MeshBasicMaterial",
|
|
2684
|
+
"MeshLambertMaterial",
|
|
2685
|
+
"MeshPhongMaterial",
|
|
2686
|
+
"MeshStandardMaterial",
|
|
2687
|
+
"MeshPhysicalMaterial"
|
|
2688
|
+
]), xt = /* @__PURE__ */ new WeakMap();
|
|
2689
|
+
let mr = 1;
|
|
2690
|
+
const Mt = new R(), le = new R(), vt = new R();
|
|
2691
|
+
function gr(i, e, t = 1e-6) {
|
|
2692
|
+
const s = i.elements, n = e.elements;
|
|
2693
|
+
for (let r = 0; r < 16; r++)
|
|
2694
|
+
if (Math.abs(s[r] - n[r]) > t) return !1;
|
|
2695
|
+
return !0;
|
|
2696
|
+
}
|
|
2697
|
+
function as(i) {
|
|
2698
|
+
let e = i;
|
|
2699
|
+
for (; e; ) {
|
|
2700
|
+
if (!e.visible) return !1;
|
|
2701
|
+
e = e.parent;
|
|
2702
|
+
}
|
|
2703
|
+
return !0;
|
|
2704
|
+
}
|
|
2705
|
+
function yr(i) {
|
|
2706
|
+
const e = i.source.data;
|
|
2707
|
+
if (!e || typeof e != "object" && typeof e != "function")
|
|
2708
|
+
return `texture:${i.uuid}`;
|
|
2709
|
+
let t = xt.get(e);
|
|
2710
|
+
return t === void 0 && (t = mr++, xt.set(e, t)), `source:${t}`;
|
|
2711
|
+
}
|
|
2712
|
+
function br(i) {
|
|
2713
|
+
return JSON.stringify([
|
|
2714
|
+
yr(i),
|
|
2715
|
+
i.mapping,
|
|
2716
|
+
i.channel,
|
|
2717
|
+
i.wrapS,
|
|
2718
|
+
i.wrapT,
|
|
2719
|
+
i.magFilter,
|
|
2720
|
+
i.minFilter,
|
|
2721
|
+
i.anisotropy,
|
|
2722
|
+
i.format,
|
|
2723
|
+
i.internalFormat,
|
|
2724
|
+
i.type,
|
|
2725
|
+
i.offset.toArray(),
|
|
2726
|
+
i.repeat.toArray(),
|
|
2727
|
+
i.center.toArray(),
|
|
2728
|
+
i.rotation,
|
|
2729
|
+
i.matrixAutoUpdate,
|
|
2730
|
+
i.matrix.toArray(),
|
|
2731
|
+
i.generateMipmaps,
|
|
2732
|
+
i.premultiplyAlpha,
|
|
2733
|
+
i.flipY,
|
|
2734
|
+
i.unpackAlignment,
|
|
2735
|
+
i.colorSpace,
|
|
2736
|
+
"compareFunction" in i ? i.compareFunction : null
|
|
2737
|
+
]);
|
|
2738
|
+
}
|
|
2739
|
+
function Ue(i) {
|
|
2740
|
+
if (Array.isArray(i)) return i.map(Ue);
|
|
2741
|
+
if (!i || typeof i != "object") return i;
|
|
2742
|
+
const e = i;
|
|
2743
|
+
return Object.fromEntries(
|
|
2744
|
+
Object.keys(e).sort().map((t) => [t, Ue(e[t])])
|
|
2745
|
+
);
|
|
2746
|
+
}
|
|
2747
|
+
function je(i, e) {
|
|
2748
|
+
if (Array.isArray(i)) return i.map((s) => je(s, e));
|
|
2749
|
+
if (!i || typeof i != "object")
|
|
2750
|
+
return typeof i == "string" ? e.get(i) ?? i : i;
|
|
2751
|
+
const t = i;
|
|
2752
|
+
return Object.fromEntries(
|
|
2753
|
+
Object.keys(t).filter((s) => s !== "metadata" && s !== "uuid" && s !== "name").sort().map((s) => [s, je(t[s], e)])
|
|
2754
|
+
);
|
|
2755
|
+
}
|
|
2756
|
+
function wr(i) {
|
|
2757
|
+
if (!fr.has(i.type) || i.transparent || i.opacity < 0.999 || i.visible === !1) return null;
|
|
2758
|
+
const e = i;
|
|
2759
|
+
if (Object.keys(e).some((r) => r.endsWith("Node") && e[r] != null) || Object.hasOwn(i, "onBeforeCompile")) return null;
|
|
2760
|
+
const t = /* @__PURE__ */ new Map();
|
|
2761
|
+
Object.values(e).forEach((r) => {
|
|
2762
|
+
r instanceof $t && t.set(r.uuid, br(r));
|
|
2763
|
+
});
|
|
2764
|
+
const s = {
|
|
2765
|
+
geometries: {},
|
|
2766
|
+
materials: {},
|
|
2767
|
+
textures: {},
|
|
2768
|
+
images: {},
|
|
2769
|
+
shapes: {},
|
|
2770
|
+
skeletons: {},
|
|
2771
|
+
animations: {},
|
|
2772
|
+
nodes: {}
|
|
2773
|
+
}, n = i.toJSON(s);
|
|
2774
|
+
return JSON.stringify(Ue(je(n, t)));
|
|
2775
|
+
}
|
|
2776
|
+
function xr(i) {
|
|
2777
|
+
if (Object.keys(i.morphAttributes).length > 0 || i.drawRange.start !== 0 || i.drawRange.count !== 1 / 0) return null;
|
|
2778
|
+
const e = Object.entries(i.attributes).sort(([t], [s]) => t.localeCompare(s)).map(([t, s]) => "isInterleavedBufferAttribute" in s ? null : [t, s.itemSize, s.normalized, s.array.constructor.name, s.gpuType]);
|
|
2779
|
+
return e.some((t) => t === null) ? null : JSON.stringify([
|
|
2780
|
+
i.index?.array.constructor.name ?? "non-indexed",
|
|
2781
|
+
e
|
|
2782
|
+
]);
|
|
2783
|
+
}
|
|
2784
|
+
function Mr(i, e) {
|
|
2785
|
+
const t = [], s = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = !e && (i.animations.length > 0 || i.mixer !== null);
|
|
2786
|
+
return r && n.add("animation"), i.updateWorldMatrix(!0, !0), Mt.copy(i.matrixWorld).invert(), i.traverseVisible((a) => {
|
|
2787
|
+
if (!(a instanceof k)) return;
|
|
2788
|
+
if (r) {
|
|
2789
|
+
s.add(a);
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
if (a instanceof Js) {
|
|
2793
|
+
s.add(a), n.add("skinned");
|
|
2794
|
+
return;
|
|
2795
|
+
}
|
|
2796
|
+
if (a.morphTargetInfluences) {
|
|
2797
|
+
s.add(a), n.add("morph");
|
|
2798
|
+
return;
|
|
2799
|
+
}
|
|
2800
|
+
if (Array.isArray(a.material)) {
|
|
2801
|
+
s.add(a), n.add("material-array");
|
|
2802
|
+
return;
|
|
2803
|
+
}
|
|
2804
|
+
const o = wr(a.material), c = xr(a.geometry);
|
|
2805
|
+
if (!o) {
|
|
2806
|
+
s.add(a), n.add(a.material.transparent || a.material.opacity < 0.999 ? "transparent" : `material:${a.material.type}`);
|
|
2807
|
+
return;
|
|
2808
|
+
}
|
|
2809
|
+
if (!c) {
|
|
2810
|
+
s.add(a), n.add("geometry-layout");
|
|
2811
|
+
return;
|
|
2812
|
+
}
|
|
2813
|
+
if (a.matrixWorld.determinant() <= 0) {
|
|
2814
|
+
s.add(a), n.add("negative-scale");
|
|
2815
|
+
return;
|
|
2816
|
+
}
|
|
2817
|
+
t.push({
|
|
2818
|
+
mesh: a,
|
|
2819
|
+
localMatrix: Mt.clone().multiply(a.matrixWorld),
|
|
2820
|
+
materialKey: o,
|
|
2821
|
+
geometryKey: c
|
|
2822
|
+
});
|
|
2823
|
+
}), t.length === 0 && s.size === 0 && n.add("empty"), {
|
|
2824
|
+
meshes: t,
|
|
2825
|
+
fallbackMeshes: s,
|
|
2826
|
+
fallbackReasons: n
|
|
2827
|
+
};
|
|
2828
|
+
}
|
|
2829
|
+
function vr(i, e) {
|
|
2830
|
+
const t = We(i), s = [], n = [];
|
|
2831
|
+
return i.traverse((r) => {
|
|
2832
|
+
r instanceof k && s.push(r);
|
|
2833
|
+
}), t.traverse((r) => {
|
|
2834
|
+
r instanceof k && n.push(r);
|
|
2835
|
+
}), s.forEach((r, a) => {
|
|
2836
|
+
e.has(r) && n[a] && (n[a].visible = !1);
|
|
2837
|
+
}), t;
|
|
2838
|
+
}
|
|
2839
|
+
function Sr(i) {
|
|
2840
|
+
const e = We(i), t = /* @__PURE__ */ new Map(), s = (n) => {
|
|
2841
|
+
let r = t.get(n);
|
|
2842
|
+
return r || (r = n.clone(), t.set(n, r)), r;
|
|
2843
|
+
};
|
|
2844
|
+
return e.traverse((n) => {
|
|
2845
|
+
n instanceof k && (n.material = Array.isArray(n.material) ? n.material.map(s) : s(n.material));
|
|
2846
|
+
}), e;
|
|
2847
|
+
}
|
|
2848
|
+
function Ir(i) {
|
|
2849
|
+
return Math.max(1, Math.ceil(Math.sqrt(Math.max(1, i))));
|
|
2850
|
+
}
|
|
2851
|
+
function Er(i) {
|
|
2852
|
+
const e = new Zs(new Float32Array(i * i * 4), i, i, en, tn);
|
|
2853
|
+
return e.magFilter = Ee, e.minFilter = Ee, e.generateMipmaps = !1, e.needsUpdate = !0, e;
|
|
2854
|
+
}
|
|
2855
|
+
function Cr(i, e) {
|
|
2856
|
+
const t = i.clone(), s = mn("batchObjectIndex", "float").toInt(), n = nt(gn(rt(e), nt(0)).x).toConst(), r = s.mod(n).toConst(), a = s.div(n).toConst(), o = rt(e, yn(r, a)), c = t.colorNode ?? Ce, l = $(o.a.greaterThan(1.5), c.mul(o.rgb), o.rgb);
|
|
2857
|
+
return t.colorNode = $(o.a.greaterThan(0.5), l, c), t.maskNode = o.a.greaterThan(-0.5), t.needsUpdate = !0, t;
|
|
2858
|
+
}
|
|
2859
|
+
function St(i) {
|
|
2860
|
+
let e = 0, t = i.parent;
|
|
2861
|
+
for (; t; )
|
|
2862
|
+
e++, t = t.parent;
|
|
2863
|
+
return e;
|
|
2864
|
+
}
|
|
2865
|
+
class Ar extends X {
|
|
2866
|
+
objectIndices;
|
|
2867
|
+
states;
|
|
2868
|
+
#s;
|
|
2869
|
+
constructor(e, t, s, n) {
|
|
2870
|
+
super(e, t), this.objectIndices = s, this.states = n, this.userData.editableGeometryBatch = !0;
|
|
2871
|
+
}
|
|
2872
|
+
raycast(e, t) {
|
|
2873
|
+
if (this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0)
|
|
2874
|
+
return !1;
|
|
2875
|
+
this.#s === void 0 && (this.#s = jt(this.geometry));
|
|
2876
|
+
const s = [];
|
|
2877
|
+
this.#s ? this.#s.raycastObject3D(this, e, s) : super.raycast(e, s), s.forEach((n) => {
|
|
2878
|
+
const r = n.faceIndex;
|
|
2879
|
+
if (r == null) return;
|
|
2880
|
+
const a = r * 3, o = this.geometry.index?.getX(a) ?? a, c = this.objectIndices[o], l = c === void 0 ? void 0 : this.states[c], h = l?.instance;
|
|
2881
|
+
!l || l.materialized || !h || !as(h) || h.getInstanceOpacity() <= 1e-3 || (n.object = h, n.batchObjectIndex = c, t.push(n));
|
|
2882
|
+
});
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
class bi extends pe {
|
|
2886
|
+
isEditableGeometryBatchLayer = !0;
|
|
2887
|
+
type = "EditableGeometryBatchLayer";
|
|
2888
|
+
options;
|
|
2889
|
+
stats = {
|
|
2890
|
+
instances: 0,
|
|
2891
|
+
sourceMeshes: 0,
|
|
2892
|
+
batches: 0,
|
|
2893
|
+
drawCallsSaved: 0,
|
|
2894
|
+
vertices: 0,
|
|
2895
|
+
indices: 0,
|
|
2896
|
+
unsupportedInstances: 0,
|
|
2897
|
+
unsupportedByReason: {}
|
|
2898
|
+
};
|
|
2899
|
+
#s = [];
|
|
2900
|
+
#a = /* @__PURE__ */ new Set();
|
|
2901
|
+
#t = [];
|
|
2902
|
+
#e = /* @__PURE__ */ new Map();
|
|
2903
|
+
#r = /* @__PURE__ */ new Set();
|
|
2904
|
+
#n = null;
|
|
2905
|
+
#o = new R();
|
|
2906
|
+
#c = !1;
|
|
2907
|
+
#l = !1;
|
|
2908
|
+
#d = !1;
|
|
2909
|
+
constructor(e = {}) {
|
|
2910
|
+
super(), this.name = "EditableGeometryBatches", this.options = {
|
|
2911
|
+
maxVerticesPerBatch: e.maxVerticesPerBatch ?? 15e5,
|
|
2912
|
+
maxIndicesPerBatch: e.maxIndicesPerBatch ?? 45e5,
|
|
2913
|
+
freezeAnimations: e.freezeAnimations ?? !1
|
|
2914
|
+
};
|
|
2915
|
+
}
|
|
2916
|
+
addSource(e) {
|
|
2917
|
+
if (this.#l) throw new Error("EditableGeometryBatchLayer has been disposed.");
|
|
2918
|
+
if (this.#c) throw new Error("EditableGeometryBatchLayer has already been built.");
|
|
2919
|
+
const { key: t, template: s, instances: n } = e, r = /* @__PURE__ */ new Set();
|
|
2920
|
+
n.forEach((l) => {
|
|
2921
|
+
if (r.has(l) || this.#a.has(l))
|
|
2922
|
+
throw new Error(
|
|
2923
|
+
"EditableGeometryBatchLayer cannot batch the same InstanceObject more than once."
|
|
2924
|
+
);
|
|
2925
|
+
r.add(l);
|
|
2926
|
+
});
|
|
2927
|
+
const { meshes: a, fallbackMeshes: o, fallbackReasons: c } = Mr(
|
|
2928
|
+
s,
|
|
2929
|
+
this.options.freezeAnimations
|
|
2930
|
+
);
|
|
2931
|
+
return r.forEach((l) => this.#a.add(l)), this.#s.push({
|
|
2932
|
+
key: t,
|
|
2933
|
+
template: s,
|
|
2934
|
+
instances: [...n],
|
|
2935
|
+
meshes: a,
|
|
2936
|
+
fallbackMeshes: o,
|
|
2937
|
+
fallbackReasons: c,
|
|
2938
|
+
bounds: new K().setFromObject(s)
|
|
2939
|
+
}), a.length > 0;
|
|
2940
|
+
}
|
|
2941
|
+
build() {
|
|
2942
|
+
if (this.#l) throw new Error("EditableGeometryBatchLayer has been disposed.");
|
|
2943
|
+
if (this.#c) throw new Error("EditableGeometryBatchLayer.build() can only be called once.");
|
|
2944
|
+
this.#c = !0, this.updateWorldMatrix(!0, !1), this.#o.copy(this.matrixWorld).invert();
|
|
2945
|
+
const e = [], t = /* @__PURE__ */ new Map(), s = (r, a, o, c) => {
|
|
2946
|
+
if (o.length === 0) return;
|
|
2947
|
+
const l = c.size > 0 ? [...c] : ["unknown"];
|
|
2948
|
+
e.push({ key: r.key, template: a, instances: o, reasons: l }), l.forEach((h) => {
|
|
2949
|
+
this.stats.unsupportedByReason[h] = (this.stats.unsupportedByReason[h] ?? 0) + o.length;
|
|
2950
|
+
});
|
|
2951
|
+
};
|
|
2952
|
+
this.#s.forEach((r) => {
|
|
2953
|
+
const a = [], o = [];
|
|
2954
|
+
r.instances.forEach((l) => {
|
|
2955
|
+
l.updateWorldMatrix(!0, !1), le.multiplyMatrices(this.#o, l.matrixWorld), le.determinant() <= 0 ? o.push(l) : a.push({ instance: l, matrix: le.clone() });
|
|
2956
|
+
});
|
|
2957
|
+
const c = r.fallbackReasons.size > 0 ? r.fallbackReasons : /* @__PURE__ */ new Set(["unknown"]);
|
|
2958
|
+
if (r.meshes.length === 0) {
|
|
2959
|
+
s(
|
|
2960
|
+
r,
|
|
2961
|
+
r.template,
|
|
2962
|
+
a.map(({ instance: l }) => l),
|
|
2963
|
+
c
|
|
2964
|
+
), s(
|
|
2965
|
+
r,
|
|
2966
|
+
r.template,
|
|
2967
|
+
o,
|
|
2968
|
+
/* @__PURE__ */ new Set([...c, "negative-scale"])
|
|
2969
|
+
);
|
|
2970
|
+
return;
|
|
2971
|
+
}
|
|
2972
|
+
r.fallbackMeshes.size > 0 && s(
|
|
2973
|
+
r,
|
|
2974
|
+
vr(
|
|
2975
|
+
r.template,
|
|
2976
|
+
new Set(r.meshes.map(({ mesh: l }) => l))
|
|
2977
|
+
),
|
|
2978
|
+
a.map(({ instance: l }) => l),
|
|
2979
|
+
c
|
|
2980
|
+
), s(
|
|
2981
|
+
r,
|
|
2982
|
+
r.template,
|
|
2983
|
+
o,
|
|
2984
|
+
/* @__PURE__ */ new Set([...r.fallbackReasons, "negative-scale"])
|
|
2985
|
+
), a.forEach(({ instance: l, matrix: h }) => {
|
|
2986
|
+
const d = this.#t.length, u = () => this.materialize(l), p = {
|
|
2987
|
+
instance: l,
|
|
2988
|
+
template: r.template,
|
|
2989
|
+
initialMatrix: h,
|
|
2990
|
+
objectIndex: d,
|
|
2991
|
+
materialized: !1,
|
|
2992
|
+
materializer: u,
|
|
2993
|
+
unsubscribe: () => {
|
|
2994
|
+
}
|
|
2995
|
+
};
|
|
2996
|
+
p.unsubscribe = l.onInstanceRenderDirty(() => this.#h(p)), this.#t.push(p), this.#e.set(l, p), l.setInstanceBounds(r.bounds), l.setInstanceMaterializer(u), this.#r.add(p), r.meshes.forEach(({ mesh: x, localMatrix: I, materialKey: _, geometryKey: C }) => {
|
|
2997
|
+
vt.multiplyMatrices(h, I);
|
|
2998
|
+
const y = x.geometry.clone().applyMatrix4(vt), w = y.getAttribute("position");
|
|
2999
|
+
y.setAttribute(
|
|
3000
|
+
"batchObjectIndex",
|
|
3001
|
+
new Qs(new Float32Array(w.count).fill(d), 1)
|
|
3002
|
+
);
|
|
3003
|
+
const g = JSON.stringify([
|
|
3004
|
+
_,
|
|
3005
|
+
C,
|
|
3006
|
+
x.castShadow,
|
|
3007
|
+
x.receiveShadow,
|
|
3008
|
+
x.renderOrder
|
|
3009
|
+
]), m = t.get(g), M = {
|
|
3010
|
+
geometry: y,
|
|
3011
|
+
material: x.material,
|
|
3012
|
+
castShadow: x.castShadow,
|
|
3013
|
+
receiveShadow: x.receiveShadow,
|
|
3014
|
+
renderOrder: x.renderOrder,
|
|
3015
|
+
objectIndices: new Array(w.count).fill(d)
|
|
3016
|
+
};
|
|
3017
|
+
m ? m.push(M) : t.set(g, [M]), this.stats.sourceMeshes++, this.stats.vertices += w.count, this.stats.indices += y.index?.count ?? w.count;
|
|
3018
|
+
});
|
|
3019
|
+
});
|
|
3020
|
+
}), this.stats.instances = this.#t.length, this.stats.unsupportedInstances = e.reduce((r, a) => r + a.instances.length, 0);
|
|
3021
|
+
const n = Ir(this.#t.length);
|
|
3022
|
+
return this.#n = Er(n), this.#i(), t.forEach((r) => this.#u(r)), this.stats.batches = this.children.length, this.stats.drawCallsSaved = Math.max(0, this.stats.sourceMeshes - this.stats.batches), this.children.forEach((r) => {
|
|
3023
|
+
r instanceof k && (r.onBeforeRender = () => this.#i());
|
|
3024
|
+
}), { stats: { ...this.stats }, unsupported: e };
|
|
3025
|
+
}
|
|
3026
|
+
materialize(e) {
|
|
3027
|
+
const t = this.#e.get(e);
|
|
3028
|
+
if (!t || t.materialized) return e.getInstanceRenderObject();
|
|
3029
|
+
const s = Sr(t.template);
|
|
3030
|
+
return s.position.set(0, 0, 0), s.quaternion.identity(), s.scale.set(1, 1, 1), s.matrix.identity(), t.materialized = !0, e.setInstanceRenderObject(s), s.updateWorldMatrix(!0, !0), this.#r.add(t), this.dispatchEvent({ type: "materialize", instance: e, object: s }), s;
|
|
3031
|
+
}
|
|
3032
|
+
#u(e) {
|
|
3033
|
+
const t = [];
|
|
3034
|
+
let s = [], n = 0, r = 0;
|
|
3035
|
+
e.forEach((a) => {
|
|
3036
|
+
const o = a.geometry.getAttribute("position").count, c = a.geometry.index?.count ?? o;
|
|
3037
|
+
s.length > 0 && (n + o > this.options.maxVerticesPerBatch || r + c > this.options.maxIndicesPerBatch) && (t.push(s), s = [], n = 0, r = 0), s.push(a), n += o, r += c;
|
|
3038
|
+
}), s.length > 0 && t.push(s), t.forEach((a) => {
|
|
3039
|
+
const o = Mn(a.map((u) => u.geometry), !1);
|
|
3040
|
+
if (a.forEach((u) => u.geometry.dispose()), !o || !this.#n) return;
|
|
3041
|
+
o.computeBoundingBox(), o.computeBoundingSphere();
|
|
3042
|
+
const c = a[0], l = a.flatMap((u) => u.objectIndices), h = Cr(c.material, this.#n), d = new Ar(
|
|
3043
|
+
o,
|
|
3044
|
+
h,
|
|
3045
|
+
l,
|
|
3046
|
+
this.#t
|
|
3047
|
+
);
|
|
3048
|
+
d.name = `EditableGeometryBatch:${this.children.length}`, d.castShadow = c.castShadow, d.receiveShadow = c.receiveShadow, d.renderOrder = c.renderOrder, d.matrixAutoUpdate = !1, this.add(d);
|
|
3049
|
+
});
|
|
3050
|
+
}
|
|
3051
|
+
#i() {
|
|
3052
|
+
if (!(!this.#n || this.#r.size === 0 || this.#d)) {
|
|
3053
|
+
this.#d = !0;
|
|
3054
|
+
try {
|
|
3055
|
+
this.updateWorldMatrix(!0, !1), this.#o.copy(this.matrixWorld).invert();
|
|
3056
|
+
const e = this.#n.image.data;
|
|
3057
|
+
[...this.#r].sort((t, s) => St(t.instance) - St(s.instance)).forEach((t) => {
|
|
3058
|
+
const { instance: s, objectIndex: n } = t;
|
|
3059
|
+
s.updateWorldMatrix(!0, !1), le.multiplyMatrices(this.#o, s.matrixWorld), !t.materialized && s.getInstanceRenderObject() !== null && !s.hasInstanceMaterializer(t.materializer) && (t.materialized = !0), !t.materialized && !gr(le, t.initialMatrix) && this.materialize(s), !t.materialized && s.getInstanceOpacity() < 0.999 && this.materialize(s);
|
|
3060
|
+
const r = n * 4, a = !t.materialized && as(s) && s.getInstanceOpacity() > 1e-3, o = s.getInstanceColor();
|
|
3061
|
+
e[r] = o.r, e[r + 1] = o.g, e[r + 2] = o.b, e[r + 3] = a ? s.getInstanceColorMode() : -1, this.#r.delete(t);
|
|
3062
|
+
}), this.#n.needsUpdate = !0;
|
|
3063
|
+
} finally {
|
|
3064
|
+
this.#d = !1;
|
|
3065
|
+
}
|
|
3066
|
+
this.#r.size > 0 && this.#i();
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
#h(e) {
|
|
3070
|
+
this.#r.add(e), this.#i();
|
|
3071
|
+
}
|
|
3072
|
+
dispose() {
|
|
3073
|
+
this.#l || (this.#l = !0, this.#t.forEach((e) => {
|
|
3074
|
+
e.unsubscribe(), e.instance.clearInstanceMaterializer(e.materializer);
|
|
3075
|
+
}), this.#t.length = 0, this.#e.clear(), this.#a.clear(), this.#r.clear(), this.#s.length = 0, this.#n?.dispose(), this.#n = null, this.traverse((e) => {
|
|
3076
|
+
if (!(e instanceof k)) return;
|
|
3077
|
+
e.geometry.dispose(), (Array.isArray(e.material) ? e.material : [e.material]).forEach((s) => s.dispose());
|
|
3078
|
+
}), this.clear());
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
const It = new R(), me = new R(), Et = new R(), Ct = new R(), At = new K(), Ot = new ne(), Bt = new ne(), Or = new sn(), Z = new P(), _t = new j(), Tt = new D(), Lt = new R(), Nt = new R(), Dt = new ne(), ge = [], os = 1e-6, H = 1e-6, cs = 0.999, Br = 0, Pt = 1;
|
|
3082
|
+
function _r(i, e, t) {
|
|
3083
|
+
const s = i.elements;
|
|
3084
|
+
for (let n = 0; n < 16; n++)
|
|
3085
|
+
if (Math.abs(s[n] - e[t + n]) > os) return !1;
|
|
3086
|
+
return !0;
|
|
3087
|
+
}
|
|
3088
|
+
function Tr(i, e, t, s) {
|
|
3089
|
+
return Math.abs(i.r - t[s]) <= H && Math.abs(i.g - t[s + 1]) <= H && Math.abs(i.b - t[s + 2]) <= H && Math.abs(e - t[s + 3]) <= H;
|
|
3090
|
+
}
|
|
3091
|
+
function Rt(i, e) {
|
|
3092
|
+
const t = i.elements, s = e.elements;
|
|
3093
|
+
for (let n = 0; n < 16; n++)
|
|
3094
|
+
if (Math.abs(t[n] - s[n]) > os) return !1;
|
|
3095
|
+
return !0;
|
|
3096
|
+
}
|
|
3097
|
+
function De(i) {
|
|
3098
|
+
let e = i;
|
|
3099
|
+
for (; e; ) {
|
|
3100
|
+
if (!e.visible) return !1;
|
|
3101
|
+
e = e.parent;
|
|
3102
|
+
}
|
|
3103
|
+
return !0;
|
|
3104
|
+
}
|
|
3105
|
+
function Lr(i) {
|
|
3106
|
+
const e = i.geometry.morphAttributes;
|
|
3107
|
+
return Object.values(e).some((t) => t?.length);
|
|
3108
|
+
}
|
|
3109
|
+
function Nr(i) {
|
|
3110
|
+
const e = i.material;
|
|
3111
|
+
if (!Array.isArray(e)) return !0;
|
|
3112
|
+
if (e.length === 0 || !e.every(Boolean)) return !1;
|
|
3113
|
+
const t = i.geometry.groups;
|
|
3114
|
+
return t.length === 0 ? !1 : t.every((s) => {
|
|
3115
|
+
const n = s.materialIndex ?? 0;
|
|
3116
|
+
return Number.isInteger(s.start) && s.start >= 0 && Number.isInteger(s.count) && s.count > 0 && Number.isInteger(n) && n >= 0 && n < e.length;
|
|
3117
|
+
});
|
|
3118
|
+
}
|
|
3119
|
+
function Dr(i) {
|
|
3120
|
+
return !i.isSkinnedMesh && !Lr(i) && Nr(i);
|
|
3121
|
+
}
|
|
3122
|
+
function kt(i) {
|
|
3123
|
+
return Array.isArray(i) ? i : [i];
|
|
3124
|
+
}
|
|
3125
|
+
function ls(i) {
|
|
3126
|
+
return i.transparent || i.opacity < cs;
|
|
3127
|
+
}
|
|
3128
|
+
function zt(i, e, t) {
|
|
3129
|
+
const s = i.clone(), n = it(e, "vec4", 4, 0), r = it(t, "float", 1, 0), a = s.colorNode ?? Ce, o = s.opacityNode ? bn(s.opacityNode) : ze, c = $(n.a.greaterThan(1.5), a.mul(n.rgb), n.rgb);
|
|
3130
|
+
return s.colorNode = $(n.a.greaterThan(0.5), c, a), s.opacityNode = o.mul(r), s.transparent = ls(i), s.needsUpdate = !0, s;
|
|
3131
|
+
}
|
|
3132
|
+
function Pr(i, e, t) {
|
|
3133
|
+
return Array.isArray(i) ? i.map((s) => zt(s, e, t)) : zt(i, e, t);
|
|
3134
|
+
}
|
|
3135
|
+
function Rr(i) {
|
|
3136
|
+
const e = [], t = new R();
|
|
3137
|
+
let s = !1;
|
|
3138
|
+
return i.updateWorldMatrix(!0, !0), t.copy(i.matrixWorld).invert(), i.traverse((n) => {
|
|
3139
|
+
if (!s && !(!(n instanceof k) || !n.visible)) {
|
|
3140
|
+
if (!Dr(n)) {
|
|
3141
|
+
s = !0;
|
|
3142
|
+
return;
|
|
3143
|
+
}
|
|
3144
|
+
n.updateWorldMatrix(!0, !1), e.push({
|
|
3145
|
+
mesh: n,
|
|
3146
|
+
localMatrix: t.clone().multiply(n.matrixWorld)
|
|
3147
|
+
});
|
|
3148
|
+
}
|
|
3149
|
+
}), s ? [] : e;
|
|
3150
|
+
}
|
|
3151
|
+
function kr(i) {
|
|
3152
|
+
const e = new K();
|
|
3153
|
+
return i.forEach(({ mesh: t, localMatrix: s }) => {
|
|
3154
|
+
const n = t.geometry;
|
|
3155
|
+
n.boundingBox || n.computeBoundingBox(), n.boundingBox && (At.copy(n.boundingBox).applyMatrix4(s), e.union(At));
|
|
3156
|
+
}), e;
|
|
3157
|
+
}
|
|
3158
|
+
function ee(i) {
|
|
3159
|
+
const e = i;
|
|
3160
|
+
"needsUpdate" in e && (e.needsUpdate = !0);
|
|
3161
|
+
}
|
|
3162
|
+
function Ut(i, e = Pt) {
|
|
3163
|
+
let t = Math.max(Pt, e);
|
|
3164
|
+
for (; t < i; )
|
|
3165
|
+
t *= 2;
|
|
3166
|
+
return t;
|
|
3167
|
+
}
|
|
3168
|
+
function zr(i) {
|
|
3169
|
+
return i !== null && typeof i == "object" && Symbol.iterator in i;
|
|
3170
|
+
}
|
|
3171
|
+
class wi extends pe {
|
|
3172
|
+
isModelInstancedLayer = !0;
|
|
3173
|
+
type = "ModelInstancedLayer";
|
|
3174
|
+
#s = [];
|
|
3175
|
+
#a = /* @__PURE__ */ new Map();
|
|
3176
|
+
#t = /* @__PURE__ */ new Map();
|
|
3177
|
+
#e = /* @__PURE__ */ new Map();
|
|
3178
|
+
#r = !0;
|
|
3179
|
+
#n = !1;
|
|
3180
|
+
#o = !0;
|
|
3181
|
+
#c = Br;
|
|
3182
|
+
#l;
|
|
3183
|
+
#d;
|
|
3184
|
+
constructor(e = {}) {
|
|
3185
|
+
super(), this.name = e.name ?? "ModelInstances", this.#l = e.instanceKind ?? "", this.#d = e.getHitUserData ?? (() => ({}));
|
|
3186
|
+
}
|
|
3187
|
+
get instanceKind() {
|
|
3188
|
+
return this.#l;
|
|
3189
|
+
}
|
|
3190
|
+
getInstances() {
|
|
3191
|
+
const e = [];
|
|
3192
|
+
return this.#i((t) => e.push(t)), e;
|
|
3193
|
+
}
|
|
3194
|
+
getInstanceById(e) {
|
|
3195
|
+
return this.#w(), this.#e.get(e);
|
|
3196
|
+
}
|
|
3197
|
+
hasInstance(e) {
|
|
3198
|
+
return this.#w(), this.#e.has(e);
|
|
3199
|
+
}
|
|
3200
|
+
getInstanceCulling() {
|
|
3201
|
+
return {
|
|
3202
|
+
enabled: this.#n,
|
|
3203
|
+
frustum: this.#o,
|
|
3204
|
+
minScreenRadius: this.#c
|
|
3205
|
+
};
|
|
3206
|
+
}
|
|
3207
|
+
setInstanceCulling(e = {}) {
|
|
3208
|
+
let t = !1;
|
|
3209
|
+
if (e.enabled !== void 0 && this.#n !== e.enabled && (this.#n = e.enabled, t = !0), e.frustum !== void 0 && this.#o !== e.frustum && (this.#o = e.frustum, t = !0), e.minScreenRadius !== void 0) {
|
|
3210
|
+
const s = Math.max(0, e.minScreenRadius);
|
|
3211
|
+
Math.abs(this.#c - s) > H && (this.#c = s, t = !0);
|
|
3212
|
+
}
|
|
3213
|
+
return t && this.#s.forEach((s) => this.#I(s)), this;
|
|
3214
|
+
}
|
|
3215
|
+
setInstanceVisible(e) {
|
|
3216
|
+
return this.visible !== e && (this.visible = e), this.#i((t) => {
|
|
3217
|
+
t.setInstanceVisible(e);
|
|
3218
|
+
}), this;
|
|
3219
|
+
}
|
|
3220
|
+
setInstanceColor(e) {
|
|
3221
|
+
return this.#i((t) => {
|
|
3222
|
+
t.setInstanceColor(e);
|
|
3223
|
+
}), this;
|
|
3224
|
+
}
|
|
3225
|
+
resetInstanceColor() {
|
|
3226
|
+
return this.#i((e) => {
|
|
3227
|
+
e.resetInstanceColor();
|
|
3228
|
+
}), this;
|
|
3229
|
+
}
|
|
3230
|
+
setInstanceOpacity(e) {
|
|
3231
|
+
return this.#i((t) => {
|
|
3232
|
+
t.setInstanceOpacity(e);
|
|
3233
|
+
}), this;
|
|
3234
|
+
}
|
|
3235
|
+
setInstanceHighlight(e, t, s = !1) {
|
|
3236
|
+
return this.#i((n) => {
|
|
3237
|
+
n.setInstanceHighlight(e, t, s);
|
|
3238
|
+
}), this;
|
|
3239
|
+
}
|
|
3240
|
+
clearInstanceHighlight() {
|
|
3241
|
+
return this.#i((e) => {
|
|
3242
|
+
e.clearInstanceHighlight();
|
|
3243
|
+
}), this;
|
|
3244
|
+
}
|
|
3245
|
+
reserveBatch(e, t, s) {
|
|
3246
|
+
const n = Math.floor(s);
|
|
3247
|
+
return n <= 0 ? !1 : this.#u(e, t, n) !== null;
|
|
3248
|
+
}
|
|
3249
|
+
addInstance(e, t, s) {
|
|
3250
|
+
return this.addInstances(e, t, [s]);
|
|
3251
|
+
}
|
|
3252
|
+
addInstances(e, t, s) {
|
|
3253
|
+
if (s.length === 0) return !1;
|
|
3254
|
+
const n = this.#a.has(e), r = this.#u(e, t, s.length);
|
|
3255
|
+
if (!r) return !1;
|
|
3256
|
+
const a = [], o = /* @__PURE__ */ new Set();
|
|
3257
|
+
return s.forEach((c) => {
|
|
3258
|
+
o.has(c) || (o.add(c), this.#t.get(c) === r) || a.push(c);
|
|
3259
|
+
}), a.length === 0 ? !0 : this.#C(a) ? (a.forEach((c) => {
|
|
3260
|
+
const l = this.#t.get(c);
|
|
3261
|
+
l && l !== r && this.#v(l, c);
|
|
3262
|
+
}), this.#M(r, r.instances.length + a.length), a.forEach((c) => {
|
|
3263
|
+
c.setInstanceBounds(r.templateBounds), r.instances.push(c), this.#t.set(c, r), r.unsubscribeByInstance.set(
|
|
3264
|
+
c,
|
|
3265
|
+
c.onInstanceRenderDirty(() => {
|
|
3266
|
+
this.#g(), this.#y(r);
|
|
3267
|
+
})
|
|
3268
|
+
);
|
|
3269
|
+
}), this.#g(), this.#b(r), this.#y(r), !0) : (!n && r.instances.length === 0 && this.#m(r), !1);
|
|
3270
|
+
}
|
|
3271
|
+
removeInstance(e) {
|
|
3272
|
+
return this.removeInstances([e]) > 0;
|
|
3273
|
+
}
|
|
3274
|
+
removeInstances(e) {
|
|
3275
|
+
const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), n = typeof e == "string" || !zr(e) ? [e] : e;
|
|
3276
|
+
for (const a of n)
|
|
3277
|
+
typeof a == "string" ? t.add(a) : this.#t.has(a) && s.add(a);
|
|
3278
|
+
t.size > 0 && (this.#w(), t.forEach((a) => {
|
|
3279
|
+
const o = this.#e.get(a);
|
|
3280
|
+
o && s.add(o);
|
|
3281
|
+
}));
|
|
3282
|
+
let r = 0;
|
|
3283
|
+
return s.forEach((a) => {
|
|
3284
|
+
const o = this.#t.get(a);
|
|
3285
|
+
o && this.#v(o, a) && r++;
|
|
3286
|
+
}), r;
|
|
3287
|
+
}
|
|
3288
|
+
removeBatch(e) {
|
|
3289
|
+
const t = this.#a.get(e);
|
|
3290
|
+
return t ? (this.#m(t), !0) : !1;
|
|
3291
|
+
}
|
|
3292
|
+
clearBatches() {
|
|
3293
|
+
return [...this.#a.values()].forEach((e) => this.#m(e)), this;
|
|
3294
|
+
}
|
|
3295
|
+
#u(e, t, s) {
|
|
3296
|
+
const n = this.#a.get(e);
|
|
3297
|
+
if (n)
|
|
3298
|
+
return this.#M(n, s), n;
|
|
3299
|
+
if (t.animations?.length) return null;
|
|
3300
|
+
const r = Rr(t);
|
|
3301
|
+
if (r.length === 0) return null;
|
|
3302
|
+
const a = kr(r), o = new W();
|
|
3303
|
+
o.name = e, this.add(o);
|
|
3304
|
+
const c = {
|
|
3305
|
+
url: e,
|
|
3306
|
+
batch: o,
|
|
3307
|
+
templateMeshes: r,
|
|
3308
|
+
templateBounds: a,
|
|
3309
|
+
records: [],
|
|
3310
|
+
instances: [],
|
|
3311
|
+
unsubscribeByInstance: /* @__PURE__ */ new Map(),
|
|
3312
|
+
capacity: Ut(s)
|
|
3313
|
+
};
|
|
3314
|
+
return r.forEach(({ mesh: l, localMatrix: h }, d) => {
|
|
3315
|
+
const u = this.#h(c, l, h, d);
|
|
3316
|
+
c.records.push(u), this.#s.push(u);
|
|
3317
|
+
}), this.#a.set(e, c), this.#b(c), c;
|
|
3318
|
+
}
|
|
3319
|
+
#i(e) {
|
|
3320
|
+
const t = /* @__PURE__ */ new Set();
|
|
3321
|
+
this.#a.forEach((s) => {
|
|
3322
|
+
s.instances.forEach((n) => {
|
|
3323
|
+
t.has(n) || (t.add(n), e(n));
|
|
3324
|
+
});
|
|
3325
|
+
});
|
|
3326
|
+
}
|
|
3327
|
+
#h(e, t, s, n) {
|
|
3328
|
+
const r = new Je(new Float32Array(e.capacity * 4), 4), a = new Je(new Float32Array(e.capacity).fill(1), 1);
|
|
3329
|
+
r.setUsage(Te), a.setUsage(Te);
|
|
3330
|
+
const o = Pr(
|
|
3331
|
+
t.material,
|
|
3332
|
+
r,
|
|
3333
|
+
a
|
|
3334
|
+
), c = kt(o), l = kt(t.material).some(
|
|
3335
|
+
ls
|
|
3336
|
+
), h = new nn(t.geometry, o, e.capacity);
|
|
3337
|
+
h.instanceMatrix = new rn(e.capacity, 16), h.count = 0, h.name = t.name || `${e.url}#${n}`, h.castShadow = t.castShadow, h.receiveShadow = t.receiveShadow, h.frustumCulled = !0, h.matrixAutoUpdate = !1, h.instanceMatrix.setUsage(Te), h.userData.url = e.url;
|
|
3338
|
+
const d = new k(t.geometry, o);
|
|
3339
|
+
d.matrixAutoUpdate = !1;
|
|
3340
|
+
const u = {
|
|
3341
|
+
batchRecord: e,
|
|
3342
|
+
mesh: h,
|
|
3343
|
+
boundsTree: void 0,
|
|
3344
|
+
raycastMesh: d,
|
|
3345
|
+
localMatrix: s.clone(),
|
|
3346
|
+
fullBoundingSphere: new ne(),
|
|
3347
|
+
materials: c,
|
|
3348
|
+
hasSourceTransparency: l,
|
|
3349
|
+
colorAttribute: r,
|
|
3350
|
+
opacityAttribute: a,
|
|
3351
|
+
renderedInstances: [],
|
|
3352
|
+
visibleInstances: [],
|
|
3353
|
+
lastCameraMatrixWorldInverse: new R(),
|
|
3354
|
+
lastCameraProjectionMatrix: new R(),
|
|
3355
|
+
lastViewportHeight: 0,
|
|
3356
|
+
hasLastCameraState: !1,
|
|
3357
|
+
dirty: !0
|
|
3358
|
+
};
|
|
3359
|
+
h.userData.getInstanceObjectByRenderIndex = (x) => u.renderedInstances[x], h.userData.raycastAcceleration = "lazy";
|
|
3360
|
+
const p = h.raycast.bind(h);
|
|
3361
|
+
return h.raycast = (x, I) => {
|
|
3362
|
+
if (this.#E(u), !this.#p(u, x)) return;
|
|
3363
|
+
u.boundsTree === void 0 && (u.boundsTree = jt(u.mesh.geometry), u.mesh.userData.raycastAcceleration = u.boundsTree ? "three-mesh-bvh" : "default");
|
|
3364
|
+
const _ = I.length;
|
|
3365
|
+
u.boundsTree ? this.#f(u, x, I) : p(x, I);
|
|
3366
|
+
for (let C = _; C < I.length; ) {
|
|
3367
|
+
const y = I[C], w = y.instanceId;
|
|
3368
|
+
if (w === void 0) {
|
|
3369
|
+
C++;
|
|
3370
|
+
continue;
|
|
3371
|
+
}
|
|
3372
|
+
const g = u.renderedInstances[w];
|
|
3373
|
+
if (!g || !De(g)) {
|
|
3374
|
+
I.splice(C, 1);
|
|
3375
|
+
continue;
|
|
3376
|
+
}
|
|
3377
|
+
y.object = g, y.instanceObject = g, y.instanceObjectId = g.instanceId, y.instanceKind = g.instanceKind || this.#l, y.instanceName = g.instanceName, y.instanceIndex = w, Object.assign(y, this.#d(g, w)), C++;
|
|
3378
|
+
}
|
|
3379
|
+
}, h.onBeforeRender = (x, I, _) => this.#E(u, x, _), e.batch.add(h), u;
|
|
3380
|
+
}
|
|
3381
|
+
#p(e, t) {
|
|
3382
|
+
const { mesh: s } = e;
|
|
3383
|
+
return s.count === 0 ? !1 : (s.boundingSphere === null && s.computeBoundingSphere(), s.boundingSphere ? (Dt.copy(s.boundingSphere).applyMatrix4(s.matrixWorld), t.ray.intersectsSphere(Dt)) : !0);
|
|
3384
|
+
}
|
|
3385
|
+
#f(e, t, s) {
|
|
3386
|
+
const { mesh: n, boundsTree: r, raycastMesh: a } = e;
|
|
3387
|
+
if (!(!r || n.count === 0)) {
|
|
3388
|
+
a.geometry = n.geometry, a.material = n.material;
|
|
3389
|
+
for (let o = 0; o < n.count; o++)
|
|
3390
|
+
n.getMatrixAt(o, Lt), Nt.multiplyMatrices(n.matrixWorld, Lt), a.matrixWorld.copy(Nt), ge.length = 0, r.raycastObject3D(a, t, ge), ge.forEach((c) => {
|
|
3391
|
+
c.instanceId = o, c.object = n, s.push(c);
|
|
3392
|
+
}), ge.length = 0;
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
#M(e, t) {
|
|
3396
|
+
if (t <= e.capacity) return;
|
|
3397
|
+
e.capacity = Ut(t, e.capacity);
|
|
3398
|
+
const s = new Set(e.records);
|
|
3399
|
+
s.forEach((n) => this.#S(n)), this.#s = this.#s.filter((n) => !s.has(n)), e.records = e.templateMeshes.map(({ mesh: n, localMatrix: r }, a) => {
|
|
3400
|
+
const o = this.#h(e, n, r, a);
|
|
3401
|
+
return this.#s.push(o), o;
|
|
3402
|
+
}), this.#y(e);
|
|
3403
|
+
}
|
|
3404
|
+
#v(e, t) {
|
|
3405
|
+
const s = e.instances.indexOf(t);
|
|
3406
|
+
return s === -1 ? !1 : (e.instances.splice(s, 1), e.records.forEach((n) => n.visibleInstances.splice(s, 1)), this.#t.delete(t), this.#g(), e.unsubscribeByInstance.get(t)?.(), e.unsubscribeByInstance.delete(t), e.instances.length === 0 ? (this.#m(e), !0) : (this.#b(e), this.#y(e), !0));
|
|
3407
|
+
}
|
|
3408
|
+
#m(e) {
|
|
3409
|
+
e.unsubscribeByInstance.forEach((s) => s()), e.instances.forEach((s) => this.#t.delete(s)), e.unsubscribeByInstance.clear(), e.instances.length = 0, this.#g();
|
|
3410
|
+
const t = new Set(e.records);
|
|
3411
|
+
t.forEach((s) => this.#S(s)), this.#s = this.#s.filter((s) => !t.has(s)), e.records.length = 0, e.templateMeshes.length = 0, this.#a.delete(e.url), this.remove(e.batch);
|
|
3412
|
+
}
|
|
3413
|
+
#S(e) {
|
|
3414
|
+
e.batchRecord.batch.remove(e.mesh), e.mesh.dispose(), e.materials.forEach((t) => t.dispose());
|
|
3415
|
+
}
|
|
3416
|
+
#b(e) {
|
|
3417
|
+
Object.assign(e.batch.userData, {
|
|
3418
|
+
url: e.url,
|
|
3419
|
+
count: e.instances.length,
|
|
3420
|
+
capacity: e.capacity,
|
|
3421
|
+
instanceKind: this.#l
|
|
3422
|
+
}), delete e.batch.userData.sceneInstances, delete e.batch.userData.facilities, e.records.forEach((t) => {
|
|
3423
|
+
delete t.mesh.userData.instances;
|
|
3424
|
+
});
|
|
3425
|
+
}
|
|
3426
|
+
#C(e) {
|
|
3427
|
+
const t = new Set(e), s = /* @__PURE__ */ new Map();
|
|
3428
|
+
for (const r of e) {
|
|
3429
|
+
const { instanceId: a } = r;
|
|
3430
|
+
if (!a) continue;
|
|
3431
|
+
const o = s.get(a);
|
|
3432
|
+
if (o && o !== r) return !1;
|
|
3433
|
+
s.set(a, r);
|
|
3434
|
+
}
|
|
3435
|
+
let n = !0;
|
|
3436
|
+
return s.forEach((r, a) => {
|
|
3437
|
+
n && this.#i((o) => {
|
|
3438
|
+
!n || t.has(o) || o.instanceId === a && (n = !1);
|
|
3439
|
+
});
|
|
3440
|
+
}), n;
|
|
3441
|
+
}
|
|
3442
|
+
#w() {
|
|
3443
|
+
if (!this.#r) return;
|
|
3444
|
+
this.#e.clear();
|
|
3445
|
+
const e = /* @__PURE__ */ new Set();
|
|
3446
|
+
this.#i((t) => {
|
|
3447
|
+
const { instanceId: s } = t;
|
|
3448
|
+
if (!s || e.has(s)) return;
|
|
3449
|
+
const n = this.#e.get(s);
|
|
3450
|
+
if (n && n !== t) {
|
|
3451
|
+
this.#e.delete(s), e.add(s);
|
|
3452
|
+
return;
|
|
3453
|
+
}
|
|
3454
|
+
this.#e.set(s, t);
|
|
3455
|
+
}), this.#r = !1;
|
|
3456
|
+
}
|
|
3457
|
+
#g() {
|
|
3458
|
+
this.#r = !0;
|
|
3459
|
+
}
|
|
3460
|
+
#y(e) {
|
|
3461
|
+
e.records.forEach((t) => this.#I(t));
|
|
3462
|
+
}
|
|
3463
|
+
#I(e) {
|
|
3464
|
+
e.dirty = !0, e.hasLastCameraState = !1, e.mesh.visible = !0, e.mesh.frustumCulled = !1, ee(e.batchRecord.batch);
|
|
3465
|
+
}
|
|
3466
|
+
#E(e, t, s) {
|
|
3467
|
+
const n = this.#O(t), r = this.#B(e, s, n);
|
|
3468
|
+
!e.dirty && !this.#A(e) && !r || this.#N(e, s, n);
|
|
3469
|
+
}
|
|
3470
|
+
#A(e) {
|
|
3471
|
+
const { instances: t } = e.batchRecord;
|
|
3472
|
+
for (let s = 0; s < t.length; s++)
|
|
3473
|
+
if (e.visibleInstances[s] !== De(t[s]))
|
|
3474
|
+
return e.dirty = !0, ee(e.batchRecord.batch), !0;
|
|
3475
|
+
return !1;
|
|
3476
|
+
}
|
|
3477
|
+
#O(e) {
|
|
3478
|
+
return e?.getDrawingBufferSize ? (e.getDrawingBufferSize(_t), _t.y) : 0;
|
|
3479
|
+
}
|
|
3480
|
+
#B(e, t, s) {
|
|
3481
|
+
return this.#x(t, s) ? e.hasLastCameraState ? !Rt(e.lastCameraMatrixWorldInverse, t.matrixWorldInverse) || !Rt(e.lastCameraProjectionMatrix, t.projectionMatrix) || Math.abs(e.lastViewportHeight - s) > H : !0 : !1;
|
|
3482
|
+
}
|
|
3483
|
+
#x(e, t) {
|
|
3484
|
+
return this.#n && e !== void 0 && (this.#o || this.#c > 0 && t > 0);
|
|
3485
|
+
}
|
|
3486
|
+
#_(e, t) {
|
|
3487
|
+
if (!this.#x(e, t)) return null;
|
|
3488
|
+
let s = null;
|
|
3489
|
+
return this.#o && (Ct.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse), s = Or.setFromProjectionMatrix(Ct)), { camera: e, frustum: s, viewportHeight: t };
|
|
3490
|
+
}
|
|
3491
|
+
#T(e, t) {
|
|
3492
|
+
return t ? t.frustum && !t.frustum.intersectsSphere(e) ? !1 : this.#c <= 0 || t.viewportHeight <= 0 ? !0 : this.#L(e, t.camera, t.viewportHeight) >= this.#c : !0;
|
|
3493
|
+
}
|
|
3494
|
+
#L(e, t, s) {
|
|
3495
|
+
const n = Math.abs(t.projectionMatrix.elements[5]);
|
|
3496
|
+
if (n <= H) return 1 / 0;
|
|
3497
|
+
if (t.isOrthographicCamera)
|
|
3498
|
+
return e.radius * n * s * 0.5;
|
|
3499
|
+
Tt.copy(e.center).applyMatrix4(t.matrixWorldInverse);
|
|
3500
|
+
const r = -Tt.z;
|
|
3501
|
+
return r <= H ? 1 / 0 : e.radius * n * s * 0.5 / r;
|
|
3502
|
+
}
|
|
3503
|
+
#N(e, t, s = 0) {
|
|
3504
|
+
this.updateWorldMatrix(!0, !1), It.copy(this.matrixWorld).invert();
|
|
3505
|
+
const n = e.mesh.instanceMatrix.array, r = e.colorAttribute.array, a = e.opacityAttribute.array, o = e.mesh.geometry;
|
|
3506
|
+
let c = !1, l = !1, h = !1, d = 0, u = 0, p = !1;
|
|
3507
|
+
const x = e.mesh.count, I = this.#_(t, s);
|
|
3508
|
+
o.boundingSphere || o.computeBoundingSphere(), e.fullBoundingSphere.makeEmpty(), e.renderedInstances.length = 0, e.batchRecord.instances.forEach((y, w) => {
|
|
3509
|
+
const g = De(y);
|
|
3510
|
+
e.visibleInstances[w] = g, y.updateWorldMatrix(!0, !1), me.multiplyMatrices(It, y.matrixWorld).multiply(e.localMatrix);
|
|
3511
|
+
const m = y.getInstanceOpacity();
|
|
3512
|
+
if (!(g && m > H) || (u++, o.boundingSphere && (Ot.copy(o.boundingSphere).applyMatrix4(me), e.fullBoundingSphere.union(Ot), I && (Et.multiplyMatrices(y.matrixWorld, e.localMatrix), Bt.copy(o.boundingSphere).applyMatrix4(Et), !this.#T(Bt, I)))))
|
|
3513
|
+
return;
|
|
3514
|
+
const b = d, S = b * 16;
|
|
3515
|
+
_r(me, n, S) || (e.mesh.setMatrixAt(b, me), c = !0), Z.copy(y.getInstanceColor(Z));
|
|
3516
|
+
const A = y.getInstanceColorMode(), v = b * 4;
|
|
3517
|
+
Tr(Z, A, r, v) || (e.colorAttribute.setXYZW(b, Z.r, Z.g, Z.b, A), l = !0), m < cs && (p = !0), Math.abs(m - a[b]) > H && (e.opacityAttribute.setX(b, m), h = !0), e.renderedInstances[b] = y, d++;
|
|
3518
|
+
}), e.mesh.count = d, x !== d && (c = !0, l = !0, h = !0, ee(e.batchRecord.batch));
|
|
3519
|
+
const _ = u > 0;
|
|
3520
|
+
e.mesh.visible !== _ && (e.mesh.visible = _, ee(e.batchRecord.batch)), e.mesh.frustumCulled !== !0 && (e.mesh.frustumCulled = !0, ee(e.batchRecord.batch)), c && (e.mesh.instanceMatrix.needsUpdate = !0), l && (e.colorAttribute.needsUpdate = !0), h && (e.opacityAttribute.needsUpdate = !0), e.mesh.boundingSphere === null && (e.mesh.boundingSphere = new ne()), e.mesh.boundingSphere.copy(e.fullBoundingSphere);
|
|
3521
|
+
const C = e.hasSourceTransparency || p;
|
|
3522
|
+
e.materials.forEach((y) => {
|
|
3523
|
+
y.transparent !== C && (y.transparent = C, y.needsUpdate = !0, ee(e.batchRecord.batch));
|
|
3524
|
+
}), t && this.#x(t, s) ? (e.lastCameraMatrixWorldInverse.copy(t.matrixWorldInverse), e.lastCameraProjectionMatrix.copy(t.projectionMatrix), e.lastViewportHeight = s, e.hasLastCameraState = !0) : e.hasLastCameraState = !1, e.dirty = !1;
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
const Ur = "0.0.31";
|
|
3528
|
+
typeof window < "u" && (window.__USPACE__ = { version: Ur });
|
|
2803
3529
|
export {
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
3530
|
+
mi as AnnotationManager,
|
|
3531
|
+
pe as BaseGroup,
|
|
3532
|
+
X as BaseMesh,
|
|
3533
|
+
Kn as BaseSprite,
|
|
3534
|
+
Li as CSS2DObject,
|
|
3535
|
+
Di as CSS3DObject,
|
|
3536
|
+
Pi as CSS3DSprite,
|
|
3537
|
+
vi as CSSRenderer,
|
|
3538
|
+
Si as CameraControls,
|
|
3539
|
+
li as CircleMesh,
|
|
3540
|
+
pi as ClippingTool,
|
|
3541
|
+
bi as EditableGeometryBatchLayer,
|
|
3542
|
+
Yt as ExtrudeMesh,
|
|
3543
|
+
wt as INSTANCE_COLOR_MODE_NONE,
|
|
3544
|
+
Ne as INSTANCE_COLOR_MODE_OVERRIDE,
|
|
3545
|
+
lr as INSTANCE_COLOR_MODE_TINT,
|
|
3546
|
+
gi as InstanceObject,
|
|
3547
|
+
Ii as InteractionEvent,
|
|
3548
|
+
Ei as InteractionManager,
|
|
3549
|
+
ri as LightManager,
|
|
3550
|
+
se as MaterialEffects,
|
|
3551
|
+
fi as MeasureTool,
|
|
3552
|
+
te as Model,
|
|
3553
|
+
$n as ModelDecodeWorkerClient,
|
|
3554
|
+
ve as ModelDecodeWorkerUnavailableError,
|
|
3555
|
+
wi as ModelInstancedLayer,
|
|
3556
|
+
V as ModelLoaderManager,
|
|
3557
|
+
Ci as ObjectManager,
|
|
3558
|
+
Q as ObjectUtils,
|
|
3559
|
+
ci as PlaneMesh,
|
|
3560
|
+
oi as Poi,
|
|
3561
|
+
Ai as RenderPipeline,
|
|
3562
|
+
Oi as RoomEnvironment,
|
|
3563
|
+
ct as SBMLoader,
|
|
3564
|
+
at as SBMXLoader,
|
|
3565
|
+
ni as SceneManager,
|
|
3566
|
+
si as Selection,
|
|
3567
|
+
Xt as ShapeMesh,
|
|
3568
|
+
qn as SphereMesh,
|
|
3569
|
+
hi as TSLEffects,
|
|
3570
|
+
ii as TextureLoaderManager,
|
|
3571
|
+
ai as Topology,
|
|
3572
|
+
lt as TubeMesh,
|
|
3573
|
+
ir as Tween,
|
|
3574
|
+
Bi as Viewer,
|
|
3575
|
+
_i as enableMeshBVHRaycast,
|
|
3576
|
+
jt as getGeometryBoundsTree,
|
|
3577
|
+
yi as isInstanceObject,
|
|
3578
|
+
di as reinterpretType,
|
|
3579
|
+
Hn as reuseDecodedImageContent,
|
|
3580
|
+
ui as tweenAnimation,
|
|
3581
|
+
Ur as version
|
|
2844
3582
|
};
|