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