@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
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { Euler, Object3D, Vector3 } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
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';
|
|
8
12
|
|
|
9
13
|
export class DIVERotateGizmo extends Object3D {
|
|
10
14
|
public children: DIVERadialHandle[];
|
|
@@ -16,7 +20,7 @@ export class DIVERotateGizmo extends Object3D {
|
|
|
16
20
|
constructor(controller: DIVEOrbitControls) {
|
|
17
21
|
super();
|
|
18
22
|
|
|
19
|
-
this.name =
|
|
23
|
+
this.name = 'DIVERotateGizmo';
|
|
20
24
|
|
|
21
25
|
this.children = [];
|
|
22
26
|
|
|
@@ -24,9 +28,33 @@ export class DIVERotateGizmo extends Object3D {
|
|
|
24
28
|
|
|
25
29
|
this._controller = controller;
|
|
26
30
|
|
|
27
|
-
this.add(
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
this.add(
|
|
32
|
+
new DIVERadialHandle(
|
|
33
|
+
'x',
|
|
34
|
+
1,
|
|
35
|
+
Math.PI / 2,
|
|
36
|
+
new Vector3(1, 0, 0),
|
|
37
|
+
AxesColorRed,
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
this.add(
|
|
41
|
+
new DIVERadialHandle(
|
|
42
|
+
'y',
|
|
43
|
+
1,
|
|
44
|
+
-Math.PI / 2,
|
|
45
|
+
new Vector3(0, 1, 0),
|
|
46
|
+
AxesColorGreen,
|
|
47
|
+
),
|
|
48
|
+
);
|
|
49
|
+
this.add(
|
|
50
|
+
new DIVERadialHandle(
|
|
51
|
+
'z',
|
|
52
|
+
1,
|
|
53
|
+
Math.PI / 2,
|
|
54
|
+
new Vector3(0, 0, 1),
|
|
55
|
+
AxesColorBlue,
|
|
56
|
+
),
|
|
57
|
+
);
|
|
30
58
|
}
|
|
31
59
|
|
|
32
60
|
public reset(): void {
|
|
@@ -35,7 +63,11 @@ export class DIVERotateGizmo extends Object3D {
|
|
|
35
63
|
});
|
|
36
64
|
}
|
|
37
65
|
|
|
38
|
-
private handleHighlight(
|
|
66
|
+
private handleHighlight(
|
|
67
|
+
axis: DIVEGizmoAxis,
|
|
68
|
+
value: boolean,
|
|
69
|
+
dragged: boolean,
|
|
70
|
+
): void {
|
|
39
71
|
// Set highlight state for all handles.
|
|
40
72
|
this.children.forEach((child) => {
|
|
41
73
|
if (dragged) {
|
|
@@ -77,9 +109,19 @@ export class DIVERotateGizmo extends Object3D {
|
|
|
77
109
|
if (!this.parent.parent) return;
|
|
78
110
|
if (!('onChange' in this.parent.parent)) return;
|
|
79
111
|
|
|
80
|
-
const currentVector = e.dragCurrent
|
|
81
|
-
|
|
82
|
-
|
|
112
|
+
const currentVector = e.dragCurrent
|
|
113
|
+
.clone()
|
|
114
|
+
.sub(this.parent.parent.position)
|
|
115
|
+
.normalize();
|
|
116
|
+
const startVector = e.dragStart
|
|
117
|
+
.clone()
|
|
118
|
+
.sub(this.parent.parent.position)
|
|
119
|
+
.normalize();
|
|
120
|
+
const signedAngle = DIVEMath.signedAngleTo(
|
|
121
|
+
startVector,
|
|
122
|
+
currentVector,
|
|
123
|
+
handle.forwardVector,
|
|
124
|
+
);
|
|
83
125
|
const euler = new Euler(
|
|
84
126
|
this._startRot.x + handle.forwardVector.x * signedAngle,
|
|
85
127
|
this._startRot.y + handle.forwardVector.y * signedAngle,
|
|
@@ -92,4 +134,4 @@ export class DIVERotateGizmo extends Object3D {
|
|
|
92
134
|
this._startRot = null;
|
|
93
135
|
this.handleHighlight(handle.axis, false, false);
|
|
94
136
|
}
|
|
95
|
-
}
|
|
137
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { Object3D, Vector3 } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
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';
|
|
8
12
|
|
|
9
13
|
export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
|
|
10
14
|
readonly isHoverable: true = true;
|
|
@@ -18,7 +22,7 @@ export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
|
|
|
18
22
|
constructor(controller: DIVEOrbitControls) {
|
|
19
23
|
super();
|
|
20
24
|
|
|
21
|
-
this.name =
|
|
25
|
+
this.name = 'DIVEScaleGizmo';
|
|
22
26
|
|
|
23
27
|
this.children = [];
|
|
24
28
|
|
|
@@ -26,9 +30,15 @@ export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
|
|
|
26
30
|
|
|
27
31
|
this._controller = controller;
|
|
28
32
|
|
|
29
|
-
this.add(
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
this.add(
|
|
34
|
+
new DIVEScaleHandle('x', 1, new Vector3(1, 0, 0), AxesColorRed),
|
|
35
|
+
);
|
|
36
|
+
this.add(
|
|
37
|
+
new DIVEScaleHandle('y', 1, new Vector3(0, 1, 0), AxesColorGreen),
|
|
38
|
+
);
|
|
39
|
+
this.add(
|
|
40
|
+
new DIVEScaleHandle('z', 1, new Vector3(0, 0, 1), AxesColorBlue),
|
|
41
|
+
);
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
public reset(): void {
|
|
@@ -43,7 +53,11 @@ export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
|
|
|
43
53
|
});
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
private handleHighlight(
|
|
56
|
+
private handleHighlight(
|
|
57
|
+
axis: DIVEGizmoAxis,
|
|
58
|
+
value: boolean,
|
|
59
|
+
dragged: boolean,
|
|
60
|
+
): void {
|
|
47
61
|
// Set highlight state for all handles.
|
|
48
62
|
this.children.forEach((child) => {
|
|
49
63
|
if (dragged) {
|
|
@@ -63,7 +77,11 @@ export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
|
|
|
63
77
|
|
|
64
78
|
if (!this.parent) return;
|
|
65
79
|
if (!this.parent.parent) return;
|
|
66
|
-
(this.parent.parent as DIVEGizmo).onHover(
|
|
80
|
+
(this.parent.parent as DIVEGizmo).onHover(
|
|
81
|
+
'translate',
|
|
82
|
+
handle.axis,
|
|
83
|
+
value,
|
|
84
|
+
);
|
|
67
85
|
|
|
68
86
|
this.handleHighlight(handle.axis, value, false);
|
|
69
87
|
}
|
|
@@ -87,11 +105,15 @@ export class DIVEScaleGizmo extends Object3D implements DIVEHoverable {
|
|
|
87
105
|
if (!('onChange' in this.parent.parent)) return;
|
|
88
106
|
|
|
89
107
|
const delta = e.dragDelta.clone().projectOnVector(axis.forwardVector);
|
|
90
|
-
(this.parent.parent as DIVEGizmo).onChange(
|
|
108
|
+
(this.parent.parent as DIVEGizmo).onChange(
|
|
109
|
+
undefined,
|
|
110
|
+
undefined,
|
|
111
|
+
this._startScale.clone().add(delta),
|
|
112
|
+
);
|
|
91
113
|
}
|
|
92
114
|
|
|
93
115
|
public onAxisDragEnd(handle: DIVEScaleHandle): void {
|
|
94
116
|
this._startScale = null;
|
|
95
117
|
this.handleHighlight(handle.axis, false, false);
|
|
96
118
|
}
|
|
97
|
-
}
|
|
119
|
+
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { Object3D, Vector3 } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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';
|
|
7
11
|
|
|
8
12
|
export class DIVETranslateGizmo extends Object3D {
|
|
9
13
|
private _controller: DIVEOrbitControls;
|
|
@@ -15,7 +19,7 @@ export class DIVETranslateGizmo extends Object3D {
|
|
|
15
19
|
constructor(controller: DIVEOrbitControls) {
|
|
16
20
|
super();
|
|
17
21
|
|
|
18
|
-
this.name =
|
|
22
|
+
this.name = 'DIVETranslateGizmo';
|
|
19
23
|
|
|
20
24
|
this.children = [];
|
|
21
25
|
|
|
@@ -23,9 +27,15 @@ export class DIVETranslateGizmo extends Object3D {
|
|
|
23
27
|
|
|
24
28
|
this._controller = controller;
|
|
25
29
|
|
|
26
|
-
this.add(
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
this.add(
|
|
31
|
+
new DIVEAxisHandle('x', 1, new Vector3(1, 0, 0), AxesColorRed),
|
|
32
|
+
);
|
|
33
|
+
this.add(
|
|
34
|
+
new DIVEAxisHandle('y', 1, new Vector3(0, 1, 0), AxesColorGreen),
|
|
35
|
+
);
|
|
36
|
+
this.add(
|
|
37
|
+
new DIVEAxisHandle('z', 1, new Vector3(0, 0, 1), AxesColorBlue),
|
|
38
|
+
);
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
public reset(): void {
|
|
@@ -34,7 +44,11 @@ export class DIVETranslateGizmo extends Object3D {
|
|
|
34
44
|
});
|
|
35
45
|
}
|
|
36
46
|
|
|
37
|
-
private handleHighlight(
|
|
47
|
+
private handleHighlight(
|
|
48
|
+
axis: DIVEGizmoAxis,
|
|
49
|
+
value: boolean,
|
|
50
|
+
dragged: boolean,
|
|
51
|
+
): void {
|
|
38
52
|
// Set highlight state for all handles.
|
|
39
53
|
this.children.forEach((child) => {
|
|
40
54
|
if (dragged) {
|
|
@@ -54,7 +68,11 @@ export class DIVETranslateGizmo extends Object3D {
|
|
|
54
68
|
|
|
55
69
|
if (!this.parent) return;
|
|
56
70
|
if (!this.parent.parent) return;
|
|
57
|
-
(this.parent.parent as DIVEGizmo).onHover(
|
|
71
|
+
(this.parent.parent as DIVEGizmo).onHover(
|
|
72
|
+
'translate',
|
|
73
|
+
handle.axis,
|
|
74
|
+
value,
|
|
75
|
+
);
|
|
58
76
|
|
|
59
77
|
this.handleHighlight(handle.axis, value, false);
|
|
60
78
|
}
|
|
@@ -78,11 +96,13 @@ export class DIVETranslateGizmo extends Object3D {
|
|
|
78
96
|
if (!('onChange' in this.parent.parent)) return;
|
|
79
97
|
|
|
80
98
|
const delta = e.dragDelta.clone().projectOnVector(handle.forwardVector);
|
|
81
|
-
(this.parent.parent as DIVEGizmo).onChange(
|
|
99
|
+
(this.parent.parent as DIVEGizmo).onChange(
|
|
100
|
+
this._startPos.clone().add(delta),
|
|
101
|
+
);
|
|
82
102
|
}
|
|
83
103
|
|
|
84
104
|
public onHandleDragEnd(handle: DIVEAxisHandle): void {
|
|
85
105
|
this._startPos = null;
|
|
86
106
|
this.handleHighlight(handle.axis, false, false);
|
|
87
107
|
}
|
|
88
|
-
}
|
|
108
|
+
}
|
package/src/grid/Grid.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
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';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* A basic grid for the scene.
|
|
@@ -13,7 +16,12 @@ export class DIVEGrid extends Object3D {
|
|
|
13
16
|
super();
|
|
14
17
|
this.name = 'Grid';
|
|
15
18
|
|
|
16
|
-
const grid = new GridHelper(
|
|
19
|
+
const grid = new GridHelper(
|
|
20
|
+
100,
|
|
21
|
+
100,
|
|
22
|
+
GRID_CENTER_LINE_COLOR,
|
|
23
|
+
GRID_SIDE_LINE_COLOR,
|
|
24
|
+
);
|
|
17
25
|
grid.material.depthTest = false;
|
|
18
26
|
grid.layers.mask = HELPER_LAYER_MASK;
|
|
19
27
|
|
|
@@ -23,4 +31,4 @@ export class DIVEGrid extends Object3D {
|
|
|
23
31
|
public SetVisibility(visible: boolean): void {
|
|
24
32
|
this.visible = visible;
|
|
25
33
|
}
|
|
26
|
-
}
|
|
34
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DIVEGrid } from '../Grid.ts';
|
|
2
|
-
import { HELPER_LAYER_MASK } from
|
|
2
|
+
import { HELPER_LAYER_MASK } from '../../constant/VisibilityLayerMask.ts';
|
|
3
3
|
import { GridHelper } from 'three';
|
|
4
4
|
|
|
5
5
|
let grid: DIVEGrid;
|
|
@@ -14,7 +14,9 @@ describe('dive/grid/DIVEGrid', () => {
|
|
|
14
14
|
expect(grid.name).toBeTruthy();
|
|
15
15
|
expect(grid.children.length).toBeGreaterThanOrEqual(1);
|
|
16
16
|
expect((grid.children[0] as GridHelper).material.depthTest).toBe(false);
|
|
17
|
-
expect((grid.children[0] as GridHelper).layers.mask).toBe(
|
|
17
|
+
expect((grid.children[0] as GridHelper).layers.mask).toBe(
|
|
18
|
+
HELPER_LAYER_MASK,
|
|
19
|
+
);
|
|
18
20
|
});
|
|
19
21
|
|
|
20
22
|
it('should set visibility', () => {
|
|
@@ -23,4 +25,4 @@ describe('dive/grid/DIVEGrid', () => {
|
|
|
23
25
|
grid.SetVisibility(true);
|
|
24
26
|
expect(grid.visible).toBe(true);
|
|
25
27
|
});
|
|
26
|
-
});
|
|
28
|
+
});
|
package/src/group/Group.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BufferGeometry, Line, LineDashedMaterial, Vector3 } from
|
|
2
|
-
import { DIVENode } from
|
|
3
|
-
import { type Object3D } from
|
|
4
|
-
import { type DIVESceneObject } from
|
|
1
|
+
import { BufferGeometry, Line, LineDashedMaterial, Vector3 } from 'three';
|
|
2
|
+
import { DIVENode } from '../node/Node';
|
|
3
|
+
import { type Object3D } from 'three';
|
|
4
|
+
import { type DIVESceneObject } from '../types';
|
|
5
5
|
|
|
6
6
|
export class DIVEGroup extends DIVENode {
|
|
7
7
|
readonly isDIVEGroup: true = true;
|
|
@@ -40,7 +40,6 @@ export class DIVEGroup extends DIVENode {
|
|
|
40
40
|
this.add(line);
|
|
41
41
|
this._lines.push(line);
|
|
42
42
|
|
|
43
|
-
|
|
44
43
|
// attach (insted of add) object to keep it's world position
|
|
45
44
|
super.attach(object);
|
|
46
45
|
this._members.push(object);
|
|
@@ -94,7 +93,10 @@ export class DIVEGroup extends DIVENode {
|
|
|
94
93
|
* Updates a line to the object.
|
|
95
94
|
*/
|
|
96
95
|
private updateLineTo(line: Line, object: Object3D): void {
|
|
97
|
-
line.geometry.setFromPoints([
|
|
96
|
+
line.geometry.setFromPoints([
|
|
97
|
+
new Vector3(0, 0, 0),
|
|
98
|
+
object.position.clone(),
|
|
99
|
+
]);
|
|
98
100
|
line.computeLineDistances();
|
|
99
101
|
}
|
|
100
102
|
|
|
@@ -155,4 +157,4 @@ export class DIVEGroup extends DIVENode {
|
|
|
155
157
|
// 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);
|
|
156
158
|
// this._boxMesh.visible = true;
|
|
157
159
|
// }
|
|
158
|
-
}
|
|
160
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DIVECommunication } from
|
|
2
|
-
import { DIVEGroup } from
|
|
1
|
+
import { DIVECommunication } from '../../com/Communication';
|
|
2
|
+
import { DIVEGroup } from '../Group';
|
|
3
3
|
|
|
4
4
|
jest.mock('../../com/Communication.ts', () => {
|
|
5
5
|
return {
|
|
@@ -7,13 +7,15 @@ jest.mock('../../com/Communication.ts', () => {
|
|
|
7
7
|
get: jest.fn(() => {
|
|
8
8
|
return {
|
|
9
9
|
PerformAction: jest.fn(),
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
}),
|
|
12
12
|
},
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
jest.spyOn(DIVECommunication, 'get').mockReturnValue({
|
|
16
|
+
jest.spyOn(DIVECommunication, 'get').mockReturnValue({
|
|
17
|
+
PerformAction: jest.fn(),
|
|
18
|
+
} as unknown as DIVECommunication);
|
|
17
19
|
|
|
18
20
|
let group: DIVEGroup;
|
|
19
21
|
|
|
@@ -105,4 +107,4 @@ describe('dive/group/DIVEGroup', () => {
|
|
|
105
107
|
jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
|
|
106
108
|
expect(() => group.onMove()).not.toThrow();
|
|
107
109
|
});
|
|
108
|
-
});
|
|
110
|
+
});
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import { applyMixins } from '../applyMixins.ts';
|
|
2
2
|
|
|
3
3
|
class Movable {
|
|
4
|
-
move() {
|
|
4
|
+
move() {}
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
class Selectable {
|
|
8
|
-
select() {
|
|
8
|
+
select() {}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
describe('dive/helper/applyMixins', () => {
|
|
12
12
|
it('should apply mixins', () => {
|
|
13
13
|
class Product {
|
|
14
|
-
doProductThings() {
|
|
14
|
+
doProductThings() {}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
interface Product extends Movable, Selectable {
|
|
17
|
+
interface Product extends Movable, Selectable {}
|
|
18
18
|
|
|
19
|
-
applyMixins(Product, [
|
|
19
|
+
applyMixins(Product, [
|
|
20
|
+
Movable,
|
|
21
|
+
Selectable,
|
|
22
|
+
]);
|
|
20
23
|
|
|
21
24
|
const instance = new Product();
|
|
22
25
|
expect(instance).toBeDefined();
|
|
@@ -24,4 +27,4 @@ describe('dive/helper/applyMixins', () => {
|
|
|
24
27
|
expect(instance.select).toBeDefined();
|
|
25
28
|
expect(instance.doProductThings).toBeDefined();
|
|
26
29
|
});
|
|
27
|
-
});
|
|
30
|
+
});
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
* Merges two class prototypes to a new one.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export const applyMixins = (
|
|
5
|
+
export const applyMixins = (
|
|
6
|
+
derivedCtor: { prototype: object },
|
|
7
|
+
constructors: { prototype: object }[],
|
|
8
|
+
): void => {
|
|
6
9
|
constructors.forEach((baseCtor) => {
|
|
7
10
|
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
|
|
8
11
|
Object.defineProperty(
|
|
9
12
|
derivedCtor.prototype,
|
|
10
13
|
name,
|
|
11
|
-
Object.getOwnPropertyDescriptor(baseCtor.prototype, name)
|
|
14
|
+
Object.getOwnPropertyDescriptor(baseCtor.prototype, name)!,
|
|
12
15
|
);
|
|
13
16
|
});
|
|
14
17
|
});
|
|
15
|
-
}
|
|
18
|
+
};
|
|
@@ -10,9 +10,11 @@ describe('dive/helper/findInterface', () => {
|
|
|
10
10
|
expect(findInterface(obj, 'isInterface')).toBe(undefined);
|
|
11
11
|
|
|
12
12
|
// add traverse function
|
|
13
|
-
obj.traverseAncestors = jest.fn(
|
|
14
|
-
callback(
|
|
15
|
-
|
|
13
|
+
obj.traverseAncestors = jest.fn(
|
|
14
|
+
(callback: (object: Object3D) => any) => {
|
|
15
|
+
callback(obj);
|
|
16
|
+
},
|
|
17
|
+
);
|
|
16
18
|
|
|
17
19
|
expect(findInterface(obj, 'isInterface')).toBe(undefined);
|
|
18
20
|
});
|
|
@@ -20,9 +22,11 @@ describe('dive/helper/findInterface', () => {
|
|
|
20
22
|
it('should find interface in object', () => {
|
|
21
23
|
const obj = {
|
|
22
24
|
isInterface: true,
|
|
23
|
-
traverseAncestors: jest.fn(
|
|
24
|
-
callback(
|
|
25
|
-
|
|
25
|
+
traverseAncestors: jest.fn(
|
|
26
|
+
(callback: (object: Object3D) => any) => {
|
|
27
|
+
callback(obj);
|
|
28
|
+
},
|
|
29
|
+
),
|
|
26
30
|
} as unknown as Object3D;
|
|
27
31
|
|
|
28
32
|
expect(findInterface(obj, 'isInterface')).toBe(obj);
|
|
@@ -30,24 +34,30 @@ describe('dive/helper/findInterface', () => {
|
|
|
30
34
|
|
|
31
35
|
it('should find interface in parent', () => {
|
|
32
36
|
const obj = {
|
|
33
|
-
traverseAncestors: jest.fn(
|
|
34
|
-
callback(
|
|
35
|
-
|
|
37
|
+
traverseAncestors: jest.fn(
|
|
38
|
+
(callback: (object: Object3D) => any) => {
|
|
39
|
+
callback(obj);
|
|
40
|
+
},
|
|
41
|
+
),
|
|
36
42
|
parent: {
|
|
37
43
|
isInterface: true,
|
|
38
44
|
|
|
39
|
-
traverseAncestors: jest.fn(
|
|
40
|
-
callback(
|
|
41
|
-
|
|
45
|
+
traverseAncestors: jest.fn(
|
|
46
|
+
(callback: (object: Object3D) => any) => {
|
|
47
|
+
callback(obj.parent!);
|
|
48
|
+
},
|
|
49
|
+
),
|
|
42
50
|
|
|
43
51
|
parent: {
|
|
44
|
-
traverseAncestors: jest.fn(
|
|
45
|
-
callback(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
traverseAncestors: jest.fn(
|
|
53
|
+
(callback: (object: Object3D) => any) => {
|
|
54
|
+
callback(obj.parent!);
|
|
55
|
+
},
|
|
56
|
+
),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
49
59
|
} as unknown as Object3D;
|
|
50
60
|
|
|
51
61
|
expect(findInterface(obj, 'isInterface')).toBe(obj.parent);
|
|
52
62
|
});
|
|
53
|
-
});
|
|
63
|
+
});
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { implementsInterface } from
|
|
2
|
-
import { type Object3D } from
|
|
1
|
+
import { implementsInterface } from '../isInterface/implementsInterface';
|
|
2
|
+
import { type Object3D } from 'three';
|
|
3
3
|
|
|
4
|
-
export function findInterface<T>(
|
|
4
|
+
export function findInterface<T>(
|
|
5
|
+
object: Object3D | null | undefined,
|
|
6
|
+
discriminator: string,
|
|
7
|
+
): (Object3D & T) | undefined {
|
|
5
8
|
if (!object) return undefined;
|
|
6
9
|
|
|
7
10
|
if (implementsInterface<T>(object, discriminator)) return object;
|
|
8
11
|
|
|
9
12
|
return findInterface<T>(object.parent, discriminator);
|
|
10
|
-
}
|
|
13
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getObjectDelta } from '../getObjectDelta.ts';
|
|
2
2
|
|
|
3
3
|
describe('dive/helper/getObjectDelta', () => {
|
|
4
|
-
|
|
5
4
|
// NO DELTAS
|
|
6
5
|
it('should not find any deltas with empty objects', () => {
|
|
7
6
|
const obj0 = {};
|
|
@@ -13,7 +12,16 @@ describe('dive/helper/getObjectDelta', () => {
|
|
|
13
12
|
});
|
|
14
13
|
|
|
15
14
|
it('should not find any deltas with equal references', () => {
|
|
16
|
-
const obj0 = {
|
|
15
|
+
const obj0 = {
|
|
16
|
+
test0: 'test',
|
|
17
|
+
value0: 42,
|
|
18
|
+
array0: [
|
|
19
|
+
187,
|
|
20
|
+
6,
|
|
21
|
+
9,
|
|
22
|
+
42,
|
|
23
|
+
],
|
|
24
|
+
};
|
|
17
25
|
const obj1 = obj0;
|
|
18
26
|
|
|
19
27
|
const delta = getObjectDelta(obj0, obj1);
|
|
@@ -22,7 +30,16 @@ describe('dive/helper/getObjectDelta', () => {
|
|
|
22
30
|
});
|
|
23
31
|
|
|
24
32
|
it('should not find any deltas with equal objects', () => {
|
|
25
|
-
const obj0 = {
|
|
33
|
+
const obj0 = {
|
|
34
|
+
test0: 'test',
|
|
35
|
+
value0: 42,
|
|
36
|
+
array0: [
|
|
37
|
+
187,
|
|
38
|
+
6,
|
|
39
|
+
9,
|
|
40
|
+
42,
|
|
41
|
+
],
|
|
42
|
+
};
|
|
26
43
|
const obj1 = { ...obj0 };
|
|
27
44
|
|
|
28
45
|
const delta = getObjectDelta(obj0, obj1);
|
|
@@ -95,8 +112,21 @@ describe('dive/helper/getObjectDelta', () => {
|
|
|
95
112
|
});
|
|
96
113
|
|
|
97
114
|
it('should find deltas with array value delta', () => {
|
|
98
|
-
const obj0 = {
|
|
99
|
-
|
|
115
|
+
const obj0 = {
|
|
116
|
+
array0: [
|
|
117
|
+
187,
|
|
118
|
+
6,
|
|
119
|
+
9,
|
|
120
|
+
42,
|
|
121
|
+
],
|
|
122
|
+
};
|
|
123
|
+
const obj1 = {
|
|
124
|
+
array0: [
|
|
125
|
+
187,
|
|
126
|
+
6,
|
|
127
|
+
9,
|
|
128
|
+
],
|
|
129
|
+
};
|
|
100
130
|
|
|
101
131
|
const delta = getObjectDelta(obj0, obj1);
|
|
102
132
|
|
|
@@ -105,7 +135,13 @@ describe('dive/helper/getObjectDelta', () => {
|
|
|
105
135
|
|
|
106
136
|
it('should find deltas with array type difference', () => {
|
|
107
137
|
const obj0 = { array0: 'array0' };
|
|
108
|
-
const obj1 = {
|
|
138
|
+
const obj1 = {
|
|
139
|
+
array0: [
|
|
140
|
+
187,
|
|
141
|
+
6,
|
|
142
|
+
9,
|
|
143
|
+
] as unknown as string,
|
|
144
|
+
};
|
|
109
145
|
|
|
110
146
|
const delta = getObjectDelta(obj0, obj1);
|
|
111
147
|
|
|
@@ -147,4 +183,4 @@ describe('dive/helper/getObjectDelta', () => {
|
|
|
147
183
|
|
|
148
184
|
expect(delta).toStrictEqual(obj1);
|
|
149
185
|
});
|
|
150
|
-
});
|
|
186
|
+
});
|