@shopware-ag/dive 1.19.1-beta.0 → 1.19.1-beta.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 (188) hide show
  1. package/build/dive.cjs +362 -199
  2. package/build/dive.cjs.map +1 -1
  3. package/build/dive.js +330 -167
  4. package/build/dive.js.map +1 -1
  5. package/build/dive.mjs +10803 -8714
  6. package/build/dive.mjs.map +1 -1
  7. package/build/src/converter/Converter.d.ts +3 -12
  8. package/build/src/dive.d.ts +1 -0
  9. package/build/src/exporter/Exporter.d.ts +20 -2
  10. package/build/src/loader/Loader.d.ts +0 -4
  11. package/build/src/types/error/index.d.ts +12 -0
  12. package/build/src/types/file/FileTypes.d.ts +17 -0
  13. package/build/src/types/file/index.d.ts +1 -0
  14. package/build/src/types/index.d.ts +5 -8
  15. package/package.json +2 -3
  16. package/build/src/types/ExporterOptions.d.ts +0 -15
  17. package/build/src/types/FileTypes.d.ts +0 -27
  18. package/src/__test__/DIVE.test.ts +0 -274
  19. package/src/animation/AnimationSystem.ts +0 -34
  20. package/src/animation/__test__/AnimationSystem.test.ts +0 -40
  21. package/src/ar/AR.ts +0 -101
  22. package/src/ar/__test__/AR.test.ts +0 -276
  23. package/src/ar/arquicklook/ARQuickLook.ts +0 -53
  24. package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +0 -144
  25. package/src/ar/sceneviewer/SceneViewer.ts +0 -119
  26. package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -190
  27. package/src/ar/webxr/WebXR.ts +0 -177
  28. package/src/ar/webxr/controller/WebXRController.ts +0 -340
  29. package/src/ar/webxr/crosshair/WebXRCrosshair.ts +0 -35
  30. package/src/ar/webxr/origin/WebXROrigin.ts +0 -192
  31. package/src/ar/webxr/overlay/Overlay.ts +0 -50
  32. package/src/ar/webxr/raycaster/WebXRRaycaster.ts +0 -131
  33. package/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts +0 -102
  34. package/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts +0 -49
  35. package/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts +0 -356
  36. package/src/axiscamera/AxisCamera.ts +0 -108
  37. package/src/axiscamera/__test__/AxisCamera.test.ts +0 -150
  38. package/src/camera/PerspectiveCamera.ts +0 -63
  39. package/src/camera/__test__/PerspectiveCamera.test.ts +0 -36
  40. package/src/com/Communication.ts +0 -806
  41. package/src/com/__test__/Communication.test.ts +0 -1030
  42. package/src/com/actions/camera/computeencompassingview.ts +0 -10
  43. package/src/com/actions/camera/getcameratransform.ts +0 -10
  44. package/src/com/actions/camera/movecamera.ts +0 -18
  45. package/src/com/actions/camera/resetcamera.ts +0 -5
  46. package/src/com/actions/camera/setcameralayer.ts +0 -5
  47. package/src/com/actions/camera/setcameratransform.ts +0 -10
  48. package/src/com/actions/camera/zoomcamera.ts +0 -5
  49. package/src/com/actions/index.ts +0 -61
  50. package/src/com/actions/media/generatemedia.ts +0 -18
  51. package/src/com/actions/object/addobject.ts +0 -7
  52. package/src/com/actions/object/deleteobject.ts +0 -7
  53. package/src/com/actions/object/deselectobject.ts +0 -7
  54. package/src/com/actions/object/getallobjects.ts +0 -7
  55. package/src/com/actions/object/getobjects.ts +0 -7
  56. package/src/com/actions/object/model/dropit.ts +0 -5
  57. package/src/com/actions/object/model/modelloaded.ts +0 -5
  58. package/src/com/actions/object/model/placeonfloor.ts +0 -5
  59. package/src/com/actions/object/selectobject.ts +0 -7
  60. package/src/com/actions/object/setparent.ts +0 -10
  61. package/src/com/actions/object/updateobject.ts +0 -7
  62. package/src/com/actions/renderer/startrender.ts +0 -5
  63. package/src/com/actions/scene/exportscene.ts +0 -7
  64. package/src/com/actions/scene/getallscenedata.ts +0 -7
  65. package/src/com/actions/scene/launchar.ts +0 -7
  66. package/src/com/actions/scene/setbackground.ts +0 -5
  67. package/src/com/actions/scene/updatescene.ts +0 -11
  68. package/src/com/actions/toolbox/select/setgizmomode.ts +0 -5
  69. package/src/com/actions/toolbox/transform/setgizmoscalelinked.ts +0 -5
  70. package/src/com/actions/toolbox/transform/setgizmovisible.ts +0 -5
  71. package/src/com/actions/toolbox/usetool.ts +0 -7
  72. package/src/com/types/COMBaseEntity.ts +0 -9
  73. package/src/com/types/COMEntity.ts +0 -7
  74. package/src/com/types/COMEntityType.ts +0 -1
  75. package/src/com/types/COMGeometry.ts +0 -8
  76. package/src/com/types/COMGeometryType.ts +0 -9
  77. package/src/com/types/COMGroup.ts +0 -9
  78. package/src/com/types/COMLight.ts +0 -11
  79. package/src/com/types/COMMaterial.ts +0 -12
  80. package/src/com/types/COMModel.ts +0 -12
  81. package/src/com/types/COMPov.ts +0 -8
  82. package/src/com/types/COMPrimitive.ts +0 -12
  83. package/src/com/types/index.ts +0 -23
  84. package/src/constant/AxisHelperColors.ts +0 -7
  85. package/src/constant/GridColors.ts +0 -2
  86. package/src/constant/VisibilityLayerMask.ts +0 -5
  87. package/src/controls/OrbitControls.ts +0 -211
  88. package/src/controls/__test__/OrbitControls.test.ts +0 -256
  89. package/src/converter/Converter.ts +0 -117
  90. package/src/dive.ts +0 -363
  91. package/src/events/EventExecutor.ts +0 -35
  92. package/src/exporter/Exporter.ts +0 -75
  93. package/src/gizmo/Gizmo.ts +0 -144
  94. package/src/gizmo/handles/AxisHandle.ts +0 -153
  95. package/src/gizmo/handles/RadialHandle.ts +0 -149
  96. package/src/gizmo/handles/ScaleHandle.ts +0 -195
  97. package/src/gizmo/plane/GizmoPlane.ts +0 -84
  98. package/src/gizmo/rotate/RotateGizmo.ts +0 -143
  99. package/src/gizmo/scale/ScaleGizmo.ts +0 -125
  100. package/src/gizmo/translate/TranslateGizmo.ts +0 -114
  101. package/src/grid/Grid.ts +0 -34
  102. package/src/grid/__test__/Grid.test.ts +0 -28
  103. package/src/group/Group.ts +0 -184
  104. package/src/group/__test__/Group.test.ts +0 -212
  105. package/src/helper/applyMixins/__test__/applyMixins.test.ts +0 -30
  106. package/src/helper/applyMixins/applyMixins.ts +0 -70
  107. package/src/helper/findInterface/__test__/findInterface.test.ts +0 -63
  108. package/src/helper/findInterface/findInterface.ts +0 -13
  109. package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +0 -40
  110. package/src/helper/findSceneRecursive/findSceneRecursive.ts +0 -16
  111. package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +0 -186
  112. package/src/helper/getObjectDelta/getObjectDelta.ts +0 -105
  113. package/src/helper/isInterface/__test__/implementsInterface.test.ts +0 -19
  114. package/src/helper/isInterface/implementsInterface.ts +0 -9
  115. package/src/info/Info.ts +0 -178
  116. package/src/info/__test__/Info.test.ts +0 -346
  117. package/src/interface/Draggable.ts +0 -14
  118. package/src/interface/Hoverable.ts +0 -14
  119. package/src/interface/Movable.ts +0 -12
  120. package/src/interface/Rotatable.ts +0 -10
  121. package/src/interface/Scalable.ts +0 -10
  122. package/src/interface/Selectable.ts +0 -11
  123. package/src/io/IO.ts +0 -62
  124. package/src/io/__test__/IO.test.ts +0 -116
  125. package/src/io/gltf/GLTFIO.ts +0 -56
  126. package/src/io/gltf/__test__/GLTFIO.test.ts +0 -108
  127. package/src/light/AmbientLight.ts +0 -39
  128. package/src/light/PointLight.ts +0 -115
  129. package/src/light/SceneLight.ts +0 -63
  130. package/src/light/__test__/AmbientLight.test.ts +0 -29
  131. package/src/light/__test__/PointLight.test.ts +0 -74
  132. package/src/light/__test__/SceneLight.test.ts +0 -47
  133. package/src/loader/Loader.ts +0 -48
  134. package/src/math/__test__/DIVEMath.test.ts +0 -12
  135. package/src/math/ceil/__test__/ceilExp.test.ts +0 -12
  136. package/src/math/ceil/ceilExp.ts +0 -6
  137. package/src/math/degToRad/__test__/degToRad.test.ts +0 -172
  138. package/src/math/degToRad/degToRad.ts +0 -5
  139. package/src/math/floor/__test__/floorExp.test.ts +0 -14
  140. package/src/math/floor/floorExp.ts +0 -6
  141. package/src/math/helper/__test__/shift.test.ts +0 -12
  142. package/src/math/helper/shift.ts +0 -4
  143. package/src/math/index.ts +0 -28
  144. package/src/math/radToDeg/__test__/radToDeg.test.ts +0 -155
  145. package/src/math/radToDeg/radToDeg.ts +0 -5
  146. package/src/math/round/__test__/roundExp.test.ts +0 -14
  147. package/src/math/round/roundExp.ts +0 -10
  148. package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +0 -20
  149. package/src/math/signedAngleTo/signedAngleTo.ts +0 -20
  150. package/src/math/toFixed/__test__/toFixedExp.test.ts +0 -14
  151. package/src/math/toFixed/toFixedExp.ts +0 -9
  152. package/src/math/truncate/__test__/truncateExp.test.ts +0 -14
  153. package/src/math/truncate/truncateExp.ts +0 -9
  154. package/src/mediacreator/MediaCreator.ts +0 -75
  155. package/src/mediacreator/__test__/MediaCreator.test.ts +0 -155
  156. package/src/model/Model.ts +0 -190
  157. package/src/model/__test__/Model.test.ts +0 -215
  158. package/src/module/Module.ts +0 -45
  159. package/src/module/__test__/Module.test.ts +0 -54
  160. package/src/node/Node.ts +0 -100
  161. package/src/node/__test__/Node.test.ts +0 -120
  162. package/src/primitive/Primitive.ts +0 -299
  163. package/src/primitive/__test__/Primitive.test.ts +0 -281
  164. package/src/primitive/floor/Floor.ts +0 -45
  165. package/src/primitive/floor/__test__/Floor.test.ts +0 -24
  166. package/src/renderer/Renderer.ts +0 -215
  167. package/src/renderer/__test__/Renderer.test.ts +0 -228
  168. package/src/scene/Scene.ts +0 -106
  169. package/src/scene/__test__/Scene.test.ts +0 -124
  170. package/src/scene/root/Root.ts +0 -426
  171. package/src/scene/root/__test__/Root.test.ts +0 -903
  172. package/src/scene/xrroot/XRRoot.ts +0 -56
  173. package/src/scene/xrroot/xrlightroot/XRLightRoot.ts +0 -80
  174. package/src/toolbox/BaseTool.ts +0 -319
  175. package/src/toolbox/Toolbox.ts +0 -129
  176. package/src/toolbox/__test__/BaseTool.test.ts +0 -627
  177. package/src/toolbox/__test__/Toolbox.test.ts +0 -143
  178. package/src/toolbox/select/SelectTool.ts +0 -92
  179. package/src/toolbox/select/__test__/SelectTool.test.ts +0 -237
  180. package/src/toolbox/transform/TransformTool.ts +0 -166
  181. package/src/toolbox/transform/__test__/TransformTool.test.ts +0 -147
  182. package/src/types/ExporterOptions.ts +0 -14
  183. package/src/types/FileTypes.ts +0 -37
  184. package/src/types/SceneData.ts +0 -26
  185. package/src/types/SceneObjects.ts +0 -14
  186. package/src/types/SceneType.ts +0 -14
  187. package/src/types/index.ts +0 -31
  188. package/src/types/info/index.ts +0 -76
@@ -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
- }