@shopware-ag/dive 1.19.0 → 1.19.1-beta.1

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 (197) hide show
  1. package/build/dive.cjs +388 -220
  2. package/build/dive.cjs.map +1 -1
  3. package/build/dive.js +395 -21946
  4. package/build/dive.js.map +1 -1
  5. package/build/dive.mjs +28206 -0
  6. package/build/dive.mjs.map +1 -0
  7. package/build/src/ar/AR.d.ts +37 -14
  8. package/build/src/ar/arquicklook/ARQuickLook.d.ts +5 -6
  9. package/build/src/ar/sceneviewer/SceneViewer.d.ts +42 -6
  10. package/build/src/com/actions/scene/launchar.d.ts +5 -2
  11. package/build/src/converter/Converter.d.ts +21 -0
  12. package/build/src/dive.d.ts +3 -2
  13. package/build/src/exporter/Exporter.d.ts +11 -0
  14. package/build/src/helper/applyMixins/applyMixins.d.ts +22 -6
  15. package/build/src/info/Info.d.ts +37 -13
  16. package/build/src/interface/Movable.d.ts +5 -5
  17. package/build/src/interface/Selectable.d.ts +4 -4
  18. package/build/src/loader/Loader.d.ts +11 -0
  19. package/build/src/model/Model.d.ts +2 -2
  20. package/build/src/node/Node.d.ts +3 -3
  21. package/build/src/scene/root/Root.d.ts +1 -1
  22. package/build/src/types/ExporterOptions.d.ts +15 -0
  23. package/build/src/types/FileTypes.d.ts +27 -0
  24. package/build/src/types/index.d.ts +4 -0
  25. package/build/src/types/info/index.d.ts +66 -0
  26. package/package.json +17 -3
  27. package/build/src/exporters/usdz/USDZExporter.d.ts +0 -15
  28. package/build/src/loadingmanager/LoadingManager.d.ts +0 -14
  29. package/src/__test__/DIVE.test.ts +0 -274
  30. package/src/animation/AnimationSystem.ts +0 -34
  31. package/src/animation/__test__/AnimationSystem.test.ts +0 -40
  32. package/src/ar/AR.ts +0 -98
  33. package/src/ar/__test__/AR.test.ts +0 -187
  34. package/src/ar/arquicklook/ARQuickLook.ts +0 -93
  35. package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +0 -93
  36. package/src/ar/sceneviewer/SceneViewer.ts +0 -74
  37. package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -93
  38. package/src/ar/webxr/WebXR.ts +0 -176
  39. package/src/ar/webxr/controller/WebXRController.ts +0 -340
  40. package/src/ar/webxr/crosshair/WebXRCrosshair.ts +0 -35
  41. package/src/ar/webxr/origin/WebXROrigin.ts +0 -192
  42. package/src/ar/webxr/overlay/Overlay.ts +0 -50
  43. package/src/ar/webxr/raycaster/WebXRRaycaster.ts +0 -131
  44. package/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts +0 -102
  45. package/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts +0 -49
  46. package/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts +0 -356
  47. package/src/axiscamera/AxisCamera.ts +0 -108
  48. package/src/axiscamera/__test__/AxisCamera.test.ts +0 -150
  49. package/src/camera/PerspectiveCamera.ts +0 -63
  50. package/src/camera/__test__/PerspectiveCamera.test.ts +0 -36
  51. package/src/com/Communication.ts +0 -808
  52. package/src/com/__test__/Communication.test.ts +0 -1024
  53. package/src/com/actions/camera/computeencompassingview.ts +0 -10
  54. package/src/com/actions/camera/getcameratransform.ts +0 -10
  55. package/src/com/actions/camera/movecamera.ts +0 -18
  56. package/src/com/actions/camera/resetcamera.ts +0 -5
  57. package/src/com/actions/camera/setcameralayer.ts +0 -5
  58. package/src/com/actions/camera/setcameratransform.ts +0 -10
  59. package/src/com/actions/camera/zoomcamera.ts +0 -5
  60. package/src/com/actions/index.ts +0 -61
  61. package/src/com/actions/media/generatemedia.ts +0 -18
  62. package/src/com/actions/object/addobject.ts +0 -7
  63. package/src/com/actions/object/deleteobject.ts +0 -7
  64. package/src/com/actions/object/deselectobject.ts +0 -7
  65. package/src/com/actions/object/getallobjects.ts +0 -7
  66. package/src/com/actions/object/getobjects.ts +0 -7
  67. package/src/com/actions/object/model/dropit.ts +0 -5
  68. package/src/com/actions/object/model/modelloaded.ts +0 -5
  69. package/src/com/actions/object/model/placeonfloor.ts +0 -5
  70. package/src/com/actions/object/selectobject.ts +0 -7
  71. package/src/com/actions/object/setparent.ts +0 -10
  72. package/src/com/actions/object/updateobject.ts +0 -7
  73. package/src/com/actions/renderer/startrender.ts +0 -5
  74. package/src/com/actions/scene/exportscene.ts +0 -7
  75. package/src/com/actions/scene/getallscenedata.ts +0 -7
  76. package/src/com/actions/scene/launchar.ts +0 -7
  77. package/src/com/actions/scene/setbackground.ts +0 -5
  78. package/src/com/actions/scene/updatescene.ts +0 -11
  79. package/src/com/actions/toolbox/select/setgizmomode.ts +0 -5
  80. package/src/com/actions/toolbox/transform/setgizmoscalelinked.ts +0 -5
  81. package/src/com/actions/toolbox/transform/setgizmovisible.ts +0 -5
  82. package/src/com/actions/toolbox/usetool.ts +0 -7
  83. package/src/com/types/COMBaseEntity.ts +0 -9
  84. package/src/com/types/COMEntity.ts +0 -7
  85. package/src/com/types/COMEntityType.ts +0 -1
  86. package/src/com/types/COMGeometry.ts +0 -8
  87. package/src/com/types/COMGeometryType.ts +0 -9
  88. package/src/com/types/COMGroup.ts +0 -9
  89. package/src/com/types/COMLight.ts +0 -11
  90. package/src/com/types/COMMaterial.ts +0 -12
  91. package/src/com/types/COMModel.ts +0 -12
  92. package/src/com/types/COMPov.ts +0 -8
  93. package/src/com/types/COMPrimitive.ts +0 -12
  94. package/src/com/types/index.ts +0 -23
  95. package/src/constant/AxisHelperColors.ts +0 -7
  96. package/src/constant/GridColors.ts +0 -2
  97. package/src/constant/VisibilityLayerMask.ts +0 -5
  98. package/src/controls/OrbitControls.ts +0 -211
  99. package/src/controls/__test__/OrbitControls.test.ts +0 -256
  100. package/src/dive.ts +0 -363
  101. package/src/events/EventExecutor.ts +0 -35
  102. package/src/exporters/usdz/USDZExporter.ts +0 -21
  103. package/src/exporters/usdz/__test__/USDZExporter.test.ts +0 -57
  104. package/src/gizmo/Gizmo.ts +0 -144
  105. package/src/gizmo/handles/AxisHandle.ts +0 -153
  106. package/src/gizmo/handles/RadialHandle.ts +0 -149
  107. package/src/gizmo/handles/ScaleHandle.ts +0 -195
  108. package/src/gizmo/plane/GizmoPlane.ts +0 -84
  109. package/src/gizmo/rotate/RotateGizmo.ts +0 -143
  110. package/src/gizmo/scale/ScaleGizmo.ts +0 -125
  111. package/src/gizmo/translate/TranslateGizmo.ts +0 -114
  112. package/src/grid/Grid.ts +0 -34
  113. package/src/grid/__test__/Grid.test.ts +0 -28
  114. package/src/group/Group.ts +0 -184
  115. package/src/group/__test__/Group.test.ts +0 -212
  116. package/src/helper/applyMixins/__test__/applyMixins.test.ts +0 -30
  117. package/src/helper/applyMixins/applyMixins.ts +0 -18
  118. package/src/helper/findInterface/__test__/findInterface.test.ts +0 -63
  119. package/src/helper/findInterface/findInterface.ts +0 -13
  120. package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +0 -40
  121. package/src/helper/findSceneRecursive/findSceneRecursive.ts +0 -16
  122. package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +0 -186
  123. package/src/helper/getObjectDelta/getObjectDelta.ts +0 -105
  124. package/src/helper/isInterface/__test__/implementsInterface.test.ts +0 -19
  125. package/src/helper/isInterface/implementsInterface.ts +0 -9
  126. package/src/info/Info.ts +0 -154
  127. package/src/info/__test__/Info.test.ts +0 -338
  128. package/src/interface/Draggable.ts +0 -14
  129. package/src/interface/Hoverable.ts +0 -14
  130. package/src/interface/Movable.ts +0 -12
  131. package/src/interface/Rotatable.ts +0 -10
  132. package/src/interface/Scalable.ts +0 -10
  133. package/src/interface/Selectable.ts +0 -11
  134. package/src/io/IO.ts +0 -62
  135. package/src/io/__test__/IO.test.ts +0 -116
  136. package/src/io/gltf/GLTFIO.ts +0 -56
  137. package/src/io/gltf/__test__/GLTFIO.test.ts +0 -108
  138. package/src/light/AmbientLight.ts +0 -39
  139. package/src/light/PointLight.ts +0 -115
  140. package/src/light/SceneLight.ts +0 -63
  141. package/src/light/__test__/AmbientLight.test.ts +0 -29
  142. package/src/light/__test__/PointLight.test.ts +0 -74
  143. package/src/light/__test__/SceneLight.test.ts +0 -47
  144. package/src/loadingmanager/LoadingManager.ts +0 -50
  145. package/src/loadingmanager/__test__/LoadingManager.test.ts +0 -27
  146. package/src/math/__test__/DIVEMath.test.ts +0 -12
  147. package/src/math/ceil/__test__/ceilExp.test.ts +0 -12
  148. package/src/math/ceil/ceilExp.ts +0 -6
  149. package/src/math/degToRad/__test__/degToRad.test.ts +0 -172
  150. package/src/math/degToRad/degToRad.ts +0 -5
  151. package/src/math/floor/__test__/floorExp.test.ts +0 -14
  152. package/src/math/floor/floorExp.ts +0 -6
  153. package/src/math/helper/__test__/shift.test.ts +0 -12
  154. package/src/math/helper/shift.ts +0 -4
  155. package/src/math/index.ts +0 -28
  156. package/src/math/radToDeg/__test__/radToDeg.test.ts +0 -155
  157. package/src/math/radToDeg/radToDeg.ts +0 -5
  158. package/src/math/round/__test__/roundExp.test.ts +0 -14
  159. package/src/math/round/roundExp.ts +0 -10
  160. package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +0 -20
  161. package/src/math/signedAngleTo/signedAngleTo.ts +0 -20
  162. package/src/math/toFixed/__test__/toFixedExp.test.ts +0 -14
  163. package/src/math/toFixed/toFixedExp.ts +0 -9
  164. package/src/math/truncate/__test__/truncateExp.test.ts +0 -14
  165. package/src/math/truncate/truncateExp.ts +0 -9
  166. package/src/mediacreator/MediaCreator.ts +0 -75
  167. package/src/mediacreator/__test__/MediaCreator.test.ts +0 -155
  168. package/src/model/Model.ts +0 -185
  169. package/src/model/__test__/Model.test.ts +0 -222
  170. package/src/module/Module.ts +0 -45
  171. package/src/module/__test__/Module.test.ts +0 -54
  172. package/src/node/Node.ts +0 -98
  173. package/src/node/__test__/Node.test.ts +0 -120
  174. package/src/primitive/Primitive.ts +0 -299
  175. package/src/primitive/__test__/Primitive.test.ts +0 -281
  176. package/src/primitive/floor/Floor.ts +0 -45
  177. package/src/primitive/floor/__test__/Floor.test.ts +0 -24
  178. package/src/renderer/Renderer.ts +0 -215
  179. package/src/renderer/__test__/Renderer.test.ts +0 -228
  180. package/src/scene/Scene.ts +0 -106
  181. package/src/scene/__test__/Scene.test.ts +0 -124
  182. package/src/scene/root/Root.ts +0 -426
  183. package/src/scene/root/__test__/Root.test.ts +0 -903
  184. package/src/scene/xrroot/XRRoot.ts +0 -56
  185. package/src/scene/xrroot/xrlightroot/XRLightRoot.ts +0 -80
  186. package/src/toolbox/BaseTool.ts +0 -319
  187. package/src/toolbox/Toolbox.ts +0 -129
  188. package/src/toolbox/__test__/BaseTool.test.ts +0 -627
  189. package/src/toolbox/__test__/Toolbox.test.ts +0 -143
  190. package/src/toolbox/select/SelectTool.ts +0 -92
  191. package/src/toolbox/select/__test__/SelectTool.test.ts +0 -237
  192. package/src/toolbox/transform/TransformTool.ts +0 -166
  193. package/src/toolbox/transform/__test__/TransformTool.test.ts +0 -147
  194. package/src/types/SceneData.ts +0 -26
  195. package/src/types/SceneObjects.ts +0 -14
  196. package/src/types/SceneType.ts +0 -14
  197. package/src/types/index.ts +0 -5
@@ -1,143 +0,0 @@
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';
12
-
13
- export class DIVERotateGizmo extends Object3D {
14
- public children: DIVERadialHandle[];
15
-
16
- private _controller: DIVEOrbitControls;
17
-
18
- public set debug(value: boolean) {
19
- this.children.forEach((child) => {
20
- child.debug = value;
21
- });
22
- }
23
-
24
- private _startRot: Euler | null;
25
-
26
- constructor(controller: DIVEOrbitControls) {
27
- super();
28
-
29
- this.name = 'DIVERotateGizmo';
30
-
31
- this.children = [];
32
-
33
- this._startRot = null;
34
-
35
- this._controller = controller;
36
-
37
- this.add(
38
- new DIVERadialHandle(
39
- 'x',
40
- 1,
41
- Math.PI / 2,
42
- new Vector3(1, 0, 0),
43
- AxesColorRed,
44
- ),
45
- );
46
- this.add(
47
- new DIVERadialHandle(
48
- 'y',
49
- 1,
50
- -Math.PI / 2,
51
- new Vector3(0, 1, 0),
52
- AxesColorGreen,
53
- ),
54
- );
55
- this.add(
56
- new DIVERadialHandle(
57
- 'z',
58
- 1,
59
- Math.PI / 2,
60
- new Vector3(0, 0, 1),
61
- AxesColorBlue,
62
- ),
63
- );
64
- }
65
-
66
- public reset(): void {
67
- this.children.forEach((child) => {
68
- child.reset();
69
- });
70
- }
71
-
72
- private handleHighlight(
73
- axis: DIVEGizmoAxis,
74
- value: boolean,
75
- dragged: boolean,
76
- ): void {
77
- // Set highlight state for all handles.
78
- this.children.forEach((child) => {
79
- if (dragged) {
80
- // Dragging has priority when it comes to highlighting.
81
- child.highlight = child.axis === axis && dragged;
82
- } else {
83
- // If nothing is dragged, decide on hovered state.
84
- child.highlight = child.axis === axis && value;
85
- }
86
- });
87
- }
88
-
89
- public onHandleHover(handle: DIVERadialHandle, value: boolean): void {
90
- // If _startRot is set, it means there is a drag operation in progress.
91
- // While dragging, we don't want to change the hover state.
92
- if (this._startRot) return;
93
-
94
- if (!this.parent) return;
95
- if (!this.parent.parent) return;
96
- (this.parent.parent as DIVEGizmo).onHover('rotate', handle.axis, value);
97
-
98
- this.handleHighlight(handle.axis, value, false);
99
- }
100
-
101
- public onHandleDragStart(handle: DIVERadialHandle): void {
102
- if (!this.parent) return;
103
- if (!this.parent.parent) return;
104
-
105
- const object = (this.parent.parent as DIVEGizmo).object;
106
- if (!object) return;
107
-
108
- this._startRot = object.rotation.clone();
109
- this.handleHighlight(handle.axis, true, true);
110
- }
111
-
112
- public onHandleDrag(handle: DIVERadialHandle, e: DraggableEvent): void {
113
- if (!this._startRot) return;
114
- if (!this.parent) return;
115
- if (!this.parent.parent) return;
116
- if (!('onChange' in this.parent.parent)) return;
117
-
118
- const currentVector = e.dragCurrent
119
- .clone()
120
- .sub(this.parent.parent.position)
121
- .normalize();
122
- const startVector = e.dragStart
123
- .clone()
124
- .sub(this.parent.parent.position)
125
- .normalize();
126
- const signedAngle = DIVEMath.signedAngleTo(
127
- startVector,
128
- currentVector,
129
- handle.forwardVector,
130
- );
131
- const euler = new Euler(
132
- this._startRot.x + handle.forwardVector.x * signedAngle,
133
- this._startRot.y + handle.forwardVector.y * signedAngle,
134
- this._startRot.z + handle.forwardVector.z * signedAngle,
135
- );
136
- (this.parent.parent as DIVEGizmo).onChange(undefined, euler);
137
- }
138
-
139
- public onHandleDragEnd(handle: DIVERadialHandle): void {
140
- this._startRot = null;
141
- this.handleHighlight(handle.axis, false, false);
142
- }
143
- }
@@ -1,125 +0,0 @@
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';
12
-
13
- export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
14
- readonly isHoverable: true = true;
15
-
16
- public children: DIVEScaleHandle[];
17
-
18
- private _controller: DIVEOrbitControls;
19
-
20
- public set debug(value: boolean) {
21
- this.children.forEach((child) => {
22
- child.debug = value;
23
- });
24
- }
25
-
26
- private _startScale: Vector3 | null;
27
-
28
- constructor(controller: DIVEOrbitControls) {
29
- super();
30
-
31
- this.name = 'DIVEScaleGizmo';
32
-
33
- this.children = [];
34
-
35
- this._startScale = null;
36
-
37
- this._controller = controller;
38
-
39
- this.add(
40
- new DIVEScaleHandle('x', 1, new Vector3(1, 0, 0), AxesColorRed),
41
- );
42
- this.add(
43
- new DIVEScaleHandle('y', 1, new Vector3(0, 1, 0), AxesColorGreen),
44
- );
45
- this.add(
46
- new DIVEScaleHandle('z', 1, new Vector3(0, 0, 1), AxesColorBlue),
47
- );
48
- }
49
-
50
- public reset(): void {
51
- this.children.forEach((child) => {
52
- child.reset();
53
- });
54
- }
55
-
56
- public update(scale: Vector3): void {
57
- this.children.forEach((child) => {
58
- child.update(scale);
59
- });
60
- }
61
-
62
- private handleHighlight(
63
- axis: DIVEGizmoAxis,
64
- value: boolean,
65
- dragged: boolean,
66
- ): void {
67
- // Set highlight state for all handles.
68
- this.children.forEach((child) => {
69
- if (dragged) {
70
- // Dragging has priority when it comes to highlighting.
71
- child.highlight = child.axis === axis && dragged;
72
- } else {
73
- // If nothing is dragged, decide on hovered state.
74
- child.highlight = child.axis === axis && value;
75
- }
76
- });
77
- }
78
-
79
- public onHoverAxis(handle: DIVEScaleHandle, value: boolean): void {
80
- // If _startScale is set, it means there is a drag operation in progress.
81
- // While dragging, we don't want to change the hover state.
82
- if (this._startScale) return;
83
-
84
- if (!this.parent) return;
85
- if (!this.parent.parent) return;
86
- (this.parent.parent as DIVEGizmo).onHover(
87
- 'translate',
88
- handle.axis,
89
- value,
90
- );
91
-
92
- this.handleHighlight(handle.axis, value, false);
93
- }
94
-
95
- public onAxisDragStart(handle: DIVEScaleHandle): void {
96
- if (!this.parent) return;
97
- if (!this.parent.parent) return;
98
-
99
- const object = (this.parent.parent as DIVEGizmo).object;
100
- if (!object) return;
101
-
102
- this._startScale = object.scale.clone();
103
- this.handleHighlight(handle.axis, true, true);
104
- }
105
-
106
- public onAxisDrag(axis: DIVEScaleHandle, e: DraggableEvent): void {
107
- if (!this._startScale) return;
108
-
109
- if (!this.parent) return;
110
- if (!this.parent.parent) return;
111
- if (!('onChange' in this.parent.parent)) return;
112
-
113
- const delta = e.dragDelta.clone().projectOnVector(axis.forwardVector);
114
- (this.parent.parent as DIVEGizmo).onChange(
115
- undefined,
116
- undefined,
117
- this._startScale.clone().add(delta),
118
- );
119
- }
120
-
121
- public onAxisDragEnd(handle: DIVEScaleHandle): void {
122
- this._startScale = null;
123
- this.handleHighlight(handle.axis, false, false);
124
- }
125
- }
@@ -1,114 +0,0 @@
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';
11
-
12
- export class DIVETranslateGizmo extends Object3D {
13
- private _controller: DIVEOrbitControls;
14
-
15
- public set debug(value: boolean) {
16
- this.children.forEach((child) => {
17
- child.debug = value;
18
- });
19
- }
20
-
21
- public children: DIVEAxisHandle[];
22
-
23
- private _startPos: Vector3 | null;
24
-
25
- constructor(controller: DIVEOrbitControls) {
26
- super();
27
-
28
- this.name = 'DIVETranslateGizmo';
29
-
30
- this.children = [];
31
-
32
- this._startPos = null;
33
-
34
- this._controller = controller;
35
-
36
- this.add(
37
- new DIVEAxisHandle('x', 1, new Vector3(1, 0, 0), AxesColorRed),
38
- );
39
- this.add(
40
- new DIVEAxisHandle('y', 1, new Vector3(0, 1, 0), AxesColorGreen),
41
- );
42
- this.add(
43
- new DIVEAxisHandle('z', 1, new Vector3(0, 0, 1), AxesColorBlue),
44
- );
45
- }
46
-
47
- public reset(): void {
48
- this.children.forEach((child) => {
49
- child.reset();
50
- });
51
- }
52
-
53
- private handleHighlight(
54
- axis: DIVEGizmoAxis,
55
- value: boolean,
56
- dragged: boolean,
57
- ): void {
58
- // Set highlight state for all handles.
59
- this.children.forEach((child) => {
60
- if (dragged) {
61
- // Dragging has priority when it comes to highlighting.
62
- child.highlight = child.axis === axis && dragged;
63
- } else {
64
- // If nothing is dragged, decide on hovered state.
65
- child.highlight = child.axis === axis && value;
66
- }
67
- });
68
- }
69
-
70
- public onHandleHover(handle: DIVEAxisHandle, value: boolean): void {
71
- // If _startPos is set, it means there is a drag operation in progress.
72
- // While dragging, we don't want to change the hover state.
73
- if (this._startPos) return;
74
-
75
- if (!this.parent) return;
76
- if (!this.parent.parent) return;
77
- (this.parent.parent as DIVEGizmo).onHover(
78
- 'translate',
79
- handle.axis,
80
- value,
81
- );
82
-
83
- this.handleHighlight(handle.axis, value, false);
84
- }
85
-
86
- public onHandleDragStart(handle: DIVEAxisHandle): void {
87
- if (!this.parent) return;
88
- if (!this.parent.parent) return;
89
-
90
- const object = (this.parent.parent as DIVEGizmo).object;
91
- if (!object) return;
92
-
93
- this._startPos = object.position.clone();
94
- this.handleHighlight(handle.axis, true, true);
95
- }
96
-
97
- public onHandleDrag(handle: DIVEAxisHandle, e: DraggableEvent): void {
98
- if (!this._startPos) return;
99
-
100
- if (!this.parent) return;
101
- if (!this.parent.parent) return;
102
- if (!('onChange' in this.parent.parent)) return;
103
-
104
- const delta = e.dragDelta.clone().projectOnVector(handle.forwardVector);
105
- (this.parent.parent as DIVEGizmo).onChange(
106
- this._startPos.clone().add(delta),
107
- );
108
- }
109
-
110
- public onHandleDragEnd(handle: DIVEAxisHandle): void {
111
- this._startPos = null;
112
- this.handleHighlight(handle.axis, false, false);
113
- }
114
- }
package/src/grid/Grid.ts DELETED
@@ -1,34 +0,0 @@
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';
7
-
8
- /**
9
- * A basic grid for the scene.
10
- *
11
- * @module
12
- */
13
-
14
- export class DIVEGrid extends Object3D {
15
- constructor() {
16
- super();
17
- this.name = 'Grid';
18
-
19
- const grid = new GridHelper(
20
- 100,
21
- 100,
22
- GRID_CENTER_LINE_COLOR,
23
- GRID_SIDE_LINE_COLOR,
24
- );
25
- grid.material.depthTest = false;
26
- grid.layers.mask = HELPER_LAYER_MASK;
27
-
28
- this.add(grid);
29
- }
30
-
31
- public SetVisibility(visible: boolean): void {
32
- this.visible = visible;
33
- }
34
- }
@@ -1,28 +0,0 @@
1
- import { DIVEGrid } from '../Grid.ts';
2
- import { HELPER_LAYER_MASK } from '../../constant/VisibilityLayerMask.ts';
3
- import { GridHelper } from 'three';
4
-
5
- let grid: DIVEGrid;
6
-
7
- describe('dive/grid/DIVEGrid', () => {
8
- beforeEach(() => {
9
- grid = new DIVEGrid();
10
- });
11
-
12
- it('should instantiate', () => {
13
- expect(grid).toBeDefined();
14
- expect(grid.name).toBeTruthy();
15
- expect(grid.children.length).toBeGreaterThanOrEqual(1);
16
- expect((grid.children[0] as GridHelper).material.depthTest).toBe(false);
17
- expect((grid.children[0] as GridHelper).layers.mask).toBe(
18
- HELPER_LAYER_MASK,
19
- );
20
- });
21
-
22
- it('should set visibility', () => {
23
- grid.SetVisibility(false);
24
- expect(grid.visible).toBe(false);
25
- grid.SetVisibility(true);
26
- expect(grid.visible).toBe(true);
27
- });
28
- });
@@ -1,184 +0,0 @@
1
- import {
2
- BufferGeometry,
3
- Line,
4
- LineDashedMaterial,
5
- Vector3,
6
- Vector3Like,
7
- } from 'three';
8
- import { DIVENode } from '../node/Node';
9
- import { type Object3D } from 'three';
10
- import { type DIVESceneObject } from '../types';
11
-
12
- export class DIVEGroup extends DIVENode {
13
- readonly isDIVEGroup: true = true;
14
-
15
- private _members: Object3D[]; // children objects
16
-
17
- public get members(): Object3D[] {
18
- return this._members;
19
- }
20
-
21
- private _lines: Line[]; // lines to children
22
-
23
- constructor() {
24
- super();
25
-
26
- this.name = 'DIVEGroup';
27
-
28
- this._members = [];
29
-
30
- this._lines = [];
31
- }
32
-
33
- public SetPosition(position: Vector3Like): void {
34
- super.SetPosition(position);
35
- this._members.forEach((member) => {
36
- if ('isDIVENode' in member) {
37
- (member as DIVENode).onMove();
38
- }
39
- });
40
- }
41
-
42
- public SetLinesVisibility(visible: boolean, object?: Object3D): void {
43
- if (!object) {
44
- this._lines.forEach((line) => {
45
- line.visible = visible;
46
- });
47
- return;
48
- }
49
-
50
- const index = this._members.indexOf(object);
51
- if (index === -1) return;
52
-
53
- this._lines[index].visible = visible;
54
- }
55
-
56
- public attach(object: DIVESceneObject): this {
57
- // Check if the object is already a member
58
- if (this._members.includes(object)) {
59
- return this;
60
- }
61
-
62
- // create a line to the new object
63
- const line = this.createLine();
64
- this.add(line);
65
- this._lines.push(line);
66
-
67
- // attach (instead of add) object to keep its world position
68
- super.attach(object);
69
- this._members.push(object);
70
-
71
- // update line to object points
72
- this.updateLineTo(line, object);
73
- this.SetLinesVisibility(true, object);
74
-
75
- return this;
76
- }
77
-
78
- public remove(object: DIVESceneObject): this {
79
- // remove line first
80
- const index = this._members.indexOf(object);
81
- if (index === -1) return this;
82
-
83
- const line = this._lines[index];
84
- super.remove(line);
85
- this._lines.splice(index, 1);
86
-
87
- // removes object from group while keeping it's world position
88
- super.remove(object);
89
- this._members.splice(index, 1);
90
-
91
- return this;
92
- }
93
-
94
- public UpdateLineTo(object: Object3D): void {
95
- const index = this._members.indexOf(object);
96
- if (index === -1) return;
97
-
98
- this.updateLineTo(this._lines[index], object);
99
- }
100
-
101
- /**
102
- * Adds a line to this grouo as last child.
103
- */
104
- private createLine(): Line {
105
- const geo = new BufferGeometry();
106
- const mat = new LineDashedMaterial({
107
- color: 0x666666,
108
- dashSize: 0.05,
109
- gapSize: 0.025,
110
- });
111
- const line = new Line(geo, mat);
112
- line.visible = false;
113
- return line;
114
- }
115
-
116
- /**
117
- * Updates a line to the object.
118
- */
119
- private updateLineTo(line: Line, object: Object3D): void {
120
- line.geometry.setFromPoints([
121
- new Vector3(0, 0, 0),
122
- object.position.clone(),
123
- ]);
124
- line.computeLineDistances();
125
- }
126
-
127
- // public SetBoundingBoxVisibility(visible: boolean): void {
128
- // this._boxMesh.visible = visible;
129
- // }
130
-
131
- // /**
132
- // * Recalculates the position of the group based on it's bounding box.
133
- // * Children's world positions are kept.
134
- // */
135
- // private recalculatePosition(): void {
136
- // // store all children's world positions
137
- // const childrensWorldPositions: Vector3[] = this.children.map((child) => child.getWorldPosition(new Vector3()));
138
-
139
- // // calculate new center and set it as the group's position
140
- // const bbcenter = this.updateBB();
141
- // this.position.copy(bbcenter);
142
-
143
- // // set childrens's positions so their world positions are kept
144
- // this.children.forEach((child, i) => {
145
- // if (child.uuid === this._boxMesh.uuid) return;
146
- // child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
147
- // });
148
-
149
- // DIVECommunication.get(this.userData.id)?.PerformAction('UPDATE_OBJECT', { id: this.userData.id, position: this.position });
150
- // }
151
-
152
- // /**
153
- // * Updates the bounding box of the group.
154
- // * @returns {Vector3} The new center of the bounding box.
155
- // */
156
- // private updateBB(): Vector3 {
157
- // this._boundingBox.makeEmpty();
158
-
159
- // if (this.children.length === 1) {
160
- // // because we always have the box mesh as 1 child
161
- // return this.position.clone();
162
- // }
163
-
164
- // this.children.forEach((child) => {
165
- // if (child.uuid === this._boxMesh.uuid) return;
166
- // this._boundingBox.expandByObject(child);
167
- // });
168
-
169
- // return this._boundingBox.getCenter(new Vector3());
170
- // }
171
-
172
- // private updateBoxMesh(): void {
173
- // if (this.children.length === 1) {
174
- // // because we always have the box mesh as 1 child
175
- // this._boxMesh.visible = false;
176
- // return;
177
- // }
178
-
179
- // this._boxMesh.quaternion.copy(this.quaternion.clone().invert());
180
- // this._boxMesh.scale.set(1 / this.scale.x, 1 / this.scale.y, 1 / this.scale.z);
181
- // 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);
182
- // this._boxMesh.visible = true;
183
- // }
184
- }