@shopware-ag/dive 2.2.17 → 2.2.18
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/build/chunks/{AssetCache-CpKF1NzV.cjs → AssetCache-BElKTasn.cjs} +1 -1
- package/build/chunks/{AssetCache-Ba-m-7zA.mjs → AssetCache-DbUJFLZt.mjs} +1 -1
- package/build/chunks/{AssetLoader-B03j7xvX.cjs → AssetLoader-CT_t_ZfO.cjs} +1 -1
- package/build/chunks/{AssetLoader-C2NGPDLw.mjs → AssetLoader-D5zuGw5p.mjs} +2 -2
- package/build/chunks/FileTypes-Bq4uWglF.mjs +2105 -0
- package/build/chunks/FileTypes-Vbu3ti7s.cjs +33 -0
- package/build/chunks/{SelectTool-ClSKQ893.cjs → SelectTool-4zYuuCRL.cjs} +1 -1
- package/build/chunks/{SelectTool-D-StWurg.mjs → SelectTool-PaTy0iER.mjs} +1 -1
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +50 -48
- package/build/engine/Dive.d.ts +6 -0
- package/build/engine/environment/Environment.d.ts +133 -0
- package/build/engine/index.d.ts +1 -0
- package/build/engine/renderer/Renderer.d.ts +3 -0
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +1 -1
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +1 -1
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.mjs +1 -1
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +16 -24
- package/build/plugins/quickview/src/QuickView.d.ts +1 -3
- package/build/plugins/quickview/types/QuickViewSettings.d.ts +0 -5
- package/build/plugins/state/index.cjs +1 -1
- package/build/plugins/state/index.mjs +2 -2
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +2 -2
- package/package.json +6 -8
- package/build/chunks/FileTypes-D5A0_pG_.cjs +0 -29
- package/build/chunks/FileTypes-Djlx9wth.mjs +0 -1804
- package/build/chunks/HDREnvorinment-CP2Uvq4_.cjs +0 -5
- package/build/chunks/HDREnvorinment-DKzwfsKr.mjs +0 -257
- package/build/plugins/hdr/index.cjs +0 -1
- package/build/plugins/hdr/index.d.ts +0 -2
- package/build/plugins/hdr/index.mjs +0 -5
- package/build/plugins/hdr/src/HDREnvorinment.d.ts +0 -35
- package/build/plugins/hdr/src/index.d.ts +0 -1
- package/build/plugins/hdr/types/HDREnvironmentSettings.d.ts +0 -44
- package/build/plugins/hdr/types/index.d.ts +0 -1
|
@@ -1,1804 +0,0 @@
|
|
|
1
|
-
var q = Object.defineProperty;
|
|
2
|
-
var K = (o, s, t) => s in o ? q(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
|
|
3
|
-
var i = (o, s, t) => K(o, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
-
import { WebGLRenderer as Q, PCFSoftShadowMap as J, PCFShadowMap as $, BasicShadowMap as j, MathUtils as I, Object3D as g, AmbientLight as tt, PointLight as et, SphereGeometry as T, MeshBasicMaterial as F, FrontSide as U, Mesh as S, HemisphereLight as it, DirectionalLight as st, Vector3 as h, Box3 as f, Box3Helper as at, Sphere as nt, MeshStandardMaterial as k, Raycaster as rt, CylinderGeometry as ot, BufferGeometry as Y, BufferAttribute as A, BoxGeometry as M, ConeGeometry as ht, LineDashedMaterial as lt, Line as dt, PlaneGeometry as ct, Color as E, GridHelper as ut, Scene as pt, TOUCH as p, MOUSE as u, EventDispatcher as mt, Spherical as C, Vector2 as c, Quaternion as O } from "three";
|
|
5
|
-
import { P as m, U as ft, H as gt, a as _t, D as z } from "./PerspectiveCamera-BFzE2TQU.mjs";
|
|
6
|
-
class wt {
|
|
7
|
-
constructor() {
|
|
8
|
-
i(this, "isDIVEClock", !0);
|
|
9
|
-
i(this, "_lastTime", 0);
|
|
10
|
-
i(this, "_isRunning", !1);
|
|
11
|
-
i(this, "_tickers", []);
|
|
12
|
-
}
|
|
13
|
-
start() {
|
|
14
|
-
this._isRunning || (this._isRunning = !0, this._lastTime = performance.now(), requestAnimationFrame(this._tick.bind(this)));
|
|
15
|
-
}
|
|
16
|
-
stop() {
|
|
17
|
-
this._isRunning = !1;
|
|
18
|
-
}
|
|
19
|
-
addTicker(s) {
|
|
20
|
-
this._tickers.find((t) => t.uuid === s.uuid) || this._tickers.push(s);
|
|
21
|
-
}
|
|
22
|
-
hasTicker(s) {
|
|
23
|
-
return this._tickers.find((t) => t.uuid === s.uuid) !== void 0;
|
|
24
|
-
}
|
|
25
|
-
removeTicker(s) {
|
|
26
|
-
const t = this._tickers.findIndex((e) => e.uuid === s.uuid);
|
|
27
|
-
t !== -1 && this._tickers.splice(t, 1);
|
|
28
|
-
}
|
|
29
|
-
dispose() {
|
|
30
|
-
this.stop(), this._tickers = [], this._isRunning = !1, this._lastTime = 0;
|
|
31
|
-
}
|
|
32
|
-
_tick(s) {
|
|
33
|
-
if (!this._isRunning) return;
|
|
34
|
-
const t = (s - this._lastTime) / 1e3;
|
|
35
|
-
this._lastTime = s, this._tickers.forEach((e) => e.tick(t)), requestAnimationFrame(this._tick.bind(this));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const W = {
|
|
39
|
-
canvas: void 0,
|
|
40
|
-
antialias: !0,
|
|
41
|
-
alpha: !0,
|
|
42
|
-
powerPreference: "high-performance",
|
|
43
|
-
precision: "highp",
|
|
44
|
-
stencil: !1,
|
|
45
|
-
depth: !0,
|
|
46
|
-
logarithmicDepthBuffer: !0,
|
|
47
|
-
shadows: !0,
|
|
48
|
-
shadowQuality: "high"
|
|
49
|
-
};
|
|
50
|
-
class H {
|
|
51
|
-
constructor(s, t, e) {
|
|
52
|
-
i(this, "isDIVERenderer", !0);
|
|
53
|
-
i(this, "_webglrenderer");
|
|
54
|
-
i(this, "_settings");
|
|
55
|
-
this._scene = s, this._camera = t, this._settings = {
|
|
56
|
-
...W,
|
|
57
|
-
...e ?? {}
|
|
58
|
-
}, this._webglrenderer = this._createWebGLRenderer();
|
|
59
|
-
}
|
|
60
|
-
get webglrenderer() {
|
|
61
|
-
return this._webglrenderer;
|
|
62
|
-
}
|
|
63
|
-
get canvas() {
|
|
64
|
-
return this._webglrenderer.domElement;
|
|
65
|
-
}
|
|
66
|
-
render() {
|
|
67
|
-
this._webglrenderer.render(this._scene, this._camera);
|
|
68
|
-
}
|
|
69
|
-
onResize(s, t) {
|
|
70
|
-
this._webglrenderer.setSize(s, t, !1);
|
|
71
|
-
}
|
|
72
|
-
dispose() {
|
|
73
|
-
this._webglrenderer.dispose();
|
|
74
|
-
}
|
|
75
|
-
setCanvas(s) {
|
|
76
|
-
this._webglrenderer.dispose(), this._settings.canvas = s, this._webglrenderer = this._createWebGLRenderer();
|
|
77
|
-
}
|
|
78
|
-
_createWebGLRenderer() {
|
|
79
|
-
const s = new Q(this._settings);
|
|
80
|
-
return s.shadowMap.enabled = this._settings.shadows, s.shadowMap.type = this._settings.shadowQuality === "high" ? J : this._settings.shadowQuality === "medium" ? $ : j, s.setPixelRatio(window.devicePixelRatio), s;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const Gt = H;
|
|
84
|
-
class yt {
|
|
85
|
-
constructor(s, t) {
|
|
86
|
-
i(this, "isDIVEResizeManager", !0);
|
|
87
|
-
i(this, "_resizeObserver");
|
|
88
|
-
i(this, "_width", 0);
|
|
89
|
-
i(this, "_height", 0);
|
|
90
|
-
this._renderer = s, this._camera = t, this._resizeObserver = new ResizeObserver((e) => {
|
|
91
|
-
const a = e[0], { width: n, height: r } = a.contentRect;
|
|
92
|
-
n === this._width && r === this._height || (this._camera.onResize(n, r), this._renderer.onResize(n, r), this._width = n, this._height = r, this._renderer.render());
|
|
93
|
-
}), this._observeCanvas(this._renderer.canvas);
|
|
94
|
-
}
|
|
95
|
-
setCanvas(s) {
|
|
96
|
-
this._resizeObserver.disconnect(), this._observeCanvas(s);
|
|
97
|
-
const { width: t, height: e } = s.getBoundingClientRect();
|
|
98
|
-
this._camera.onResize(t, e), this._renderer.onResize(t, e), this._width = t, this._height = e, this._renderer.render();
|
|
99
|
-
}
|
|
100
|
-
dispose() {
|
|
101
|
-
this._resizeObserver.disconnect();
|
|
102
|
-
}
|
|
103
|
-
_observeCanvas(s) {
|
|
104
|
-
if (s.parentElement)
|
|
105
|
-
this._resizeObserver.observe(s.parentElement);
|
|
106
|
-
else {
|
|
107
|
-
const t = setInterval(() => {
|
|
108
|
-
s.parentElement && (this._resizeObserver.observe(s.parentElement), clearInterval(t));
|
|
109
|
-
}, 16);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
class B {
|
|
114
|
-
constructor(s, t, e) {
|
|
115
|
-
i(this, "isDIVEView", !0);
|
|
116
|
-
i(this, "uuid", I.generateUUID());
|
|
117
|
-
i(this, "_paused", !1);
|
|
118
|
-
i(this, "_renderer");
|
|
119
|
-
i(this, "_resizeManager");
|
|
120
|
-
this._scene = s, this._camera = t, this._settings = e, this._renderer = new H(
|
|
121
|
-
this._scene,
|
|
122
|
-
this._camera,
|
|
123
|
-
this._settings
|
|
124
|
-
), this._resizeManager = new yt(
|
|
125
|
-
this._renderer,
|
|
126
|
-
this._camera
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
get renderer() {
|
|
130
|
-
return this._renderer;
|
|
131
|
-
}
|
|
132
|
-
get camera() {
|
|
133
|
-
return this._camera;
|
|
134
|
-
}
|
|
135
|
-
get canvas() {
|
|
136
|
-
return this._renderer.canvas;
|
|
137
|
-
}
|
|
138
|
-
tick() {
|
|
139
|
-
this._paused || this._renderer.render();
|
|
140
|
-
}
|
|
141
|
-
dispose() {
|
|
142
|
-
this._resizeManager.dispose(), this._renderer.dispose();
|
|
143
|
-
}
|
|
144
|
-
onResize(s, t) {
|
|
145
|
-
this._renderer.onResize(s, t), this._camera.onResize(s, t);
|
|
146
|
-
}
|
|
147
|
-
setCanvas(s) {
|
|
148
|
-
this._renderer.setCanvas(s), this._resizeManager.setCanvas(s), this.onResize(
|
|
149
|
-
this._renderer.canvas.clientWidth,
|
|
150
|
-
this._renderer.canvas.clientHeight
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
// TODO: add methods to individually pause and resume the view
|
|
154
|
-
pause() {
|
|
155
|
-
this._paused = !0;
|
|
156
|
-
}
|
|
157
|
-
resume() {
|
|
158
|
-
this._paused = !1;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
class bt extends g {
|
|
162
|
-
constructor() {
|
|
163
|
-
super();
|
|
164
|
-
i(this, "isDIVELight", !0);
|
|
165
|
-
i(this, "isDIVEAmbientLight", !0);
|
|
166
|
-
i(this, "isSelectable", !0);
|
|
167
|
-
i(this, "_light");
|
|
168
|
-
this.name = "DIVEAmbientLight", this._light = new tt(16777215, 1), this._light.layers.mask = m, this.add(this._light);
|
|
169
|
-
}
|
|
170
|
-
setColor(t) {
|
|
171
|
-
this._light.color = t;
|
|
172
|
-
}
|
|
173
|
-
setIntensity(t) {
|
|
174
|
-
this._light.intensity = t;
|
|
175
|
-
}
|
|
176
|
-
setEnabled(t) {
|
|
177
|
-
this._light.visible = t;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
class Dt extends g {
|
|
181
|
-
constructor() {
|
|
182
|
-
super();
|
|
183
|
-
i(this, "isDIVELight", !0);
|
|
184
|
-
i(this, "isDIVEPointLight", !0);
|
|
185
|
-
i(this, "isMovable", !0);
|
|
186
|
-
i(this, "isSelectable", !0);
|
|
187
|
-
i(this, "gizmo", null);
|
|
188
|
-
i(this, "light");
|
|
189
|
-
i(this, "mesh");
|
|
190
|
-
this.name = "DIVEPointLight", this.light = new et(16777215, 1), this.light.layers.mask = m, this.light.castShadow = !0, this.light.shadow.mapSize.width = 512, this.light.shadow.mapSize.height = 512, this.add(this.light);
|
|
191
|
-
const t = 0.1, e = new T(
|
|
192
|
-
t,
|
|
193
|
-
t * 320,
|
|
194
|
-
t * 320
|
|
195
|
-
), a = new F({
|
|
196
|
-
color: this.light.color,
|
|
197
|
-
transparent: !0,
|
|
198
|
-
opacity: 0.8,
|
|
199
|
-
side: U
|
|
200
|
-
});
|
|
201
|
-
this.mesh = new S(e, a), this.mesh.layers.mask = ft, this.add(this.mesh);
|
|
202
|
-
}
|
|
203
|
-
setColor(t) {
|
|
204
|
-
this.light.color = t, this.mesh.material.color = t;
|
|
205
|
-
}
|
|
206
|
-
setIntensity(t) {
|
|
207
|
-
this.light.intensity = t, this.mesh.material.opacity = t > 0.8 ? 0.8 : t * 0.8;
|
|
208
|
-
}
|
|
209
|
-
setEnabled(t) {
|
|
210
|
-
this.light.visible = t;
|
|
211
|
-
}
|
|
212
|
-
onMove() {
|
|
213
|
-
import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
214
|
-
var e;
|
|
215
|
-
(e = t.get(this.userData.id)) == null || e.performAction("UPDATE_OBJECT", {
|
|
216
|
-
id: this.userData.id,
|
|
217
|
-
position: this.position
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
onSelect() {
|
|
222
|
-
import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
223
|
-
var e;
|
|
224
|
-
(e = t.get(this.userData.id)) == null || e.performAction("SELECT_OBJECT", {
|
|
225
|
-
id: this.userData.id
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
onDeselect() {
|
|
230
|
-
import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
231
|
-
var e;
|
|
232
|
-
(e = t.get(this.userData.id)) == null || e.performAction("DESELECT_OBJECT", {
|
|
233
|
-
id: this.userData.id
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
class Et extends g {
|
|
239
|
-
constructor() {
|
|
240
|
-
super();
|
|
241
|
-
i(this, "isDIVELight", !0);
|
|
242
|
-
i(this, "isDIVESceneLight", !0);
|
|
243
|
-
i(this, "isSelectable", !0);
|
|
244
|
-
i(this, "_hemiLight");
|
|
245
|
-
i(this, "_dirLight");
|
|
246
|
-
this.name = "DIVESceneLight", this._hemiLight = new it(16777215, 16777215, 2), this._hemiLight.layers.mask = m, this._hemiLight.position.set(0, 50, 0), this._hemiLight.visible = !0, this.add(this._hemiLight), this._dirLight = new st(16777215, 3), this._dirLight.layers.mask = m, this._dirLight.position.set(1, 1.75, 1), this._dirLight.position.multiplyScalar(30), this._dirLight.castShadow = !0, this._dirLight.visible = !0, this._dirLight.shadow.mapSize.width = 2048, this._dirLight.shadow.mapSize.height = 2048;
|
|
247
|
-
const t = 5;
|
|
248
|
-
this._dirLight.shadow.camera.left = -5, this._dirLight.shadow.camera.right = t, this._dirLight.shadow.camera.top = t, this._dirLight.shadow.camera.bottom = -5, this._dirLight.shadow.camera.far = 3500, this.add(this._dirLight);
|
|
249
|
-
}
|
|
250
|
-
setColor(t) {
|
|
251
|
-
this._hemiLight.color = t, this._dirLight.color = t;
|
|
252
|
-
}
|
|
253
|
-
setIntensity(t) {
|
|
254
|
-
this._hemiLight.intensity = t * 2, this._dirLight.intensity = t * 3;
|
|
255
|
-
}
|
|
256
|
-
setEnabled(t) {
|
|
257
|
-
this._hemiLight.visible = t, this._dirLight.visible = t;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
const Z = (o) => o.parent ? Z(o.parent) : o;
|
|
261
|
-
class x extends g {
|
|
262
|
-
constructor() {
|
|
263
|
-
super();
|
|
264
|
-
i(this, "isSelectable", !0);
|
|
265
|
-
i(this, "isMovable", !0);
|
|
266
|
-
i(this, "isDIVENode", !0);
|
|
267
|
-
i(this, "gizmo", null);
|
|
268
|
-
i(this, "_positionWorldBuffer");
|
|
269
|
-
i(this, "_boundingBox");
|
|
270
|
-
this.layers.mask = m, this._positionWorldBuffer = new h(), this._boundingBox = new f();
|
|
271
|
-
}
|
|
272
|
-
setPosition(t) {
|
|
273
|
-
if (!this.parent) {
|
|
274
|
-
this.position.set(t.x, t.y, t.z);
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
const e = new h(t.x, t.y, t.z);
|
|
278
|
-
this.position.copy(this.parent.worldToLocal(e)), "isDIVEGroup" in this.parent && this.parent.updateLineTo(this);
|
|
279
|
-
}
|
|
280
|
-
setRotation(t) {
|
|
281
|
-
this.rotation.set(t.x, t.y, t.z);
|
|
282
|
-
}
|
|
283
|
-
setScale(t) {
|
|
284
|
-
this.scale.set(t.x, t.y, t.z);
|
|
285
|
-
}
|
|
286
|
-
setVisibility(t) {
|
|
287
|
-
this.visible = t;
|
|
288
|
-
}
|
|
289
|
-
setToWorldOrigin() {
|
|
290
|
-
this.position.set(0, 0, 0), import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
291
|
-
var e;
|
|
292
|
-
(e = t.get(this.userData.id)) == null || e.performAction("UPDATE_OBJECT", {
|
|
293
|
-
id: this.userData.id,
|
|
294
|
-
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
295
|
-
rotation: this.rotation,
|
|
296
|
-
scale: this.scale
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Can be called when the object is moved from a foreign object (gizmo, parent, etc.) to update the object's position.
|
|
302
|
-
*/
|
|
303
|
-
onMove() {
|
|
304
|
-
import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
305
|
-
var e;
|
|
306
|
-
(e = t.get(this.userData.id)) == null || e.performAction("UPDATE_OBJECT", {
|
|
307
|
-
id: this.userData.id,
|
|
308
|
-
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
309
|
-
rotation: this.rotation,
|
|
310
|
-
scale: this.scale
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
onSelect() {
|
|
315
|
-
import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
316
|
-
var e;
|
|
317
|
-
(e = t.get(this.userData.id)) == null || e.performAction("SELECT_OBJECT", {
|
|
318
|
-
id: this.userData.id
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
onDeselect() {
|
|
323
|
-
import("../plugins/state/index.mjs").then(({ State: t }) => {
|
|
324
|
-
var e;
|
|
325
|
-
(e = t.get(this.userData.id)) == null || e.performAction("DESELECT_OBJECT", {
|
|
326
|
-
id: this.userData.id
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
class L extends x {
|
|
332
|
-
/**
|
|
333
|
-
* Creates a new BoundingBox instance for the specified 3D object.
|
|
334
|
-
*
|
|
335
|
-
* The constructor computes both a bounding box and bounding sphere for the given object.
|
|
336
|
-
* It handles complex objects with multiple meshes and nested transformations.
|
|
337
|
-
*
|
|
338
|
-
* @param object - The 3D object to compute bounding volumes for
|
|
339
|
-
* @param axisAligned - Whether to create an axis-aligned bounding box (true) or oriented bounding box (false). Defaults to false.
|
|
340
|
-
* @param wireframeColor - The color for the wireframe helpers. Can be a hex number or ColorRepresentation. Defaults to green (0x00ff00).
|
|
341
|
-
*
|
|
342
|
-
* @example
|
|
343
|
-
* ```typescript
|
|
344
|
-
* // Create an oriented bounding box (aligned with object's rotation)
|
|
345
|
-
* const obb = new BoundingBox(mesh, false, 0x00ff00);
|
|
346
|
-
*
|
|
347
|
-
* // Create an axis-aligned bounding box (aligned with world coordinates)
|
|
348
|
-
* const aabb = new BoundingBox(mesh, true, 0xff0000);
|
|
349
|
-
*
|
|
350
|
-
* // Use default green color
|
|
351
|
-
* const defaultBox = new BoundingBox(mesh);
|
|
352
|
-
* ```
|
|
353
|
-
*/
|
|
354
|
-
constructor(t, e = !1, a = 65280) {
|
|
355
|
-
super();
|
|
356
|
-
/** The computed bounding box (Box3) */
|
|
357
|
-
i(this, "_box");
|
|
358
|
-
/** The computed bounding sphere (Sphere) */
|
|
359
|
-
i(this, "_sphere");
|
|
360
|
-
/** The center point of the bounding box */
|
|
361
|
-
i(this, "_center");
|
|
362
|
-
/** The radius of the bounding sphere */
|
|
363
|
-
i(this, "_radius");
|
|
364
|
-
/** Visual helper for the bounding box wireframe */
|
|
365
|
-
i(this, "_boxHelper");
|
|
366
|
-
/** Visual helper for the bounding sphere wireframe */
|
|
367
|
-
i(this, "_sphereHelper");
|
|
368
|
-
/** The dimensions (width, height, depth) of the bounding box */
|
|
369
|
-
i(this, "_size");
|
|
370
|
-
const n = new f();
|
|
371
|
-
e ? n.setFromObject(t) : (t.updateWorldMatrix(!0, !0), t.traverse((l) => {
|
|
372
|
-
if (!("isMesh" in l) || !l.isMesh) return;
|
|
373
|
-
const d = l;
|
|
374
|
-
d.geometry.computeBoundingBox(), d.geometry.boundingBox && n.union(
|
|
375
|
-
d.geometry.boundingBox.clone().applyMatrix4(d.matrixWorld)
|
|
376
|
-
);
|
|
377
|
-
})), this.rotation.copy(t.rotation), this._box = n, this._size = n.getSize(new h()), this._center = n.getCenter(new h()), this._boxHelper = new at(this._box, a), this._boxHelper.visible = !1, this.add(this._boxHelper), this._sphere = n.getBoundingSphere(new nt()), this._radius = this._sphere.radius;
|
|
378
|
-
const r = new T(this._radius, 32, 32);
|
|
379
|
-
r.translate(this._center.x, this._center.y, this._center.z), this._sphereHelper = new S(
|
|
380
|
-
r,
|
|
381
|
-
new F({ color: a, wireframe: !0 })
|
|
382
|
-
), this._sphereHelper.visible = !1, this.add(this._sphereHelper);
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Gets the computed bounding box.
|
|
386
|
-
* @returns The Box3 instance representing the bounding box
|
|
387
|
-
*/
|
|
388
|
-
get box() {
|
|
389
|
-
return this._box;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Gets the computed bounding sphere.
|
|
393
|
-
* @returns The Sphere instance representing the bounding sphere
|
|
394
|
-
*/
|
|
395
|
-
get sphere() {
|
|
396
|
-
return this._sphere;
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* Gets the center point of the bounding box.
|
|
400
|
-
* @returns A Vector3 representing the center coordinates
|
|
401
|
-
*/
|
|
402
|
-
get center() {
|
|
403
|
-
return this._center;
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* Gets the radius of the bounding sphere.
|
|
407
|
-
* @returns The radius as a number
|
|
408
|
-
*/
|
|
409
|
-
get radius() {
|
|
410
|
-
return this._radius;
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Gets the dimensions of the bounding box.
|
|
414
|
-
* @returns A Vector3 representing width, height, and depth
|
|
415
|
-
*/
|
|
416
|
-
get size() {
|
|
417
|
-
return this._size;
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* Sets the visibility of the bounding box wireframe helper.
|
|
421
|
-
*
|
|
422
|
-
* @param visible - Whether the box helper should be visible
|
|
423
|
-
*
|
|
424
|
-
* @example
|
|
425
|
-
* ```typescript
|
|
426
|
-
* const boundingBox = new BoundingBox(mesh);
|
|
427
|
-
*
|
|
428
|
-
* // Show the bounding box wireframe
|
|
429
|
-
* boundingBox.setBoxHelperVisible(true);
|
|
430
|
-
*
|
|
431
|
-
* // Hide the bounding box wireframe
|
|
432
|
-
* boundingBox.setBoxHelperVisible(false);
|
|
433
|
-
* ```
|
|
434
|
-
*/
|
|
435
|
-
setBoxHelperVisible(t) {
|
|
436
|
-
this._boxHelper.visible = t;
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Sets the visibility of the bounding sphere wireframe helper.
|
|
440
|
-
*
|
|
441
|
-
* @param visible - Whether the sphere helper should be visible
|
|
442
|
-
*
|
|
443
|
-
* @example
|
|
444
|
-
* ```typescript
|
|
445
|
-
* const boundingBox = new BoundingBox(mesh);
|
|
446
|
-
*
|
|
447
|
-
* // Show the bounding sphere wireframe
|
|
448
|
-
* boundingBox.setSphereHelperVisible(true);
|
|
449
|
-
*
|
|
450
|
-
* // Hide the bounding sphere wireframe
|
|
451
|
-
* boundingBox.setSphereHelperVisible(false);
|
|
452
|
-
* ```
|
|
453
|
-
*/
|
|
454
|
-
setSphereHelperVisible(t) {
|
|
455
|
-
this._sphereHelper.visible = t;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
class N extends x {
|
|
459
|
-
constructor() {
|
|
460
|
-
super();
|
|
461
|
-
i(this, "isDIVEModel", !0);
|
|
462
|
-
i(this, "_gltf", null);
|
|
463
|
-
i(this, "_mesh", null);
|
|
464
|
-
i(this, "_material", null);
|
|
465
|
-
i(this, "_assetLoader", null);
|
|
466
|
-
this.name = "DIVEModel";
|
|
467
|
-
}
|
|
468
|
-
async _getAssetLoader() {
|
|
469
|
-
return this._assetLoader || (this._assetLoader = new (await import("../plugins/assetloader/index.mjs")).AssetLoader()), this._assetLoader;
|
|
470
|
-
}
|
|
471
|
-
async setFromURL(t) {
|
|
472
|
-
const a = await (await this._getAssetLoader()).load(t);
|
|
473
|
-
return this.setFromGLTF(a), import("../plugins/state/index.mjs").then(({ State: n }) => {
|
|
474
|
-
var r;
|
|
475
|
-
(r = n.get(this.userData.id)) == null || r.performAction("MODEL_LOADED", {
|
|
476
|
-
id: this.userData.id
|
|
477
|
-
});
|
|
478
|
-
}), this;
|
|
479
|
-
}
|
|
480
|
-
setFromGLTF(t) {
|
|
481
|
-
return this.clear(), this._boundingBox.makeEmpty(), this._gltf = t, this._gltf.name = "GLTF", this._gltf.traverse((e) => {
|
|
482
|
-
e.castShadow = !0, e.receiveShadow = !0, e.layers.mask = this.layers.mask, this._boundingBox.expandByObject(e), !this._mesh && "isMesh" in e && (this._mesh = e, this._material ? this._mesh.material = this._material : this._material = e.material);
|
|
483
|
-
}), this.add(this._gltf), this;
|
|
484
|
-
}
|
|
485
|
-
setMaterial(t) {
|
|
486
|
-
this._material || (this._material = new k()), t.vertexColors !== void 0 && (this._material.vertexColors = t.vertexColors), t.color !== void 0 && this._material.color.set(t.color), t.map !== void 0 && (this._material.map = t.map), t.normalMap !== void 0 && (this._material.normalMap = t.normalMap), t.roughness !== void 0 && (this._material.roughness = t.roughness), t.roughnessMap !== void 0 && (this._material.roughnessMap = t.roughnessMap, this._material.roughnessMap && (this._material.roughness = 1)), t.metalness !== void 0 && (this._material.metalness = t.metalness), t.metalnessMap !== void 0 && (this._material.metalnessMap = t.metalnessMap, this._material.metalnessMap && (this._material.metalness = 1)), this._mesh && (this._mesh.material = this._material);
|
|
487
|
-
}
|
|
488
|
-
placeOnFloor() {
|
|
489
|
-
this.updateWorldMatrix(!0, !0);
|
|
490
|
-
const t = this.getWorldPosition(this._positionWorldBuffer), e = t.clone(), a = new f();
|
|
491
|
-
this.children.forEach((r) => {
|
|
492
|
-
r instanceof L || a.expandByObject(r, !0);
|
|
493
|
-
});
|
|
494
|
-
const n = -a.min.y;
|
|
495
|
-
Math.abs(n) < 1e-9 || (t.y += n, t.y !== e.y && (this.setPosition(t), import("../plugins/state/index.mjs").then(({ State: r }) => {
|
|
496
|
-
var l;
|
|
497
|
-
(l = r.get(this.userData.id)) == null || l.performAction("UPDATE_OBJECT", {
|
|
498
|
-
id: this.userData.id,
|
|
499
|
-
position: t,
|
|
500
|
-
rotation: this.rotation,
|
|
501
|
-
scale: this.scale
|
|
502
|
-
});
|
|
503
|
-
}), this.onMove()));
|
|
504
|
-
}
|
|
505
|
-
dropIt() {
|
|
506
|
-
if (!this.parent) {
|
|
507
|
-
console.warn(
|
|
508
|
-
"DIVEModel: dropIt() called on a model that is not in the scene.",
|
|
509
|
-
this
|
|
510
|
-
);
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
const t = this.getWorldPosition(this._positionWorldBuffer), e = t.clone(), a = new f();
|
|
514
|
-
this.children.forEach((d) => {
|
|
515
|
-
d instanceof L || a.expandByObject(d, !0);
|
|
516
|
-
});
|
|
517
|
-
const n = a.getCenter(new h());
|
|
518
|
-
n.y = a.min.y;
|
|
519
|
-
const r = new rt(n, new h(0, -1, 0));
|
|
520
|
-
r.layers.mask = m;
|
|
521
|
-
const l = r.intersectObjects(
|
|
522
|
-
Z(this).root.children,
|
|
523
|
-
!0
|
|
524
|
-
);
|
|
525
|
-
if (l.length > 0) {
|
|
526
|
-
const d = l[0].object, w = new f().setFromObject(d).max.y - a.min.y;
|
|
527
|
-
if (Math.abs(w) < 1e-9 || (t.y += w, t.y === e.y)) return;
|
|
528
|
-
this.setPosition(t), import("../plugins/state/index.mjs").then(({ State: v }) => {
|
|
529
|
-
var y;
|
|
530
|
-
(y = v.get(this.userData.id)) == null || y.performAction("UPDATE_OBJECT", {
|
|
531
|
-
id: this.userData.id,
|
|
532
|
-
position: t,
|
|
533
|
-
rotation: this.rotation,
|
|
534
|
-
scale: this.scale
|
|
535
|
-
});
|
|
536
|
-
}), this.onMove();
|
|
537
|
-
} else
|
|
538
|
-
this.placeOnFloor();
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
class St extends N {
|
|
542
|
-
constructor() {
|
|
543
|
-
super();
|
|
544
|
-
i(this, "isDIVEPrimitive", !0);
|
|
545
|
-
i(this, "_mesh");
|
|
546
|
-
i(this, "_material");
|
|
547
|
-
this._mesh = new S(), this._mesh.name = "PrimitiveMesh", this._mesh.layers.mask = m, this._mesh.castShadow = !0, this._mesh.receiveShadow = !0, this.add(this._mesh), this._material = new k(), this._mesh.material = this._material;
|
|
548
|
-
}
|
|
549
|
-
setGeometry(t) {
|
|
550
|
-
const e = this.assembleGeometry(t);
|
|
551
|
-
e && (e.computeVertexNormals(), e.computeBoundingBox(), e.computeBoundingSphere(), this._mesh.geometry = e, this._boundingBox.setFromObject(this._mesh));
|
|
552
|
-
}
|
|
553
|
-
assembleGeometry(t) {
|
|
554
|
-
switch (this._material.flatShading = !1, t.name.toLowerCase()) {
|
|
555
|
-
case "cylinder":
|
|
556
|
-
return this.createCylinderGeometry(t);
|
|
557
|
-
case "sphere":
|
|
558
|
-
return this.createSphereGeometry(t);
|
|
559
|
-
case "pyramid":
|
|
560
|
-
return this._material.flatShading = !0, this.createPyramidGeometry(t);
|
|
561
|
-
case "cube":
|
|
562
|
-
case "box":
|
|
563
|
-
return this.createBoxGeometry(t);
|
|
564
|
-
case "cone":
|
|
565
|
-
return this.createConeGeometry(t);
|
|
566
|
-
case "wall":
|
|
567
|
-
return this.createWallGeometry(t);
|
|
568
|
-
case "plane":
|
|
569
|
-
return this.createPlaneGeometry(t);
|
|
570
|
-
default:
|
|
571
|
-
return console.warn(
|
|
572
|
-
"DIVEPrimitive.assembleGeometry: Invalid geometry type:",
|
|
573
|
-
t.name.toLowerCase()
|
|
574
|
-
), null;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
createCylinderGeometry(t) {
|
|
578
|
-
const e = new ot(
|
|
579
|
-
t.width / 2,
|
|
580
|
-
t.width / 2,
|
|
581
|
-
t.height,
|
|
582
|
-
64
|
|
583
|
-
);
|
|
584
|
-
return e.translate(0, t.height / 2, 0), e;
|
|
585
|
-
}
|
|
586
|
-
createSphereGeometry(t) {
|
|
587
|
-
return new T(t.width / 2, 256, 256);
|
|
588
|
-
}
|
|
589
|
-
createPyramidGeometry(t) {
|
|
590
|
-
const e = new Float32Array([
|
|
591
|
-
-t.width / 2,
|
|
592
|
-
0,
|
|
593
|
-
-t.depth / 2,
|
|
594
|
-
// 0
|
|
595
|
-
t.width / 2,
|
|
596
|
-
0,
|
|
597
|
-
-t.depth / 2,
|
|
598
|
-
// 1
|
|
599
|
-
t.width / 2,
|
|
600
|
-
0,
|
|
601
|
-
t.depth / 2,
|
|
602
|
-
// 2
|
|
603
|
-
-t.width / 2,
|
|
604
|
-
0,
|
|
605
|
-
t.depth / 2,
|
|
606
|
-
// 3
|
|
607
|
-
0,
|
|
608
|
-
t.height,
|
|
609
|
-
0
|
|
610
|
-
]), a = new Uint16Array([
|
|
611
|
-
0,
|
|
612
|
-
1,
|
|
613
|
-
2,
|
|
614
|
-
0,
|
|
615
|
-
2,
|
|
616
|
-
3,
|
|
617
|
-
0,
|
|
618
|
-
4,
|
|
619
|
-
1,
|
|
620
|
-
1,
|
|
621
|
-
4,
|
|
622
|
-
2,
|
|
623
|
-
2,
|
|
624
|
-
4,
|
|
625
|
-
3,
|
|
626
|
-
3,
|
|
627
|
-
4,
|
|
628
|
-
0
|
|
629
|
-
]), n = new Y();
|
|
630
|
-
return n.setAttribute(
|
|
631
|
-
"position",
|
|
632
|
-
new A(e, 3)
|
|
633
|
-
), n.setIndex(new A(a, 1)), n;
|
|
634
|
-
}
|
|
635
|
-
createBoxGeometry(t) {
|
|
636
|
-
const e = new M(
|
|
637
|
-
t.width,
|
|
638
|
-
t.height,
|
|
639
|
-
t.depth
|
|
640
|
-
);
|
|
641
|
-
return e.translate(0, t.height / 2, 0), e;
|
|
642
|
-
}
|
|
643
|
-
createConeGeometry(t) {
|
|
644
|
-
const e = new ht(t.width / 2, t.height, 256);
|
|
645
|
-
return e.translate(0, t.height / 2, 0), e;
|
|
646
|
-
}
|
|
647
|
-
createWallGeometry(t) {
|
|
648
|
-
const e = new M(
|
|
649
|
-
t.width,
|
|
650
|
-
t.height,
|
|
651
|
-
t.depth || 0.05,
|
|
652
|
-
16
|
|
653
|
-
);
|
|
654
|
-
return e.translate(0, t.height / 2, 0), e;
|
|
655
|
-
}
|
|
656
|
-
createPlaneGeometry(t) {
|
|
657
|
-
const e = new M(
|
|
658
|
-
t.width,
|
|
659
|
-
t.height,
|
|
660
|
-
t.depth
|
|
661
|
-
);
|
|
662
|
-
return e.translate(0, t.height / 2, 0), e;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
class Pt extends x {
|
|
666
|
-
// lines to children
|
|
667
|
-
constructor() {
|
|
668
|
-
super();
|
|
669
|
-
i(this, "isDIVEGroup", !0);
|
|
670
|
-
i(this, "_members");
|
|
671
|
-
i(this, "_lines");
|
|
672
|
-
this.name = "DIVEGroup", this._members = [], this._lines = [];
|
|
673
|
-
}
|
|
674
|
-
// children objects
|
|
675
|
-
get members() {
|
|
676
|
-
return this._members;
|
|
677
|
-
}
|
|
678
|
-
setPosition(t) {
|
|
679
|
-
super.setPosition(t), this._members.forEach((e) => {
|
|
680
|
-
"isDIVENode" in e && e.onMove();
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
setLinesVisibility(t, e) {
|
|
684
|
-
if (!e) {
|
|
685
|
-
this._lines.forEach((n) => {
|
|
686
|
-
n.visible = t;
|
|
687
|
-
});
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
const a = this._members.indexOf(e);
|
|
691
|
-
a !== -1 && (this._lines[a].visible = t);
|
|
692
|
-
}
|
|
693
|
-
attach(t) {
|
|
694
|
-
if (this._members.includes(t))
|
|
695
|
-
return this;
|
|
696
|
-
const e = this.createLine();
|
|
697
|
-
return this.add(e), this._lines.push(e), super.attach(t), this._members.push(t), this._updateLineTo(e, t), this.setLinesVisibility(!0, t), this;
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* Removes an object from the group.
|
|
701
|
-
* @param object - The object to remove.
|
|
702
|
-
* @returns The group instance.
|
|
703
|
-
*/
|
|
704
|
-
remove(t) {
|
|
705
|
-
const e = this._members.indexOf(t);
|
|
706
|
-
if (e === -1)
|
|
707
|
-
return this;
|
|
708
|
-
const a = this._lines[e];
|
|
709
|
-
return super.remove(a), this._lines.splice(e, 1), super.remove(t), this._members.splice(e, 1), this;
|
|
710
|
-
}
|
|
711
|
-
updateLineTo(t) {
|
|
712
|
-
const e = this._members.indexOf(t);
|
|
713
|
-
e !== -1 && this._updateLineTo(this._lines[e], t);
|
|
714
|
-
}
|
|
715
|
-
/**
|
|
716
|
-
* Creates a line for visualization.
|
|
717
|
-
*/
|
|
718
|
-
createLine() {
|
|
719
|
-
const t = new Y(), e = new lt({
|
|
720
|
-
color: 6710886,
|
|
721
|
-
dashSize: 0.05,
|
|
722
|
-
gapSize: 0.025
|
|
723
|
-
}), a = new dt(t, e);
|
|
724
|
-
return a.visible = !1, a;
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* Updates a line to the object.
|
|
728
|
-
*/
|
|
729
|
-
_updateLineTo(t, e) {
|
|
730
|
-
const a = [
|
|
731
|
-
new h(0, 0, 0),
|
|
732
|
-
e.position.clone()
|
|
733
|
-
];
|
|
734
|
-
t.geometry.setFromPoints(a), t.computeLineDistances();
|
|
735
|
-
}
|
|
736
|
-
// public setBoundingBoxVisibility(visible: boolean): void {
|
|
737
|
-
// this._boxMesh.visible = visible;
|
|
738
|
-
// }
|
|
739
|
-
// /**
|
|
740
|
-
// * Recalculates the position of the group based on it's bounding box.
|
|
741
|
-
// * Children's world positions are kept.
|
|
742
|
-
// */
|
|
743
|
-
// private recalculatePosition(): void {
|
|
744
|
-
// // store all children's world positions
|
|
745
|
-
// const childrensWorldPositions: Vector3[] = this.children.map((child) => child.getWorldPosition(new Vector3()));
|
|
746
|
-
// // calculate new center and set it as the group's position
|
|
747
|
-
// const bbcenter = this.updateBB();
|
|
748
|
-
// this.position.copy(bbcenter);
|
|
749
|
-
// // set childrens's positions so their world positions are kept
|
|
750
|
-
// this.children.forEach((child, i) => {
|
|
751
|
-
// if (child.uuid === this._boxMesh.uuid) return;
|
|
752
|
-
// child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
|
|
753
|
-
// });
|
|
754
|
-
// DIVECommunication.get(this.userData.id)?.performAction('UPDATE_OBJECT', { id: this.userData.id, position: this.position });
|
|
755
|
-
// }
|
|
756
|
-
// /**
|
|
757
|
-
// * Updates the bounding box of the group.
|
|
758
|
-
// * @returns {Vector3} The new center of the bounding box.
|
|
759
|
-
// */
|
|
760
|
-
// private updateBB(): Vector3 {
|
|
761
|
-
// this._boundingBox.makeEmpty();
|
|
762
|
-
// if (this.children.length === 1) {
|
|
763
|
-
// // because we always have the box mesh as 1 child
|
|
764
|
-
// return this.position.clone();
|
|
765
|
-
// }
|
|
766
|
-
// this.children.forEach((child) => {
|
|
767
|
-
// if (child.uuid === this._boxMesh.uuid) return;
|
|
768
|
-
// this._boundingBox.expandByObject(child);
|
|
769
|
-
// });
|
|
770
|
-
// return this._boundingBox.getCenter(new Vector3());
|
|
771
|
-
// }
|
|
772
|
-
// private updateBoxMesh(): void {
|
|
773
|
-
// if (this.children.length === 1) {
|
|
774
|
-
// // because we always have the box mesh as 1 child
|
|
775
|
-
// this._boxMesh.visible = false;
|
|
776
|
-
// return;
|
|
777
|
-
// }
|
|
778
|
-
// this._boxMesh.quaternion.copy(this.quaternion.clone().invert());
|
|
779
|
-
// this._boxMesh.scale.set(1 / this.scale.x, 1 / this.scale.y, 1 / this.scale.z);
|
|
780
|
-
// this._boxMesh.geometry = new BoxGeometry(this._boundingBox.max.x - this._boundingBox.min.x, this._boundingBox.max.y - this._boundingBox.min.y, this._boundingBox.max.z - this._boundingBox.min.z);
|
|
781
|
-
// this._boxMesh.visible = true;
|
|
782
|
-
// }
|
|
783
|
-
}
|
|
784
|
-
class vt extends S {
|
|
785
|
-
constructor() {
|
|
786
|
-
const t = new ct(1, 1);
|
|
787
|
-
t.scale(1e3, 1e3, 1), t.rotateX(-Math.PI / 2);
|
|
788
|
-
const e = new k({
|
|
789
|
-
color: new E(16777215),
|
|
790
|
-
side: U
|
|
791
|
-
});
|
|
792
|
-
super(t, e);
|
|
793
|
-
i(this, "isDIVEFloor", !0);
|
|
794
|
-
this.name = "Floor", this.layers.mask = m, this.receiveShadow = !0;
|
|
795
|
-
}
|
|
796
|
-
setVisibility(t) {
|
|
797
|
-
this.visible = t;
|
|
798
|
-
}
|
|
799
|
-
setColor(t) {
|
|
800
|
-
this.material.color = new E(t);
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
class Mt extends g {
|
|
804
|
-
constructor() {
|
|
805
|
-
super();
|
|
806
|
-
i(this, "isDIVERoot", !0);
|
|
807
|
-
i(this, "_floor");
|
|
808
|
-
this.name = "Root", this._floor = new vt(), this.add(this._floor);
|
|
809
|
-
}
|
|
810
|
-
get floor() {
|
|
811
|
-
return this._floor;
|
|
812
|
-
}
|
|
813
|
-
computeSceneBB() {
|
|
814
|
-
const t = new f();
|
|
815
|
-
return this.children.forEach((e) => {
|
|
816
|
-
"isDIVEFloor" in e || e.traverse((a) => {
|
|
817
|
-
"isObject3D" in a && t.expandByObject(a);
|
|
818
|
-
});
|
|
819
|
-
}), t;
|
|
820
|
-
}
|
|
821
|
-
getSceneObject(t) {
|
|
822
|
-
let e;
|
|
823
|
-
return this.traverse((a) => {
|
|
824
|
-
e || a.userData.id === t.id && (e = a);
|
|
825
|
-
}), e;
|
|
826
|
-
}
|
|
827
|
-
addSceneObject(t) {
|
|
828
|
-
let e = this.getSceneObject(t);
|
|
829
|
-
if (e)
|
|
830
|
-
return console.warn(
|
|
831
|
-
`DIVERoot.addSceneObject: Scene object with id ${t.id} already exists`
|
|
832
|
-
), e;
|
|
833
|
-
switch (t.entityType) {
|
|
834
|
-
case "pov":
|
|
835
|
-
break;
|
|
836
|
-
case "light": {
|
|
837
|
-
switch (t.type) {
|
|
838
|
-
case "scene": {
|
|
839
|
-
e = new Et();
|
|
840
|
-
break;
|
|
841
|
-
}
|
|
842
|
-
case "ambient": {
|
|
843
|
-
e = new bt();
|
|
844
|
-
break;
|
|
845
|
-
}
|
|
846
|
-
case "point": {
|
|
847
|
-
e = new Dt();
|
|
848
|
-
break;
|
|
849
|
-
}
|
|
850
|
-
default:
|
|
851
|
-
throw new Error(
|
|
852
|
-
`DIVERoot.addSceneObject: Unknown light type: ${t.type}`
|
|
853
|
-
);
|
|
854
|
-
}
|
|
855
|
-
e.name = t.name, e.userData.id = t.id, this.add(e), this._updateLight(e, t);
|
|
856
|
-
break;
|
|
857
|
-
}
|
|
858
|
-
case "model": {
|
|
859
|
-
e = new N(), e.name = t.name, e.userData.id = t.id, e.userData.uri = t.uri, this.add(e), this._updateModel(e, t);
|
|
860
|
-
break;
|
|
861
|
-
}
|
|
862
|
-
case "primitive": {
|
|
863
|
-
e = new St(), e.name = t.name, e.userData.id = t.id, this.add(e), this._updatePrimitive(e, t);
|
|
864
|
-
break;
|
|
865
|
-
}
|
|
866
|
-
case "group": {
|
|
867
|
-
e = new Pt(), e.name = t.name, e.userData.id = t.id, this.add(e), this._updateGroup(e, t);
|
|
868
|
-
break;
|
|
869
|
-
}
|
|
870
|
-
default:
|
|
871
|
-
throw new Error(
|
|
872
|
-
`DIVERoot.addSceneObject: Unknown entity type: ${t.entityType}`
|
|
873
|
-
);
|
|
874
|
-
}
|
|
875
|
-
return e;
|
|
876
|
-
}
|
|
877
|
-
updateSceneObject(t) {
|
|
878
|
-
const e = this.getSceneObject(t);
|
|
879
|
-
if (!e) {
|
|
880
|
-
console.warn(
|
|
881
|
-
`DIVERoot.updateSceneObject: Scene object with id ${t.id} does not exist`
|
|
882
|
-
);
|
|
883
|
-
return;
|
|
884
|
-
}
|
|
885
|
-
switch (t.entityType) {
|
|
886
|
-
case "pov":
|
|
887
|
-
break;
|
|
888
|
-
case "light": {
|
|
889
|
-
this._updateLight(e, t);
|
|
890
|
-
break;
|
|
891
|
-
}
|
|
892
|
-
case "model": {
|
|
893
|
-
this._updateModel(e, t);
|
|
894
|
-
break;
|
|
895
|
-
}
|
|
896
|
-
case "primitive": {
|
|
897
|
-
this._updatePrimitive(e, t);
|
|
898
|
-
break;
|
|
899
|
-
}
|
|
900
|
-
case "group": {
|
|
901
|
-
this._updateGroup(e, t);
|
|
902
|
-
break;
|
|
903
|
-
}
|
|
904
|
-
default:
|
|
905
|
-
throw new Error(
|
|
906
|
-
`DIVERoot.updateSceneObject: Unknown entity type: ${t.entityType}`
|
|
907
|
-
);
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
deleteSceneObject(t) {
|
|
911
|
-
const e = this.getSceneObject(t);
|
|
912
|
-
if (!e) {
|
|
913
|
-
console.warn(
|
|
914
|
-
`DIVERoot.deleteSceneObject: Object with id ${t.id} not found`
|
|
915
|
-
);
|
|
916
|
-
return;
|
|
917
|
-
}
|
|
918
|
-
switch (t.entityType) {
|
|
919
|
-
case "pov":
|
|
920
|
-
break;
|
|
921
|
-
case "light": {
|
|
922
|
-
this._deleteLight(e);
|
|
923
|
-
break;
|
|
924
|
-
}
|
|
925
|
-
case "model": {
|
|
926
|
-
this._deleteModel(e);
|
|
927
|
-
break;
|
|
928
|
-
}
|
|
929
|
-
case "primitive": {
|
|
930
|
-
this._deletePrimitive(e);
|
|
931
|
-
break;
|
|
932
|
-
}
|
|
933
|
-
case "group": {
|
|
934
|
-
this._deleteGroup(e);
|
|
935
|
-
break;
|
|
936
|
-
}
|
|
937
|
-
default:
|
|
938
|
-
throw new Error(
|
|
939
|
-
`DIVERoot.deleteSceneObject: Unknown entity type: ${t.entityType}`
|
|
940
|
-
);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
_updateLight(t, e) {
|
|
944
|
-
e.name !== void 0 && e.name !== null && (t.name = e.name), e.position !== void 0 && e.position !== null && t.position.set(
|
|
945
|
-
e.position.x,
|
|
946
|
-
e.position.y,
|
|
947
|
-
e.position.z
|
|
948
|
-
), e.intensity !== void 0 && e.intensity !== null && t.setIntensity(e.intensity), e.enabled !== void 0 && e.enabled !== null && t.setEnabled(e.enabled), e.color !== void 0 && e.color !== null && t.setColor(new E(e.color)), e.visible !== void 0 && e.visible !== null && (t.visible = e.visible), e.parentId !== void 0 && this._setParent({ ...e, parentId: e.parentId });
|
|
949
|
-
}
|
|
950
|
-
_updateModel(t, e) {
|
|
951
|
-
e.uri !== void 0 && t.setFromURL(e.uri), e.name !== void 0 && (t.name = e.name), e.position !== void 0 && t.setPosition(e.position), e.rotation !== void 0 && t.setRotation(e.rotation), e.scale !== void 0 && t.setScale(e.scale), e.visible !== void 0 && t.setVisibility(e.visible), e.material !== void 0 && t.setMaterial(e.material), e.parentId !== void 0 && this._setParent({ ...e, parentId: e.parentId });
|
|
952
|
-
}
|
|
953
|
-
_updatePrimitive(t, e) {
|
|
954
|
-
e.name !== void 0 && (t.name = e.name), e.geometry !== void 0 && t.setGeometry(e.geometry), e.position !== void 0 && t.setPosition(e.position), e.rotation !== void 0 && t.setRotation(e.rotation), e.scale !== void 0 && t.setScale(e.scale), e.visible !== void 0 && t.setVisibility(e.visible), e.material !== void 0 && t.setMaterial(e.material), e.parentId !== void 0 && this._setParent({ ...e, parentId: e.parentId });
|
|
955
|
-
}
|
|
956
|
-
_updateGroup(t, e) {
|
|
957
|
-
e.name !== void 0 && (t.name = e.name), e.position !== void 0 && t.setPosition(e.position), e.rotation !== void 0 && t.setRotation(e.rotation), e.scale !== void 0 && t.setScale(e.scale), e.visible !== void 0 && t.setVisibility(e.visible), e.bbVisible !== void 0 && t.setLinesVisibility(e.bbVisible), e.parentId !== void 0 && this._setParent({ ...e, parentId: e.parentId });
|
|
958
|
-
}
|
|
959
|
-
_deleteLight(t) {
|
|
960
|
-
this._detachTransformControls(t), t.parent.remove(t);
|
|
961
|
-
}
|
|
962
|
-
_deleteModel(t) {
|
|
963
|
-
this._detachTransformControls(t), t.parent.remove(t);
|
|
964
|
-
}
|
|
965
|
-
_deletePrimitive(t) {
|
|
966
|
-
this._detachTransformControls(t), t.parent.remove(t);
|
|
967
|
-
}
|
|
968
|
-
_deleteGroup(t) {
|
|
969
|
-
this._detachTransformControls(t);
|
|
970
|
-
for (let e = t.members.length - 1; e >= 0; e--)
|
|
971
|
-
this.attach(t.members[e]);
|
|
972
|
-
t.parent.remove(t);
|
|
973
|
-
}
|
|
974
|
-
_setParent(t) {
|
|
975
|
-
const e = this.getSceneObject(t);
|
|
976
|
-
if (t.parentId !== null) {
|
|
977
|
-
const a = this.getSceneObject({
|
|
978
|
-
id: t.parentId,
|
|
979
|
-
entityType: t.entityType
|
|
980
|
-
});
|
|
981
|
-
if (!a) return;
|
|
982
|
-
a.attach(e);
|
|
983
|
-
} else
|
|
984
|
-
this.attach(e);
|
|
985
|
-
}
|
|
986
|
-
_detachTransformControls(t) {
|
|
987
|
-
this._findScene(t).children.find((e) => {
|
|
988
|
-
"isTransformControls" in e && e.detach();
|
|
989
|
-
});
|
|
990
|
-
}
|
|
991
|
-
_findScene(t) {
|
|
992
|
-
return t.parent !== null ? this._findScene(t.parent) : t;
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
const Lt = "#888888", It = "#dddddd";
|
|
996
|
-
class Tt extends g {
|
|
997
|
-
constructor() {
|
|
998
|
-
super(), this.name = "Grid";
|
|
999
|
-
const s = new ut(
|
|
1000
|
-
100,
|
|
1001
|
-
100,
|
|
1002
|
-
Lt,
|
|
1003
|
-
It
|
|
1004
|
-
);
|
|
1005
|
-
s.material.depthTest = !1, s.layers.mask = gt, this.add(s);
|
|
1006
|
-
}
|
|
1007
|
-
setVisibility(s) {
|
|
1008
|
-
this.visible = s;
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
const D = {
|
|
1012
|
-
displayFloor: !1,
|
|
1013
|
-
displayGrid: !1,
|
|
1014
|
-
backgroundColor: "#ffffff"
|
|
1015
|
-
};
|
|
1016
|
-
class kt extends pt {
|
|
1017
|
-
constructor(t) {
|
|
1018
|
-
super();
|
|
1019
|
-
i(this, "isDIVEScene", !0);
|
|
1020
|
-
i(this, "_root");
|
|
1021
|
-
i(this, "_grid");
|
|
1022
|
-
this.setBackground(
|
|
1023
|
-
(t == null ? void 0 : t.backgroundColor) ?? D.backgroundColor
|
|
1024
|
-
), this._root = new Mt(), this._root.floor.setVisibility(
|
|
1025
|
-
(t == null ? void 0 : t.displayFloor) ?? D.displayFloor
|
|
1026
|
-
), this.add(this._root), this._grid = new Tt(), this._grid.setVisibility(
|
|
1027
|
-
(t == null ? void 0 : t.displayGrid) ?? D.displayGrid
|
|
1028
|
-
), this.add(this._grid);
|
|
1029
|
-
}
|
|
1030
|
-
get root() {
|
|
1031
|
-
return this._root;
|
|
1032
|
-
}
|
|
1033
|
-
get grid() {
|
|
1034
|
-
return this._grid;
|
|
1035
|
-
}
|
|
1036
|
-
setBackground(t) {
|
|
1037
|
-
this.background = new E(t);
|
|
1038
|
-
}
|
|
1039
|
-
computeSceneBB() {
|
|
1040
|
-
return this._root.computeSceneBB();
|
|
1041
|
-
}
|
|
1042
|
-
dispose() {
|
|
1043
|
-
this.remove(this._root), this.remove(this._grid);
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
const xt = {
|
|
1047
|
-
enableDamping: !0,
|
|
1048
|
-
dampingFactor: 0.05,
|
|
1049
|
-
enabled: !0,
|
|
1050
|
-
target: new h(),
|
|
1051
|
-
minDistance: 0,
|
|
1052
|
-
maxDistance: 1 / 0,
|
|
1053
|
-
minZoom: 0,
|
|
1054
|
-
maxZoom: 1 / 0,
|
|
1055
|
-
minPolarAngle: 0,
|
|
1056
|
-
maxPolarAngle: Math.PI,
|
|
1057
|
-
minAzimuthAngle: -1 / 0,
|
|
1058
|
-
maxAzimuthAngle: 1 / 0,
|
|
1059
|
-
enableZoom: !0,
|
|
1060
|
-
zoomSpeed: 1,
|
|
1061
|
-
enableRotate: !0,
|
|
1062
|
-
rotateSpeed: 1,
|
|
1063
|
-
enablePan: !0,
|
|
1064
|
-
panSpeed: 1,
|
|
1065
|
-
screenSpacePanning: !0,
|
|
1066
|
-
keyPanSpeed: 7,
|
|
1067
|
-
autoRotate: !1,
|
|
1068
|
-
autoRotateSpeed: 2,
|
|
1069
|
-
keys: {
|
|
1070
|
-
LEFT: "ArrowLeft",
|
|
1071
|
-
UP: "ArrowUp",
|
|
1072
|
-
RIGHT: "ArrowRight",
|
|
1073
|
-
BOTTOM: "ArrowDown"
|
|
1074
|
-
},
|
|
1075
|
-
mouseButtons: {
|
|
1076
|
-
LEFT: u.ROTATE,
|
|
1077
|
-
MIDDLE: u.DOLLY,
|
|
1078
|
-
RIGHT: u.PAN
|
|
1079
|
-
},
|
|
1080
|
-
touches: {
|
|
1081
|
-
ONE: p.ROTATE,
|
|
1082
|
-
TWO: p.DOLLY_PAN
|
|
1083
|
-
}
|
|
1084
|
-
}, _ = class _ extends mt {
|
|
1085
|
-
constructor(t, e, a) {
|
|
1086
|
-
super();
|
|
1087
|
-
// public API
|
|
1088
|
-
i(this, "object");
|
|
1089
|
-
i(this, "domElements");
|
|
1090
|
-
i(this, "enabled", !0);
|
|
1091
|
-
i(this, "target", new h());
|
|
1092
|
-
i(this, "minDistance", 0);
|
|
1093
|
-
i(this, "maxDistance", 1 / 0);
|
|
1094
|
-
i(this, "minZoom", 0);
|
|
1095
|
-
i(this, "maxZoom", 1 / 0);
|
|
1096
|
-
i(this, "minPolarAngle", 0);
|
|
1097
|
-
// radians
|
|
1098
|
-
i(this, "maxPolarAngle", Math.PI);
|
|
1099
|
-
// radians
|
|
1100
|
-
i(this, "minAzimuthAngle", -1 / 0);
|
|
1101
|
-
// radians
|
|
1102
|
-
i(this, "maxAzimuthAngle", 1 / 0);
|
|
1103
|
-
// radians
|
|
1104
|
-
i(this, "enableDamping", !0);
|
|
1105
|
-
i(this, "dampingFactor", 0.05);
|
|
1106
|
-
i(this, "enableZoom", !0);
|
|
1107
|
-
i(this, "zoomSpeed", 1);
|
|
1108
|
-
i(this, "enableRotate", !0);
|
|
1109
|
-
i(this, "rotateSpeed", 1);
|
|
1110
|
-
i(this, "enablePan", !0);
|
|
1111
|
-
i(this, "panSpeed", 1);
|
|
1112
|
-
i(this, "screenSpacePanning", !0);
|
|
1113
|
-
i(this, "keyPanSpeed", 7);
|
|
1114
|
-
i(this, "autoRotate", !1);
|
|
1115
|
-
i(this, "autoRotateSpeed", 2);
|
|
1116
|
-
i(this, "keys", {
|
|
1117
|
-
LEFT: "ArrowLeft",
|
|
1118
|
-
UP: "ArrowUp",
|
|
1119
|
-
RIGHT: "ArrowRight",
|
|
1120
|
-
BOTTOM: "ArrowDown"
|
|
1121
|
-
});
|
|
1122
|
-
i(this, "mouseButtons", {
|
|
1123
|
-
LEFT: u.ROTATE,
|
|
1124
|
-
MIDDLE: u.DOLLY,
|
|
1125
|
-
RIGHT: u.PAN
|
|
1126
|
-
});
|
|
1127
|
-
i(this, "touches", { ONE: p.ROTATE, TWO: p.DOLLY_PAN });
|
|
1128
|
-
i(this, "target0");
|
|
1129
|
-
i(this, "position0");
|
|
1130
|
-
i(this, "zoom0");
|
|
1131
|
-
i(this, "uuid", I.generateUUID());
|
|
1132
|
-
// private state
|
|
1133
|
-
i(this, "state", -1);
|
|
1134
|
-
i(this, "EPS", 1e-6);
|
|
1135
|
-
i(this, "spherical", new C());
|
|
1136
|
-
i(this, "sphericalDelta", new C());
|
|
1137
|
-
i(this, "scale", 1);
|
|
1138
|
-
i(this, "panOffset", new h());
|
|
1139
|
-
i(this, "zoomChanged", !1);
|
|
1140
|
-
i(this, "rotateStart", new c());
|
|
1141
|
-
i(this, "rotateEnd", new c());
|
|
1142
|
-
i(this, "rotateDelta", new c());
|
|
1143
|
-
i(this, "panStart", new c());
|
|
1144
|
-
i(this, "panEnd", new c());
|
|
1145
|
-
i(this, "panDelta", new c());
|
|
1146
|
-
i(this, "dollyStart", new c());
|
|
1147
|
-
i(this, "dollyEnd", new c());
|
|
1148
|
-
i(this, "dollyDelta", new c());
|
|
1149
|
-
i(this, "pointers", []);
|
|
1150
|
-
i(this, "pointerPositions", {});
|
|
1151
|
-
// for update() function
|
|
1152
|
-
i(this, "offset", new h());
|
|
1153
|
-
i(this, "quat");
|
|
1154
|
-
i(this, "quatInverse");
|
|
1155
|
-
i(this, "lastPosition", new h());
|
|
1156
|
-
i(this, "lastQuaternion", new O());
|
|
1157
|
-
i(this, "lastTarget", new h());
|
|
1158
|
-
i(this, "panLeft", (() => {
|
|
1159
|
-
const t = new h();
|
|
1160
|
-
return (e, a) => {
|
|
1161
|
-
t.setFromMatrixColumn(a, 0), t.multiplyScalar(-e), this.panOffset.add(t);
|
|
1162
|
-
};
|
|
1163
|
-
})());
|
|
1164
|
-
i(this, "panUp", (() => {
|
|
1165
|
-
const t = new h();
|
|
1166
|
-
return (e, a) => {
|
|
1167
|
-
this.screenSpacePanning === !0 ? t.setFromMatrixColumn(a, 1) : (t.setFromMatrixColumn(a, 0), t.crossVectors(this.object.up, t)), t.multiplyScalar(e), this.panOffset.add(t);
|
|
1168
|
-
};
|
|
1169
|
-
})());
|
|
1170
|
-
i(this, "onMouseDown", (t) => {
|
|
1171
|
-
let e;
|
|
1172
|
-
switch (t.button) {
|
|
1173
|
-
case 0:
|
|
1174
|
-
e = this.mouseButtons.LEFT;
|
|
1175
|
-
break;
|
|
1176
|
-
case 1:
|
|
1177
|
-
e = this.mouseButtons.MIDDLE;
|
|
1178
|
-
break;
|
|
1179
|
-
case 2:
|
|
1180
|
-
e = this.mouseButtons.RIGHT;
|
|
1181
|
-
break;
|
|
1182
|
-
default:
|
|
1183
|
-
e = -1;
|
|
1184
|
-
}
|
|
1185
|
-
switch (e) {
|
|
1186
|
-
case u.DOLLY:
|
|
1187
|
-
if (this.enableZoom === !1) return;
|
|
1188
|
-
this.handleMouseDownDolly(t), this.state = 1;
|
|
1189
|
-
break;
|
|
1190
|
-
case u.ROTATE:
|
|
1191
|
-
if (t.ctrlKey || t.metaKey || t.shiftKey) {
|
|
1192
|
-
if (this.enablePan === !1) return;
|
|
1193
|
-
this.handleMouseDownPan(t), this.state = 2;
|
|
1194
|
-
} else {
|
|
1195
|
-
if (this.enableRotate === !1) return;
|
|
1196
|
-
this.handleMouseDownRotate(t), this.state = 0;
|
|
1197
|
-
}
|
|
1198
|
-
break;
|
|
1199
|
-
case u.PAN:
|
|
1200
|
-
if (t.ctrlKey || t.metaKey || t.shiftKey) {
|
|
1201
|
-
if (this.enableRotate === !1) return;
|
|
1202
|
-
this.handleMouseDownRotate(t), this.state = 0;
|
|
1203
|
-
} else {
|
|
1204
|
-
if (this.enablePan === !1) return;
|
|
1205
|
-
this.handleMouseDownPan(t), this.state = 2;
|
|
1206
|
-
}
|
|
1207
|
-
break;
|
|
1208
|
-
default:
|
|
1209
|
-
this.state = -1;
|
|
1210
|
-
}
|
|
1211
|
-
this.state !== -1 && this.dispatchEvent({ type: "start" });
|
|
1212
|
-
});
|
|
1213
|
-
i(this, "onMouseMove", (t) => {
|
|
1214
|
-
if (this.enabled !== !1)
|
|
1215
|
-
switch (this.state) {
|
|
1216
|
-
case 0:
|
|
1217
|
-
if (this.enableRotate === !1) return;
|
|
1218
|
-
this.handleMouseMoveRotate(t);
|
|
1219
|
-
break;
|
|
1220
|
-
case 1:
|
|
1221
|
-
if (this.enableZoom === !1) return;
|
|
1222
|
-
this.handleMouseMoveDolly(t);
|
|
1223
|
-
break;
|
|
1224
|
-
case 2:
|
|
1225
|
-
if (this.enablePan === !1) return;
|
|
1226
|
-
this.handleMouseMovePan(t);
|
|
1227
|
-
break;
|
|
1228
|
-
}
|
|
1229
|
-
});
|
|
1230
|
-
i(this, "onMouseWheel", (t) => {
|
|
1231
|
-
this.enabled === !1 || this.enableZoom === !1 || this.state !== -1 || (t.preventDefault(), this.dispatchEvent({ type: "start" }), this.handleMouseWheel(t), this.dispatchEvent({ type: "end" }));
|
|
1232
|
-
});
|
|
1233
|
-
i(this, "onKeyDown", (t) => {
|
|
1234
|
-
this.enabled === !1 || this.enablePan === !1 || this.handleKeyDown(t);
|
|
1235
|
-
});
|
|
1236
|
-
i(this, "onTouchStart", (t) => {
|
|
1237
|
-
switch (this.trackPointer(t), this.pointers.length) {
|
|
1238
|
-
case 1:
|
|
1239
|
-
switch (this.touches.ONE) {
|
|
1240
|
-
case p.ROTATE:
|
|
1241
|
-
if (this.enableRotate === !1) return;
|
|
1242
|
-
this.handleTouchStartRotate(t), this.state = 3;
|
|
1243
|
-
break;
|
|
1244
|
-
case p.PAN:
|
|
1245
|
-
if (this.enablePan === !1) return;
|
|
1246
|
-
this.handleTouchStartPan(t), this.state = 4;
|
|
1247
|
-
break;
|
|
1248
|
-
default:
|
|
1249
|
-
this.state = -1;
|
|
1250
|
-
}
|
|
1251
|
-
break;
|
|
1252
|
-
case 2:
|
|
1253
|
-
switch (this.touches.TWO) {
|
|
1254
|
-
case p.DOLLY_PAN:
|
|
1255
|
-
if (this.enableZoom === !1 && this.enablePan === !1)
|
|
1256
|
-
return;
|
|
1257
|
-
this.handleTouchStartDollyPan(t), this.state = 5;
|
|
1258
|
-
break;
|
|
1259
|
-
case p.DOLLY_ROTATE:
|
|
1260
|
-
if (this.enableZoom === !1 && this.enableRotate === !1)
|
|
1261
|
-
return;
|
|
1262
|
-
this.handleTouchStartDollyRotate(t), this.state = 6;
|
|
1263
|
-
break;
|
|
1264
|
-
default:
|
|
1265
|
-
this.state = -1;
|
|
1266
|
-
}
|
|
1267
|
-
break;
|
|
1268
|
-
default:
|
|
1269
|
-
this.state = -1;
|
|
1270
|
-
}
|
|
1271
|
-
this.state !== -1 && this.dispatchEvent({ type: "start" });
|
|
1272
|
-
});
|
|
1273
|
-
i(this, "onTouchMove", (t) => {
|
|
1274
|
-
switch (this.trackPointer(t), this.state) {
|
|
1275
|
-
case 3:
|
|
1276
|
-
if (this.enableRotate === !1) return;
|
|
1277
|
-
this.handleTouchMoveRotate(t), this.update();
|
|
1278
|
-
break;
|
|
1279
|
-
case 4:
|
|
1280
|
-
if (this.enablePan === !1) return;
|
|
1281
|
-
this.handleTouchMovePan(t), this.update();
|
|
1282
|
-
break;
|
|
1283
|
-
case 5:
|
|
1284
|
-
if (this.enableZoom === !1 && this.enablePan === !1)
|
|
1285
|
-
return;
|
|
1286
|
-
this.handleTouchMoveDollyPan(t), this.update();
|
|
1287
|
-
break;
|
|
1288
|
-
case 6:
|
|
1289
|
-
if (this.enableZoom === !1 && this.enableRotate === !1)
|
|
1290
|
-
return;
|
|
1291
|
-
this.handleTouchMoveDollyRotate(t), this.update();
|
|
1292
|
-
break;
|
|
1293
|
-
default:
|
|
1294
|
-
this.state = -1;
|
|
1295
|
-
}
|
|
1296
|
-
});
|
|
1297
|
-
i(this, "onPointerDown", (t) => {
|
|
1298
|
-
if (this.enabled !== !1) {
|
|
1299
|
-
if (this.pointers.length === 0) {
|
|
1300
|
-
const e = t.currentTarget;
|
|
1301
|
-
e.setPointerCapture(t.pointerId), e.addEventListener("pointermove", this.onPointerMove), e.addEventListener("pointerup", this.onPointerUp);
|
|
1302
|
-
}
|
|
1303
|
-
this.isTrackingPointer(t) || (this.addPointer(t), t.pointerType === "touch" ? this.onTouchStart(t) : this.onMouseDown(t));
|
|
1304
|
-
}
|
|
1305
|
-
});
|
|
1306
|
-
i(this, "onPointerMove", (t) => {
|
|
1307
|
-
this.enabled !== !1 && (t.pointerType === "touch" ? this.onTouchMove(t) : this.onMouseMove(t));
|
|
1308
|
-
});
|
|
1309
|
-
i(this, "onPointerUp", (t) => {
|
|
1310
|
-
if (this.removePointer(t), this.pointers.length === 0) {
|
|
1311
|
-
const e = t.currentTarget;
|
|
1312
|
-
e.releasePointerCapture(t.pointerId), e.removeEventListener("pointermove", this.onPointerMove), e.removeEventListener("pointerup", this.onPointerUp), this.dispatchEvent({ type: "end" }), this.state = -1;
|
|
1313
|
-
}
|
|
1314
|
-
});
|
|
1315
|
-
i(this, "onPointerCancel", (t) => {
|
|
1316
|
-
this.removePointer(t);
|
|
1317
|
-
});
|
|
1318
|
-
i(this, "onContextMenu", (t) => {
|
|
1319
|
-
this.enabled !== !1 && t.preventDefault();
|
|
1320
|
-
});
|
|
1321
|
-
this.object = t, this.domElements = Array.isArray(e) ? e : [e], Object.assign(this, a), this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this.quat = new O().setFromUnitVectors(
|
|
1322
|
-
t.up,
|
|
1323
|
-
new h(0, 1, 0)
|
|
1324
|
-
), this.quatInverse = this.quat.clone().invert(), this.domElements.forEach((n) => this.addEventListeners(n)), this.update();
|
|
1325
|
-
}
|
|
1326
|
-
get domElement() {
|
|
1327
|
-
return this.domElements[0];
|
|
1328
|
-
}
|
|
1329
|
-
tick() {
|
|
1330
|
-
this.enabled && this.update();
|
|
1331
|
-
}
|
|
1332
|
-
getPolarAngle() {
|
|
1333
|
-
return this.spherical.phi;
|
|
1334
|
-
}
|
|
1335
|
-
getAzimuthalAngle() {
|
|
1336
|
-
return this.spherical.theta;
|
|
1337
|
-
}
|
|
1338
|
-
getDistance() {
|
|
1339
|
-
return this.object.position.distanceTo(this.target);
|
|
1340
|
-
}
|
|
1341
|
-
saveState() {
|
|
1342
|
-
this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
|
|
1343
|
-
}
|
|
1344
|
-
reset() {
|
|
1345
|
-
this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent({ type: "change" }), this.update(), this.state = -1;
|
|
1346
|
-
}
|
|
1347
|
-
update() {
|
|
1348
|
-
return this.offset.copy(this.object.position).sub(this.target), this.offset.applyQuaternion(this.quat), this.spherical.setFromVector3(this.offset), this.autoRotate && this.state === -1 && this.rotateLeft(this.getAutoRotationAngle()), this.enableDamping ? (this.spherical.theta += this.sphericalDelta.theta * this.dampingFactor, this.spherical.phi += this.sphericalDelta.phi * this.dampingFactor) : (this.spherical.theta += this.sphericalDelta.theta, this.spherical.phi += this.sphericalDelta.phi), this.spherical.theta = Math.max(
|
|
1349
|
-
this.minAzimuthAngle,
|
|
1350
|
-
Math.min(this.maxAzimuthAngle, this.spherical.theta)
|
|
1351
|
-
), this.spherical.phi = Math.max(
|
|
1352
|
-
this.minPolarAngle,
|
|
1353
|
-
Math.min(this.maxPolarAngle, this.spherical.phi)
|
|
1354
|
-
), this.spherical.makeSafe(), this.spherical.radius *= this.scale, this.spherical.radius = Math.max(
|
|
1355
|
-
this.minDistance,
|
|
1356
|
-
Math.min(this.maxDistance, this.spherical.radius)
|
|
1357
|
-
), this.enableDamping === !0 ? this.target.addScaledVector(this.panOffset, this.dampingFactor) : this.target.add(this.panOffset), this.offset.setFromSpherical(this.spherical), this.offset.applyQuaternion(this.quatInverse), this.object.position.copy(this.target).add(this.offset), this.object.lookAt(this.target), this.enableDamping === !0 ? (this.sphericalDelta.theta *= 1 - this.dampingFactor, this.sphericalDelta.phi *= 1 - this.dampingFactor, this.panOffset.multiplyScalar(1 - this.dampingFactor)) : (this.sphericalDelta.set(0, 0, 0), this.panOffset.set(0, 0, 0)), this.scale = 1, this.zoomChanged || this.lastPosition.distanceToSquared(this.object.position) > this.EPS || 8 * (1 - this.lastQuaternion.dot(this.object.quaternion)) > this.EPS || this.lastTarget.distanceToSquared(this.target) > this.EPS ? (this.dispatchEvent({ type: "change" }), this.lastPosition.copy(this.object.position), this.lastQuaternion.copy(this.object.quaternion), this.lastTarget.copy(this.target), this.zoomChanged = !1, !0) : !1;
|
|
1358
|
-
}
|
|
1359
|
-
dispose() {
|
|
1360
|
-
this.domElements.forEach(
|
|
1361
|
-
(t) => this.removeEventListeners(t)
|
|
1362
|
-
), this.dispatchEvent({ type: "dispose" });
|
|
1363
|
-
}
|
|
1364
|
-
addDomElements(...t) {
|
|
1365
|
-
t.forEach((e) => {
|
|
1366
|
-
this.domElements.includes(e) || (this.domElements.push(e), this.addEventListeners(e));
|
|
1367
|
-
});
|
|
1368
|
-
}
|
|
1369
|
-
removeDomElements(...t) {
|
|
1370
|
-
t.forEach((e) => {
|
|
1371
|
-
const a = this.domElements.indexOf(e);
|
|
1372
|
-
a > -1 && (this.removeEventListeners(e), this.domElements.splice(a, 1));
|
|
1373
|
-
});
|
|
1374
|
-
}
|
|
1375
|
-
setDomElements(...t) {
|
|
1376
|
-
this.removeDomElements(...this.domElements), this.domElements = [], this.addDomElements(...t);
|
|
1377
|
-
}
|
|
1378
|
-
computeEncompassingView(t, e = 0) {
|
|
1379
|
-
const a = t.center, r = t.sphere.radius, l = this.object.fov * (Math.PI / 180), d = this.object.aspect, P = l / 2, R = Math.atan(Math.tan(P) * d), w = r / Math.sin(P), v = r / Math.sin(R), y = Math.max(w, v) * (1 + e), V = this.object.position.clone().sub(this.target).normalize(), X = V.length() > 1e-3 ? V : new h(0, 0, 1);
|
|
1380
|
-
return {
|
|
1381
|
-
position: a.clone().add(X.multiplyScalar(y)),
|
|
1382
|
-
target: a
|
|
1383
|
-
};
|
|
1384
|
-
}
|
|
1385
|
-
focusObject(t, e = 0) {
|
|
1386
|
-
const a = new L(t), n = this.computeEncompassingView(a, e);
|
|
1387
|
-
this.object.position.copy(n.position), this.target.copy(n.target), this.update();
|
|
1388
|
-
}
|
|
1389
|
-
zoomIn(t) {
|
|
1390
|
-
this.dollyIn(Math.pow(0.95, t ?? _.DEFAULT_ZOOM_FACTOR)), this.update();
|
|
1391
|
-
}
|
|
1392
|
-
zoomOut(t) {
|
|
1393
|
-
this.dollyOut(
|
|
1394
|
-
Math.pow(0.95, t ?? _.DEFAULT_ZOOM_FACTOR)
|
|
1395
|
-
), this.update();
|
|
1396
|
-
}
|
|
1397
|
-
getState() {
|
|
1398
|
-
return {
|
|
1399
|
-
target: this.target.clone(),
|
|
1400
|
-
azimuthalAngle: this.getAzimuthalAngle(),
|
|
1401
|
-
polarAngle: this.getPolarAngle(),
|
|
1402
|
-
distance: this.getDistance(),
|
|
1403
|
-
position: this.object.position.clone(),
|
|
1404
|
-
quaternion: this.object.quaternion.clone()
|
|
1405
|
-
};
|
|
1406
|
-
}
|
|
1407
|
-
setState(t) {
|
|
1408
|
-
this.target.copy(t.target), this.object.position.copy(t.position), this.object.quaternion.copy(t.quaternion), this.update();
|
|
1409
|
-
}
|
|
1410
|
-
//
|
|
1411
|
-
// Private methods
|
|
1412
|
-
//
|
|
1413
|
-
addEventListeners(t) {
|
|
1414
|
-
t.style.touchAction = "none", t.addEventListener("contextmenu", this.onContextMenu), t.addEventListener("pointerdown", this.onPointerDown), t.addEventListener("pointercancel", this.onPointerCancel), t.addEventListener("wheel", this.onMouseWheel, {
|
|
1415
|
-
passive: !1
|
|
1416
|
-
}), t.addEventListener("keydown", this.onKeyDown);
|
|
1417
|
-
}
|
|
1418
|
-
removeEventListeners(t) {
|
|
1419
|
-
t.removeEventListener("contextmenu", this.onContextMenu), t.removeEventListener("pointerdown", this.onPointerDown), t.removeEventListener("pointercancel", this.onPointerCancel), t.removeEventListener("wheel", this.onMouseWheel), t.removeEventListener("keydown", this.onKeyDown), t.removeEventListener("pointermove", this.onPointerMove), t.removeEventListener("pointerup", this.onPointerUp);
|
|
1420
|
-
}
|
|
1421
|
-
getAutoRotationAngle() {
|
|
1422
|
-
return 2 * Math.PI / 60 / 60 * this.autoRotateSpeed;
|
|
1423
|
-
}
|
|
1424
|
-
getZoomScale() {
|
|
1425
|
-
return Math.pow(0.95, this.zoomSpeed);
|
|
1426
|
-
}
|
|
1427
|
-
rotateLeft(t) {
|
|
1428
|
-
this.sphericalDelta.theta -= t;
|
|
1429
|
-
}
|
|
1430
|
-
rotateUp(t) {
|
|
1431
|
-
this.sphericalDelta.phi -= t;
|
|
1432
|
-
}
|
|
1433
|
-
pan(t, e, a) {
|
|
1434
|
-
const n = new h();
|
|
1435
|
-
if ("isPerspectiveCamera" in this.object) {
|
|
1436
|
-
const r = this.object.position;
|
|
1437
|
-
n.copy(r).sub(this.target);
|
|
1438
|
-
let l = n.length();
|
|
1439
|
-
l *= Math.tan(
|
|
1440
|
-
this.object.fov / 2 * Math.PI / 180
|
|
1441
|
-
), this.panLeft(
|
|
1442
|
-
2 * t * l / a.clientHeight,
|
|
1443
|
-
this.object.matrix
|
|
1444
|
-
), this.panUp(
|
|
1445
|
-
2 * e * l / a.clientHeight,
|
|
1446
|
-
this.object.matrix
|
|
1447
|
-
);
|
|
1448
|
-
} else "isOrthographicCamera" in this.object ? (this.panLeft(
|
|
1449
|
-
t * (this.object.right - this.object.left) / this.object.zoom / a.clientWidth,
|
|
1450
|
-
this.object.matrix
|
|
1451
|
-
), this.panUp(
|
|
1452
|
-
e * (this.object.top - this.object.bottom) / this.object.zoom / a.clientHeight,
|
|
1453
|
-
this.object.matrix
|
|
1454
|
-
)) : (console.warn(
|
|
1455
|
-
"WARNING: OrbitController encountered an unknown camera type - pan disabled."
|
|
1456
|
-
), this.enablePan = !1);
|
|
1457
|
-
}
|
|
1458
|
-
dollyIn(t) {
|
|
1459
|
-
"isPerspectiveCamera" in this.object || "isOrthographicCamera" in this.object ? this.scale *= t : (console.warn(
|
|
1460
|
-
"WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."
|
|
1461
|
-
), this.enableZoom = !1);
|
|
1462
|
-
}
|
|
1463
|
-
dollyOut(t) {
|
|
1464
|
-
"isPerspectiveCamera" in this.object || "isOrthographicCamera" in this.object ? this.scale /= t : (console.warn(
|
|
1465
|
-
"WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."
|
|
1466
|
-
), this.enableZoom = !1);
|
|
1467
|
-
}
|
|
1468
|
-
// event callbacks
|
|
1469
|
-
handleMouseDownRotate(t) {
|
|
1470
|
-
this.rotateStart.set(t.clientX, t.clientY);
|
|
1471
|
-
}
|
|
1472
|
-
handleMouseDownDolly(t) {
|
|
1473
|
-
this.dollyStart.set(t.clientX, t.clientY);
|
|
1474
|
-
}
|
|
1475
|
-
handleMouseDownPan(t) {
|
|
1476
|
-
this.panStart.set(t.clientX, t.clientY);
|
|
1477
|
-
}
|
|
1478
|
-
handleMouseMoveRotate(t) {
|
|
1479
|
-
this.rotateEnd.set(t.clientX, t.clientY), this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart).multiplyScalar(this.rotateSpeed);
|
|
1480
|
-
const e = t.currentTarget;
|
|
1481
|
-
this.rotateLeft(
|
|
1482
|
-
2 * Math.PI * this.rotateDelta.x / e.clientHeight
|
|
1483
|
-
), this.rotateUp(
|
|
1484
|
-
2 * Math.PI * this.rotateDelta.y / e.clientHeight
|
|
1485
|
-
), this.rotateStart.copy(this.rotateEnd), this.update();
|
|
1486
|
-
}
|
|
1487
|
-
handleMouseMoveDolly(t) {
|
|
1488
|
-
this.dollyEnd.set(t.clientX, t.clientY), this.dollyDelta.subVectors(this.dollyEnd, this.dollyStart), this.dollyDelta.y > 0 ? this.dollyIn(this.getZoomScale()) : this.dollyDelta.y < 0 && this.dollyOut(this.getZoomScale()), this.dollyStart.copy(this.dollyEnd), this.update();
|
|
1489
|
-
}
|
|
1490
|
-
handleMouseMovePan(t) {
|
|
1491
|
-
const e = t.currentTarget;
|
|
1492
|
-
this.panEnd.set(t.clientX, t.clientY), this.panDelta.subVectors(this.panEnd, this.panStart).multiplyScalar(this.panSpeed), this.pan(this.panDelta.x, this.panDelta.y, e), this.panStart.copy(this.panEnd), this.update();
|
|
1493
|
-
}
|
|
1494
|
-
handleMouseWheel(t) {
|
|
1495
|
-
t.deltaY < 0 ? this.dollyIn(this.getZoomScale()) : t.deltaY > 0 && this.dollyOut(this.getZoomScale()), this.update();
|
|
1496
|
-
}
|
|
1497
|
-
handleKeyDown(t) {
|
|
1498
|
-
let e = !1;
|
|
1499
|
-
const a = t.currentTarget;
|
|
1500
|
-
switch (t.code) {
|
|
1501
|
-
case this.keys.UP:
|
|
1502
|
-
this.pan(0, this.keyPanSpeed, a), e = !0;
|
|
1503
|
-
break;
|
|
1504
|
-
case this.keys.BOTTOM:
|
|
1505
|
-
this.pan(0, -this.keyPanSpeed, a), e = !0;
|
|
1506
|
-
break;
|
|
1507
|
-
case this.keys.LEFT:
|
|
1508
|
-
this.pan(this.keyPanSpeed, 0, a), e = !0;
|
|
1509
|
-
break;
|
|
1510
|
-
case this.keys.RIGHT:
|
|
1511
|
-
this.pan(-this.keyPanSpeed, 0, a), e = !0;
|
|
1512
|
-
break;
|
|
1513
|
-
}
|
|
1514
|
-
e && (t.preventDefault(), this.update());
|
|
1515
|
-
}
|
|
1516
|
-
handleTouchStartRotate(t) {
|
|
1517
|
-
if (this.pointers.length === 1)
|
|
1518
|
-
this.rotateStart.set(t.pageX, t.pageY);
|
|
1519
|
-
else {
|
|
1520
|
-
const e = this.getSecondPointer(t), a = 0.5 * (t.pageX + e.pageX), n = 0.5 * (t.pageY + e.pageY);
|
|
1521
|
-
this.rotateStart.set(a, n);
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
handleTouchStartPan(t) {
|
|
1525
|
-
if (this.pointers.length === 1)
|
|
1526
|
-
this.panStart.set(t.pageX, t.pageY);
|
|
1527
|
-
else {
|
|
1528
|
-
const e = this.getSecondPointer(t), a = 0.5 * (t.pageX + e.pageX), n = 0.5 * (t.pageY + e.pageY);
|
|
1529
|
-
this.panStart.set(a, n);
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
handleTouchStartDolly(t) {
|
|
1533
|
-
const e = this.getSecondPointer(t), a = t.pageX - e.pageX, n = t.pageY - e.pageY, r = Math.sqrt(a * a + n * n);
|
|
1534
|
-
this.dollyStart.set(0, r);
|
|
1535
|
-
}
|
|
1536
|
-
handleTouchStartDollyPan(t) {
|
|
1537
|
-
this.enableZoom && this.handleTouchStartDolly(t), this.enablePan && this.handleTouchStartPan(t);
|
|
1538
|
-
}
|
|
1539
|
-
handleTouchStartDollyRotate(t) {
|
|
1540
|
-
this.enableZoom && this.handleTouchStartDolly(t), this.enableRotate && this.handleTouchStartRotate(t);
|
|
1541
|
-
}
|
|
1542
|
-
handleTouchMoveRotate(t) {
|
|
1543
|
-
if (this.pointers.length === 1)
|
|
1544
|
-
this.rotateEnd.set(t.pageX, t.pageY);
|
|
1545
|
-
else {
|
|
1546
|
-
const a = this.getSecondPointer(t), n = 0.5 * (t.pageX + a.pageX), r = 0.5 * (t.pageY + a.pageY);
|
|
1547
|
-
this.rotateEnd.set(n, r);
|
|
1548
|
-
}
|
|
1549
|
-
const e = t.currentTarget;
|
|
1550
|
-
this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart).multiplyScalar(this.rotateSpeed), this.rotateLeft(
|
|
1551
|
-
2 * Math.PI * this.rotateDelta.x / e.clientHeight
|
|
1552
|
-
), this.rotateUp(
|
|
1553
|
-
2 * Math.PI * this.rotateDelta.y / e.clientHeight
|
|
1554
|
-
), this.rotateStart.copy(this.rotateEnd);
|
|
1555
|
-
}
|
|
1556
|
-
handleTouchMovePan(t) {
|
|
1557
|
-
if (this.pointers.length === 1)
|
|
1558
|
-
this.panEnd.set(t.pageX, t.pageY);
|
|
1559
|
-
else {
|
|
1560
|
-
const a = this.getSecondPointer(t), n = 0.5 * (t.pageX + a.pageX), r = 0.5 * (t.pageY + a.pageY);
|
|
1561
|
-
this.panEnd.set(n, r);
|
|
1562
|
-
}
|
|
1563
|
-
const e = t.currentTarget;
|
|
1564
|
-
this.panDelta.subVectors(this.panEnd, this.panStart).multiplyScalar(this.panSpeed), this.pan(this.panDelta.x, this.panDelta.y, e), this.panStart.copy(this.panEnd);
|
|
1565
|
-
}
|
|
1566
|
-
handleTouchMoveDolly(t) {
|
|
1567
|
-
const e = this.getSecondPointer(t), a = t.pageX - e.pageX, n = t.pageY - e.pageY, r = Math.sqrt(a * a + n * n);
|
|
1568
|
-
this.dollyEnd.set(0, r), this.dollyDelta.set(
|
|
1569
|
-
0,
|
|
1570
|
-
Math.pow(this.dollyEnd.y / this.dollyStart.y, this.zoomSpeed)
|
|
1571
|
-
), this.dollyOut(this.dollyDelta.y), this.dollyStart.copy(this.dollyEnd);
|
|
1572
|
-
}
|
|
1573
|
-
handleTouchMoveDollyPan(t) {
|
|
1574
|
-
this.enableZoom && this.handleTouchMoveDolly(t), this.enablePan && this.handleTouchMovePan(t);
|
|
1575
|
-
}
|
|
1576
|
-
handleTouchMoveDollyRotate(t) {
|
|
1577
|
-
this.enableZoom && this.handleTouchMoveDolly(t), this.enableRotate && this.handleTouchMoveRotate(t);
|
|
1578
|
-
}
|
|
1579
|
-
addPointer(t) {
|
|
1580
|
-
this.pointers.push(t);
|
|
1581
|
-
}
|
|
1582
|
-
removePointer(t) {
|
|
1583
|
-
delete this.pointerPositions[t.pointerId];
|
|
1584
|
-
for (let e = 0; e < this.pointers.length; e++)
|
|
1585
|
-
if (this.pointers[e].pointerId == t.pointerId) {
|
|
1586
|
-
this.pointers.splice(e, 1);
|
|
1587
|
-
return;
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
trackPointer(t) {
|
|
1591
|
-
let e = this.pointerPositions[t.pointerId];
|
|
1592
|
-
e === void 0 && (e = new c(), this.pointerPositions[t.pointerId] = e), e.set(t.pageX, t.pageY);
|
|
1593
|
-
}
|
|
1594
|
-
getSecondPointer(t) {
|
|
1595
|
-
return this.pointers[0].pointerId === t.pointerId ? this.pointers[1] : this.pointers[0];
|
|
1596
|
-
}
|
|
1597
|
-
isTrackingPointer(t) {
|
|
1598
|
-
return this.pointers.some(
|
|
1599
|
-
(e) => e.pointerId === t.pointerId
|
|
1600
|
-
);
|
|
1601
|
-
}
|
|
1602
|
-
};
|
|
1603
|
-
i(_, "DEFAULT_ZOOM_FACTOR", 1);
|
|
1604
|
-
let G = _;
|
|
1605
|
-
const Rt = `
|
|
1606
|
-
@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@
|
|
1607
|
-
@@@@+-:::::::---------------------==------------------------------=#@@@@
|
|
1608
|
-
@@%=::::.......::---------------------------------------------------------+@@
|
|
1609
|
-
@@+:::...........::-----------------------------------------------------------#@@
|
|
1610
|
-
@@=:::.........::::::-------------------------------------------------------------%@
|
|
1611
|
-
@%:::.......:::::::-----------------------------------------------------------------#@
|
|
1612
|
-
@*:::.....:::::-----------------------------------------------------------------------*@
|
|
1613
|
-
@%::::::.::::---------------------------------------------------------------------------@@
|
|
1614
|
-
@@-:::::::::-----------------------------------------------------------------------------=@
|
|
1615
|
-
@%::::::::--------------------------------------------------------------------------------%@
|
|
1616
|
-
@+::::::::--------------------------------=@@@@@%-----------------------------------------%@
|
|
1617
|
-
@=:::::::--------------------------------*@@ @@+---------------------------------------#@
|
|
1618
|
-
@+:::::::-------------------------------*@ @*--------------------------------------%@
|
|
1619
|
-
@#::::::::-----------------------------=@@ @@=-------------------------------------%@
|
|
1620
|
-
@@-::::::::----------------------------@@ @@------------------------------------=@
|
|
1621
|
-
@%:::::::::--------------------------*@ @*-----------------------------------@@
|
|
1622
|
-
@*:::::::::-------------------------@@ @@----------------------------------%@
|
|
1623
|
-
@#::::::::::----------------------%@ @%--------------------------------%@
|
|
1624
|
-
@#:::::::::::-------------------=@@ @@=------------------------------%@
|
|
1625
|
-
@@-::::::::::::----------------%@ @%----------------------------=@@
|
|
1626
|
-
@@#::::::::::::::------------*@ @*--------------------------#@@
|
|
1627
|
-
@@+::::::::::::::::--------@@ @@------------------------+@@
|
|
1628
|
-
@@*:::::::::::::::::----@@ @@---------------------+@@
|
|
1629
|
-
@@@-:::::::::::::::--#@ @#-----------------=%@@
|
|
1630
|
-
@@%-::::::::::::-%@ @%-------------=%@@
|
|
1631
|
-
@@@@+:::::::#@@ @@*-------*@@@@
|
|
1632
|
-
@@@@@@@ @@@@@@
|
|
1633
|
-
`;
|
|
1634
|
-
window.DIVE = {
|
|
1635
|
-
instances: [],
|
|
1636
|
-
get instance() {
|
|
1637
|
-
return window.DIVE.instances[0];
|
|
1638
|
-
}
|
|
1639
|
-
};
|
|
1640
|
-
const b = {
|
|
1641
|
-
autoStart: !0,
|
|
1642
|
-
displayAxes: !1,
|
|
1643
|
-
...D,
|
|
1644
|
-
..._t,
|
|
1645
|
-
...W,
|
|
1646
|
-
...xt
|
|
1647
|
-
};
|
|
1648
|
-
class Vt {
|
|
1649
|
-
constructor(s) {
|
|
1650
|
-
// descriptive members
|
|
1651
|
-
i(this, "_instanceId", I.generateUUID());
|
|
1652
|
-
i(this, "_settings");
|
|
1653
|
-
i(this, "_views");
|
|
1654
|
-
i(this, "_mainView");
|
|
1655
|
-
i(this, "_scene");
|
|
1656
|
-
i(this, "_clock");
|
|
1657
|
-
i(this, "_orientationDisplay", null);
|
|
1658
|
-
this._settings = {
|
|
1659
|
-
...b,
|
|
1660
|
-
...s ?? {}
|
|
1661
|
-
}, this._clock = new wt(), this._scene = new kt({
|
|
1662
|
-
backgroundColor: (s == null ? void 0 : s.backgroundColor) ?? b.backgroundColor,
|
|
1663
|
-
displayGrid: (s == null ? void 0 : s.displayGrid) ?? b.displayGrid,
|
|
1664
|
-
displayFloor: (s == null ? void 0 : s.displayFloor) ?? b.displayFloor
|
|
1665
|
-
});
|
|
1666
|
-
const t = new B(
|
|
1667
|
-
this._scene,
|
|
1668
|
-
new z(),
|
|
1669
|
-
this._settings
|
|
1670
|
-
);
|
|
1671
|
-
this._clock.addTicker(t), this._views = [t], this._mainView = t, this._settings.displayAxes && import("../plugins/orientationdisplay/index.mjs").then(
|
|
1672
|
-
({ OrientationDisplay: e }) => {
|
|
1673
|
-
this._orientationDisplay = new e(
|
|
1674
|
-
this.mainView.renderer,
|
|
1675
|
-
this.scene,
|
|
1676
|
-
this.mainView.camera
|
|
1677
|
-
), this._clock.addTicker(this._orientationDisplay);
|
|
1678
|
-
}
|
|
1679
|
-
), this._settings.autoStart && this.start(), console.log("DIVE 2.2.17 initialized successfully!"), console.log(Rt), window.DIVE.instances.push(this);
|
|
1680
|
-
}
|
|
1681
|
-
/**
|
|
1682
|
-
* @deprecated This static method will be removed in a future version. Please use `import { QuickView, QuickViewSettings, QuickViewDefaultSettings } from '@shopware-ag/dive/quickview'` instead.
|
|
1683
|
-
*/
|
|
1684
|
-
static async QuickView(s, t) {
|
|
1685
|
-
return import("../plugins/quickview/index.mjs").then(
|
|
1686
|
-
({ QuickView: e }) => e(s, t)
|
|
1687
|
-
);
|
|
1688
|
-
}
|
|
1689
|
-
/**
|
|
1690
|
-
* @deprecated This property will be removed in a future version. Please use properties on the DIVE instance and mainView directly.
|
|
1691
|
-
*/
|
|
1692
|
-
get engine() {
|
|
1693
|
-
return {
|
|
1694
|
-
scene: this.scene,
|
|
1695
|
-
camera: this.mainView.camera,
|
|
1696
|
-
renderer: this.mainView.renderer,
|
|
1697
|
-
setCanvas: (s) => {
|
|
1698
|
-
this.mainView.setCanvas(s);
|
|
1699
|
-
},
|
|
1700
|
-
clock: this.clock,
|
|
1701
|
-
start: () => {
|
|
1702
|
-
this.start();
|
|
1703
|
-
},
|
|
1704
|
-
stop: () => {
|
|
1705
|
-
this.stop();
|
|
1706
|
-
},
|
|
1707
|
-
dispose: () => {
|
|
1708
|
-
this.dispose();
|
|
1709
|
-
}
|
|
1710
|
-
};
|
|
1711
|
-
}
|
|
1712
|
-
get views() {
|
|
1713
|
-
return this._views;
|
|
1714
|
-
}
|
|
1715
|
-
get mainView() {
|
|
1716
|
-
return this._mainView;
|
|
1717
|
-
}
|
|
1718
|
-
get canvas() {
|
|
1719
|
-
return this.mainView.canvas;
|
|
1720
|
-
}
|
|
1721
|
-
get scene() {
|
|
1722
|
-
return this._scene;
|
|
1723
|
-
}
|
|
1724
|
-
get clock() {
|
|
1725
|
-
return this._clock;
|
|
1726
|
-
}
|
|
1727
|
-
start() {
|
|
1728
|
-
this._clock.start();
|
|
1729
|
-
}
|
|
1730
|
-
stop() {
|
|
1731
|
-
this._clock.stop();
|
|
1732
|
-
}
|
|
1733
|
-
async dispose() {
|
|
1734
|
-
return new Promise((s) => {
|
|
1735
|
-
this._views.forEach((t) => {
|
|
1736
|
-
t.dispose();
|
|
1737
|
-
}), this._views = [], this._orientationDisplay && (this._clock.removeTicker(this._orientationDisplay), this._orientationDisplay.dispose()), this.scene.dispose(), window.DIVE.instances = window.DIVE.instances.filter(
|
|
1738
|
-
(t) => t._instanceId !== this._instanceId
|
|
1739
|
-
), s();
|
|
1740
|
-
});
|
|
1741
|
-
}
|
|
1742
|
-
createView(s) {
|
|
1743
|
-
const t = new B(
|
|
1744
|
-
this._scene,
|
|
1745
|
-
s ?? new z(),
|
|
1746
|
-
{
|
|
1747
|
-
...this._settings,
|
|
1748
|
-
canvas: void 0
|
|
1749
|
-
// instantiate new canvas for created view
|
|
1750
|
-
}
|
|
1751
|
-
);
|
|
1752
|
-
return this._views.push(t), this._clock.addTicker(t), this._views.length === 1 && (this._mainView = t), t;
|
|
1753
|
-
}
|
|
1754
|
-
disposeView(s) {
|
|
1755
|
-
this._views = this._views.filter((t) => t !== s), this._clock.removeTicker(s), this._mainView === s && (this._mainView = this._views[0]), s.dispose();
|
|
1756
|
-
}
|
|
1757
|
-
}
|
|
1758
|
-
const Ft = Vt, At = {
|
|
1759
|
-
glb: {
|
|
1760
|
-
key: "glb",
|
|
1761
|
-
extension: "glb"
|
|
1762
|
-
},
|
|
1763
|
-
gltf: {
|
|
1764
|
-
key: "gltf",
|
|
1765
|
-
extension: "gltf"
|
|
1766
|
-
},
|
|
1767
|
-
usdz: {
|
|
1768
|
-
key: "usdz",
|
|
1769
|
-
extension: "usdz"
|
|
1770
|
-
}
|
|
1771
|
-
}, Ut = Object.values(At).map(
|
|
1772
|
-
(o) => o.extension
|
|
1773
|
-
);
|
|
1774
|
-
export {
|
|
1775
|
-
L as B,
|
|
1776
|
-
b as D,
|
|
1777
|
-
At as F,
|
|
1778
|
-
Lt as G,
|
|
1779
|
-
xt as O,
|
|
1780
|
-
Ut as S,
|
|
1781
|
-
G as a,
|
|
1782
|
-
Vt as b,
|
|
1783
|
-
Et as c,
|
|
1784
|
-
N as d,
|
|
1785
|
-
Ft as e,
|
|
1786
|
-
wt as f,
|
|
1787
|
-
W as g,
|
|
1788
|
-
H as h,
|
|
1789
|
-
Gt as i,
|
|
1790
|
-
yt as j,
|
|
1791
|
-
D as k,
|
|
1792
|
-
kt as l,
|
|
1793
|
-
B as m,
|
|
1794
|
-
It as n,
|
|
1795
|
-
vt as o,
|
|
1796
|
-
Tt as p,
|
|
1797
|
-
Pt as q,
|
|
1798
|
-
bt as r,
|
|
1799
|
-
Dt as s,
|
|
1800
|
-
x as t,
|
|
1801
|
-
St as u,
|
|
1802
|
-
Mt as v,
|
|
1803
|
-
Z as w
|
|
1804
|
-
};
|