@shopware-ag/dive 2.0.1-beta.10 → 2.0.1-beta.11

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 (57) hide show
  1. package/build/chunks/{AssetCache-CZV5A70i.mjs → AssetCache-CsfCIl9J.mjs} +1 -1
  2. package/build/chunks/{AssetCache-C-7MpNrK.cjs → AssetCache-DGLqbo2B.cjs} +1 -1
  3. package/build/chunks/{AssetLoader-Dnh5tbUZ.mjs → AssetLoader-DvF8gL8a.mjs} +2 -2
  4. package/build/chunks/{AssetLoader-BZlqXTbf.cjs → AssetLoader-H_GSIMop.cjs} +1 -1
  5. package/build/chunks/FileTypes-CHutqD19.cjs +30 -0
  6. package/build/chunks/{FileTypes-DMybIHHj.mjs → FileTypes-IBuu9ohV.mjs} +153 -205
  7. package/build/chunks/OrbitController-BQ6SV1O_.mjs +1159 -0
  8. package/build/chunks/OrbitController-CpFQ3A1H.cjs +1 -0
  9. package/build/chunks/PerspectiveCamera-BByyG5R4.cjs +1 -0
  10. package/build/chunks/PerspectiveCamera-PMJPzAn3.mjs +34 -0
  11. package/build/chunks/{SelectTool-D5QfT5rr.mjs → SelectTool-BU0vTDXg.mjs} +4 -4
  12. package/build/chunks/SelectTool-CAqDMcoM.cjs +1 -0
  13. package/build/chunks/VisibilityLayerMask-BI7jPKdx.cjs +1 -0
  14. package/build/chunks/VisibilityLayerMask-CXgt1fJc.mjs +8 -0
  15. package/build/chunks/package-CmvmIjT5.cjs +1 -0
  16. package/build/chunks/package-DSKqbNMb.mjs +39 -0
  17. package/build/dive.cjs +1 -1
  18. package/build/dive.mjs +55 -53
  19. package/build/plugins/ar/index.cjs +1 -1
  20. package/build/plugins/ar/index.mjs +1 -1
  21. package/build/plugins/assetcache/index.cjs +1 -1
  22. package/build/plugins/assetcache/index.mjs +1 -1
  23. package/build/plugins/assetloader/index.cjs +1 -1
  24. package/build/plugins/assetloader/index.mjs +1 -1
  25. package/build/plugins/mediacreator/index.cjs +1 -1
  26. package/build/plugins/mediacreator/index.mjs +1 -1
  27. package/build/plugins/orbitcontroller/index.cjs +1 -1
  28. package/build/plugins/orbitcontroller/index.mjs +1 -1
  29. package/build/plugins/orientationdisplay/index.cjs +1 -0
  30. package/build/plugins/orientationdisplay/index.d.ts +2 -0
  31. package/build/plugins/orientationdisplay/index.mjs +5 -0
  32. package/build/plugins/state/index.cjs +3 -3
  33. package/build/plugins/state/index.mjs +353 -352
  34. package/build/plugins/toolbox/index.cjs +1 -1
  35. package/build/plugins/toolbox/index.mjs +12 -12
  36. package/build/src/components/boundingbox/BoundingBox.d.ts +136 -0
  37. package/build/src/core/Dive.d.ts +1 -1
  38. package/build/src/plugins/orbitcontroller/src/OrbitController.d.ts +17 -2
  39. package/build/src/plugins/orientationdisplay/index.d.ts +2 -0
  40. package/build/src/plugins/{axiscamera/src/AxisCamera.d.ts → orientationdisplay/src/OrientationDisplay.d.ts} +5 -5
  41. package/build/src/plugins/orientationdisplay/src/axes/Axes.d.ts +6 -0
  42. package/build/src/plugins/state/src/actions/toolbox/setgizmovisible.d.ts +2 -2
  43. package/build/src/plugins/toolbox/src/Toolbox.d.ts +1 -1
  44. package/build/src/plugins/toolbox/src/transform/TransformTool.d.ts +1 -1
  45. package/package.json +6 -6
  46. package/build/chunks/FileTypes-PEcAgRZ8.cjs +0 -30
  47. package/build/chunks/OrbitController-D-WNei2f.mjs +0 -940
  48. package/build/chunks/OrbitController-rMX8EHvJ.cjs +0 -1
  49. package/build/chunks/PerspectiveCamera-CONx93im.cjs +0 -1
  50. package/build/chunks/PerspectiveCamera-DUiWJJIj.mjs +0 -38
  51. package/build/chunks/SelectTool-BVxDEcnM.cjs +0 -1
  52. package/build/chunks/package-Bf92jAR_.cjs +0 -1
  53. package/build/chunks/package-ZPbjnXun.mjs +0 -39
  54. package/build/plugins/axiscamera/index.cjs +0 -1
  55. package/build/plugins/axiscamera/index.d.ts +0 -2
  56. package/build/plugins/axiscamera/index.mjs +0 -4
  57. package/build/src/plugins/axiscamera/index.d.ts +0 -1
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var r=(t,e,o)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var i=(t,e,o)=>r(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../chunks/SelectTool-BVxDEcnM.cjs");class n{constructor(e,o){i(this,"_scene");i(this,"_controller");i(this,"_activeTool");i(this,"_selectTool");this._scene=e,this._controller=o,this._selectTool=null,this._activeTool=null}get selectTool(){return this._selectTool||(this._selectTool=new l.DIVESelectTool(this._scene,this._controller)),this._selectTool}dispose(){this.removeEventListeners()}getActiveTool(){return this._activeTool}useTool(e){var o;switch((o=this._activeTool)==null||o.deactivate(),e){case"select":{this.addEventListeners(),this.selectTool.activate(),this._activeTool=this.selectTool;break}case"none":{this.removeEventListeners(),this._activeTool=null;break}default:console.warn(`DIVEToolBox.useTool: Unknown tool: ${e}`)}}setGizmoMode(e){this.selectTool.setGizmoMode(e)}setGizmoVisibility(e){this.selectTool.setGizmoVisibility(e)}setGizmoScaleLinked(e){this.selectTool.setGizmoScaleLinked(e)}onPointerMove(e){var o;(o=this._activeTool)==null||o.onPointerMove(e)}onPointerDown(e){var o;(o=this._activeTool)==null||o.onPointerDown(e)}onPointerUp(e){var o;(o=this._activeTool)==null||o.onPointerUp(e)}onWheel(e){var o;(o=this._activeTool)==null||o.onWheel(e)}addEventListeners(){this._controller.domElement.addEventListener("pointermove",e=>this.onPointerMove(e)),this._controller.domElement.addEventListener("pointerdown",e=>this.onPointerDown(e)),this._controller.domElement.addEventListener("pointerup",e=>this.onPointerUp(e)),this._controller.domElement.addEventListener("wheel",e=>this.onWheel(e))}removeEventListeners(){this._controller.domElement.removeEventListener("pointermove",e=>this.onPointerMove(e)),this._controller.domElement.removeEventListener("pointerdown",e=>this.onPointerDown(e)),this._controller.domElement.removeEventListener("pointerup",e=>this.onPointerUp(e)),this._controller.domElement.removeEventListener("wheel",e=>this.onWheel(e))}}i(n,"DefaultTool","select");exports.DIVEBaseTool=l.DIVEBaseTool;exports.DIVESelectTool=l.DIVESelectTool;exports.DIVETransformTool=l.DIVETransformTool;exports.isSelectTool=l.isSelectTool;exports.isTransformTool=l.isTransformTool;exports.Toolbox=n;
1
+ "use strict";var s=Object.defineProperty;var r=(t,e,o)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var l=(t,e,o)=>r(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../chunks/SelectTool-CAqDMcoM.cjs");class i{constructor(e,o){l(this,"_scene");l(this,"_controller");l(this,"_activeTool");l(this,"_selectTool");this._scene=e,this._controller=o,this._selectTool=null,this._activeTool=null}get selectTool(){return this._selectTool||(this._selectTool=new n.DIVESelectTool(this._scene,this._controller)),this._selectTool}dispose(){this.removeEventListeners()}getActiveTool(){return this._activeTool}useTool(e){var o;switch((o=this._activeTool)==null||o.deactivate(),e){case"select":{this.addEventListeners(),this.selectTool.activate(),this._activeTool=this.selectTool;break}case"none":{this.removeEventListeners(),this._activeTool=null;break}default:console.warn(`DIVEToolBox.useTool: Unknown tool: ${e}`)}}setGizmoMode(e){this.selectTool.setGizmoMode(e)}setGizmoVisible(e){this.selectTool.setGizmoVisible(e)}setGizmoScaleLinked(e){this.selectTool.setGizmoScaleLinked(e)}onPointerMove(e){var o;(o=this._activeTool)==null||o.onPointerMove(e)}onPointerDown(e){var o;(o=this._activeTool)==null||o.onPointerDown(e)}onPointerUp(e){var o;(o=this._activeTool)==null||o.onPointerUp(e)}onWheel(e){var o;(o=this._activeTool)==null||o.onWheel(e)}addEventListeners(){this._controller.domElement.addEventListener("pointermove",e=>this.onPointerMove(e)),this._controller.domElement.addEventListener("pointerdown",e=>this.onPointerDown(e)),this._controller.domElement.addEventListener("pointerup",e=>this.onPointerUp(e)),this._controller.domElement.addEventListener("wheel",e=>this.onWheel(e))}removeEventListeners(){this._controller.domElement.removeEventListener("pointermove",e=>this.onPointerMove(e)),this._controller.domElement.removeEventListener("pointerdown",e=>this.onPointerDown(e)),this._controller.domElement.removeEventListener("pointerup",e=>this.onPointerUp(e)),this._controller.domElement.removeEventListener("wheel",e=>this.onWheel(e))}}l(i,"DefaultTool","select");exports.DIVEBaseTool=n.DIVEBaseTool;exports.DIVESelectTool=n.DIVESelectTool;exports.DIVETransformTool=n.DIVETransformTool;exports.isSelectTool=n.isSelectTool;exports.isTransformTool=n.isTransformTool;exports.Toolbox=i;
@@ -1,14 +1,14 @@
1
- var n = Object.defineProperty;
2
- var s = (t, e, o) => e in t ? n(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
- var i = (t, e, o) => s(t, typeof e != "symbol" ? e + "" : e, o);
4
- import { D as l } from "../../chunks/SelectTool-D5QfT5rr.mjs";
5
- import { a as m, c as T, i as d, b as _ } from "../../chunks/SelectTool-D5QfT5rr.mjs";
1
+ var i = Object.defineProperty;
2
+ var s = (t, e, o) => e in t ? i(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var n = (t, e, o) => s(t, typeof e != "symbol" ? e + "" : e, o);
4
+ import { D as l } from "../../chunks/SelectTool-BU0vTDXg.mjs";
5
+ import { a as m, c as T, i as d, b as _ } from "../../chunks/SelectTool-BU0vTDXg.mjs";
6
6
  class r {
7
7
  constructor(e, o) {
8
- i(this, "_scene");
9
- i(this, "_controller");
10
- i(this, "_activeTool");
11
- i(this, "_selectTool");
8
+ n(this, "_scene");
9
+ n(this, "_controller");
10
+ n(this, "_activeTool");
11
+ n(this, "_selectTool");
12
12
  this._scene = e, this._controller = o, this._selectTool = null, this._activeTool = null;
13
13
  }
14
14
  get selectTool() {
@@ -41,8 +41,8 @@ class r {
41
41
  setGizmoMode(e) {
42
42
  this.selectTool.setGizmoMode(e);
43
43
  }
44
- setGizmoVisibility(e) {
45
- this.selectTool.setGizmoVisibility(e);
44
+ setGizmoVisible(e) {
45
+ this.selectTool.setGizmoVisible(e);
46
46
  }
47
47
  setGizmoScaleLinked(e) {
48
48
  this.selectTool.setGizmoScaleLinked(e);
@@ -94,7 +94,7 @@ class r {
94
94
  );
95
95
  }
96
96
  }
97
- i(r, "DefaultTool", "select");
97
+ n(r, "DefaultTool", "select");
98
98
  export {
99
99
  m as DIVEBaseTool,
100
100
  l as DIVESelectTool,
@@ -0,0 +1,136 @@
1
+ import { Box3, Object3D, Sphere, Vector3, ColorRepresentation } from 'three';
2
+ import { DIVENode } from '../node/Node.ts';
3
+ /**
4
+ * A bounding box component that provides both axis-aligned and oriented bounding boxes
5
+ * along with bounding spheres for 3D objects.
6
+ *
7
+ * The BoundingBox class extends DIVENode and creates visual representations of the
8
+ * bounding volumes of 3D objects. It supports two modes:
9
+ * - **Axis-aligned bounding box (AABB)**: Aligned with the world coordinate system
10
+ * - **Oriented bounding box (OBB)**: Aligned with the object's local coordinate system
11
+ *
12
+ * The class also automatically computes a bounding sphere that encompasses the entire object.
13
+ * Both the bounding box and sphere can be visualized as wireframe helpers.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Create a bounding box for a 3D object
18
+ * const mesh = new Mesh(geometry, material);
19
+ * const boundingBox = new BoundingBox(mesh, false, 0x00ff00);
20
+ *
21
+ * // Show the bounding box wireframe
22
+ * boundingBox.setBoxHelperVisible(true);
23
+ *
24
+ * // Access bounding box properties
25
+ * console.log('Center:', boundingBox.center);
26
+ * console.log('Size:', boundingBox.size);
27
+ * console.log('Radius:', boundingBox.radius);
28
+ * ```
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * // Create an axis-aligned bounding box
33
+ * const aabb = new BoundingBox(mesh, true, 0xff0000);
34
+ *
35
+ * // Show the bounding sphere wireframe
36
+ * aabb.setSphereHelperVisible(true);
37
+ * ```
38
+ */
39
+ export declare class BoundingBox extends DIVENode {
40
+ /** The computed bounding box (Box3) */
41
+ private _box;
42
+ /** The computed bounding sphere (Sphere) */
43
+ private _sphere;
44
+ /** The center point of the bounding box */
45
+ private _center;
46
+ /** The radius of the bounding sphere */
47
+ private _radius;
48
+ /** Visual helper for the bounding box wireframe */
49
+ private _boxHelper;
50
+ /** Visual helper for the bounding sphere wireframe */
51
+ private _sphereHelper;
52
+ /** The dimensions (width, height, depth) of the bounding box */
53
+ private _size;
54
+ /**
55
+ * Gets the computed bounding box.
56
+ * @returns The Box3 instance representing the bounding box
57
+ */
58
+ get box(): Box3;
59
+ /**
60
+ * Gets the computed bounding sphere.
61
+ * @returns The Sphere instance representing the bounding sphere
62
+ */
63
+ get sphere(): Sphere;
64
+ /**
65
+ * Gets the center point of the bounding box.
66
+ * @returns A Vector3 representing the center coordinates
67
+ */
68
+ get center(): Vector3;
69
+ /**
70
+ * Gets the radius of the bounding sphere.
71
+ * @returns The radius as a number
72
+ */
73
+ get radius(): number;
74
+ /**
75
+ * Gets the dimensions of the bounding box.
76
+ * @returns A Vector3 representing width, height, and depth
77
+ */
78
+ get size(): Vector3;
79
+ /**
80
+ * Creates a new BoundingBox instance for the specified 3D object.
81
+ *
82
+ * The constructor computes both a bounding box and bounding sphere for the given object.
83
+ * It handles complex objects with multiple meshes and nested transformations.
84
+ *
85
+ * @param object - The 3D object to compute bounding volumes for
86
+ * @param axisAligned - Whether to create an axis-aligned bounding box (true) or oriented bounding box (false). Defaults to false.
87
+ * @param wireframeColor - The color for the wireframe helpers. Can be a hex number or ColorRepresentation. Defaults to green (0x00ff00).
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * // Create an oriented bounding box (aligned with object's rotation)
92
+ * const obb = new BoundingBox(mesh, false, 0x00ff00);
93
+ *
94
+ * // Create an axis-aligned bounding box (aligned with world coordinates)
95
+ * const aabb = new BoundingBox(mesh, true, 0xff0000);
96
+ *
97
+ * // Use default green color
98
+ * const defaultBox = new BoundingBox(mesh);
99
+ * ```
100
+ */
101
+ constructor(object: Object3D, axisAligned?: boolean, wireframeColor?: ColorRepresentation | number);
102
+ /**
103
+ * Sets the visibility of the bounding box wireframe helper.
104
+ *
105
+ * @param visible - Whether the box helper should be visible
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * const boundingBox = new BoundingBox(mesh);
110
+ *
111
+ * // Show the bounding box wireframe
112
+ * boundingBox.setBoxHelperVisible(true);
113
+ *
114
+ * // Hide the bounding box wireframe
115
+ * boundingBox.setBoxHelperVisible(false);
116
+ * ```
117
+ */
118
+ setBoxHelperVisible(visible: boolean): void;
119
+ /**
120
+ * Sets the visibility of the bounding sphere wireframe helper.
121
+ *
122
+ * @param visible - Whether the sphere helper should be visible
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * const boundingBox = new BoundingBox(mesh);
127
+ *
128
+ * // Show the bounding sphere wireframe
129
+ * boundingBox.setSphereHelperVisible(true);
130
+ *
131
+ * // Hide the bounding sphere wireframe
132
+ * boundingBox.setSphereHelperVisible(false);
133
+ * ```
134
+ */
135
+ setSphereHelperVisible(visible: boolean): void;
136
+ }
@@ -50,7 +50,7 @@ export declare class DIVE {
50
50
  get engine(): DIVEEngine;
51
51
  private _engine;
52
52
  private orbitController;
53
- private axisCamera;
53
+ private orientationDisplay;
54
54
  get canvas(): HTMLCanvasElement;
55
55
  setCanvas(canvas: HTMLCanvasElement): void;
56
56
  constructor(settings?: Partial<DIVESettings>);
@@ -1,7 +1,8 @@
1
1
  import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
2
2
  import { Vector3Like } from 'three/src/math/Vector3.js';
3
- import { Box3 } from 'three/src/math/Box3.js';
3
+ import { Object3D } from 'three/src/core/Object3D.js';
4
4
  import { DIVEPerspectiveCamera, DIVETicker } from '../../../index.ts';
5
+ import { BoundingBox } from 'src/components/boundingbox/BoundingBox.ts';
5
6
  export type OrbitControllerSettings = {
6
7
  /** Whether to enable damping for smooth camera movement */
7
8
  enableDamping: boolean;
@@ -21,10 +22,24 @@ export declare class OrbitController extends OrbitControls implements DIVETicker
21
22
  object: DIVEPerspectiveCamera;
22
23
  constructor(camera: DIVEPerspectiveCamera, domElement: HTMLCanvasElement, settings?: Partial<OrbitControllerSettings>);
23
24
  tick(): void;
24
- computeEncompassingView(bb: Box3): {
25
+ /**
26
+ * Computes the camera position and target to perfectly fit a bounding sphere into the camera's frustum.
27
+ * This robust approach ensures the entire object is always visible, regardless of rotation or aspect ratio.
28
+ *
29
+ * @param bb - The bounding box to encompass
30
+ * @param padding - Optional padding factor to add space around the object depending on the object's bounding sphere diameter (default: 0.0 = no padding)
31
+ * @returns Object containing the calculated camera position and target
32
+ */
33
+ computeEncompassingView(bb: BoundingBox, padding?: number): {
25
34
  position: Vector3Like;
26
35
  target: Vector3Like;
27
36
  };
37
+ /**
38
+ * Focus the camera on a specific object by computing its bounding box
39
+ * @param object - The object to focus on
40
+ * @param padding - Optional padding factor to add space around the object depending on the object's bounding sphere diameter (default: 0.0 = no padding)
41
+ */
42
+ focusOnObject(object: Object3D, padding?: number): void;
28
43
  zoomIn(by?: number): void;
29
44
  zoomOut(by?: number): void;
30
45
  }
@@ -0,0 +1,2 @@
1
+ export * from './src/OrientationDisplay.ts';
2
+ export * from './src/axes/Axes.ts';
@@ -1,18 +1,18 @@
1
- import { Matrix4, OrthographicCamera } from 'three';
2
1
  import { DIVERenderPipeline, DIVETicker, DIVEScene, DIVEPerspectiveCamera } from '../../../index.ts';
3
2
  /**
4
3
  * Shows the scene axes in the bottom left corner of the screen.
5
4
  *
6
5
  * @module
7
6
  */
8
- export declare class DIVEAxisCamera extends OrthographicCamera implements DIVETicker {
9
- private axesHelper;
7
+ export declare class OrientationDisplay implements DIVETicker {
10
8
  private _renderer;
11
9
  private _scene;
12
10
  private _camera;
11
+ uuid: string;
12
+ private _axes;
13
+ private _orthographicCamera;
13
14
  private _restoreViewport;
14
- constructor(renderer: DIVERenderPipeline, scene: DIVEScene, camera: DIVEPerspectiveCamera);
15
+ constructor(_renderer: DIVERenderPipeline, _scene: DIVEScene, _camera: DIVEPerspectiveCamera);
15
16
  tick(): void;
16
17
  dispose(): void;
17
- setFromCameraMatrix(matrix: Matrix4): void;
18
18
  }
@@ -0,0 +1,6 @@
1
+ import { Matrix4, Object3D } from 'three';
2
+ export declare class OrientationDisplayAxes extends Object3D {
3
+ private _axesHelper;
4
+ constructor();
5
+ setFromCameraMatrix(matrix: Matrix4): void;
6
+ }
@@ -1,8 +1,8 @@
1
1
  import { Action } from '../action.ts';
2
2
  import { ActionDependencies } from '../../../types/index.ts';
3
- export declare const SetGizmoVisibilityAction: new (payload: boolean, dependencies: Pick<ActionDependencies, "getToolbox">) => Action<boolean, Pick<ActionDependencies, "getToolbox">, Promise<void>>;
3
+ export declare const SetGizmoVisibleAction: new (payload: boolean, dependencies: Pick<ActionDependencies, "getToolbox">) => Action<boolean, Pick<ActionDependencies, "getToolbox">, Promise<void>>;
4
4
  declare global {
5
5
  interface ActionTypes {
6
- SET_GIZMO_VISIBILITY: typeof SetGizmoVisibilityAction;
6
+ SET_GIZMO_VISIBILITY: typeof SetGizmoVisibleAction;
7
7
  }
8
8
  }
@@ -15,7 +15,7 @@ export declare class Toolbox {
15
15
  getActiveTool(): DIVEBaseTool | null;
16
16
  useTool(tool: ToolType): void;
17
17
  setGizmoMode(mode: 'translate' | 'rotate' | 'scale'): void;
18
- setGizmoVisibility(active: boolean): void;
18
+ setGizmoVisible(active: boolean): void;
19
19
  setGizmoScaleLinked(linked: boolean): void;
20
20
  onPointerMove(e: PointerEvent): void;
21
21
  onPointerDown(e: PointerEvent): void;
@@ -17,7 +17,7 @@ export declare class DIVETransformTool extends DIVEBaseTool {
17
17
  constructor(scene: DIVEScene, controller: OrbitController);
18
18
  activate(): void;
19
19
  setGizmoMode(mode: 'translate' | 'rotate' | 'scale'): void;
20
- setGizmoVisibility(active: boolean): void;
20
+ setGizmoVisible(visible: boolean): void;
21
21
  setGizmoScaleLinked(linked: boolean): void;
22
22
  private initGizmo;
23
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/dive",
3
- "version": "2.0.1-beta.10",
3
+ "version": "2.0.1-beta.11",
4
4
  "description": "Shopware Spatial Framework",
5
5
  "type": "module",
6
6
  "main": "build/dive.cjs",
@@ -42,11 +42,6 @@
42
42
  "import": "./build/plugins/assetloader/index.mjs",
43
43
  "require": "./build/plugins/assetloader/index.cjs"
44
44
  },
45
- "./axiscamera": {
46
- "types": "./build/plugins/axiscamera/index.d.ts",
47
- "import": "./build/plugins/axiscamera/index.mjs",
48
- "require": "./build/plugins/axiscamera/index.cjs"
49
- },
50
45
  "./mediacreator": {
51
46
  "types": "./build/plugins/mediacreator/index.d.ts",
52
47
  "import": "./build/plugins/mediacreator/index.mjs",
@@ -57,6 +52,11 @@
57
52
  "import": "./build/plugins/orbitcontroller/index.mjs",
58
53
  "require": "./build/plugins/orbitcontroller/index.cjs"
59
54
  },
55
+ "./orientationdisplay": {
56
+ "types": "./build/plugins/orientationdisplay/index.d.ts",
57
+ "import": "./build/plugins/orientationdisplay/index.mjs",
58
+ "require": "./build/plugins/orientationdisplay/index.cjs"
59
+ },
60
60
  "./state": {
61
61
  "types": "./build/plugins/state/index.d.ts",
62
62
  "import": "./build/plugins/state/index.mjs",
@@ -1,30 +0,0 @@
1
- "use strict";var N=Object.defineProperty;var H=(a,i,e)=>i in a?N(a,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[i]=e;var r=(a,i,e)=>H(a,typeof i!="symbol"?i+"":i,e);const w=require("./OrbitController-rMX8EHvJ.cjs"),s=require("three"),p=require("three-spritetext"),l=require("./PerspectiveCamera-CONx93im.cjs");class L extends s.OrthographicCamera{constructor(e,t,n){super(-1,1,1,-1,.1,100);r(this,"axesHelper");r(this,"_renderer");r(this,"_scene");r(this,"_camera");r(this,"_restoreViewport",new s.Vector4);this.layers.mask=l.COORDINATE_LAYER_MASK,this.axesHelper=new s.AxesHelper(.5),this.axesHelper.layers.mask=l.COORDINATE_LAYER_MASK,this.axesHelper.material.depthTest=!1,this.axesHelper.position.set(0,0,-1),this.axesHelper.setColors(new s.Color(F),new s.Color(Y),new s.Color(W));const o=new p("X",.2,v),h=new p("Y",.2,b),d=new p("Z",.2,C);o.layers.mask=l.COORDINATE_LAYER_MASK,h.layers.mask=l.COORDINATE_LAYER_MASK,d.layers.mask=l.COORDINATE_LAYER_MASK,o.position.set(.7,0,0),h.position.set(0,.7,0),d.position.set(0,0,.7),this.axesHelper.add(o),this.axesHelper.add(h),this.axesHelper.add(d),this.add(this.axesHelper),this._renderer=e,this._scene=t,this._camera=n,this._scene.add(this)}tick(){const e=this._scene.background;this._scene.background=null,this._renderer.webglrenderer.getViewport(this._restoreViewport),this._renderer.webglrenderer.setViewport(0,0,150,150),this._renderer.webglrenderer.autoClear=!1,this.setFromCameraMatrix(this._camera.matrix),this._renderer.webglrenderer.render(this._scene,this),this._renderer.webglrenderer.setViewport(this._restoreViewport),this._renderer.webglrenderer.autoClear=!0,this._scene.background=e}dispose(){this._scene.remove(this)}setFromCameraMatrix(e){this.axesHelper.rotation.setFromRotationMatrix(new s.Matrix4().extractRotation(e).invert())}}class S extends s.Object3D{constructor(){super();r(this,"isDIVELight",!0);r(this,"isDIVEAmbientLight",!0);r(this,"_light");this.name="DIVEAmbientLight",this._light=new s.AmbientLight(16777215,1),this._light.layers.mask=l.PRODUCT_LAYER_MASK,this.add(this._light)}setColor(e){this._light.color=e}setIntensity(e){this._light.intensity=e}setEnabled(e){this._light.visible=e}}class x extends s.Object3D{constructor(){super();r(this,"isDIVELight",!0);r(this,"isDIVEPointLight",!0);r(this,"isMovable",!0);r(this,"isSelectable",!0);r(this,"gizmo",null);r(this,"light");r(this,"mesh");this.name="DIVEPointLight",this.light=new s.PointLight(16777215,1),this.light.layers.mask=l.PRODUCT_LAYER_MASK,this.light.castShadow=!0,this.light.shadow.mapSize.width=512,this.light.shadow.mapSize.height=512,this.add(this.light);const e=.1,t=new s.SphereGeometry(e,e*320,e*320),n=new s.MeshBasicMaterial({color:this.light.color,transparent:!0,opacity:.8,side:s.FrontSide});this.mesh=new s.Mesh(t,n),this.mesh.layers.mask=l.UI_LAYER_MASK,this.add(this.mesh)}setColor(e){this.light.color=e,this.mesh.material.color=e}setIntensity(e){this.light.intensity=e,this.mesh.material.opacity=e>.8?.8:e*.8}setEnabled(e){this.light.visible=e}onMove(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("UPDATE_OBJECT",{id:this.userData.id,position:this.position})})}onSelect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("SELECT_OBJECT",{id:this.userData.id})})}onDeselect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("DESELECT_OBJECT",{id:this.userData.id})})}}class f extends s.Object3D{constructor(){super();r(this,"isDIVELight",!0);r(this,"isDIVESceneLight",!0);r(this,"_hemiLight");r(this,"_dirLight");this.name="DIVESceneLight",this._hemiLight=new s.HemisphereLight(16777215,16777215,2),this._hemiLight.layers.mask=l.PRODUCT_LAYER_MASK,this._hemiLight.position.set(0,50,0),this.add(this._hemiLight),this._dirLight=new s.DirectionalLight(16777215,3),this._dirLight.layers.mask=l.PRODUCT_LAYER_MASK,this._dirLight.position.set(1,1.75,1),this._dirLight.position.multiplyScalar(30),this._dirLight.castShadow=!0,this._dirLight.shadow.mapSize.width=2048,this._dirLight.shadow.mapSize.height=2048;const e=5;this._dirLight.shadow.camera.left=-5,this._dirLight.shadow.camera.right=e,this._dirLight.shadow.camera.top=e,this._dirLight.shadow.camera.bottom=-5,this._dirLight.shadow.camera.far=3500,this.add(this._dirLight)}setColor(e){this._hemiLight.color=e,this._dirLight.color=e}setIntensity(e){this._hemiLight.intensity=e*2,this._dirLight.intensity=e*3}setEnabled(e){this._hemiLight.visible=e,this._dirLight.visible=e}}const m=a=>a.parent?m(a.parent):a;class g extends s.Object3D{constructor(){super();r(this,"isSelectable",!0);r(this,"isMovable",!0);r(this,"isDIVENode",!0);r(this,"gizmo",null);r(this,"_positionWorldBuffer");r(this,"_boundingBox");this.layers.mask=l.PRODUCT_LAYER_MASK,this._positionWorldBuffer=new s.Vector3,this._boundingBox=new s.Box3}setPosition(e){if(!this.parent){this.position.set(e.x,e.y,e.z);return}const t=new s.Vector3(e.x,e.y,e.z);this.position.copy(this.parent.worldToLocal(t)),"isDIVEGroup"in this.parent&&this.parent.updateLineTo(this)}setRotation(e){this.rotation.set(e.x,e.y,e.z)}setScale(e){this.scale.set(e.x,e.y,e.z)}setVisibility(e){this.visible=e}setToWorldOrigin(){this.position.set(0,0,0),Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("UPDATE_OBJECT",{id:this.userData.id,position:this.getWorldPosition(this._positionWorldBuffer),rotation:this.rotation,scale:this.scale})})}onMove(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("UPDATE_OBJECT",{id:this.userData.id,position:this.getWorldPosition(this._positionWorldBuffer),rotation:this.rotation,scale:this.scale})})}onSelect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("SELECT_OBJECT",{id:this.userData.id})})}onDeselect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("DESELECT_OBJECT",{id:this.userData.id})})}}class E extends g{constructor(){super(...arguments);r(this,"isDIVEModel",!0);r(this,"_mesh",null);r(this,"_material",null);r(this,"_assetLoader",null)}async _getAssetLoader(){return this._assetLoader||(this._assetLoader=new(await Promise.resolve().then(()=>require("../plugins/assetloader/index.cjs"))).AssetLoader),this._assetLoader}async setFromURL(e){const n=await(await this._getAssetLoader()).load(e);this.setFromGLTF(n),Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:o})=>{var h;(h=o.get(this.userData.id))==null||h.performAction("MODEL_LOADED",{id:this.userData.id})})}setFromGLTF(e){this.clear(),this._boundingBox.makeEmpty(),e.traverse(t=>{t.castShadow=!0,t.receiveShadow=!0,t.layers.mask=this.layers.mask,this._boundingBox.expandByObject(t),!this._mesh&&"isMesh"in t&&(this._mesh=t,this._material?this._mesh.material=this._material:this._material=t.material)}),this.add(e)}setMaterial(e){this._material||(this._material=new s.MeshStandardMaterial),e.vertexColors!==void 0&&(this._material.vertexColors=e.vertexColors),e.color!==void 0&&this._material.color.set(e.color),e.map!==void 0&&(this._material.map=e.map),e.normalMap!==void 0&&(this._material.normalMap=e.normalMap),e.roughness!==void 0&&(this._material.roughness=e.roughness),e.roughnessMap!==void 0&&(this._material.roughnessMap=e.roughnessMap,this._material.roughnessMap&&(this._material.roughness=1)),e.metalness!==void 0&&(this._material.metalness=e.metalness),e.metalnessMap!==void 0&&(this._material.metalnessMap=e.metalnessMap,this._material.metalnessMap&&(this._material.metalness=1)),this._mesh&&(this._mesh.material=this._material)}placeOnFloor(){var o,h,d,c;const e=this.getWorldPosition(this._positionWorldBuffer),t=e.clone();(h=(o=this._mesh)==null?void 0:o.geometry)==null||h.computeBoundingBox();const n=(c=(d=this._mesh)==null?void 0:d.geometry)==null?void 0:c.boundingBox;!n||!this._mesh||(e.y=e.y-this._mesh.localToWorld(n.min.clone()).y,e.y!==t.y&&Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:_})=>{var u;(u=_.get(this.userData.id))==null||u.performAction("UPDATE_OBJECT",{id:this.userData.id,position:e,rotation:this.rotation,scale:this.scale})}))}dropIt(){if(!this.parent){console.warn("DIVEModel: dropIt() called on a model that is not in the scene.",this);return}const e=this._boundingBox.min.y*this.scale.y,t=this.localToWorld(this._boundingBox.getCenter(new s.Vector3).multiply(this.scale));t.y=e+this.position.y;const n=new s.Raycaster(t,new s.Vector3(0,-1,0));n.layers.mask=l.PRODUCT_LAYER_MASK;const o=n.intersectObjects(m(this).root.children,!0);if(o.length>0){const h=o[0].object;h.geometry.computeBoundingBox();const d=h.geometry.boundingBox,c=h.localToWorld(d.max.clone()),_=this.position.clone(),u=this.position.clone().setY(c.y).sub(new s.Vector3(0,e,0));if(this.position.copy(u),this.position.y===_.y)return;this.onMove()}}}class V extends g{constructor(){super();r(this,"isDIVEPrimitive",!0);r(this,"_mesh");this._mesh=new s.Mesh,this._mesh.layers.mask=l.PRODUCT_LAYER_MASK,this._mesh.castShadow=!0,this._mesh.receiveShadow=!0,this._mesh.material=new s.MeshStandardMaterial,this.add(this._mesh)}setGeometry(e){const t=this.assembleGeometry(e);t&&(this._mesh.geometry=t,this._boundingBox.setFromObject(this._mesh))}setMaterial(e){const t=this._mesh.material;e.vertexColors!==void 0&&(t.vertexColors=e.vertexColors),e.color!==void 0&&(t.color=new s.Color(e.color)),e.map!==void 0&&(t.map=e.map),e.normalMap!==void 0&&(t.normalMap=e.normalMap),e.roughness!==void 0&&(t.roughness=e.roughness),e.roughnessMap!==void 0&&(t.roughnessMap=e.roughnessMap,t.roughnessMap&&(t.roughness=1)),e.metalness!==void 0&&(t.metalness=e.metalness),e.metalnessMap!==void 0&&(t.metalnessMap=e.metalnessMap,t.metalnessMap&&(t.metalness=0)),this._mesh&&(this._mesh.material=t)}placeOnFloor(){var o,h,d,c;const e=this.getWorldPosition(this._positionWorldBuffer),t=e.clone();(h=(o=this._mesh)==null?void 0:o.geometry)==null||h.computeBoundingBox();const n=(c=(d=this._mesh)==null?void 0:d.geometry)==null?void 0:c.boundingBox;!n||!this._mesh||(e.y=e.y-this._mesh.localToWorld(n.min.clone()).y,e.y!==t.y&&Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:_})=>{var u;(u=_.get(this.userData.id))==null||u.performAction("UPDATE_OBJECT",{id:this.userData.id,position:e,rotation:this.rotation,scale:this.scale})}))}dropIt(){if(!this.parent){console.warn("DIVEPrimitive: dropIt() called on a model that is not in the scene.",this);return}const e=this._boundingBox.min.y*this.scale.y,t=this.localToWorld(this._boundingBox.getCenter(new s.Vector3).multiply(this.scale));t.y=e+this.position.y;const n=new s.Raycaster(t,new s.Vector3(0,-1,0));n.layers.mask=l.PRODUCT_LAYER_MASK;const o=n.intersectObjects(m(this).root.children,!0);if(o.length>0){const h=o[0].object;h.geometry.computeBoundingBox();const d=h.geometry.boundingBox,c=h.localToWorld(d.max.clone()),_=this.position.clone(),u=this.position.clone().setY(c.y).sub(new s.Vector3(0,e,0));if(this.position.copy(u),this.position.y===_.y)return;this.onMove()}}assembleGeometry(e){switch(this._mesh.material.flatShading=!1,e.name.toLowerCase()){case"cylinder":return this.createCylinderGeometry(e);case"sphere":return this.createSphereGeometry(e);case"pyramid":return this._mesh.material.flatShading=!0,this.createPyramidGeometry(e);case"cube":case"box":return this.createBoxGeometry(e);case"cone":return this.createConeGeometry(e);case"wall":return this.createWallGeometry(e);case"plane":return this.createPlaneGeometry(e);default:return console.warn("DIVEPrimitive.assembleGeometry: Invalid geometry type:",e.name.toLowerCase()),null}}createCylinderGeometry(e){const t=new s.CylinderGeometry(e.width/2,e.width/2,e.height,64);return t.translate(0,e.height/2,0),t}createSphereGeometry(e){return new s.SphereGeometry(e.width/2,256,256)}createPyramidGeometry(e){const t=new Float32Array([-e.width/2,0,-e.depth/2,e.width/2,0,-e.depth/2,e.width/2,0,e.depth/2,-e.width/2,0,e.depth/2,0,e.height,0]),n=new Uint16Array([0,1,2,0,2,3,0,4,1,1,4,2,2,4,3,3,4,0]),o=new s.BufferGeometry;return o.setAttribute("position",new s.BufferAttribute(t,3)),o.setIndex(new s.BufferAttribute(n,1)),o.computeVertexNormals(),o.computeBoundingBox(),o.computeBoundingSphere(),o}createBoxGeometry(e){const t=new s.BoxGeometry(e.width,e.height,e.depth);return t.translate(0,e.height/2,0),t}createConeGeometry(e){const t=new s.ConeGeometry(e.width/2,e.height,256);return t.translate(0,e.height/2,0),t}createWallGeometry(e){const t=new s.BoxGeometry(e.width,e.height,e.depth||.05,16);return t.translate(0,e.height/2,0),t}createPlaneGeometry(e){const t=new s.BoxGeometry(e.width,e.height,e.depth);return t.translate(0,e.height/2,0),t}}class P extends g{constructor(){super();r(this,"isDIVEGroup",!0);r(this,"_members");r(this,"_lines");this.name="DIVEGroup",this._members=[],this._lines=[]}get members(){return this._members}setPosition(e){super.setPosition(e),this._members.forEach(t=>{"isDIVENode"in t&&t.onMove()})}setLinesVisibility(e,t){if(!t){this._lines.forEach(o=>{o.visible=e});return}const n=this._members.indexOf(t);n!==-1&&(this._lines[n].visible=e)}attach(e){if(this._members.includes(e))return this;const t=this.createLine();return this.add(t),this._lines.push(t),super.attach(e),this._members.push(e),this._updateLineTo(t,e),this.setLinesVisibility(!0,e),this}remove(e){const t=this._members.indexOf(e);if(t===-1)return this;const n=this._lines[t];return super.remove(n),this._lines.splice(t,1),super.remove(e),this._members.splice(t,1),this}updateLineTo(e){const t=this._members.indexOf(e);t!==-1&&this._updateLineTo(this._lines[t],e)}createLine(){const e=new s.BufferGeometry,t=new s.LineDashedMaterial({color:6710886,dashSize:.05,gapSize:.025}),n=new s.Line(e,t);return n.visible=!1,n}_updateLineTo(e,t){const n=[new s.Vector3(0,0,0),t.position.clone()];e.geometry.setFromPoints(n),e.computeLineDistances()}}class M extends s.Mesh{constructor(){const e=new s.PlaneGeometry(1,1);e.scale(1e3,1e3,1),e.rotateX(-Math.PI/2);const t=new s.MeshStandardMaterial({color:new s.Color(16777215),side:s.FrontSide});super(e,t);r(this,"isDIVEFloor",!0);this.name="Floor",this.layers.mask=l.PRODUCT_LAYER_MASK,this.receiveShadow=!0}setVisibility(e){this.visible=e}setColor(e){this.material.color=new s.Color(e)}}class R extends s.Object3D{constructor(){super();r(this,"isDIVERoot",!0);r(this,"_floor");this.name="Root",this._floor=new M,this.add(this._floor)}get floor(){return this._floor}computeSceneBB(){const e=new s.Box3;return this.children.forEach(t=>{"isDIVEFloor"in t||t.traverse(n=>{"isObject3D"in n&&e.expandByObject(n)})}),e}getSceneObject(e){let t;return this.traverse(n=>{t||n.userData.id===e.id&&(t=n)}),t}addSceneObject(e){let t=this.getSceneObject(e);if(t)return console.warn(`DIVERoot.addSceneObject: Scene object with id ${e.id} already exists`),t;switch(e.entityType){case"pov":break;case"light":{switch(e.type){case"scene":{t=new f;break}case"ambient":{t=new S;break}case"point":{t=new x;break}default:throw new Error(`DIVERoot.addSceneObject: Unknown light type: ${e.type}`)}t.name=e.name,t.userData.id=e.id,this.add(t),this._updateLight(t,e);break}case"model":{t=new E,t.name=e.name,t.userData.id=e.id,t.userData.uri=e.uri,this.add(t),this._updateModel(t,e);break}case"primitive":{t=new V,t.name=e.name,t.userData.id=e.id,this.add(t),this._updatePrimitive(t,e);break}case"group":{t=new P,t.name=e.name,t.userData.id=e.id,this.add(t),this._updateGroup(t,e);break}default:throw new Error(`DIVERoot.addSceneObject: Unknown entity type: ${e.entityType}`)}return t}updateSceneObject(e){const t=this.getSceneObject(e);if(!t){console.warn(`DIVERoot.updateSceneObject: Scene object with id ${e.id} does not exist`);return}switch(e.entityType){case"pov":break;case"light":{this._updateLight(t,e);break}case"model":{this._updateModel(t,e);break}case"primitive":{this._updatePrimitive(t,e);break}case"group":{this._updateGroup(t,e);break}default:throw new Error(`DIVERoot.updateSceneObject: Unknown entity type: ${e.entityType}`)}}deleteSceneObject(e){const t=this.getSceneObject(e);if(!t){console.warn(`DIVERoot.deleteSceneObject: Object with id ${e.id} not found`);return}switch(e.entityType){case"pov":break;case"light":{this._deleteLight(t);break}case"model":{this._deleteModel(t);break}case"primitive":{this._deletePrimitive(t);break}case"group":{this._deleteGroup(t);break}default:throw new Error(`DIVERoot.deleteSceneObject: Unknown entity type: ${e.entityType}`)}}_updateLight(e,t){t.name!==void 0&&t.name!==null&&(e.name=t.name),t.position!==void 0&&t.position!==null&&e.position.set(t.position.x,t.position.y,t.position.z),t.intensity!==void 0&&t.intensity!==null&&e.setIntensity(t.intensity),t.enabled!==void 0&&t.enabled!==null&&e.setEnabled(t.enabled),t.color!==void 0&&t.color!==null&&e.setColor(new s.Color(t.color)),t.visible!==void 0&&t.visible!==null&&(e.visible=t.visible),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId})}_updateModel(e,t){t.uri!==void 0&&e.setFromURL(t.uri),t.name!==void 0&&(e.name=t.name),t.position!==void 0&&e.setPosition(t.position),t.rotation!==void 0&&e.setRotation(t.rotation),t.scale!==void 0&&e.setScale(t.scale),t.visible!==void 0&&e.setVisibility(t.visible),t.material!==void 0&&e.setMaterial(t.material),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId})}_updatePrimitive(e,t){t.name!==void 0&&(e.name=t.name),t.geometry!==void 0&&e.setGeometry(t.geometry),t.position!==void 0&&e.setPosition(t.position),t.rotation!==void 0&&e.setRotation(t.rotation),t.scale!==void 0&&e.setScale(t.scale),t.visible!==void 0&&e.setVisibility(t.visible),t.material!==void 0&&e.setMaterial(t.material),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId})}_updateGroup(e,t){t.name!==void 0&&(e.name=t.name),t.position!==void 0&&e.setPosition(t.position),t.rotation!==void 0&&e.setRotation(t.rotation),t.scale!==void 0&&e.setScale(t.scale),t.visible!==void 0&&e.setVisibility(t.visible),t.bbVisible!==void 0&&e.setLinesVisibility(t.bbVisible),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId})}_deleteLight(e){this._detachTransformControls(e),e.parent.remove(e)}_deleteModel(e){this._detachTransformControls(e),e.parent.remove(e)}_deletePrimitive(e){this._detachTransformControls(e),e.parent.remove(e)}_deleteGroup(e){this._detachTransformControls(e);for(let t=e.members.length-1;t>=0;t--)this.attach(e.members[t]);e.parent.remove(e)}_setParent(e){const t=this.getSceneObject(e);if(e.parentId!==null){const n=this.getSceneObject({id:e.parentId,entityType:e.entityType});if(!n)return;n.attach(t)}else this.attach(t)}_detachTransformControls(e){this._findScene(e).children.find(t=>{"isTransformControls"in t&&t.detach()})}_findScene(e){return e.parent!==null?this._findScene(e.parent):e}}const k="#888888",T="#dddddd";class A extends s.Object3D{constructor(){super(),this.name="Grid";const i=new s.GridHelper(100,100,k,T);i.material.depthTest=!1,i.layers.mask=l.HELPER_LAYER_MASK,this.add(i)}setVisibility(i){this.visible=i}}class B extends s.Scene{constructor(){super();r(this,"_root");r(this,"_grid");this.background=new s.Color(16777215),this._root=new R,this.add(this._root),this._grid=new A,this.add(this._grid)}get root(){return this._root}get grid(){return this._grid}setBackground(e){this.background=new s.Color(e)}computeSceneBB(){return this.root.computeSceneBB()}}const D={canvas:void 0,antialias:!0,alpha:!0,powerPreference:"high-performance",precision:"highp",stencil:!1,depth:!0,logarithmicDepthBuffer:!1,shadows:!0,shadowQuality:"high"};class O{constructor(i,e,t){r(this,"_webglrenderer");r(this,"_settings");this._scene=i,this._camera=e,this._settings={...D,...t??{}},this._webglrenderer=new s.WebGLRenderer(this._settings),this._webglrenderer.shadowMap.enabled=this._settings.shadows,this._webglrenderer.shadowMap.type=this._settings.shadowQuality==="high"?s.PCFSoftShadowMap:this._settings.shadowQuality==="medium"?s.PCFShadowMap:s.BasicShadowMap}get webglrenderer(){return this._webglrenderer}setCanvas(i){this._webglrenderer.dispose(),this._settings.canvas=i,this._webglrenderer=new s.WebGLRenderer(this._settings)}render(){this._webglrenderer.render(this._scene,this._camera)}onResize(i,e){this._webglrenderer.setSize(i,e,!1)}dispose(){this._webglrenderer.dispose()}}class G{constructor(){r(this,"_renderer",null);r(this,"_lastTime",0);r(this,"_isRunning",!1);r(this,"_tickers",[])}start(){this._isRunning||(this._isRunning=!0,this._lastTime=performance.now(),requestAnimationFrame(this._tick.bind(this)))}stop(){this._isRunning=!1}setRenderer(i){this._renderer=i}addTicker(i){this._tickers.find(e=>e.uuid===i.uuid)||this._tickers.push(i)}hasTicker(i){return this._tickers.find(e=>e.uuid===i.uuid)!==void 0}removeTicker(i){const e=this._tickers.findIndex(t=>t.uuid===i.uuid);e!==-1&&this._tickers.splice(e,1)}dispose(){this.stop(),this._tickers.forEach(i=>{var e;return(e=i.dispose)==null?void 0:e.call(i)}),this._tickers=[],this._isRunning=!1,this._lastTime=0}_tick(i){var t;if(!this._isRunning)return;const e=(i-this._lastTime)/1e3;this._lastTime=i,this._tickers.forEach(n=>n.tick(e)),(t=this._renderer)==null||t.render(),requestAnimationFrame(this._tick.bind(this))}}class z{constructor(i,e){r(this,"_resizeObserver");r(this,"_width",0);r(this,"_height",0);this._resizeObserver=new ResizeObserver(t=>{for(const n of t){const{width:o,height:h}=n.contentRect;o===this._width&&h===this._height||(i.onResize(o,h),e.onResize(o,h),this._width=o,this._height=h)}}),this._observeCanvas(i.webglrenderer.domElement)}setCanvas(i){this._resizeObserver.disconnect(),this._observeCanvas(i)}dispose(){this._resizeObserver.disconnect()}_observeCanvas(i){if(i.parentElement)this._resizeObserver.observe(i.parentElement);else{const e=setInterval(()=>{i.parentElement&&(this._resizeObserver.observe(i.parentElement),clearInterval(e))},16)}}}const y={autoStart:!0,displayAxes:!1,...l.DIVEPerspectiveCameraDefaultSettings,...D};class U{constructor(i){r(this,"_renderer");r(this,"_scene");r(this,"_camera");r(this,"_resizeManager");r(this,"_clock");r(this,"_settings");this._settings={...y,...i??{}},this._scene=new B,this._camera=new l.DIVEPerspectiveCamera(this._settings),this._renderer=new O(this._scene,this._camera,this._settings),this._resizeManager=new z(this._renderer,this._camera),this._clock=new G,this._clock.setRenderer(this._renderer),this._settings.autoStart&&this.start()}get scene(){return this._scene}get camera(){return this._camera}get renderer(){return this._renderer}setCanvas(i){this._renderer.setCanvas(i),this._resizeManager.setCanvas(i)}get clock(){return this._clock}start(){this._clock.start()}stop(){this._clock.stop()}dispose(){this._clock.dispose(),this._resizeManager.dispose(),this._renderer.dispose()}}const v="#c20017",b="#00ab26",C="#0081d4",F=v,Y=b,W=C;window.DIVE={instances:[],get instance(){return window.DIVE.instances[0]}};const q={...y,...w.OrbitControllerDefaultSettings};class I{constructor(i){r(this,"_instanceId",s.MathUtils.generateUUID());r(this,"_settings");r(this,"_engine");r(this,"orbitController");r(this,"axisCamera");this._settings={...q,...i??{}},this._engine=new U(i),this.orbitController=new w.OrbitController(this._engine.camera,this._engine.renderer.webglrenderer.domElement,this._settings),this._engine.clock.addTicker(this.orbitController),this._settings.displayAxes?(this.axisCamera=new L(this._engine.renderer,this._engine.scene,this._engine.camera),this._engine.clock.addTicker(this.axisCamera)):this.axisCamera=null,Promise.resolve().then(()=>require("./package-Bf92jAR_.cjs")).then(e=>{console.log(`DIVE ${e.default.version} initialized successfully!`),console.log(`
2
- @@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@
3
- @@@@+-:::::::---------------------==------------------------------=#@@@@
4
- @@%=::::.......::---------------------------------------------------------+@@
5
- @@+:::...........::-----------------------------------------------------------#@@
6
- @@=:::.........::::::-------------------------------------------------------------%@
7
- @%:::.......:::::::-----------------------------------------------------------------#@
8
- @*:::.....:::::-----------------------------------------------------------------------*@
9
- @%::::::.::::---------------------------------------------------------------------------@@
10
- @@-:::::::::-----------------------------------------------------------------------------=@
11
- @%::::::::--------------------------------------------------------------------------------%@
12
- @+::::::::--------------------------------=@@@@@%-----------------------------------------%@
13
- @=:::::::--------------------------------*@@ @@+---------------------------------------#@
14
- @+:::::::-------------------------------*@ @*--------------------------------------%@
15
- @#::::::::-----------------------------=@@ @@=-------------------------------------%@
16
- @@-::::::::----------------------------@@ @@------------------------------------=@
17
- @%:::::::::--------------------------*@ @*-----------------------------------@@
18
- @*:::::::::-------------------------@@ @@----------------------------------%@
19
- @#::::::::::----------------------%@ @%--------------------------------%@
20
- @#:::::::::::-------------------=@@ @@=------------------------------%@
21
- @@-::::::::::::----------------%@ @%----------------------------=@@
22
- @@#::::::::::::::------------*@ @*--------------------------#@@
23
- @@+::::::::::::::::--------@@ @@------------------------+@@
24
- @@*:::::::::::::::::----@@ @@---------------------+@@
25
- @@@-:::::::::::::::--#@ @#-----------------=%@@
26
- @@%-::::::::::::-%@ @%-------------=%@@
27
- @@@@+:::::::#@@ @@*-------*@@@@
28
- @@@@@@@ @@@@@@
29
-
30
- `)}),window.DIVE.instances.push(this)}static async QuickView(i,e){const t=new I(e);t.engine.scene.background=new s.Color(16777215),t.engine.scene.grid.setVisibility(!1),t.engine.scene.root.floor.setVisibility(!0),t.engine.camera.position.set(0,2,2),t.orbitController.target.set(0,.5,0);const n=new f;n.name="SceneLight",n.userData.id=s.MathUtils.generateUUID(),n.setEnabled(!0),n.visible=!0,n.setIntensity((e==null?void 0:e.lightIntensity)??1),n.setColor(new s.Color(16777215)),t.engine.scene.root.add(n);const o=new E;o.name="object",o.userData.id=s.MathUtils.generateUUID(),o.userData.uri=i,o.visible=!0,t.engine.scene.root.add(o),await o.setFromURL(i);const h=t.engine.scene.computeSceneBB(),d=t.orbitController.computeEncompassingView(h);return t.engine.camera.position.copy(d.position),t.orbitController.target.copy(d.target),t}get engine(){return this._engine}get canvas(){return this._engine.renderer.webglrenderer.domElement}setCanvas(i){this._engine.setCanvas(i),this._engine.clock.removeTicker(this.orbitController),this.orbitController.dispose(),this.orbitController=new w.OrbitController(this._engine.camera,i,this._settings),this._engine.clock.addTicker(this.orbitController)}async dispose(){return new Promise(i=>{this._engine.clock.removeTicker(this.orbitController),this.orbitController.dispose(),this.axisCamera&&(this._engine.clock.removeTicker(this.axisCamera),this.axisCamera.dispose()),window.DIVE.instances=window.DIVE.instances.filter(e=>e._instanceId!==this._instanceId),i()})}}const K={glb:{key:"glb",extension:"glb"},gltf:{key:"gltf",extension:"gltf"},usdz:{key:"usdz",extension:"usdz"}},J=Object.values(K).map(a=>a.extension);exports.AxesColorBlue=W;exports.AxesColorBlueLetter=C;exports.AxesColorGreen=Y;exports.AxesColorGreenLetter=b;exports.AxesColorRed=F;exports.AxesColorRedLetter=v;exports.DIVE=I;exports.DIVEAmbientLight=S;exports.DIVEAxisCamera=L;exports.DIVEClock=G;exports.DIVEDefaultSettings=q;exports.DIVEEngine=U;exports.DIVEFloor=M;exports.DIVEGrid=A;exports.DIVEGroup=P;exports.DIVEModel=E;exports.DIVENode=g;exports.DIVEPointLight=x;exports.DIVEPrimitive=V;exports.DIVERenderPipeline=O;exports.DIVERenderPipelineDefaultSettings=D;exports.DIVEResizeManager=z;exports.DIVERoot=R;exports.DIVEScene=B;exports.DIVESceneLight=f;exports.EngineDefaultSettings=y;exports.FILE_TYPES=K;exports.GRID_CENTER_LINE_COLOR=k;exports.GRID_SIDE_LINE_COLOR=T;exports.SUPPORTED_FILE_TYPES=J;exports.findSceneRecursive=m;