@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,6 +1,6 @@
1
- import { type Vector3Like } from "three";
2
- import { type COMMaterial } from "./COMMaterial";
3
- import { type COMBaseEntity } from "./COMBaseEntity";
1
+ import { type Vector3Like } from 'three';
2
+ import { type COMMaterial } from './COMMaterial';
3
+ import { type COMBaseEntity } from './COMBaseEntity';
4
4
 
5
5
  export type COMModel = COMBaseEntity & {
6
6
  uri: string;
@@ -9,4 +9,4 @@ export type COMModel = COMBaseEntity & {
9
9
  scale: Vector3Like;
10
10
  loaded: boolean;
11
11
  material?: Partial<COMMaterial>;
12
- };
12
+ };
@@ -1,8 +1,8 @@
1
- import { type Vector3Like } from "three";
2
- import { type COMBaseEntity } from "./COMBaseEntity";
1
+ import { type Vector3Like } from 'three';
2
+ import { type COMBaseEntity } from './COMBaseEntity';
3
3
 
4
4
  export type COMPov = COMBaseEntity & {
5
5
  position: Vector3Like;
6
6
  target: Vector3Like;
7
7
  locked?: boolean;
8
- };
8
+ };
@@ -1,7 +1,7 @@
1
- import { type Vector3Like } from "three";
2
- import { type COMBaseEntity } from "./COMBaseEntity";
3
- import { type COMGeometry } from "./COMGeometry";
4
- import { type COMMaterial } from "./COMMaterial";
1
+ import { type Vector3Like } from 'three';
2
+ import { type COMBaseEntity } from './COMBaseEntity';
3
+ import { type COMGeometry } from './COMGeometry';
4
+ import { type COMMaterial } from './COMMaterial';
5
5
 
6
6
  export type COMPrimitive = COMBaseEntity & {
7
7
  position: Vector3Like;
@@ -9,4 +9,4 @@ export type COMPrimitive = COMBaseEntity & {
9
9
  scale: Vector3Like;
10
10
  geometry: COMGeometry;
11
11
  material?: Partial<COMMaterial>;
12
- };
12
+ };
@@ -1,12 +1,12 @@
1
- import { type COMEntity } from "./COMEntity";
2
- import { type COMPrimitive } from "./COMPrimitive";
3
- import { type COMModel } from "./COMModel";
4
- import { type COMLight } from "./COMLight";
5
- import { type COMPov } from "./COMPov";
6
- import { type COMGeometry } from "./COMGeometry";
7
- import { type COMMaterial } from "./COMMaterial";
8
- import { type COMGroup } from "./COMGroup";
9
- import { type COMEntityType } from "./COMEntityType";
1
+ import { type COMEntity } from './COMEntity';
2
+ import { type COMPrimitive } from './COMPrimitive';
3
+ import { type COMModel } from './COMModel';
4
+ import { type COMLight } from './COMLight';
5
+ import { type COMPov } from './COMPov';
6
+ import { type COMGeometry } from './COMGeometry';
7
+ import { type COMMaterial } from './COMMaterial';
8
+ import { type COMGroup } from './COMGroup';
9
+ import { type COMEntityType } from './COMEntityType';
10
10
 
11
11
  export type {
12
12
  COMEntity,
@@ -18,4 +18,4 @@ export type {
18
18
  COMMaterial,
19
19
  COMGroup,
20
20
  COMEntityType,
21
- }
21
+ };
@@ -4,4 +4,4 @@ export const AxesColorBlueLetter = '#0081d4';
4
4
 
5
5
  export const AxesColorRed = AxesColorRedLetter;
6
6
  export const AxesColorGreen = AxesColorGreenLetter;
7
- export const AxesColorBlue = AxesColorBlueLetter;
7
+ export const AxesColorBlue = AxesColorBlueLetter;
@@ -1,2 +1,2 @@
1
1
  export const GRID_CENTER_LINE_COLOR = '#888888';
2
- export const GRID_SIDE_LINE_COLOR = '#dddddd';
2
+ export const GRID_SIDE_LINE_COLOR = '#dddddd';
@@ -1,19 +1,19 @@
1
- import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
2
- import DIVEPerspectiveCamera from "../camera/PerspectiveCamera.ts";
3
- import { DIVERenderer } from "../renderer/Renderer.ts";
4
- import { type Box3, MathUtils, Vector3, Vector3Like } from "three";
5
- import { Easing } from "@tweenjs/tween.js";
6
- import { type DIVEAnimationSystem } from "../animation/AnimationSystem.ts";
1
+ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
2
+ import DIVEPerspectiveCamera from '../camera/PerspectiveCamera.ts';
3
+ import { DIVERenderer } from '../renderer/Renderer.ts';
4
+ import { type Box3, MathUtils, Vector3, Vector3Like } from 'three';
5
+ import { Easing } from '@tweenjs/tween.js';
6
+ import { type DIVEAnimationSystem } from '../animation/AnimationSystem.ts';
7
7
 
8
8
  export type DIVEOrbitControlsSettings = {
9
9
  enableDamping: boolean;
10
10
  dampingFactor: number;
11
- }
11
+ };
12
12
 
13
13
  export const DIVEOrbitControlsDefaultSettings: DIVEOrbitControlsSettings = {
14
14
  enableDamping: true,
15
15
  dampingFactor: 0.04,
16
- }
16
+ };
17
17
 
18
18
  /**
19
19
  * Orbit Controls. Basic functionality to orbit around a given target point in the scene.
@@ -26,20 +26,25 @@ export default class DIVEOrbitControls extends OrbitControls {
26
26
 
27
27
  private _animationSystem: DIVEAnimationSystem;
28
28
 
29
- private last: { pos: Vector3Like, target: Vector3Like } | null = null;
29
+ private last: { pos: Vector3Like; target: Vector3Like } | null = null;
30
30
 
31
31
  private animating: boolean = false;
32
32
  private locked: boolean = false;
33
33
 
34
- private stopMoveTo: () => void = () => { };
35
- private stopRevertLast: () => void = () => { };
34
+ private stopMoveTo: () => void = () => {};
35
+ private stopRevertLast: () => void = () => {};
36
36
 
37
37
  public object: DIVEPerspectiveCamera;
38
38
  public domElement: HTMLCanvasElement;
39
39
 
40
- private _removePreRenderCallback: () => void = () => { };
40
+ private _removePreRenderCallback: () => void = () => {};
41
41
 
42
- constructor(camera: DIVEPerspectiveCamera, renderer: DIVERenderer, animationSystem: DIVEAnimationSystem, settings: Partial<DIVEOrbitControlsSettings> = DIVEOrbitControlsDefaultSettings) {
42
+ constructor(
43
+ camera: DIVEPerspectiveCamera,
44
+ renderer: DIVERenderer,
45
+ animationSystem: DIVEAnimationSystem,
46
+ settings: Partial<DIVEOrbitControlsSettings> = DIVEOrbitControlsDefaultSettings,
47
+ ) {
43
48
  super(camera, renderer.domElement);
44
49
 
45
50
  this._animationSystem = animationSystem;
@@ -54,10 +59,14 @@ export default class DIVEOrbitControls extends OrbitControls {
54
59
 
55
60
  this._removePreRenderCallback = () => {
56
61
  renderer.RemovePreRenderCallback(id);
57
- }
62
+ };
58
63
 
59
- this.enableDamping = settings.enableDamping || DIVEOrbitControlsDefaultSettings.enableDamping;
60
- this.dampingFactor = settings.dampingFactor || DIVEOrbitControlsDefaultSettings.dampingFactor;
64
+ this.enableDamping =
65
+ settings.enableDamping ||
66
+ DIVEOrbitControlsDefaultSettings.enableDamping;
67
+ this.dampingFactor =
68
+ settings.dampingFactor ||
69
+ DIVEOrbitControlsDefaultSettings.dampingFactor;
61
70
 
62
71
  // initialize camera transformation
63
72
  this.object.position.set(0, 2, 2);
@@ -70,7 +79,10 @@ export default class DIVEOrbitControls extends OrbitControls {
70
79
  this.dispose();
71
80
  }
72
81
 
73
- public ComputeEncompassingView(bb: Box3): { position: Vector3Like, target: Vector3Like } {
82
+ public ComputeEncompassingView(bb: Box3): {
83
+ position: Vector3Like;
84
+ target: Vector3Like;
85
+ } {
74
86
  const center = bb.getCenter(new Vector3());
75
87
  const size = bb.getSize(new Vector3());
76
88
  const distance = Math.max(size.x, size.y, size.z) * 1.25;
@@ -85,7 +97,11 @@ export default class DIVEOrbitControls extends OrbitControls {
85
97
  public ZoomIn(by?: number): void {
86
98
  const zoomBy = by || DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
87
99
  const { minDistance, maxDistance } = this;
88
- this.minDistance = this.maxDistance = MathUtils.clamp(this.getDistance() - zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
100
+ this.minDistance = this.maxDistance = MathUtils.clamp(
101
+ this.getDistance() - zoomBy,
102
+ minDistance + zoomBy,
103
+ maxDistance - zoomBy,
104
+ );
89
105
  this.update();
90
106
  this.minDistance = minDistance;
91
107
  this.maxDistance = maxDistance;
@@ -94,13 +110,22 @@ export default class DIVEOrbitControls extends OrbitControls {
94
110
  public ZoomOut(by?: number): void {
95
111
  const zoomBy = by || DIVEOrbitControls.DEFAULT_ZOOM_FACTOR;
96
112
  const { minDistance, maxDistance } = this;
97
- this.minDistance = this.maxDistance = MathUtils.clamp(this.getDistance() + zoomBy, minDistance + zoomBy, maxDistance - zoomBy);
113
+ this.minDistance = this.maxDistance = MathUtils.clamp(
114
+ this.getDistance() + zoomBy,
115
+ minDistance + zoomBy,
116
+ maxDistance - zoomBy,
117
+ );
98
118
  this.update();
99
119
  this.minDistance = minDistance;
100
120
  this.maxDistance = maxDistance;
101
121
  }
102
122
 
103
- public MoveTo(pos: Vector3Like | undefined, target: Vector3Like | undefined, duration: number, lock: boolean): void {
123
+ public MoveTo(
124
+ pos: Vector3Like | undefined,
125
+ target: Vector3Like | undefined,
126
+ duration: number,
127
+ lock: boolean,
128
+ ): void {
104
129
  if (this.animating) return;
105
130
 
106
131
  const toPosition = pos || this.object.position.clone();
@@ -108,18 +133,24 @@ export default class DIVEOrbitControls extends OrbitControls {
108
133
 
109
134
  this.stopRevertLast();
110
135
 
111
- if (!this.locked) this.last = { pos: this.object.position.clone(), target: this.target.clone() };
136
+ if (!this.locked)
137
+ this.last = {
138
+ pos: this.object.position.clone(),
139
+ target: this.target.clone(),
140
+ };
112
141
 
113
142
  this.animating = duration > 0;
114
143
  this.locked = lock;
115
144
  this.enabled = false;
116
145
 
117
- const tweenPos = this._animationSystem.Animate(this.object.position)
146
+ const tweenPos = this._animationSystem
147
+ .Animate(this.object.position)
118
148
  .to(toPosition, duration)
119
149
  .easing(Easing.Quadratic.Out)
120
150
  .start();
121
151
 
122
- const tweenQuat = this._animationSystem.Animate(this.target)
152
+ const tweenQuat = this._animationSystem
153
+ .Animate(this.target)
123
154
  .to(toTarget, duration)
124
155
  .easing(Easing.Quadratic.Out)
125
156
  .onUpdate(() => {
@@ -134,7 +165,7 @@ export default class DIVEOrbitControls extends OrbitControls {
134
165
  this.stopMoveTo = () => {
135
166
  tweenPos.stop();
136
167
  tweenQuat.stop();
137
- }
168
+ };
138
169
  }
139
170
 
140
171
  public RevertLast(duration: number): void {
@@ -147,12 +178,14 @@ export default class DIVEOrbitControls extends OrbitControls {
147
178
 
148
179
  const { pos, target } = this.last!;
149
180
 
150
- const tweenPos = this._animationSystem.Animate(this.object.position)
181
+ const tweenPos = this._animationSystem
182
+ .Animate(this.object.position)
151
183
  .to(pos, duration)
152
184
  .easing(Easing.Quadratic.Out)
153
185
  .start();
154
186
 
155
- const tweenQuat = this._animationSystem.Animate(this.target)
187
+ const tweenQuat = this._animationSystem
188
+ .Animate(this.target)
156
189
  .to(target, duration)
157
190
  .easing(Easing.Quadratic.Out)
158
191
  .onUpdate(() => {
@@ -168,11 +201,11 @@ export default class DIVEOrbitControls extends OrbitControls {
168
201
  this.stopRevertLast = () => {
169
202
  tweenPos.stop();
170
203
  tweenQuat.stop();
171
- }
204
+ };
172
205
  }
173
206
 
174
207
  private preRenderCallback = (): void => {
175
208
  if (this.locked) return;
176
209
  this.update();
177
- }
178
- }
210
+ };
211
+ }
@@ -7,9 +7,9 @@ import { Tween } from '@tweenjs/tween.js';
7
7
 
8
8
  jest.mock('@tweenjs/tween.js', () => {
9
9
  return {
10
- Tween: jest.fn(() => { }),
10
+ Tween: jest.fn(() => {}),
11
11
  update: jest.fn(),
12
- }
12
+ };
13
13
  });
14
14
 
15
15
  jest.mock('three/examples/jsm/controls/OrbitControls', () => {
@@ -52,7 +52,7 @@ jest.mock('three/examples/jsm/controls/OrbitControls', () => {
52
52
  };
53
53
  return this;
54
54
  }),
55
- }
55
+ };
56
56
  });
57
57
 
58
58
  jest.mock('../../renderer/Renderer', () => {
@@ -80,7 +80,7 @@ jest.mock('../../animation/AnimationSystem', () => {
80
80
 
81
81
  return this;
82
82
  }),
83
- }
83
+ };
84
84
  });
85
85
 
86
86
  jest.mock('@tweenjs/tween.js', () => {
@@ -94,16 +94,30 @@ jest.mock('@tweenjs/tween.js', () => {
94
94
  },
95
95
  Tween: jest.fn(() => {
96
96
  const instance: object = {
97
- easing: () => { return instance; },
98
- to: () => { return instance; },
99
- start: () => { return instance; },
100
- stop: () => { return instance; },
101
- onComplete: (callback: () => typeof instance) => { callback(); return instance; },
102
- onUpdate: (callback: () => typeof instance) => { callback(); return instance; },
103
- }
97
+ easing: () => {
98
+ return instance;
99
+ },
100
+ to: () => {
101
+ return instance;
102
+ },
103
+ start: () => {
104
+ return instance;
105
+ },
106
+ stop: () => {
107
+ return instance;
108
+ },
109
+ onComplete: (callback: () => typeof instance) => {
110
+ callback();
111
+ return instance;
112
+ },
113
+ onUpdate: (callback: () => typeof instance) => {
114
+ callback();
115
+ return instance;
116
+ },
117
+ };
104
118
  return instance;
105
119
  }),
106
- }
120
+ };
107
121
  });
108
122
 
109
123
  const moveToPos = { x: 10, y: 0, z: 0 };
@@ -150,89 +164,165 @@ describe('dive/controls/DIVEOrbitControls', () => {
150
164
  });
151
165
 
152
166
  it('should instantiate', () => {
153
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem, {});
167
+ const controller = new DIVEOrbitControls(
168
+ mockCamera,
169
+ mockRenderer,
170
+ mockAnimSystem,
171
+ {},
172
+ );
154
173
  expect(controller).toBeDefined();
155
174
  });
156
175
 
157
176
  it('should instantiate with settings', () => {
158
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem, {
159
- enableDamping: false,
160
- dampingFactor: 0.5,
161
- });
177
+ const controller = new DIVEOrbitControls(
178
+ mockCamera,
179
+ mockRenderer,
180
+ mockAnimSystem,
181
+ {
182
+ enableDamping: false,
183
+ dampingFactor: 0.5,
184
+ },
185
+ );
162
186
  expect(controller).toBeDefined();
163
187
  });
164
188
 
165
189
  it('should dispose', () => {
166
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
190
+ const controller = new DIVEOrbitControls(
191
+ mockCamera,
192
+ mockRenderer,
193
+ mockAnimSystem,
194
+ );
167
195
  expect(() => controller.Dispose()).not.toThrow();
168
196
  });
169
197
 
170
198
  it('should compute encompassing view', () => {
171
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
172
- expect(() => controller.ComputeEncompassingView(new Box3())).not.toThrow();
199
+ const controller = new DIVEOrbitControls(
200
+ mockCamera,
201
+ mockRenderer,
202
+ mockAnimSystem,
203
+ );
204
+ expect(() =>
205
+ controller.ComputeEncompassingView(new Box3()),
206
+ ).not.toThrow();
173
207
  });
174
208
 
175
209
  it('should zoom in with default value', () => {
176
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
210
+ const controller = new DIVEOrbitControls(
211
+ mockCamera,
212
+ mockRenderer,
213
+ mockAnimSystem,
214
+ );
177
215
  expect(() => controller.ZoomIn()).not.toThrow();
178
216
  });
179
217
 
180
218
  it('should zoom in with custom value', () => {
181
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
219
+ const controller = new DIVEOrbitControls(
220
+ mockCamera,
221
+ mockRenderer,
222
+ mockAnimSystem,
223
+ );
182
224
  expect(() => controller.ZoomIn(10)).not.toThrow();
183
225
  });
184
226
 
185
227
  it('should zoom out with default value', () => {
186
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
228
+ const controller = new DIVEOrbitControls(
229
+ mockCamera,
230
+ mockRenderer,
231
+ mockAnimSystem,
232
+ );
187
233
  expect(() => controller.ZoomOut()).not.toThrow();
188
234
  });
189
235
 
190
236
  it('should zoom out with custom value', () => {
191
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
237
+ const controller = new DIVEOrbitControls(
238
+ mockCamera,
239
+ mockRenderer,
240
+ mockAnimSystem,
241
+ );
192
242
  expect(() => controller.ZoomOut(10)).not.toThrow();
193
243
  });
194
244
 
195
245
  it('should move to', () => {
196
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
197
- expect(() => controller.MoveTo(moveToPos, moveToQuat, moveToDuration, false)).not.toThrow();
246
+ const controller = new DIVEOrbitControls(
247
+ mockCamera,
248
+ mockRenderer,
249
+ mockAnimSystem,
250
+ );
251
+ expect(() =>
252
+ controller.MoveTo(moveToPos, moveToQuat, moveToDuration, false),
253
+ ).not.toThrow();
198
254
  });
199
255
 
200
256
  it('should revert move to', () => {
201
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
257
+ const controller = new DIVEOrbitControls(
258
+ mockCamera,
259
+ mockRenderer,
260
+ mockAnimSystem,
261
+ );
202
262
  controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
203
263
  expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
204
264
  });
205
265
 
206
266
  it('should revert move to without values', () => {
207
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
208
- expect(() => controller.MoveTo(undefined, undefined, moveToDuration, true)).not.toThrow();
267
+ const controller = new DIVEOrbitControls(
268
+ mockCamera,
269
+ mockRenderer,
270
+ mockAnimSystem,
271
+ );
272
+ expect(() =>
273
+ controller.MoveTo(undefined, undefined, moveToDuration, true),
274
+ ).not.toThrow();
209
275
  });
210
276
 
211
277
  it('should revert move to with lock', async () => {
212
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
278
+ const controller = new DIVEOrbitControls(
279
+ mockCamera,
280
+ mockRenderer,
281
+ mockAnimSystem,
282
+ );
213
283
  controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
214
284
  expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
215
285
  });
216
286
 
217
287
  it('should move after revert with lock', async () => {
218
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
288
+ const controller = new DIVEOrbitControls(
289
+ mockCamera,
290
+ mockRenderer,
291
+ mockAnimSystem,
292
+ );
219
293
  controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
220
294
  controller.RevertLast(moveToDuration);
221
- expect(() => controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true)).not.toThrow();
295
+ expect(() =>
296
+ controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true),
297
+ ).not.toThrow();
222
298
  });
223
299
 
224
300
  it('should catch multiple move tos', () => {
225
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
301
+ const controller = new DIVEOrbitControls(
302
+ mockCamera,
303
+ mockRenderer,
304
+ mockAnimSystem,
305
+ );
226
306
  controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
227
307
  controller.RevertLast(moveToDuration);
228
- expect(() => controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true)).not.toThrow();
308
+ expect(() =>
309
+ controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true),
310
+ ).not.toThrow();
229
311
  controller['animating'] = true;
230
- expect(() => controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true)).not.toThrow();
231
- expect(() => controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true)).not.toThrow();
312
+ expect(() =>
313
+ controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true),
314
+ ).not.toThrow();
315
+ expect(() =>
316
+ controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true),
317
+ ).not.toThrow();
232
318
  });
233
319
 
234
320
  it('should catch multiple reverts', () => {
235
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
321
+ const controller = new DIVEOrbitControls(
322
+ mockCamera,
323
+ mockRenderer,
324
+ mockAnimSystem,
325
+ );
236
326
  controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
237
327
  expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
238
328
  expect(() => controller.RevertLast(moveToDuration)).not.toThrow();
@@ -240,10 +330,14 @@ describe('dive/controls/DIVEOrbitControls', () => {
240
330
  });
241
331
 
242
332
  it('should execute preRenderCallback', () => {
243
- const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem);
333
+ const controller = new DIVEOrbitControls(
334
+ mockCamera,
335
+ mockRenderer,
336
+ mockAnimSystem,
337
+ );
244
338
  controller.MoveTo(moveToPos, moveToQuat, moveToDuration, true);
245
339
  expect(() => controller['preRenderCallback']()).not.toThrow();
246
340
  controller['locked'] = true;
247
341
  expect(() => controller['preRenderCallback']()).not.toThrow();
248
342
  });
249
- });
343
+ });