@shopware-ag/dive 1.16.0 → 1.16.2

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 (143) hide show
  1. package/README.md +271 -40
  2. package/build/dive.cjs +575 -159
  3. package/build/dive.cjs.map +1 -1
  4. package/build/dive.d.cts +83 -57
  5. package/build/dive.d.ts +83 -57
  6. package/build/dive.js +614 -164
  7. package/build/dive.js.map +1 -1
  8. package/package.json +72 -60
  9. package/src/__test__/DIVE.test.ts +35 -31
  10. package/src/animation/AnimationSystem.ts +4 -4
  11. package/src/animation/__test__/AnimationSystem.test.ts +3 -3
  12. package/src/axiscamera/AxisCamera.ts +31 -11
  13. package/src/axiscamera/__test__/AxisCamera.test.ts +18 -10
  14. package/src/camera/PerspectiveCamera.ts +28 -13
  15. package/src/camera/__test__/PerspectiveCamera.test.ts +2 -2
  16. package/src/com/Communication.ts +282 -100
  17. package/src/com/__test__/Communication.test.ts +207 -141
  18. package/src/com/actions/camera/computeencompassingview.ts +8 -7
  19. package/src/com/actions/camera/getcameratransform.ts +8 -7
  20. package/src/com/actions/camera/movecamera.ts +16 -13
  21. package/src/com/actions/camera/resetcamera.ts +4 -3
  22. package/src/com/actions/camera/setcameralayer.ts +4 -3
  23. package/src/com/actions/camera/setcameratransform.ts +8 -7
  24. package/src/com/actions/camera/zoomcamera.ts +4 -3
  25. package/src/com/actions/index.ts +54 -54
  26. package/src/com/actions/media/generatemedia.ts +17 -13
  27. package/src/com/actions/object/addobject.ts +5 -4
  28. package/src/com/actions/object/deleteobject.ts +5 -4
  29. package/src/com/actions/object/deselectobject.ts +5 -4
  30. package/src/com/actions/object/getallobjects.ts +5 -4
  31. package/src/com/actions/object/getobjects.ts +5 -4
  32. package/src/com/actions/object/model/dropit.ts +4 -3
  33. package/src/com/actions/object/model/modelloaded.ts +4 -3
  34. package/src/com/actions/object/model/placeonfloor.ts +4 -3
  35. package/src/com/actions/object/selectobject.ts +5 -4
  36. package/src/com/actions/object/setparent.ts +8 -7
  37. package/src/com/actions/object/updateobject.ts +5 -4
  38. package/src/com/actions/scene/exportscene.ts +5 -4
  39. package/src/com/actions/scene/getallscenedata.ts +24 -18
  40. package/src/com/actions/scene/setbackground.ts +4 -3
  41. package/src/com/actions/scene/updatescene.ts +10 -9
  42. package/src/com/actions/toolbox/select/setgizmomode.ts +4 -3
  43. package/src/com/actions/toolbox/transform/setgizmovisible.ts +4 -3
  44. package/src/com/actions/toolbox/usetool.ts +5 -4
  45. package/src/com/types/COMBaseEntity.ts +2 -2
  46. package/src/com/types/COMEntity.ts +6 -6
  47. package/src/com/types/COMEntityType.ts +1 -1
  48. package/src/com/types/COMGeometry.ts +2 -2
  49. package/src/com/types/COMGroup.ts +3 -3
  50. package/src/com/types/COMLight.ts +3 -3
  51. package/src/com/types/COMMaterial.ts +2 -2
  52. package/src/com/types/COMModel.ts +4 -4
  53. package/src/com/types/COMPov.ts +3 -3
  54. package/src/com/types/COMPrimitive.ts +5 -5
  55. package/src/com/types/index.ts +10 -10
  56. package/src/constant/AxisHelperColors.ts +1 -1
  57. package/src/constant/GridColors.ts +1 -1
  58. package/src/controls/OrbitControls.ts +62 -29
  59. package/src/controls/__test__/OrbitControls.test.ts +133 -39
  60. package/src/dive.ts +82 -36
  61. package/src/gizmo/Gizmo.ts +21 -13
  62. package/src/gizmo/handles/AxisHandle.ts +40 -17
  63. package/src/gizmo/handles/RadialHandle.ts +39 -15
  64. package/src/gizmo/handles/ScaleHandle.ts +62 -25
  65. package/src/gizmo/plane/GizmoPlane.ts +5 -6
  66. package/src/gizmo/rotate/RotateGizmo.ts +58 -16
  67. package/src/gizmo/scale/ScaleGizmo.ts +37 -15
  68. package/src/gizmo/translate/TranslateGizmo.ts +34 -14
  69. package/src/grid/Grid.ts +13 -5
  70. package/src/grid/__test__/Grid.test.ts +5 -3
  71. package/src/group/Group.ts +9 -7
  72. package/src/group/__test__/Group.test.ts +8 -6
  73. package/src/helper/applyMixins/__test__/applyMixins.test.ts +9 -6
  74. package/src/helper/applyMixins/applyMixins.ts +6 -3
  75. package/src/helper/findInterface/__test__/findInterface.test.ts +28 -18
  76. package/src/helper/findInterface/findInterface.ts +7 -4
  77. package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +1 -1
  78. package/src/helper/findSceneRecursive/findSceneRecursive.ts +1 -1
  79. package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +43 -7
  80. package/src/helper/getObjectDelta/getObjectDelta.ts +13 -9
  81. package/src/helper/isInterface/__test__/implementsInterface.test.ts +1 -1
  82. package/src/helper/isInterface/implementsInterface.ts +6 -3
  83. package/src/info/Info.ts +20 -16
  84. package/src/info/__test__/Info.test.ts +67 -36
  85. package/src/interface/Draggable.ts +2 -2
  86. package/src/interface/Hoverable.ts +2 -2
  87. package/src/interface/Movable.ts +1 -1
  88. package/src/interface/Rotatable.ts +1 -1
  89. package/src/interface/Scalable.ts +1 -1
  90. package/src/io/IO.ts +21 -43
  91. package/src/io/__test__/IO.test.ts +16 -62
  92. package/src/io/gltf/GLTFIO.ts +34 -31
  93. package/src/io/gltf/__test__/GLTFIO.test.ts +88 -78
  94. package/src/light/PointLight.ts +42 -9
  95. package/src/light/SceneLight.ts +5 -5
  96. package/src/light/__test__/AmbientLight.test.ts +5 -4
  97. package/src/light/__test__/PointLight.test.ts +14 -10
  98. package/src/light/__test__/SceneLight.test.ts +19 -13
  99. package/src/loadingmanager/LoadingManager.ts +11 -6
  100. package/src/loadingmanager/__test__/LoadingManager.test.ts +14 -9
  101. package/src/math/__test__/DIVEMath.test.ts +1 -1
  102. package/src/math/ceil/__test__/ceilExp.test.ts +1 -1
  103. package/src/math/ceil/ceilExp.ts +2 -2
  104. package/src/math/floor/__test__/floorExp.test.ts +1 -1
  105. package/src/math/floor/floorExp.ts +2 -2
  106. package/src/math/helper/__test__/shift.test.ts +1 -1
  107. package/src/math/helper/shift.ts +1 -1
  108. package/src/math/index.ts +7 -7
  109. package/src/math/round/__test__/roundExp.test.ts +1 -1
  110. package/src/math/round/roundExp.ts +6 -3
  111. package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +10 -4
  112. package/src/math/signedAngleTo/signedAngleTo.ts +11 -4
  113. package/src/math/toFixed/__test__/toFixedExp.test.ts +9 -9
  114. package/src/math/toFixed/toFixedExp.ts +6 -3
  115. package/src/math/truncate/__test__/truncateExp.test.ts +1 -1
  116. package/src/math/truncate/truncateExp.ts +6 -3
  117. package/src/mediacreator/MediaCreator.ts +20 -10
  118. package/src/mediacreator/__test__/MediaCreator.test.ts +27 -12
  119. package/src/model/Model.ts +35 -7
  120. package/src/model/__test__/Model.test.ts +71 -44
  121. package/src/node/Node.ts +34 -12
  122. package/src/node/__test__/Node.test.ts +17 -13
  123. package/src/primitive/Primitive.ts +78 -13
  124. package/src/primitive/__test__/Primitive.test.ts +49 -38
  125. package/src/primitive/floor/Floor.ts +14 -3
  126. package/src/primitive/floor/__test__/Floor.test.ts +10 -4
  127. package/src/renderer/Renderer.ts +46 -15
  128. package/src/renderer/__test__/Renderer.test.ts +74 -24
  129. package/src/scene/Scene.ts +9 -3
  130. package/src/scene/__test__/Scene.test.ts +2 -2
  131. package/src/scene/root/Root.ts +142 -75
  132. package/src/scene/root/__test__/Root.test.ts +439 -111
  133. package/src/toolbox/BaseTool.ts +69 -33
  134. package/src/toolbox/Toolbox.ts +37 -17
  135. package/src/toolbox/__test__/BaseTool.test.ts +324 -160
  136. package/src/toolbox/__test__/Toolbox.test.ts +31 -14
  137. package/src/toolbox/select/SelectTool.ts +24 -19
  138. package/src/toolbox/select/__test__/SelectTool.test.ts +95 -59
  139. package/src/toolbox/transform/TransformTool.ts +40 -17
  140. package/src/toolbox/transform/__test__/TransformTool.test.ts +22 -15
  141. package/src/types/SceneObjects.ts +8 -8
  142. package/src/types/SceneType.ts +3 -3
  143. package/src/types/index.ts +3 -6
@@ -1,10 +1,14 @@
1
- import { Euler, Object3D, Vector3 } from "three";
2
- import { AxesColorBlue, AxesColorGreen, AxesColorRed } from "../../constant/AxisHelperColors";
3
- import DIVEOrbitControls from "../../controls/OrbitControls";
4
- import { DIVERadialHandle } from "../handles/RadialHandle";
5
- import { DIVEGizmo, DIVEGizmoAxis } from "../Gizmo";
6
- import { DraggableEvent } from "../../toolbox/BaseTool";
7
- import { DIVEMath } from "../../math";
1
+ import { Euler, Object3D, Vector3 } from 'three';
2
+ import {
3
+ AxesColorBlue,
4
+ AxesColorGreen,
5
+ AxesColorRed,
6
+ } from '../../constant/AxisHelperColors';
7
+ import DIVEOrbitControls from '../../controls/OrbitControls';
8
+ import { DIVERadialHandle } from '../handles/RadialHandle';
9
+ import { DIVEGizmo, DIVEGizmoAxis } from '../Gizmo';
10
+ import { DraggableEvent } from '../../toolbox/BaseTool';
11
+ import { DIVEMath } from '../../math';
8
12
 
9
13
  export class DIVERotateGizmo extends Object3D {
10
14
  public children: DIVERadialHandle[];
@@ -16,7 +20,7 @@ export class DIVERotateGizmo extends Object3D {
16
20
  constructor(controller: DIVEOrbitControls) {
17
21
  super();
18
22
 
19
- this.name = "DIVERotateGizmo";
23
+ this.name = 'DIVERotateGizmo';
20
24
 
21
25
  this.children = [];
22
26
 
@@ -24,9 +28,33 @@ export class DIVERotateGizmo extends Object3D {
24
28
 
25
29
  this._controller = controller;
26
30
 
27
- this.add(new DIVERadialHandle('x', 1, Math.PI / 2, new Vector3(1, 0, 0), AxesColorRed));
28
- this.add(new DIVERadialHandle('y', 1, -Math.PI / 2, new Vector3(0, 1, 0), AxesColorGreen));
29
- this.add(new DIVERadialHandle('z', 1, Math.PI / 2, new Vector3(0, 0, 1), AxesColorBlue));
31
+ this.add(
32
+ new DIVERadialHandle(
33
+ 'x',
34
+ 1,
35
+ Math.PI / 2,
36
+ new Vector3(1, 0, 0),
37
+ AxesColorRed,
38
+ ),
39
+ );
40
+ this.add(
41
+ new DIVERadialHandle(
42
+ 'y',
43
+ 1,
44
+ -Math.PI / 2,
45
+ new Vector3(0, 1, 0),
46
+ AxesColorGreen,
47
+ ),
48
+ );
49
+ this.add(
50
+ new DIVERadialHandle(
51
+ 'z',
52
+ 1,
53
+ Math.PI / 2,
54
+ new Vector3(0, 0, 1),
55
+ AxesColorBlue,
56
+ ),
57
+ );
30
58
  }
31
59
 
32
60
  public reset(): void {
@@ -35,7 +63,11 @@ export class DIVERotateGizmo extends Object3D {
35
63
  });
36
64
  }
37
65
 
38
- private handleHighlight(axis: DIVEGizmoAxis, value: boolean, dragged: boolean): void {
66
+ private handleHighlight(
67
+ axis: DIVEGizmoAxis,
68
+ value: boolean,
69
+ dragged: boolean,
70
+ ): void {
39
71
  // Set highlight state for all handles.
40
72
  this.children.forEach((child) => {
41
73
  if (dragged) {
@@ -77,9 +109,19 @@ export class DIVERotateGizmo extends Object3D {
77
109
  if (!this.parent.parent) return;
78
110
  if (!('onChange' in this.parent.parent)) return;
79
111
 
80
- const currentVector = e.dragCurrent.clone().sub(this.parent.parent.position).normalize();
81
- const startVector = e.dragStart.clone().sub(this.parent.parent.position).normalize();
82
- const signedAngle = DIVEMath.signedAngleTo(startVector, currentVector, handle.forwardVector);
112
+ const currentVector = e.dragCurrent
113
+ .clone()
114
+ .sub(this.parent.parent.position)
115
+ .normalize();
116
+ const startVector = e.dragStart
117
+ .clone()
118
+ .sub(this.parent.parent.position)
119
+ .normalize();
120
+ const signedAngle = DIVEMath.signedAngleTo(
121
+ startVector,
122
+ currentVector,
123
+ handle.forwardVector,
124
+ );
83
125
  const euler = new Euler(
84
126
  this._startRot.x + handle.forwardVector.x * signedAngle,
85
127
  this._startRot.y + handle.forwardVector.y * signedAngle,
@@ -92,4 +134,4 @@ export class DIVERotateGizmo extends Object3D {
92
134
  this._startRot = null;
93
135
  this.handleHighlight(handle.axis, false, false);
94
136
  }
95
- }
137
+ }
@@ -1,10 +1,14 @@
1
- import { Object3D, Vector3 } from "three";
2
- import { AxesColorBlue, AxesColorGreen, AxesColorRed } from "../../constant/AxisHelperColors";
3
- import { DIVEHoverable } from "../../interface/Hoverable";
4
- import DIVEOrbitControls from "../../controls/OrbitControls";
5
- import { DIVEScaleHandle } from "../handles/ScaleHandle";
6
- import { DraggableEvent } from "../../toolbox/BaseTool";
7
- import { DIVEGizmoAxis, DIVEGizmo } from "../Gizmo";
1
+ import { Object3D, Vector3 } from 'three';
2
+ import {
3
+ AxesColorBlue,
4
+ AxesColorGreen,
5
+ AxesColorRed,
6
+ } from '../../constant/AxisHelperColors';
7
+ import { DIVEHoverable } from '../../interface/Hoverable';
8
+ import DIVEOrbitControls from '../../controls/OrbitControls';
9
+ import { DIVEScaleHandle } from '../handles/ScaleHandle';
10
+ import { DraggableEvent } from '../../toolbox/BaseTool';
11
+ import { DIVEGizmoAxis, DIVEGizmo } from '../Gizmo';
8
12
 
9
13
  export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
10
14
  readonly isHoverable: true = true;
@@ -18,7 +22,7 @@ export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
18
22
  constructor(controller: DIVEOrbitControls) {
19
23
  super();
20
24
 
21
- this.name = "DIVEScaleGizmo";
25
+ this.name = 'DIVEScaleGizmo';
22
26
 
23
27
  this.children = [];
24
28
 
@@ -26,9 +30,15 @@ export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
26
30
 
27
31
  this._controller = controller;
28
32
 
29
- this.add(new DIVEScaleHandle('x', 1, new Vector3(1, 0, 0), AxesColorRed));
30
- this.add(new DIVEScaleHandle('y', 1, new Vector3(0, 1, 0), AxesColorGreen));
31
- this.add(new DIVEScaleHandle('z', 1, new Vector3(0, 0, 1), AxesColorBlue));
33
+ this.add(
34
+ new DIVEScaleHandle('x', 1, new Vector3(1, 0, 0), AxesColorRed),
35
+ );
36
+ this.add(
37
+ new DIVEScaleHandle('y', 1, new Vector3(0, 1, 0), AxesColorGreen),
38
+ );
39
+ this.add(
40
+ new DIVEScaleHandle('z', 1, new Vector3(0, 0, 1), AxesColorBlue),
41
+ );
32
42
  }
33
43
 
34
44
  public reset(): void {
@@ -43,7 +53,11 @@ export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
43
53
  });
44
54
  }
45
55
 
46
- private handleHighlight(axis: DIVEGizmoAxis, value: boolean, dragged: boolean): void {
56
+ private handleHighlight(
57
+ axis: DIVEGizmoAxis,
58
+ value: boolean,
59
+ dragged: boolean,
60
+ ): void {
47
61
  // Set highlight state for all handles.
48
62
  this.children.forEach((child) => {
49
63
  if (dragged) {
@@ -63,7 +77,11 @@ export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
63
77
 
64
78
  if (!this.parent) return;
65
79
  if (!this.parent.parent) return;
66
- (this.parent.parent as DIVEGizmo).onHover('translate', handle.axis, value);
80
+ (this.parent.parent as DIVEGizmo).onHover(
81
+ 'translate',
82
+ handle.axis,
83
+ value,
84
+ );
67
85
 
68
86
  this.handleHighlight(handle.axis, value, false);
69
87
  }
@@ -87,11 +105,15 @@ export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
87
105
  if (!('onChange' in this.parent.parent)) return;
88
106
 
89
107
  const delta = e.dragDelta.clone().projectOnVector(axis.forwardVector);
90
- (this.parent.parent as DIVEGizmo).onChange(undefined, undefined, this._startScale.clone().add(delta));
108
+ (this.parent.parent as DIVEGizmo).onChange(
109
+ undefined,
110
+ undefined,
111
+ this._startScale.clone().add(delta),
112
+ );
91
113
  }
92
114
 
93
115
  public onAxisDragEnd(handle: DIVEScaleHandle): void {
94
116
  this._startScale = null;
95
117
  this.handleHighlight(handle.axis, false, false);
96
118
  }
97
- }
119
+ }
@@ -1,9 +1,13 @@
1
- import { Object3D, Vector3 } from "three";
2
- import { AxesColorBlue, AxesColorGreen, AxesColorRed } from "../../constant/AxisHelperColors";
3
- import DIVEOrbitControls from "../../controls/OrbitControls";
4
- import { DIVEAxisHandle } from "../handles/AxisHandle";
5
- import { DIVEGizmo, DIVEGizmoAxis } from "../Gizmo";
6
- import { DraggableEvent } from "../../toolbox/BaseTool";
1
+ import { Object3D, Vector3 } from 'three';
2
+ import {
3
+ AxesColorBlue,
4
+ AxesColorGreen,
5
+ AxesColorRed,
6
+ } from '../../constant/AxisHelperColors';
7
+ import DIVEOrbitControls from '../../controls/OrbitControls';
8
+ import { DIVEAxisHandle } from '../handles/AxisHandle';
9
+ import { DIVEGizmo, DIVEGizmoAxis } from '../Gizmo';
10
+ import { DraggableEvent } from '../../toolbox/BaseTool';
7
11
 
8
12
  export class DIVETranslateGizmo extends Object3D {
9
13
  private _controller: DIVEOrbitControls;
@@ -15,7 +19,7 @@ export class DIVETranslateGizmo extends Object3D {
15
19
  constructor(controller: DIVEOrbitControls) {
16
20
  super();
17
21
 
18
- this.name = "DIVETranslateGizmo";
22
+ this.name = 'DIVETranslateGizmo';
19
23
 
20
24
  this.children = [];
21
25
 
@@ -23,9 +27,15 @@ export class DIVETranslateGizmo extends Object3D {
23
27
 
24
28
  this._controller = controller;
25
29
 
26
- this.add(new DIVEAxisHandle('x', 1, new Vector3(1, 0, 0), AxesColorRed));
27
- this.add(new DIVEAxisHandle('y', 1, new Vector3(0, 1, 0), AxesColorGreen));
28
- this.add(new DIVEAxisHandle('z', 1, new Vector3(0, 0, 1), AxesColorBlue));
30
+ this.add(
31
+ new DIVEAxisHandle('x', 1, new Vector3(1, 0, 0), AxesColorRed),
32
+ );
33
+ this.add(
34
+ new DIVEAxisHandle('y', 1, new Vector3(0, 1, 0), AxesColorGreen),
35
+ );
36
+ this.add(
37
+ new DIVEAxisHandle('z', 1, new Vector3(0, 0, 1), AxesColorBlue),
38
+ );
29
39
  }
30
40
 
31
41
  public reset(): void {
@@ -34,7 +44,11 @@ export class DIVETranslateGizmo extends Object3D {
34
44
  });
35
45
  }
36
46
 
37
- private handleHighlight(axis: DIVEGizmoAxis, value: boolean, dragged: boolean): void {
47
+ private handleHighlight(
48
+ axis: DIVEGizmoAxis,
49
+ value: boolean,
50
+ dragged: boolean,
51
+ ): void {
38
52
  // Set highlight state for all handles.
39
53
  this.children.forEach((child) => {
40
54
  if (dragged) {
@@ -54,7 +68,11 @@ export class DIVETranslateGizmo extends Object3D {
54
68
 
55
69
  if (!this.parent) return;
56
70
  if (!this.parent.parent) return;
57
- (this.parent.parent as DIVEGizmo).onHover('translate', handle.axis, value);
71
+ (this.parent.parent as DIVEGizmo).onHover(
72
+ 'translate',
73
+ handle.axis,
74
+ value,
75
+ );
58
76
 
59
77
  this.handleHighlight(handle.axis, value, false);
60
78
  }
@@ -78,11 +96,13 @@ export class DIVETranslateGizmo extends Object3D {
78
96
  if (!('onChange' in this.parent.parent)) return;
79
97
 
80
98
  const delta = e.dragDelta.clone().projectOnVector(handle.forwardVector);
81
- (this.parent.parent as DIVEGizmo).onChange(this._startPos.clone().add(delta));
99
+ (this.parent.parent as DIVEGizmo).onChange(
100
+ this._startPos.clone().add(delta),
101
+ );
82
102
  }
83
103
 
84
104
  public onHandleDragEnd(handle: DIVEAxisHandle): void {
85
105
  this._startPos = null;
86
106
  this.handleHighlight(handle.axis, false, false);
87
107
  }
88
- }
108
+ }
package/src/grid/Grid.ts CHANGED
@@ -1,6 +1,9 @@
1
- import { GRID_SIDE_LINE_COLOR, GRID_CENTER_LINE_COLOR } from "../constant/GridColors.ts";
2
- import { HELPER_LAYER_MASK } from "../constant/VisibilityLayerMask.ts";
3
- import { GridHelper, Object3D } from "three";
1
+ import {
2
+ GRID_SIDE_LINE_COLOR,
3
+ GRID_CENTER_LINE_COLOR,
4
+ } from '../constant/GridColors.ts';
5
+ import { HELPER_LAYER_MASK } from '../constant/VisibilityLayerMask.ts';
6
+ import { GridHelper, Object3D } from 'three';
4
7
 
5
8
  /**
6
9
  * A basic grid for the scene.
@@ -13,7 +16,12 @@ export class DIVEGrid extends Object3D {
13
16
  super();
14
17
  this.name = 'Grid';
15
18
 
16
- const grid = new GridHelper(100, 100, GRID_CENTER_LINE_COLOR, GRID_SIDE_LINE_COLOR);
19
+ const grid = new GridHelper(
20
+ 100,
21
+ 100,
22
+ GRID_CENTER_LINE_COLOR,
23
+ GRID_SIDE_LINE_COLOR,
24
+ );
17
25
  grid.material.depthTest = false;
18
26
  grid.layers.mask = HELPER_LAYER_MASK;
19
27
 
@@ -23,4 +31,4 @@ export class DIVEGrid extends Object3D {
23
31
  public SetVisibility(visible: boolean): void {
24
32
  this.visible = visible;
25
33
  }
26
- }
34
+ }
@@ -1,5 +1,5 @@
1
1
  import { DIVEGrid } from '../Grid.ts';
2
- import { HELPER_LAYER_MASK } from "../../constant/VisibilityLayerMask.ts";
2
+ import { HELPER_LAYER_MASK } from '../../constant/VisibilityLayerMask.ts';
3
3
  import { GridHelper } from 'three';
4
4
 
5
5
  let grid: DIVEGrid;
@@ -14,7 +14,9 @@ describe('dive/grid/DIVEGrid', () => {
14
14
  expect(grid.name).toBeTruthy();
15
15
  expect(grid.children.length).toBeGreaterThanOrEqual(1);
16
16
  expect((grid.children[0] as GridHelper).material.depthTest).toBe(false);
17
- expect((grid.children[0] as GridHelper).layers.mask).toBe(HELPER_LAYER_MASK);
17
+ expect((grid.children[0] as GridHelper).layers.mask).toBe(
18
+ HELPER_LAYER_MASK,
19
+ );
18
20
  });
19
21
 
20
22
  it('should set visibility', () => {
@@ -23,4 +25,4 @@ describe('dive/grid/DIVEGrid', () => {
23
25
  grid.SetVisibility(true);
24
26
  expect(grid.visible).toBe(true);
25
27
  });
26
- });
28
+ });
@@ -1,7 +1,7 @@
1
- import { BufferGeometry, Line, LineDashedMaterial, Vector3 } from "three";
2
- import { DIVENode } from "../node/Node";
3
- import { type Object3D } from "three";
4
- import { type DIVESceneObject } from "../types";
1
+ import { BufferGeometry, Line, LineDashedMaterial, Vector3 } from 'three';
2
+ import { DIVENode } from '../node/Node';
3
+ import { type Object3D } from 'three';
4
+ import { type DIVESceneObject } from '../types';
5
5
 
6
6
  export class DIVEGroup extends DIVENode {
7
7
  readonly isDIVEGroup: true = true;
@@ -40,7 +40,6 @@ export class DIVEGroup extends DIVENode {
40
40
  this.add(line);
41
41
  this._lines.push(line);
42
42
 
43
-
44
43
  // attach (insted of add) object to keep it's world position
45
44
  super.attach(object);
46
45
  this._members.push(object);
@@ -94,7 +93,10 @@ export class DIVEGroup extends DIVENode {
94
93
  * Updates a line to the object.
95
94
  */
96
95
  private updateLineTo(line: Line, object: Object3D): void {
97
- line.geometry.setFromPoints([new Vector3(0, 0, 0), object.position.clone()]);
96
+ line.geometry.setFromPoints([
97
+ new Vector3(0, 0, 0),
98
+ object.position.clone(),
99
+ ]);
98
100
  line.computeLineDistances();
99
101
  }
100
102
 
@@ -155,4 +157,4 @@ export class DIVEGroup extends DIVENode {
155
157
  // 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);
156
158
  // this._boxMesh.visible = true;
157
159
  // }
158
- }
160
+ }
@@ -1,5 +1,5 @@
1
- import { DIVECommunication } from "../../com/Communication";
2
- import { DIVEGroup } from "../Group";
1
+ import { DIVECommunication } from '../../com/Communication';
2
+ import { DIVEGroup } from '../Group';
3
3
 
4
4
  jest.mock('../../com/Communication.ts', () => {
5
5
  return {
@@ -7,13 +7,15 @@ jest.mock('../../com/Communication.ts', () => {
7
7
  get: jest.fn(() => {
8
8
  return {
9
9
  PerformAction: jest.fn(),
10
- }
10
+ };
11
11
  }),
12
12
  },
13
- }
13
+ };
14
14
  });
15
15
 
16
- jest.spyOn(DIVECommunication, 'get').mockReturnValue({ PerformAction: jest.fn() } as unknown as DIVECommunication);
16
+ jest.spyOn(DIVECommunication, 'get').mockReturnValue({
17
+ PerformAction: jest.fn(),
18
+ } as unknown as DIVECommunication);
17
19
 
18
20
  let group: DIVEGroup;
19
21
 
@@ -105,4 +107,4 @@ describe('dive/group/DIVEGroup', () => {
105
107
  jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
106
108
  expect(() => group.onMove()).not.toThrow();
107
109
  });
108
- });
110
+ });
@@ -1,22 +1,25 @@
1
1
  import { applyMixins } from '../applyMixins.ts';
2
2
 
3
3
  class Movable {
4
- move() { }
4
+ move() {}
5
5
  }
6
6
 
7
7
  class Selectable {
8
- select() { }
8
+ select() {}
9
9
  }
10
10
 
11
11
  describe('dive/helper/applyMixins', () => {
12
12
  it('should apply mixins', () => {
13
13
  class Product {
14
- doProductThings() { }
14
+ doProductThings() {}
15
15
  }
16
16
 
17
- interface Product extends Movable, Selectable { }
17
+ interface Product extends Movable, Selectable {}
18
18
 
19
- applyMixins(Product, [Movable, Selectable]);
19
+ applyMixins(Product, [
20
+ Movable,
21
+ Selectable,
22
+ ]);
20
23
 
21
24
  const instance = new Product();
22
25
  expect(instance).toBeDefined();
@@ -24,4 +27,4 @@ describe('dive/helper/applyMixins', () => {
24
27
  expect(instance.select).toBeDefined();
25
28
  expect(instance.doProductThings).toBeDefined();
26
29
  });
27
- });
30
+ });
@@ -2,14 +2,17 @@
2
2
  * Merges two class prototypes to a new one.
3
3
  */
4
4
 
5
- export const applyMixins = (derivedCtor: { prototype: object }, constructors: { prototype: object }[]): void => {
5
+ export const applyMixins = (
6
+ derivedCtor: { prototype: object },
7
+ constructors: { prototype: object }[],
8
+ ): void => {
6
9
  constructors.forEach((baseCtor) => {
7
10
  Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
8
11
  Object.defineProperty(
9
12
  derivedCtor.prototype,
10
13
  name,
11
- Object.getOwnPropertyDescriptor(baseCtor.prototype, name)!
14
+ Object.getOwnPropertyDescriptor(baseCtor.prototype, name)!,
12
15
  );
13
16
  });
14
17
  });
15
- }
18
+ };
@@ -10,9 +10,11 @@ describe('dive/helper/findInterface', () => {
10
10
  expect(findInterface(obj, 'isInterface')).toBe(undefined);
11
11
 
12
12
  // add traverse function
13
- obj.traverseAncestors = jest.fn((callback: (object: Object3D) => any) => {
14
- callback(obj);
15
- });
13
+ obj.traverseAncestors = jest.fn(
14
+ (callback: (object: Object3D) => any) => {
15
+ callback(obj);
16
+ },
17
+ );
16
18
 
17
19
  expect(findInterface(obj, 'isInterface')).toBe(undefined);
18
20
  });
@@ -20,9 +22,11 @@ describe('dive/helper/findInterface', () => {
20
22
  it('should find interface in object', () => {
21
23
  const obj = {
22
24
  isInterface: true,
23
- traverseAncestors: jest.fn((callback: (object: Object3D) => any) => {
24
- callback(obj);
25
- }),
25
+ traverseAncestors: jest.fn(
26
+ (callback: (object: Object3D) => any) => {
27
+ callback(obj);
28
+ },
29
+ ),
26
30
  } as unknown as Object3D;
27
31
 
28
32
  expect(findInterface(obj, 'isInterface')).toBe(obj);
@@ -30,24 +34,30 @@ describe('dive/helper/findInterface', () => {
30
34
 
31
35
  it('should find interface in parent', () => {
32
36
  const obj = {
33
- traverseAncestors: jest.fn((callback: (object: Object3D) => any) => {
34
- callback(obj);
35
- }),
37
+ traverseAncestors: jest.fn(
38
+ (callback: (object: Object3D) => any) => {
39
+ callback(obj);
40
+ },
41
+ ),
36
42
  parent: {
37
43
  isInterface: true,
38
44
 
39
- traverseAncestors: jest.fn((callback: (object: Object3D) => any) => {
40
- callback(obj.parent!);
41
- }),
45
+ traverseAncestors: jest.fn(
46
+ (callback: (object: Object3D) => any) => {
47
+ callback(obj.parent!);
48
+ },
49
+ ),
42
50
 
43
51
  parent: {
44
- traverseAncestors: jest.fn((callback: (object: Object3D) => any) => {
45
- callback(obj.parent!);
46
- }),
47
- }
48
- }
52
+ traverseAncestors: jest.fn(
53
+ (callback: (object: Object3D) => any) => {
54
+ callback(obj.parent!);
55
+ },
56
+ ),
57
+ },
58
+ },
49
59
  } as unknown as Object3D;
50
60
 
51
61
  expect(findInterface(obj, 'isInterface')).toBe(obj.parent);
52
62
  });
53
- });
63
+ });
@@ -1,10 +1,13 @@
1
- import { implementsInterface } from "../isInterface/implementsInterface";
2
- import { type Object3D } from "three";
1
+ import { implementsInterface } from '../isInterface/implementsInterface';
2
+ import { type Object3D } from 'three';
3
3
 
4
- export function findInterface<T>(object: Object3D | null | undefined, discriminator: string): (Object3D & T) | undefined {
4
+ export function findInterface<T>(
5
+ object: Object3D | null | undefined,
6
+ discriminator: string,
7
+ ): (Object3D & T) | undefined {
5
8
  if (!object) return undefined;
6
9
 
7
10
  if (implementsInterface<T>(object, discriminator)) return object;
8
11
 
9
12
  return findInterface<T>(object.parent, discriminator);
10
- }
13
+ }
@@ -37,4 +37,4 @@ describe('dive/helper/findSceneRecursive', () => {
37
37
 
38
38
  expect(found).toStrictEqual(scene);
39
39
  });
40
- });
40
+ });
@@ -13,4 +13,4 @@ export const findSceneRecursive = (object: Object3D): DIVEScene => {
13
13
  return findSceneRecursive(object.parent);
14
14
  }
15
15
  return object as DIVEScene;
16
- }
16
+ };
@@ -1,7 +1,6 @@
1
1
  import { getObjectDelta } from '../getObjectDelta.ts';
2
2
 
3
3
  describe('dive/helper/getObjectDelta', () => {
4
-
5
4
  // NO DELTAS
6
5
  it('should not find any deltas with empty objects', () => {
7
6
  const obj0 = {};
@@ -13,7 +12,16 @@ describe('dive/helper/getObjectDelta', () => {
13
12
  });
14
13
 
15
14
  it('should not find any deltas with equal references', () => {
16
- const obj0 = { test0: 'test', value0: 42, array0: [187, 6, 9, 42] };
15
+ const obj0 = {
16
+ test0: 'test',
17
+ value0: 42,
18
+ array0: [
19
+ 187,
20
+ 6,
21
+ 9,
22
+ 42,
23
+ ],
24
+ };
17
25
  const obj1 = obj0;
18
26
 
19
27
  const delta = getObjectDelta(obj0, obj1);
@@ -22,7 +30,16 @@ describe('dive/helper/getObjectDelta', () => {
22
30
  });
23
31
 
24
32
  it('should not find any deltas with equal objects', () => {
25
- const obj0 = { test0: 'test', value0: 42, array0: [187, 6, 9, 42] };
33
+ const obj0 = {
34
+ test0: 'test',
35
+ value0: 42,
36
+ array0: [
37
+ 187,
38
+ 6,
39
+ 9,
40
+ 42,
41
+ ],
42
+ };
26
43
  const obj1 = { ...obj0 };
27
44
 
28
45
  const delta = getObjectDelta(obj0, obj1);
@@ -95,8 +112,21 @@ describe('dive/helper/getObjectDelta', () => {
95
112
  });
96
113
 
97
114
  it('should find deltas with array value delta', () => {
98
- const obj0 = { array0: [187, 6, 9, 42] };
99
- const obj1 = { array0: [187, 6, 9] };
115
+ const obj0 = {
116
+ array0: [
117
+ 187,
118
+ 6,
119
+ 9,
120
+ 42,
121
+ ],
122
+ };
123
+ const obj1 = {
124
+ array0: [
125
+ 187,
126
+ 6,
127
+ 9,
128
+ ],
129
+ };
100
130
 
101
131
  const delta = getObjectDelta(obj0, obj1);
102
132
 
@@ -105,7 +135,13 @@ describe('dive/helper/getObjectDelta', () => {
105
135
 
106
136
  it('should find deltas with array type difference', () => {
107
137
  const obj0 = { array0: 'array0' };
108
- const obj1 = { array0: [187, 6, 9] as unknown as string };
138
+ const obj1 = {
139
+ array0: [
140
+ 187,
141
+ 6,
142
+ 9,
143
+ ] as unknown as string,
144
+ };
109
145
 
110
146
  const delta = getObjectDelta(obj0, obj1);
111
147
 
@@ -147,4 +183,4 @@ describe('dive/helper/getObjectDelta', () => {
147
183
 
148
184
  expect(delta).toStrictEqual(obj1);
149
185
  });
150
- });
186
+ });