@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,153 +0,0 @@
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
- {
20
- readonly isHoverable: true = true;
21
- readonly isDraggable: true = true;
22
-
23
- public set debug(value: boolean) {
24
- this._colliderMesh.visible = value;
25
- }
26
-
27
- public parent: DIVETranslateGizmo | null = null;
28
-
29
- public axis: 'x' | 'y' | 'z';
30
-
31
- private _color: Color = new Color(0xff00ff);
32
- private _colorHover: Color;
33
- private _hovered: boolean;
34
- private _highlight: boolean;
35
- public get highlight(): boolean {
36
- return this._highlight;
37
- }
38
- public set highlight(highlight: boolean) {
39
- this._highlight = highlight;
40
- this._lineMaterial.color =
41
- this._highlight || this._hovered ? this._colorHover : this._color;
42
- }
43
-
44
- private _lineMaterial: MeshBasicMaterial;
45
-
46
- private _colliderMesh: Mesh;
47
-
48
- public get forwardVector(): Vector3 {
49
- return new Vector3(0, 0, 1)
50
- .applyQuaternion(this.quaternion)
51
- .normalize();
52
- }
53
-
54
- public get rightVector(): Vector3 {
55
- return new Vector3(1, 0, 0)
56
- .applyQuaternion(this.quaternion)
57
- .normalize();
58
- }
59
-
60
- public get upVector(): Vector3 {
61
- return new Vector3(0, 1, 0)
62
- .applyQuaternion(this.quaternion)
63
- .normalize();
64
- }
65
-
66
- constructor(
67
- axis: 'x' | 'y' | 'z',
68
- length: number,
69
- direction: Vector3,
70
- color: ColorRepresentation,
71
- ) {
72
- super();
73
-
74
- this.name = 'DIVEAxisHandle';
75
- this.axis = axis;
76
-
77
- this._color.set(color);
78
- this._colorHover = this._color.clone().multiplyScalar(2);
79
-
80
- this._highlight = false;
81
- this._hovered = false;
82
-
83
- // create line
84
- const lineGeo = new CylinderGeometry(0.01, 0.01, length, 13);
85
- this._lineMaterial = new MeshBasicMaterial({
86
- color: color,
87
- depthTest: false,
88
- depthWrite: false,
89
- });
90
- const lineMesh = new Mesh(lineGeo, this._lineMaterial);
91
- lineMesh.layers.mask = UI_LAYER_MASK;
92
- lineMesh.renderOrder = Infinity;
93
- lineMesh.rotateX(Math.PI / 2);
94
- lineMesh.translateY(length / 2);
95
- this.add(lineMesh);
96
-
97
- // create collider
98
- const colliderGeo = new CylinderGeometry(0.1, 0.1, length, 3);
99
- const colliderMaterial = new MeshBasicMaterial({
100
- color: 0xff00ff,
101
- transparent: true,
102
- opacity: 0.15,
103
- depthTest: false,
104
- depthWrite: false,
105
- });
106
- this._colliderMesh = new Mesh(colliderGeo, colliderMaterial);
107
- this._colliderMesh.visible = false;
108
- this._colliderMesh.layers.mask = UI_LAYER_MASK;
109
- this._colliderMesh.renderOrder = Infinity;
110
- this._colliderMesh.rotateX(Math.PI / 2);
111
- this._colliderMesh.translateY(length / 2);
112
- this.add(this._colliderMesh);
113
-
114
- this.rotateX((direction.y * -Math.PI) / 2);
115
- this.rotateY((direction.x * Math.PI) / 2);
116
- }
117
-
118
- public reset(): void {
119
- this._lineMaterial.color = this._color;
120
- }
121
-
122
- public onPointerEnter(): void {
123
- this._hovered = true;
124
- if (this.parent) {
125
- this.parent.onHandleHover(this, true);
126
- }
127
- }
128
-
129
- public onPointerLeave(): void {
130
- this._hovered = false;
131
- if (this.parent) {
132
- this.parent.onHandleHover(this, false);
133
- }
134
- }
135
-
136
- public onDragStart(): void {
137
- if (this.parent) {
138
- this.parent.onHandleDragStart(this);
139
- }
140
- }
141
-
142
- public onDrag(e: DraggableEvent): void {
143
- if (this.parent) {
144
- this.parent.onHandleDrag(this, e);
145
- }
146
- }
147
-
148
- public onDragEnd(): void {
149
- if (this.parent) {
150
- this.parent.onHandleDragEnd(this);
151
- }
152
- }
153
- }
@@ -1,149 +0,0 @@
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
- {
20
- readonly isHoverable: true = true;
21
- readonly isDraggable: true = true;
22
-
23
- public set debug(value: boolean) {
24
- this._colliderMesh.visible = value;
25
- }
26
-
27
- public parent: DIVERotateGizmo | null = null;
28
-
29
- public axis: 'x' | 'y' | 'z';
30
-
31
- private _color: Color = new Color(0xff00ff);
32
- private _colorHover: Color;
33
- private _hovered: boolean;
34
- private _highlight: boolean;
35
- public get highlight(): boolean {
36
- return this._highlight;
37
- }
38
- public set highlight(highlight: boolean) {
39
- this._highlight = highlight;
40
- this._lineMaterial.color =
41
- this._highlight || this._hovered ? this._colorHover : this._color;
42
- }
43
-
44
- private _lineMaterial: MeshBasicMaterial;
45
-
46
- private _colliderMesh: Mesh;
47
-
48
- public get forwardVector(): Vector3 {
49
- return new Vector3(0, 0, 1)
50
- .applyQuaternion(this.quaternion)
51
- .normalize();
52
- }
53
-
54
- public get rightVector(): Vector3 {
55
- return new Vector3(1, 0, 0)
56
- .applyQuaternion(this.quaternion)
57
- .normalize();
58
- }
59
-
60
- public get upVector(): Vector3 {
61
- return new Vector3(0, 1, 0)
62
- .applyQuaternion(this.quaternion)
63
- .normalize();
64
- }
65
-
66
- constructor(
67
- axis: 'x' | 'y' | 'z',
68
- radius: number,
69
- arc: number,
70
- direction: Vector3,
71
- color: ColorRepresentation,
72
- ) {
73
- super();
74
-
75
- this.name = 'DIVERadialHandle';
76
- this.axis = axis;
77
-
78
- this._color.set(color);
79
- this._colorHover = this._color.clone().multiplyScalar(2);
80
- this._hovered = false;
81
- this._highlight = false;
82
-
83
- // create line
84
- const lineGeo = new TorusGeometry(radius, 0.01, 13, 48, arc);
85
- this._lineMaterial = new MeshBasicMaterial({
86
- color: color,
87
- depthTest: false,
88
- depthWrite: false,
89
- });
90
- const lineMesh = new Mesh(lineGeo, this._lineMaterial);
91
- lineMesh.layers.mask = UI_LAYER_MASK;
92
- lineMesh.renderOrder = Infinity;
93
- this.add(lineMesh);
94
-
95
- // create collider
96
- const colliderGeo = new TorusGeometry(radius, 0.1, 3, 48, arc);
97
- const colliderMaterial = new MeshBasicMaterial({
98
- color: 0xff00ff,
99
- transparent: true,
100
- opacity: 0.15,
101
- depthTest: false,
102
- depthWrite: false,
103
- });
104
- this._colliderMesh = new Mesh(colliderGeo, colliderMaterial);
105
- this._colliderMesh.visible = false;
106
- this._colliderMesh.layers.mask = UI_LAYER_MASK;
107
- this._colliderMesh.renderOrder = Infinity;
108
-
109
- this.add(this._colliderMesh);
110
-
111
- this.lookAt(direction);
112
- }
113
-
114
- public reset(): void {
115
- this._lineMaterial.color = this._color;
116
- }
117
-
118
- public onPointerEnter(): void {
119
- this._hovered = true;
120
- if (this.parent) {
121
- this.parent.onHandleHover(this, true);
122
- }
123
- }
124
-
125
- public onPointerLeave(): void {
126
- this._hovered = false;
127
- if (this.parent) {
128
- this.parent.onHandleHover(this, false);
129
- }
130
- }
131
-
132
- public onDragStart(): void {
133
- if (this.parent) {
134
- this.parent.onHandleDragStart(this);
135
- }
136
- }
137
-
138
- public onDrag(e: DraggableEvent): void {
139
- if (this.parent) {
140
- this.parent.onHandleDrag(this, e);
141
- }
142
- }
143
-
144
- public onDragEnd(): void {
145
- if (this.parent) {
146
- this.parent.onHandleDragEnd(this);
147
- }
148
- }
149
- }
@@ -1,195 +0,0 @@
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
- {
21
- readonly isHoverable: true = true;
22
- readonly isDraggable: true = true;
23
-
24
- public set debug(value: boolean) {
25
- this._colliderMesh.visible = value;
26
- }
27
-
28
- public parent: DIVEScaleGizmo | null = null;
29
-
30
- public axis: 'x' | 'y' | 'z';
31
-
32
- private _color: Color = new Color(0xff00ff);
33
- private _colorHover: Color;
34
- private _hovered: boolean;
35
- private _highlight: boolean;
36
- public get highlight(): boolean {
37
- return this._highlight;
38
- }
39
- public set highlight(highlight: boolean) {
40
- this._highlight = highlight;
41
- this._lineMaterial.color =
42
- this._highlight || this._hovered ? this._colorHover : this._color;
43
- }
44
-
45
- private _lineMaterial: MeshBasicMaterial;
46
-
47
- private _colliderMesh: Mesh;
48
-
49
- private _box: Mesh;
50
- private _boxSize: number;
51
-
52
- public get forwardVector(): Vector3 {
53
- return new Vector3(0, 0, 1)
54
- .applyQuaternion(this.quaternion)
55
- .normalize();
56
- }
57
-
58
- public get rightVector(): Vector3 {
59
- return new Vector3(1, 0, 0)
60
- .applyQuaternion(this.quaternion)
61
- .normalize();
62
- }
63
-
64
- public get upVector(): Vector3 {
65
- return new Vector3(0, 1, 0)
66
- .applyQuaternion(this.quaternion)
67
- .normalize();
68
- }
69
-
70
- constructor(
71
- axis: 'x' | 'y' | 'z',
72
- length: number,
73
- direction: Vector3,
74
- color: ColorRepresentation,
75
- boxSize: number = 0.05,
76
- ) {
77
- super();
78
-
79
- this.name = 'DIVEScaleHandle';
80
- this.axis = axis;
81
-
82
- this._color.set(color);
83
- this._colorHover = this._color.clone().multiplyScalar(2);
84
- this._hovered = false;
85
- this._highlight = false;
86
-
87
- this._boxSize = boxSize;
88
-
89
- // create line
90
- const lineGeo = new CylinderGeometry(
91
- 0.01,
92
- 0.01,
93
- length - boxSize / 2,
94
- 13,
95
- );
96
- this._lineMaterial = new MeshBasicMaterial({
97
- color: color,
98
- depthTest: false,
99
- depthWrite: false,
100
- });
101
- const lineMesh = new Mesh(lineGeo, this._lineMaterial);
102
- lineMesh.layers.mask = UI_LAYER_MASK;
103
- lineMesh.renderOrder = Infinity;
104
- lineMesh.rotateX(Math.PI / 2);
105
- lineMesh.translateY(length / 2 - boxSize / 4);
106
- this.add(lineMesh);
107
-
108
- // create box
109
- this._box = new Mesh(
110
- new BoxGeometry(boxSize, boxSize, boxSize),
111
- this._lineMaterial,
112
- );
113
- this._box.layers.mask = UI_LAYER_MASK;
114
- this._box.renderOrder = Infinity;
115
- this._box.rotateX(Math.PI / 2);
116
- this._box.translateY(length - boxSize / 2);
117
- this._box.rotateZ((direction.x * Math.PI) / 2);
118
- this._box.rotateX((direction.z * Math.PI) / 2);
119
- this.add(this._box);
120
-
121
- // create collider
122
- const colliderGeo = new CylinderGeometry(
123
- 0.1,
124
- 0.1,
125
- length + boxSize / 2,
126
- 3,
127
- );
128
- const colliderMaterial = new MeshBasicMaterial({
129
- color: 0xff00ff,
130
- transparent: true,
131
- opacity: 0.15,
132
- depthTest: false,
133
- depthWrite: false,
134
- });
135
- this._colliderMesh = new Mesh(colliderGeo, colliderMaterial);
136
- this._colliderMesh.visible = false;
137
- this._colliderMesh.layers.mask = UI_LAYER_MASK;
138
- this._colliderMesh.renderOrder = Infinity;
139
- this._colliderMesh.rotateX(Math.PI / 2);
140
- this._colliderMesh.translateY(length / 2);
141
- this.add(this._colliderMesh);
142
-
143
- this.rotateX((direction.y * -Math.PI) / 2);
144
- this.rotateY((direction.x * Math.PI) / 2);
145
- }
146
-
147
- public reset(): void {
148
- this._lineMaterial.color = this._color;
149
- }
150
-
151
- public update(scale: Vector3): void {
152
- this._box.scale.copy(
153
- new Vector3(1, 1, 1) // identity scale ...
154
- .sub(this.forwardVector) // subtracted the forward vector ...
155
- .add(
156
- // to then add ...
157
- scale
158
- .clone() // the scale ...
159
- .multiply(this.forwardVector), // that is scaled by the forward vector again to get the forward vector as the only direction
160
- ),
161
- );
162
- }
163
-
164
- public onPointerEnter(): void {
165
- this._hovered = true;
166
- if (this.parent) {
167
- this.parent.onHoverAxis(this, true);
168
- }
169
- }
170
-
171
- public onPointerLeave(): void {
172
- this._hovered = false;
173
- if (this.parent) {
174
- this.parent.onHoverAxis(this, false);
175
- }
176
- }
177
-
178
- public onDragStart(): void {
179
- if (this.parent) {
180
- this.parent.onAxisDragStart(this);
181
- }
182
- }
183
-
184
- public onDrag(e: DraggableEvent): void {
185
- if (this.parent) {
186
- this.parent.onAxisDrag(this, e);
187
- }
188
- }
189
-
190
- public onDragEnd(): void {
191
- if (this.parent) {
192
- this.parent.onAxisDragEnd(this);
193
- }
194
- }
195
- }
@@ -1,84 +0,0 @@
1
- import { Mesh, MeshBasicMaterial, Object3D, PlaneGeometry } from 'three';
2
- import { UI_LAYER_MASK } from '../../constant/VisibilityLayerMask';
3
- import { DIVEGizmoAxis, DIVEGizmoMode } from '../Gizmo';
4
-
5
- export class DIVEGizmoPlane extends Object3D {
6
- private _meshX: Mesh;
7
- public get XPlane(): Mesh {
8
- return this._meshX;
9
- }
10
- private _meshY: Mesh;
11
- public get YPlane(): Mesh {
12
- return this._meshY;
13
- }
14
- private _meshZ: Mesh;
15
- public get ZPlane(): Mesh {
16
- return this._meshZ;
17
- }
18
-
19
- constructor() {
20
- super();
21
- this.name = 'DIVEGizmoPlane';
22
-
23
- const material = new MeshBasicMaterial({
24
- transparent: true,
25
- opacity: 0.15,
26
- depthTest: false,
27
- depthWrite: false,
28
- side: 2,
29
- });
30
-
31
- const geoX = new PlaneGeometry(100, 100, 2, 2);
32
- const matX = material.clone();
33
- matX.color.set(0xff0000);
34
- this._meshX = new Mesh(geoX, matX);
35
- this._meshX.layers.mask = UI_LAYER_MASK;
36
- this._meshX.rotateY(Math.PI / 2);
37
-
38
- const geoY = new PlaneGeometry(100, 100, 2, 2);
39
- const matY = material.clone();
40
- matY.color.set(0x00ff00);
41
- this._meshY = new Mesh(geoY, matY);
42
- this._meshY.layers.mask = UI_LAYER_MASK;
43
- this._meshY.rotateX(-Math.PI / 2);
44
-
45
- const geoZ = new PlaneGeometry(100, 100, 2, 2);
46
- const matZ = material.clone();
47
- matZ.color.set(0x0000ff);
48
- this._meshZ = new Mesh(geoZ, matZ);
49
- this._meshZ.layers.mask = UI_LAYER_MASK;
50
- }
51
-
52
- public assemble(mode: DIVEGizmoMode, axis: DIVEGizmoAxis): void {
53
- this.clear();
54
-
55
- if (mode === 'translate' || mode === 'scale') {
56
- switch (axis) {
57
- case 'x':
58
- this.add(this._meshY);
59
- this.add(this._meshZ);
60
- break;
61
- case 'y':
62
- this.add(this._meshX);
63
- this.add(this._meshZ);
64
- break;
65
- case 'z':
66
- this.add(this._meshX);
67
- this.add(this._meshY);
68
- break;
69
- }
70
- } else if (mode === 'rotate') {
71
- switch (axis) {
72
- case 'x':
73
- this.add(this._meshX);
74
- break;
75
- case 'y':
76
- this.add(this._meshY);
77
- break;
78
- case 'z':
79
- this.add(this._meshZ);
80
- break;
81
- }
82
- }
83
- }
84
- }