@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.
- package/README.md +271 -40
- package/build/dive.cjs +575 -159
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +83 -57
- package/build/dive.d.ts +83 -57
- package/build/dive.js +614 -164
- package/build/dive.js.map +1 -1
- package/package.json +72 -60
- package/src/__test__/DIVE.test.ts +35 -31
- package/src/animation/AnimationSystem.ts +4 -4
- package/src/animation/__test__/AnimationSystem.test.ts +3 -3
- package/src/axiscamera/AxisCamera.ts +31 -11
- package/src/axiscamera/__test__/AxisCamera.test.ts +18 -10
- package/src/camera/PerspectiveCamera.ts +28 -13
- package/src/camera/__test__/PerspectiveCamera.test.ts +2 -2
- package/src/com/Communication.ts +282 -100
- package/src/com/__test__/Communication.test.ts +207 -141
- package/src/com/actions/camera/computeencompassingview.ts +8 -7
- package/src/com/actions/camera/getcameratransform.ts +8 -7
- package/src/com/actions/camera/movecamera.ts +16 -13
- package/src/com/actions/camera/resetcamera.ts +4 -3
- package/src/com/actions/camera/setcameralayer.ts +4 -3
- package/src/com/actions/camera/setcameratransform.ts +8 -7
- package/src/com/actions/camera/zoomcamera.ts +4 -3
- package/src/com/actions/index.ts +54 -54
- package/src/com/actions/media/generatemedia.ts +17 -13
- package/src/com/actions/object/addobject.ts +5 -4
- package/src/com/actions/object/deleteobject.ts +5 -4
- package/src/com/actions/object/deselectobject.ts +5 -4
- package/src/com/actions/object/getallobjects.ts +5 -4
- package/src/com/actions/object/getobjects.ts +5 -4
- package/src/com/actions/object/model/dropit.ts +4 -3
- package/src/com/actions/object/model/modelloaded.ts +4 -3
- package/src/com/actions/object/model/placeonfloor.ts +4 -3
- package/src/com/actions/object/selectobject.ts +5 -4
- package/src/com/actions/object/setparent.ts +8 -7
- package/src/com/actions/object/updateobject.ts +5 -4
- package/src/com/actions/scene/exportscene.ts +5 -4
- package/src/com/actions/scene/getallscenedata.ts +24 -18
- package/src/com/actions/scene/setbackground.ts +4 -3
- package/src/com/actions/scene/updatescene.ts +10 -9
- package/src/com/actions/toolbox/select/setgizmomode.ts +4 -3
- package/src/com/actions/toolbox/transform/setgizmovisible.ts +4 -3
- package/src/com/actions/toolbox/usetool.ts +5 -4
- package/src/com/types/COMBaseEntity.ts +2 -2
- package/src/com/types/COMEntity.ts +6 -6
- package/src/com/types/COMEntityType.ts +1 -1
- package/src/com/types/COMGeometry.ts +2 -2
- package/src/com/types/COMGroup.ts +3 -3
- package/src/com/types/COMLight.ts +3 -3
- package/src/com/types/COMMaterial.ts +2 -2
- package/src/com/types/COMModel.ts +4 -4
- package/src/com/types/COMPov.ts +3 -3
- package/src/com/types/COMPrimitive.ts +5 -5
- package/src/com/types/index.ts +10 -10
- package/src/constant/AxisHelperColors.ts +1 -1
- package/src/constant/GridColors.ts +1 -1
- package/src/controls/OrbitControls.ts +62 -29
- package/src/controls/__test__/OrbitControls.test.ts +133 -39
- package/src/dive.ts +82 -36
- package/src/gizmo/Gizmo.ts +21 -13
- package/src/gizmo/handles/AxisHandle.ts +40 -17
- package/src/gizmo/handles/RadialHandle.ts +39 -15
- package/src/gizmo/handles/ScaleHandle.ts +62 -25
- package/src/gizmo/plane/GizmoPlane.ts +5 -6
- package/src/gizmo/rotate/RotateGizmo.ts +58 -16
- package/src/gizmo/scale/ScaleGizmo.ts +37 -15
- package/src/gizmo/translate/TranslateGizmo.ts +34 -14
- package/src/grid/Grid.ts +13 -5
- package/src/grid/__test__/Grid.test.ts +5 -3
- package/src/group/Group.ts +9 -7
- package/src/group/__test__/Group.test.ts +8 -6
- package/src/helper/applyMixins/__test__/applyMixins.test.ts +9 -6
- package/src/helper/applyMixins/applyMixins.ts +6 -3
- package/src/helper/findInterface/__test__/findInterface.test.ts +28 -18
- package/src/helper/findInterface/findInterface.ts +7 -4
- package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +1 -1
- package/src/helper/findSceneRecursive/findSceneRecursive.ts +1 -1
- package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +43 -7
- package/src/helper/getObjectDelta/getObjectDelta.ts +13 -9
- package/src/helper/isInterface/__test__/implementsInterface.test.ts +1 -1
- package/src/helper/isInterface/implementsInterface.ts +6 -3
- package/src/info/Info.ts +20 -16
- package/src/info/__test__/Info.test.ts +67 -36
- package/src/interface/Draggable.ts +2 -2
- package/src/interface/Hoverable.ts +2 -2
- package/src/interface/Movable.ts +1 -1
- package/src/interface/Rotatable.ts +1 -1
- package/src/interface/Scalable.ts +1 -1
- package/src/io/IO.ts +21 -43
- package/src/io/__test__/IO.test.ts +16 -62
- package/src/io/gltf/GLTFIO.ts +34 -31
- package/src/io/gltf/__test__/GLTFIO.test.ts +88 -78
- package/src/light/PointLight.ts +42 -9
- package/src/light/SceneLight.ts +5 -5
- package/src/light/__test__/AmbientLight.test.ts +5 -4
- package/src/light/__test__/PointLight.test.ts +14 -10
- package/src/light/__test__/SceneLight.test.ts +19 -13
- package/src/loadingmanager/LoadingManager.ts +11 -6
- package/src/loadingmanager/__test__/LoadingManager.test.ts +14 -9
- package/src/math/__test__/DIVEMath.test.ts +1 -1
- package/src/math/ceil/__test__/ceilExp.test.ts +1 -1
- package/src/math/ceil/ceilExp.ts +2 -2
- package/src/math/floor/__test__/floorExp.test.ts +1 -1
- package/src/math/floor/floorExp.ts +2 -2
- package/src/math/helper/__test__/shift.test.ts +1 -1
- package/src/math/helper/shift.ts +1 -1
- package/src/math/index.ts +7 -7
- package/src/math/round/__test__/roundExp.test.ts +1 -1
- package/src/math/round/roundExp.ts +6 -3
- package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +10 -4
- package/src/math/signedAngleTo/signedAngleTo.ts +11 -4
- package/src/math/toFixed/__test__/toFixedExp.test.ts +9 -9
- package/src/math/toFixed/toFixedExp.ts +6 -3
- package/src/math/truncate/__test__/truncateExp.test.ts +1 -1
- package/src/math/truncate/truncateExp.ts +6 -3
- package/src/mediacreator/MediaCreator.ts +20 -10
- package/src/mediacreator/__test__/MediaCreator.test.ts +27 -12
- package/src/model/Model.ts +35 -7
- package/src/model/__test__/Model.test.ts +71 -44
- package/src/node/Node.ts +34 -12
- package/src/node/__test__/Node.test.ts +17 -13
- package/src/primitive/Primitive.ts +78 -13
- package/src/primitive/__test__/Primitive.test.ts +49 -38
- package/src/primitive/floor/Floor.ts +14 -3
- package/src/primitive/floor/__test__/Floor.test.ts +10 -4
- package/src/renderer/Renderer.ts +46 -15
- package/src/renderer/__test__/Renderer.test.ts +74 -24
- package/src/scene/Scene.ts +9 -3
- package/src/scene/__test__/Scene.test.ts +2 -2
- package/src/scene/root/Root.ts +142 -75
- package/src/scene/root/__test__/Root.test.ts +439 -111
- package/src/toolbox/BaseTool.ts +69 -33
- package/src/toolbox/Toolbox.ts +37 -17
- package/src/toolbox/__test__/BaseTool.test.ts +324 -160
- package/src/toolbox/__test__/Toolbox.test.ts +31 -14
- package/src/toolbox/select/SelectTool.ts +24 -19
- package/src/toolbox/select/__test__/SelectTool.test.ts +95 -59
- package/src/toolbox/transform/TransformTool.ts +40 -17
- package/src/toolbox/transform/__test__/TransformTool.test.ts +22 -15
- package/src/types/SceneObjects.ts +8 -8
- package/src/types/SceneType.ts +3 -3
- package/src/types/index.ts +3 -6
package/src/dive.ts
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
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(
|
|
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)
|
|
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)
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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)
|
|
168
|
-
|
|
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(
|
|
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 = {
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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)
|
|
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
|
-
|
package/src/gizmo/Gizmo.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Euler, Object3D, Vector3 } from
|
|
2
|
-
import { DIVERotateGizmo } from
|
|
3
|
-
import { DIVETranslateGizmo } from
|
|
4
|
-
import DIVEOrbitControls from
|
|
5
|
-
import { DIVEScaleGizmo } from
|
|
6
|
-
import { DIVEGizmoPlane as DIVEGizmoPlane } from
|
|
7
|
-
import { DIVESelectable } from
|
|
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 =
|
|
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 =
|
|
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:
|
|
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(
|
|
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(
|
|
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 {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 =
|
|
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)
|
|
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)
|
|
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)
|
|
55
|
+
return new Vector3(0, 1, 0)
|
|
56
|
+
.applyQuaternion(this.quaternion)
|
|
57
|
+
.normalize();
|
|
40
58
|
}
|
|
41
59
|
|
|
42
|
-
constructor(
|
|
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 =
|
|
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 {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 =
|
|
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)
|
|
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)
|
|
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)
|
|
55
|
+
return new Vector3(0, 1, 0)
|
|
56
|
+
.applyQuaternion(this.quaternion)
|
|
57
|
+
.normalize();
|
|
40
58
|
}
|
|
41
59
|
|
|
42
|
-
constructor(
|
|
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 =
|
|
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 {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 =
|
|
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)
|
|
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)
|
|
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)
|
|
59
|
+
return new Vector3(0, 1, 0)
|
|
60
|
+
.applyQuaternion(this.quaternion)
|
|
61
|
+
.normalize();
|
|
43
62
|
}
|
|
44
63
|
|
|
45
|
-
constructor(
|
|
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 =
|
|
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(
|
|
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(
|
|
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(
|
|
115
|
-
|
|
116
|
-
|
|
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
|
|
2
|
-
import { UI_LAYER_MASK } from
|
|
3
|
-
import { DIVEGizmoAxis, DIVEGizmoMode } from
|
|
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 =
|
|
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
|
+
}
|