@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
package/src/dive.ts CHANGED
@@ -1,15 +1,25 @@
1
- import { DIVERenderer, DIVERendererDefaultSettings, DIVERendererSettings } from "./renderer/Renderer.ts";
2
- import { DIVEScene } from "./scene/Scene.ts";
3
- import DIVEPerspectiveCamera, { DIVEPerspectiveCameraDefaultSettings, DIVEPerspectiveCameraSettings } from "./camera/PerspectiveCamera.ts";
4
- import DIVEOrbitControls, { DIVEOrbitControlsDefaultSettings, DIVEOrbitControlsSettings } from "./controls/OrbitControls.ts";
5
- import DIVEToolbox from "./toolbox/Toolbox.ts";
6
- import { DIVECommunication } from "./com/Communication.ts";
7
- import { DIVEAnimationSystem } from "./animation/AnimationSystem.ts";
8
- import DIVEAxisCamera from "./axiscamera/AxisCamera.ts";
9
- import { getObjectDelta } from "./helper/getObjectDelta/getObjectDelta.ts";
10
-
11
- import { generateUUID } from "three/src/math/MathUtils";
12
- import { DIVEInfo } from "./info/Info.ts";
1
+ import {
2
+ DIVERenderer,
3
+ DIVERendererDefaultSettings,
4
+ DIVERendererSettings,
5
+ } from './renderer/Renderer.ts';
6
+ import { DIVEScene } from './scene/Scene.ts';
7
+ import DIVEPerspectiveCamera, {
8
+ DIVEPerspectiveCameraDefaultSettings,
9
+ DIVEPerspectiveCameraSettings,
10
+ } from './camera/PerspectiveCamera.ts';
11
+ import DIVEOrbitControls, {
12
+ DIVEOrbitControlsDefaultSettings,
13
+ DIVEOrbitControlsSettings,
14
+ } from './controls/OrbitControls.ts';
15
+ import DIVEToolbox from './toolbox/Toolbox.ts';
16
+ import { DIVECommunication } from './com/Communication.ts';
17
+ import { DIVEAnimationSystem } from './animation/AnimationSystem.ts';
18
+ import DIVEAxisCamera from './axiscamera/AxisCamera.ts';
19
+ import { getObjectDelta } from './helper/getObjectDelta/getObjectDelta.ts';
20
+
21
+ import { generateUUID } from 'three/src/math/MathUtils';
22
+ import { DIVEInfo } from './info/Info.ts';
13
23
  import pkgjson from '../package.json';
14
24
 
15
25
  export type DIVESettings = {
@@ -18,7 +28,7 @@ export type DIVESettings = {
18
28
  renderer: Partial<DIVERendererSettings>;
19
29
  perspectiveCamera: Partial<DIVEPerspectiveCameraSettings>;
20
30
  orbitControls: Partial<DIVEOrbitControlsSettings>;
21
- }
31
+ };
22
32
 
23
33
  export const DIVEDefaultSettings: DIVESettings = {
24
34
  autoResize: true,
@@ -26,7 +36,7 @@ export const DIVEDefaultSettings: DIVESettings = {
26
36
  renderer: DIVERendererDefaultSettings,
27
37
  perspectiveCamera: DIVEPerspectiveCameraDefaultSettings,
28
38
  orbitControls: DIVEOrbitControlsDefaultSettings,
29
- }
39
+ };
30
40
 
31
41
  /**
32
42
  * #### DIVE
@@ -86,7 +96,10 @@ export default class DIVE {
86
96
  id: modelid,
87
97
  });
88
98
 
89
- const transform = dive.Communication.PerformAction('COMPUTE_ENCOMPASSING_VIEW', {});
99
+ const transform = dive.Communication.PerformAction(
100
+ 'COMPUTE_ENCOMPASSING_VIEW',
101
+ {},
102
+ );
90
103
 
91
104
  dive.Communication.PerformAction('SET_CAMERA_TRANSFORM', {
92
105
  position: transform.position,
@@ -153,19 +166,33 @@ export default class DIVE {
153
166
  const settingsDelta = getObjectDelta(this._settings, settings);
154
167
 
155
168
  // apply renderer settings (we have to rebuild the renderer to apply the settings)
156
- if (settingsDelta.renderer) this.renderer = new DIVERenderer(this._settings.renderer);
169
+ if (settingsDelta.renderer)
170
+ this.renderer = new DIVERenderer(this._settings.renderer);
157
171
 
158
172
  // apply perspective camera settings
159
173
  if (settingsDelta.perspectiveCamera) {
160
- if (settingsDelta.perspectiveCamera.fov !== undefined) this.perspectiveCamera.fov = settingsDelta.perspectiveCamera.fov;
161
- if (settingsDelta.perspectiveCamera.near !== undefined) this.perspectiveCamera.near = settingsDelta.perspectiveCamera.near;
162
- if (settingsDelta.perspectiveCamera.far !== undefined) this.perspectiveCamera.far = settingsDelta.perspectiveCamera.far;
163
- this.perspectiveCamera.OnResize(this.renderer.domElement.width, this.renderer.domElement.height);
174
+ if (settingsDelta.perspectiveCamera.fov !== undefined)
175
+ this.perspectiveCamera.fov =
176
+ settingsDelta.perspectiveCamera.fov;
177
+ if (settingsDelta.perspectiveCamera.near !== undefined)
178
+ this.perspectiveCamera.near =
179
+ settingsDelta.perspectiveCamera.near;
180
+ if (settingsDelta.perspectiveCamera.far !== undefined)
181
+ this.perspectiveCamera.far =
182
+ settingsDelta.perspectiveCamera.far;
183
+ this.perspectiveCamera.OnResize(
184
+ this.renderer.domElement.width,
185
+ this.renderer.domElement.height,
186
+ );
164
187
  }
165
188
  // apply orbit controls settings
166
189
  if (settingsDelta.orbitControls) {
167
- if (settingsDelta.orbitControls.enableDamping !== undefined) this.orbitControls.enableDamping = settingsDelta.orbitControls.enableDamping;
168
- if (settingsDelta.orbitControls.dampingFactor !== undefined) this.orbitControls.dampingFactor = settingsDelta.orbitControls.dampingFactor;
190
+ if (settingsDelta.orbitControls.enableDamping !== undefined)
191
+ this.orbitControls.enableDamping =
192
+ settingsDelta.orbitControls.enableDamping;
193
+ if (settingsDelta.orbitControls.dampingFactor !== undefined)
194
+ this.orbitControls.dampingFactor =
195
+ settingsDelta.orbitControls.dampingFactor;
169
196
  }
170
197
 
171
198
  if (settingsDelta.autoResize !== this._settings.autoResize) {
@@ -177,7 +204,11 @@ export default class DIVE {
177
204
  }
178
205
 
179
206
  if (settingsDelta.displayAxes) {
180
- this.axisCamera = new DIVEAxisCamera(this.renderer, this.scene, this.orbitControls);
207
+ this.axisCamera = new DIVEAxisCamera(
208
+ this.renderer,
209
+ this.scene,
210
+ this.orbitControls,
211
+ );
181
212
  } else {
182
213
  this.axisCamera?.Dispose();
183
214
  this.axisCamera = null;
@@ -187,7 +218,10 @@ export default class DIVE {
187
218
  }
188
219
 
189
220
  constructor(settings?: Partial<DIVESettings>) {
190
- this._settings = { ...DIVEDefaultSettings, ...(settings !== undefined ? settings : {}) };
221
+ this._settings = {
222
+ ...DIVEDefaultSettings,
223
+ ...(settings !== undefined ? settings : {}),
224
+ };
191
225
 
192
226
  this._resizeObserverId = '';
193
227
  this._width = 0;
@@ -196,19 +230,34 @@ export default class DIVE {
196
230
  // initialize functional components
197
231
  this.renderer = new DIVERenderer(this._settings.renderer);
198
232
  this.scene = new DIVEScene();
199
- this.perspectiveCamera = new DIVEPerspectiveCamera(this._settings.perspectiveCamera);
233
+ this.perspectiveCamera = new DIVEPerspectiveCamera(
234
+ this._settings.perspectiveCamera,
235
+ );
200
236
 
201
237
  // initialize animation system
202
238
  this.animationSystem = new DIVEAnimationSystem(this.renderer);
203
239
 
204
- this.orbitControls = new DIVEOrbitControls(this.perspectiveCamera, this.renderer, this.animationSystem, this._settings.orbitControls);
240
+ this.orbitControls = new DIVEOrbitControls(
241
+ this.perspectiveCamera,
242
+ this.renderer,
243
+ this.animationSystem,
244
+ this._settings.orbitControls,
245
+ );
205
246
  this.toolbox = new DIVEToolbox(this.scene, this.orbitControls);
206
- this.communication = new DIVECommunication(this.renderer, this.scene, this.orbitControls, this.toolbox);
207
-
247
+ this.communication = new DIVECommunication(
248
+ this.renderer,
249
+ this.scene,
250
+ this.orbitControls,
251
+ this.toolbox,
252
+ );
208
253
 
209
254
  // initialize axis camera
210
255
  if (this._settings.displayAxes) {
211
- this.axisCamera = new DIVEAxisCamera(this.renderer, this.scene, this.orbitControls);
256
+ this.axisCamera = new DIVEAxisCamera(
257
+ this.renderer,
258
+ this.scene,
259
+ this.orbitControls,
260
+ );
212
261
  } else {
213
262
  this.axisCamera = null;
214
263
  }
@@ -226,7 +275,7 @@ export default class DIVE {
226
275
  PrintScene: () => {
227
276
  console.log(this.scene);
228
277
  },
229
- }
278
+ };
230
279
 
231
280
  console.log(`DIVE ${pkgjson.version} initialized`);
232
281
  }
@@ -257,7 +306,8 @@ export default class DIVE {
257
306
  if (!canvasWrapper) return;
258
307
 
259
308
  const { clientWidth, clientHeight } = canvasWrapper;
260
- if (clientWidth === this._width && clientHeight === this._height) return;
309
+ if (clientWidth === this._width && clientHeight === this._height)
310
+ return;
261
311
 
262
312
  this.OnResize(clientWidth, clientHeight);
263
313
 
@@ -271,13 +321,9 @@ export default class DIVE {
271
321
  }
272
322
  }
273
323
 
274
- export {
275
- DIVE,
276
- DIVECommunication,
277
- }
324
+ export { DIVE, DIVECommunication };
278
325
 
279
326
  export * from './math/index.ts';
280
327
 
281
328
  export type * from './com/actions/index.ts';
282
329
  export type * from './com/types';
283
-
@@ -1,12 +1,12 @@
1
- import { Euler, Object3D, Vector3 } from "three";
2
- import { DIVERotateGizmo } from "./rotate/RotateGizmo";
3
- import { DIVETranslateGizmo } from "./translate/TranslateGizmo";
4
- import DIVEOrbitControls from "../controls/OrbitControls";
5
- import { DIVEScaleGizmo } from "./scale/ScaleGizmo";
6
- import { DIVEGizmoPlane as DIVEGizmoPlane } from "./plane/GizmoPlane";
7
- import { DIVESelectable } from "../interface/Selectable";
1
+ import { Euler, Object3D, Vector3 } from 'three';
2
+ import { DIVERotateGizmo } from './rotate/RotateGizmo';
3
+ import { DIVETranslateGizmo } from './translate/TranslateGizmo';
4
+ import DIVEOrbitControls from '../controls/OrbitControls';
5
+ import { DIVEScaleGizmo } from './scale/ScaleGizmo';
6
+ import { DIVEGizmoPlane as DIVEGizmoPlane } from './plane/GizmoPlane';
7
+ import { DIVESelectable } from '../interface/Selectable';
8
8
 
9
- export type DIVEGizmoMode = ('translate' | 'rotate' | 'scale');
9
+ export type DIVEGizmoMode = 'translate' | 'rotate' | 'scale';
10
10
 
11
11
  export type DIVEGizmoAxis = 'x' | 'y' | 'z';
12
12
 
@@ -41,7 +41,7 @@ export class DIVEGizmo extends Object3D {
41
41
 
42
42
  constructor(controller: DIVEOrbitControls) {
43
43
  super();
44
- this.name = "DIVEGizmo";
44
+ this.name = 'DIVEGizmo';
45
45
 
46
46
  controller.addEventListener('change', () => {
47
47
  const size = controller.getDistance() / 2.5;
@@ -63,7 +63,7 @@ export class DIVEGizmo extends Object3D {
63
63
  this._object = null;
64
64
  }
65
65
 
66
- public attach(object: (Object3D & DIVESelectable)): this {
66
+ public attach(object: Object3D & DIVESelectable): this {
67
67
  this._object = object;
68
68
  this.assemble();
69
69
  return this;
@@ -75,12 +75,20 @@ export class DIVEGizmo extends Object3D {
75
75
  return this;
76
76
  }
77
77
 
78
- public onHover(mode: DIVEGizmoMode, axis: DIVEGizmoAxis, value: boolean): void {
78
+ public onHover(
79
+ mode: DIVEGizmoMode,
80
+ axis: DIVEGizmoAxis,
81
+ value: boolean,
82
+ ): void {
79
83
  if (!value) return;
80
84
  this._gizmoPlane.assemble(mode, axis);
81
85
  }
82
86
 
83
- public onChange(position?: Vector3, rotation?: Euler, scale?: Vector3): void {
87
+ public onChange(
88
+ position?: Vector3,
89
+ rotation?: Euler,
90
+ scale?: Vector3,
91
+ ): void {
84
92
  if (this.object === null) return;
85
93
 
86
94
  if (position) {
@@ -127,4 +135,4 @@ export class DIVEGizmo extends Object3D {
127
135
  // add plane for raycasting properly while dragging
128
136
  this.add(this._gizmoPlane);
129
137
  }
130
- }
138
+ }
@@ -1,11 +1,22 @@
1
- import { Color, ColorRepresentation, CylinderGeometry, Mesh, MeshBasicMaterial, Object3D, Vector3 } from "three";
2
- import { UI_LAYER_MASK } from "../../constant/VisibilityLayerMask";
3
- import { DIVEHoverable } from "../../interface/Hoverable";
4
- import { DIVETranslateGizmo } from "../translate/TranslateGizmo";
5
- import { DIVEDraggable } from "../../interface/Draggable";
6
- import { DraggableEvent } from "../../toolbox/BaseTool";
7
-
8
- export class DIVEAxisHandle extends Object3D implements DIVEHoverable, DIVEDraggable {
1
+ import {
2
+ Color,
3
+ ColorRepresentation,
4
+ CylinderGeometry,
5
+ Mesh,
6
+ MeshBasicMaterial,
7
+ Object3D,
8
+ Vector3,
9
+ } from 'three';
10
+ import { UI_LAYER_MASK } from '../../constant/VisibilityLayerMask';
11
+ import { DIVEHoverable } from '../../interface/Hoverable';
12
+ import { DIVETranslateGizmo } from '../translate/TranslateGizmo';
13
+ import { DIVEDraggable } from '../../interface/Draggable';
14
+ import { DraggableEvent } from '../../toolbox/BaseTool';
15
+
16
+ export class DIVEAxisHandle
17
+ extends Object3D
18
+ implements DIVEHoverable, DIVEDraggable
19
+ {
9
20
  readonly isHoverable: true = true;
10
21
  readonly isDraggable: true = true;
11
22
 
@@ -22,27 +33,39 @@ export class DIVEAxisHandle extends Object3D implements DIVEHoverable, DIVEDragg
22
33
  }
23
34
  public set highlight(highlight: boolean) {
24
35
  this._highlight = highlight;
25
- this._lineMaterial.color = this._highlight || this._hovered ? this._colorHover : this._color;
36
+ this._lineMaterial.color =
37
+ this._highlight || this._hovered ? this._colorHover : this._color;
26
38
  }
27
39
 
28
40
  private _lineMaterial: MeshBasicMaterial;
29
41
 
30
42
  public get forwardVector(): Vector3 {
31
- return new Vector3(0, 0, 1).applyQuaternion(this.quaternion).normalize();
43
+ return new Vector3(0, 0, 1)
44
+ .applyQuaternion(this.quaternion)
45
+ .normalize();
32
46
  }
33
47
 
34
48
  public get rightVector(): Vector3 {
35
- return new Vector3(1, 0, 0).applyQuaternion(this.quaternion).normalize();
49
+ return new Vector3(1, 0, 0)
50
+ .applyQuaternion(this.quaternion)
51
+ .normalize();
36
52
  }
37
53
 
38
54
  public get upVector(): Vector3 {
39
- return new Vector3(0, 1, 0).applyQuaternion(this.quaternion).normalize();
55
+ return new Vector3(0, 1, 0)
56
+ .applyQuaternion(this.quaternion)
57
+ .normalize();
40
58
  }
41
59
 
42
- constructor(axis: 'x' | 'y' | 'z', length: number, direction: Vector3, color: ColorRepresentation) {
60
+ constructor(
61
+ axis: 'x' | 'y' | 'z',
62
+ length: number,
63
+ direction: Vector3,
64
+ color: ColorRepresentation,
65
+ ) {
43
66
  super();
44
67
 
45
- this.name = "DIVEAxisHandle";
68
+ this.name = 'DIVEAxisHandle';
46
69
  this.axis = axis;
47
70
 
48
71
  this._color.set(color);
@@ -82,8 +105,8 @@ export class DIVEAxisHandle extends Object3D implements DIVEHoverable, DIVEDragg
82
105
  colliderMesh.translateY(length / 2);
83
106
  this.add(colliderMesh);
84
107
 
85
- this.rotateX(direction.y * -Math.PI / 2);
86
- this.rotateY(direction.x * Math.PI / 2);
108
+ this.rotateX((direction.y * -Math.PI) / 2);
109
+ this.rotateY((direction.x * Math.PI) / 2);
87
110
  }
88
111
 
89
112
  public reset(): void {
@@ -121,4 +144,4 @@ export class DIVEAxisHandle extends Object3D implements DIVEHoverable, DIVEDragg
121
144
  this.parent.onHandleDragEnd(this);
122
145
  }
123
146
  }
124
- }
147
+ }
@@ -1,11 +1,22 @@
1
- import { Color, ColorRepresentation, Mesh, MeshBasicMaterial, Object3D, TorusGeometry, Vector3 } from "three";
2
- import { UI_LAYER_MASK } from "../../constant/VisibilityLayerMask";
3
- import { DIVEHoverable } from "../../interface/Hoverable";
4
- import { DraggableEvent } from "../../toolbox/BaseTool";
5
- import { DIVERotateGizmo } from "../rotate/RotateGizmo";
6
- import { DIVEDraggable } from "../../interface/Draggable";
7
-
8
- export class DIVERadialHandle extends Object3D implements DIVEHoverable, DIVEDraggable {
1
+ import {
2
+ Color,
3
+ ColorRepresentation,
4
+ Mesh,
5
+ MeshBasicMaterial,
6
+ Object3D,
7
+ TorusGeometry,
8
+ Vector3,
9
+ } from 'three';
10
+ import { UI_LAYER_MASK } from '../../constant/VisibilityLayerMask';
11
+ import { DIVEHoverable } from '../../interface/Hoverable';
12
+ import { DraggableEvent } from '../../toolbox/BaseTool';
13
+ import { DIVERotateGizmo } from '../rotate/RotateGizmo';
14
+ import { DIVEDraggable } from '../../interface/Draggable';
15
+
16
+ export class DIVERadialHandle
17
+ extends Object3D
18
+ implements DIVEHoverable, DIVEDraggable
19
+ {
9
20
  readonly isHoverable: true = true;
10
21
  readonly isDraggable: true = true;
11
22
 
@@ -22,27 +33,40 @@ export class DIVERadialHandle extends Object3D implements DIVEHoverable, DIVEDra
22
33
  }
23
34
  public set highlight(highlight: boolean) {
24
35
  this._highlight = highlight;
25
- this._lineMaterial.color = this._highlight || this._hovered ? this._colorHover : this._color;
36
+ this._lineMaterial.color =
37
+ this._highlight || this._hovered ? this._colorHover : this._color;
26
38
  }
27
39
 
28
40
  private _lineMaterial: MeshBasicMaterial;
29
41
 
30
42
  public get forwardVector(): Vector3 {
31
- return new Vector3(0, 0, 1).applyQuaternion(this.quaternion).normalize();
43
+ return new Vector3(0, 0, 1)
44
+ .applyQuaternion(this.quaternion)
45
+ .normalize();
32
46
  }
33
47
 
34
48
  public get rightVector(): Vector3 {
35
- return new Vector3(1, 0, 0).applyQuaternion(this.quaternion).normalize();
49
+ return new Vector3(1, 0, 0)
50
+ .applyQuaternion(this.quaternion)
51
+ .normalize();
36
52
  }
37
53
 
38
54
  public get upVector(): Vector3 {
39
- return new Vector3(0, 1, 0).applyQuaternion(this.quaternion).normalize();
55
+ return new Vector3(0, 1, 0)
56
+ .applyQuaternion(this.quaternion)
57
+ .normalize();
40
58
  }
41
59
 
42
- constructor(axis: 'x' | 'y' | 'z', radius: number, arc: number, direction: Vector3, color: ColorRepresentation) {
60
+ constructor(
61
+ axis: 'x' | 'y' | 'z',
62
+ radius: number,
63
+ arc: number,
64
+ direction: Vector3,
65
+ color: ColorRepresentation,
66
+ ) {
43
67
  super();
44
68
 
45
- this.name = "DIVERadialHandle";
69
+ this.name = 'DIVERadialHandle';
46
70
  this.axis = axis;
47
71
 
48
72
  this._color.set(color);
@@ -116,4 +140,4 @@ export class DIVERadialHandle extends Object3D implements DIVEHoverable, DIVEDra
116
140
  this.parent.onHandleDragEnd(this);
117
141
  }
118
142
  }
119
- }
143
+ }
@@ -1,11 +1,23 @@
1
- import { BoxGeometry, Color, ColorRepresentation, CylinderGeometry, Mesh, MeshBasicMaterial, Object3D, Vector3 } from "three";
2
- import { UI_LAYER_MASK } from "../../constant/VisibilityLayerMask";
3
- import { DIVEHoverable } from "../../interface/Hoverable";
4
- import { DIVEScaleGizmo } from "../scale/ScaleGizmo";
5
- import { DIVEDraggable } from "../../interface/Draggable";
6
- import { DraggableEvent } from "../../toolbox/BaseTool";
7
-
8
- export class DIVEScaleHandle extends Object3D implements DIVEHoverable, DIVEDraggable {
1
+ import {
2
+ BoxGeometry,
3
+ Color,
4
+ ColorRepresentation,
5
+ CylinderGeometry,
6
+ Mesh,
7
+ MeshBasicMaterial,
8
+ Object3D,
9
+ Vector3,
10
+ } from 'three';
11
+ import { UI_LAYER_MASK } from '../../constant/VisibilityLayerMask';
12
+ import { DIVEHoverable } from '../../interface/Hoverable';
13
+ import { DIVEScaleGizmo } from '../scale/ScaleGizmo';
14
+ import { DIVEDraggable } from '../../interface/Draggable';
15
+ import { DraggableEvent } from '../../toolbox/BaseTool';
16
+
17
+ export class DIVEScaleHandle
18
+ extends Object3D
19
+ implements DIVEHoverable, DIVEDraggable
20
+ {
9
21
  readonly isHoverable: true = true;
10
22
  readonly isDraggable: true = true;
11
23
 
@@ -22,7 +34,8 @@ export class DIVEScaleHandle extends Object3D implements DIVEHoverable, DIVEDrag
22
34
  }
23
35
  public set highlight(highlight: boolean) {
24
36
  this._highlight = highlight;
25
- this._lineMaterial.color = this._highlight || this._hovered ? this._colorHover : this._color;
37
+ this._lineMaterial.color =
38
+ this._highlight || this._hovered ? this._colorHover : this._color;
26
39
  }
27
40
 
28
41
  private _lineMaterial: MeshBasicMaterial;
@@ -31,21 +44,33 @@ export class DIVEScaleHandle extends Object3D implements DIVEHoverable, DIVEDrag
31
44
  private _boxSize: number;
32
45
 
33
46
  public get forwardVector(): Vector3 {
34
- return new Vector3(0, 0, 1).applyQuaternion(this.quaternion).normalize();
47
+ return new Vector3(0, 0, 1)
48
+ .applyQuaternion(this.quaternion)
49
+ .normalize();
35
50
  }
36
51
 
37
52
  public get rightVector(): Vector3 {
38
- return new Vector3(1, 0, 0).applyQuaternion(this.quaternion).normalize();
53
+ return new Vector3(1, 0, 0)
54
+ .applyQuaternion(this.quaternion)
55
+ .normalize();
39
56
  }
40
57
 
41
58
  public get upVector(): Vector3 {
42
- return new Vector3(0, 1, 0).applyQuaternion(this.quaternion).normalize();
59
+ return new Vector3(0, 1, 0)
60
+ .applyQuaternion(this.quaternion)
61
+ .normalize();
43
62
  }
44
63
 
45
- constructor(axis: 'x' | 'y' | 'z', length: number, direction: Vector3, color: ColorRepresentation, boxSize: number = 0.05) {
64
+ constructor(
65
+ axis: 'x' | 'y' | 'z',
66
+ length: number,
67
+ direction: Vector3,
68
+ color: ColorRepresentation,
69
+ boxSize: number = 0.05,
70
+ ) {
46
71
  super();
47
72
 
48
- this.name = "DIVEScaleHandle";
73
+ this.name = 'DIVEScaleHandle';
49
74
  this.axis = axis;
50
75
 
51
76
  this._color.set(color);
@@ -56,7 +81,12 @@ export class DIVEScaleHandle extends Object3D implements DIVEHoverable, DIVEDrag
56
81
  this._boxSize = boxSize;
57
82
 
58
83
  // create line
59
- const lineGeo = new CylinderGeometry(0.01, 0.01, length - boxSize / 2, 13);
84
+ const lineGeo = new CylinderGeometry(
85
+ 0.01,
86
+ 0.01,
87
+ length - boxSize / 2,
88
+ 13,
89
+ );
60
90
  this._lineMaterial = new MeshBasicMaterial({
61
91
  color: color,
62
92
  depthTest: false,
@@ -78,12 +108,17 @@ export class DIVEScaleHandle extends Object3D implements DIVEHoverable, DIVEDrag
78
108
  this._box.renderOrder = Infinity;
79
109
  this._box.rotateX(Math.PI / 2);
80
110
  this._box.translateY(length - boxSize / 2);
81
- this._box.rotateZ(direction.x * Math.PI / 2);
82
- this._box.rotateX(direction.z * Math.PI / 2);
111
+ this._box.rotateZ((direction.x * Math.PI) / 2);
112
+ this._box.rotateX((direction.z * Math.PI) / 2);
83
113
  this.add(this._box);
84
114
 
85
115
  // create collider
86
- const collider = new CylinderGeometry(0.1, 0.1, length + boxSize / 2, 3);
116
+ const collider = new CylinderGeometry(
117
+ 0.1,
118
+ 0.1,
119
+ length + boxSize / 2,
120
+ 3,
121
+ );
87
122
  const colliderMaterial = new MeshBasicMaterial({
88
123
  color: 0xff00ff,
89
124
  transparent: true,
@@ -99,8 +134,8 @@ export class DIVEScaleHandle extends Object3D implements DIVEHoverable, DIVEDrag
99
134
  colliderMesh.translateY(length / 2);
100
135
  this.add(colliderMesh);
101
136
 
102
- this.rotateX(direction.y * -Math.PI / 2);
103
- this.rotateY(direction.x * Math.PI / 2);
137
+ this.rotateX((direction.y * -Math.PI) / 2);
138
+ this.rotateY((direction.x * Math.PI) / 2);
104
139
  }
105
140
 
106
141
  public reset(): void {
@@ -111,10 +146,12 @@ export class DIVEScaleHandle extends Object3D implements DIVEHoverable, DIVEDrag
111
146
  this._box.scale.copy(
112
147
  new Vector3(1, 1, 1) // identity scale ...
113
148
  .sub(this.forwardVector) // subtracted the forward vector ...
114
- .add( // to then add ...
115
- scale.clone() // the scale ...
116
- .multiply(this.forwardVector) // that is scaled by the forward vector again to get the forward vector as the only direction
117
- )
149
+ .add(
150
+ // to then add ...
151
+ scale
152
+ .clone() // the scale ...
153
+ .multiply(this.forwardVector), // that is scaled by the forward vector again to get the forward vector as the only direction
154
+ ),
118
155
  );
119
156
  }
120
157
 
@@ -149,4 +186,4 @@ export class DIVEScaleHandle extends Object3D implements DIVEHoverable, DIVEDrag
149
186
  this.parent.onAxisDragEnd(this);
150
187
  }
151
188
  }
152
- }
189
+ }
@@ -1,6 +1,6 @@
1
- import { Mesh, MeshBasicMaterial, Object3D, PlaneGeometry } from "three";
2
- import { UI_LAYER_MASK } from "../../constant/VisibilityLayerMask";
3
- import { DIVEGizmoAxis, DIVEGizmoMode } from "../Gizmo";
1
+ import { Mesh, MeshBasicMaterial, Object3D, PlaneGeometry } from 'three';
2
+ import { UI_LAYER_MASK } from '../../constant/VisibilityLayerMask';
3
+ import { DIVEGizmoAxis, DIVEGizmoMode } from '../Gizmo';
4
4
 
5
5
  export class DIVEGizmoPlane extends Object3D {
6
6
  private _meshX: Mesh;
@@ -18,7 +18,7 @@ export class DIVEGizmoPlane extends Object3D {
18
18
 
19
19
  constructor() {
20
20
  super();
21
- this.name = "DIVEGizmoPlane";
21
+ this.name = 'DIVEGizmoPlane';
22
22
 
23
23
  const material = new MeshBasicMaterial({
24
24
  transparent: true,
@@ -80,6 +80,5 @@ export class DIVEGizmoPlane extends Object3D {
80
80
  break;
81
81
  }
82
82
  }
83
-
84
83
  }
85
- }
84
+ }