@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.
- package/build/dive.cjs +388 -220
- package/build/dive.cjs.map +1 -1
- package/build/dive.js +395 -21946
- package/build/dive.js.map +1 -1
- package/build/dive.mjs +28206 -0
- package/build/dive.mjs.map +1 -0
- package/build/src/ar/AR.d.ts +37 -14
- package/build/src/ar/arquicklook/ARQuickLook.d.ts +5 -6
- package/build/src/ar/sceneviewer/SceneViewer.d.ts +42 -6
- package/build/src/com/actions/scene/launchar.d.ts +5 -2
- package/build/src/converter/Converter.d.ts +21 -0
- package/build/src/dive.d.ts +3 -2
- package/build/src/exporter/Exporter.d.ts +11 -0
- package/build/src/helper/applyMixins/applyMixins.d.ts +22 -6
- package/build/src/info/Info.d.ts +37 -13
- package/build/src/interface/Movable.d.ts +5 -5
- package/build/src/interface/Selectable.d.ts +4 -4
- package/build/src/loader/Loader.d.ts +11 -0
- package/build/src/model/Model.d.ts +2 -2
- package/build/src/node/Node.d.ts +3 -3
- package/build/src/scene/root/Root.d.ts +1 -1
- package/build/src/types/ExporterOptions.d.ts +15 -0
- package/build/src/types/FileTypes.d.ts +27 -0
- package/build/src/types/index.d.ts +4 -0
- package/build/src/types/info/index.d.ts +66 -0
- package/package.json +17 -3
- package/build/src/exporters/usdz/USDZExporter.d.ts +0 -15
- package/build/src/loadingmanager/LoadingManager.d.ts +0 -14
- package/src/__test__/DIVE.test.ts +0 -274
- package/src/animation/AnimationSystem.ts +0 -34
- package/src/animation/__test__/AnimationSystem.test.ts +0 -40
- package/src/ar/AR.ts +0 -98
- package/src/ar/__test__/AR.test.ts +0 -187
- package/src/ar/arquicklook/ARQuickLook.ts +0 -93
- package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +0 -93
- package/src/ar/sceneviewer/SceneViewer.ts +0 -74
- package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -93
- package/src/ar/webxr/WebXR.ts +0 -176
- package/src/ar/webxr/controller/WebXRController.ts +0 -340
- package/src/ar/webxr/crosshair/WebXRCrosshair.ts +0 -35
- package/src/ar/webxr/origin/WebXROrigin.ts +0 -192
- package/src/ar/webxr/overlay/Overlay.ts +0 -50
- package/src/ar/webxr/raycaster/WebXRRaycaster.ts +0 -131
- package/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts +0 -102
- package/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts +0 -49
- package/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts +0 -356
- package/src/axiscamera/AxisCamera.ts +0 -108
- package/src/axiscamera/__test__/AxisCamera.test.ts +0 -150
- package/src/camera/PerspectiveCamera.ts +0 -63
- package/src/camera/__test__/PerspectiveCamera.test.ts +0 -36
- package/src/com/Communication.ts +0 -808
- package/src/com/__test__/Communication.test.ts +0 -1024
- package/src/com/actions/camera/computeencompassingview.ts +0 -10
- package/src/com/actions/camera/getcameratransform.ts +0 -10
- package/src/com/actions/camera/movecamera.ts +0 -18
- package/src/com/actions/camera/resetcamera.ts +0 -5
- package/src/com/actions/camera/setcameralayer.ts +0 -5
- package/src/com/actions/camera/setcameratransform.ts +0 -10
- package/src/com/actions/camera/zoomcamera.ts +0 -5
- package/src/com/actions/index.ts +0 -61
- package/src/com/actions/media/generatemedia.ts +0 -18
- package/src/com/actions/object/addobject.ts +0 -7
- package/src/com/actions/object/deleteobject.ts +0 -7
- package/src/com/actions/object/deselectobject.ts +0 -7
- package/src/com/actions/object/getallobjects.ts +0 -7
- package/src/com/actions/object/getobjects.ts +0 -7
- package/src/com/actions/object/model/dropit.ts +0 -5
- package/src/com/actions/object/model/modelloaded.ts +0 -5
- package/src/com/actions/object/model/placeonfloor.ts +0 -5
- package/src/com/actions/object/selectobject.ts +0 -7
- package/src/com/actions/object/setparent.ts +0 -10
- package/src/com/actions/object/updateobject.ts +0 -7
- package/src/com/actions/renderer/startrender.ts +0 -5
- package/src/com/actions/scene/exportscene.ts +0 -7
- package/src/com/actions/scene/getallscenedata.ts +0 -7
- package/src/com/actions/scene/launchar.ts +0 -7
- package/src/com/actions/scene/setbackground.ts +0 -5
- package/src/com/actions/scene/updatescene.ts +0 -11
- package/src/com/actions/toolbox/select/setgizmomode.ts +0 -5
- package/src/com/actions/toolbox/transform/setgizmoscalelinked.ts +0 -5
- package/src/com/actions/toolbox/transform/setgizmovisible.ts +0 -5
- package/src/com/actions/toolbox/usetool.ts +0 -7
- package/src/com/types/COMBaseEntity.ts +0 -9
- package/src/com/types/COMEntity.ts +0 -7
- package/src/com/types/COMEntityType.ts +0 -1
- package/src/com/types/COMGeometry.ts +0 -8
- package/src/com/types/COMGeometryType.ts +0 -9
- package/src/com/types/COMGroup.ts +0 -9
- package/src/com/types/COMLight.ts +0 -11
- package/src/com/types/COMMaterial.ts +0 -12
- package/src/com/types/COMModel.ts +0 -12
- package/src/com/types/COMPov.ts +0 -8
- package/src/com/types/COMPrimitive.ts +0 -12
- package/src/com/types/index.ts +0 -23
- package/src/constant/AxisHelperColors.ts +0 -7
- package/src/constant/GridColors.ts +0 -2
- package/src/constant/VisibilityLayerMask.ts +0 -5
- package/src/controls/OrbitControls.ts +0 -211
- package/src/controls/__test__/OrbitControls.test.ts +0 -256
- package/src/dive.ts +0 -363
- package/src/events/EventExecutor.ts +0 -35
- package/src/exporters/usdz/USDZExporter.ts +0 -21
- package/src/exporters/usdz/__test__/USDZExporter.test.ts +0 -57
- package/src/gizmo/Gizmo.ts +0 -144
- package/src/gizmo/handles/AxisHandle.ts +0 -153
- package/src/gizmo/handles/RadialHandle.ts +0 -149
- package/src/gizmo/handles/ScaleHandle.ts +0 -195
- package/src/gizmo/plane/GizmoPlane.ts +0 -84
- package/src/gizmo/rotate/RotateGizmo.ts +0 -143
- package/src/gizmo/scale/ScaleGizmo.ts +0 -125
- package/src/gizmo/translate/TranslateGizmo.ts +0 -114
- package/src/grid/Grid.ts +0 -34
- package/src/grid/__test__/Grid.test.ts +0 -28
- package/src/group/Group.ts +0 -184
- package/src/group/__test__/Group.test.ts +0 -212
- package/src/helper/applyMixins/__test__/applyMixins.test.ts +0 -30
- package/src/helper/applyMixins/applyMixins.ts +0 -18
- package/src/helper/findInterface/__test__/findInterface.test.ts +0 -63
- package/src/helper/findInterface/findInterface.ts +0 -13
- package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +0 -40
- package/src/helper/findSceneRecursive/findSceneRecursive.ts +0 -16
- package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +0 -186
- package/src/helper/getObjectDelta/getObjectDelta.ts +0 -105
- package/src/helper/isInterface/__test__/implementsInterface.test.ts +0 -19
- package/src/helper/isInterface/implementsInterface.ts +0 -9
- package/src/info/Info.ts +0 -154
- package/src/info/__test__/Info.test.ts +0 -338
- package/src/interface/Draggable.ts +0 -14
- package/src/interface/Hoverable.ts +0 -14
- package/src/interface/Movable.ts +0 -12
- package/src/interface/Rotatable.ts +0 -10
- package/src/interface/Scalable.ts +0 -10
- package/src/interface/Selectable.ts +0 -11
- package/src/io/IO.ts +0 -62
- package/src/io/__test__/IO.test.ts +0 -116
- package/src/io/gltf/GLTFIO.ts +0 -56
- package/src/io/gltf/__test__/GLTFIO.test.ts +0 -108
- package/src/light/AmbientLight.ts +0 -39
- package/src/light/PointLight.ts +0 -115
- package/src/light/SceneLight.ts +0 -63
- package/src/light/__test__/AmbientLight.test.ts +0 -29
- package/src/light/__test__/PointLight.test.ts +0 -74
- package/src/light/__test__/SceneLight.test.ts +0 -47
- package/src/loadingmanager/LoadingManager.ts +0 -50
- package/src/loadingmanager/__test__/LoadingManager.test.ts +0 -27
- package/src/math/__test__/DIVEMath.test.ts +0 -12
- package/src/math/ceil/__test__/ceilExp.test.ts +0 -12
- package/src/math/ceil/ceilExp.ts +0 -6
- package/src/math/degToRad/__test__/degToRad.test.ts +0 -172
- package/src/math/degToRad/degToRad.ts +0 -5
- package/src/math/floor/__test__/floorExp.test.ts +0 -14
- package/src/math/floor/floorExp.ts +0 -6
- package/src/math/helper/__test__/shift.test.ts +0 -12
- package/src/math/helper/shift.ts +0 -4
- package/src/math/index.ts +0 -28
- package/src/math/radToDeg/__test__/radToDeg.test.ts +0 -155
- package/src/math/radToDeg/radToDeg.ts +0 -5
- package/src/math/round/__test__/roundExp.test.ts +0 -14
- package/src/math/round/roundExp.ts +0 -10
- package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +0 -20
- package/src/math/signedAngleTo/signedAngleTo.ts +0 -20
- package/src/math/toFixed/__test__/toFixedExp.test.ts +0 -14
- package/src/math/toFixed/toFixedExp.ts +0 -9
- package/src/math/truncate/__test__/truncateExp.test.ts +0 -14
- package/src/math/truncate/truncateExp.ts +0 -9
- package/src/mediacreator/MediaCreator.ts +0 -75
- package/src/mediacreator/__test__/MediaCreator.test.ts +0 -155
- package/src/model/Model.ts +0 -185
- package/src/model/__test__/Model.test.ts +0 -222
- package/src/module/Module.ts +0 -45
- package/src/module/__test__/Module.test.ts +0 -54
- package/src/node/Node.ts +0 -98
- package/src/node/__test__/Node.test.ts +0 -120
- package/src/primitive/Primitive.ts +0 -299
- package/src/primitive/__test__/Primitive.test.ts +0 -281
- package/src/primitive/floor/Floor.ts +0 -45
- package/src/primitive/floor/__test__/Floor.test.ts +0 -24
- package/src/renderer/Renderer.ts +0 -215
- package/src/renderer/__test__/Renderer.test.ts +0 -228
- package/src/scene/Scene.ts +0 -106
- package/src/scene/__test__/Scene.test.ts +0 -124
- package/src/scene/root/Root.ts +0 -426
- package/src/scene/root/__test__/Root.test.ts +0 -903
- package/src/scene/xrroot/XRRoot.ts +0 -56
- package/src/scene/xrroot/xrlightroot/XRLightRoot.ts +0 -80
- package/src/toolbox/BaseTool.ts +0 -319
- package/src/toolbox/Toolbox.ts +0 -129
- package/src/toolbox/__test__/BaseTool.test.ts +0 -627
- package/src/toolbox/__test__/Toolbox.test.ts +0 -143
- package/src/toolbox/select/SelectTool.ts +0 -92
- package/src/toolbox/select/__test__/SelectTool.test.ts +0 -237
- package/src/toolbox/transform/TransformTool.ts +0 -166
- package/src/toolbox/transform/__test__/TransformTool.test.ts +0 -147
- package/src/types/SceneData.ts +0 -26
- package/src/types/SceneObjects.ts +0 -14
- package/src/types/SceneType.ts +0 -14
- package/src/types/index.ts +0 -5
|
@@ -1,1024 +0,0 @@
|
|
|
1
|
-
import { DIVECommunication } from '../Communication';
|
|
2
|
-
import '../types';
|
|
3
|
-
import { type Actions } from '../actions';
|
|
4
|
-
import '../actions/camera/movecamera';
|
|
5
|
-
import '../actions/camera/resetcamera';
|
|
6
|
-
import '../actions/camera/setcameralayer';
|
|
7
|
-
import '../actions/camera/setcameratransform';
|
|
8
|
-
import '../actions/camera/zoomcamera';
|
|
9
|
-
import '../actions/media/generatemedia';
|
|
10
|
-
import '../actions/object/addobject';
|
|
11
|
-
import '../actions/object/deleteobject';
|
|
12
|
-
import '../actions/object/getallobjects';
|
|
13
|
-
import '../actions/object/getobjects';
|
|
14
|
-
import '../actions/object/selectobject';
|
|
15
|
-
import '../actions/object/updateobject';
|
|
16
|
-
import '../actions/object/model/modelloaded';
|
|
17
|
-
import '../actions/object/model/placeonfloor';
|
|
18
|
-
import '../actions/scene/getallscenedata';
|
|
19
|
-
import '../actions/scene/setbackground';
|
|
20
|
-
import '../actions/scene/updatescene';
|
|
21
|
-
import '../actions/toolbox/select/setgizmomode';
|
|
22
|
-
import '../actions/toolbox/transform/setgizmovisible';
|
|
23
|
-
import '../actions/camera/getcameratransform';
|
|
24
|
-
import { type DIVEScene } from '../../scene/Scene';
|
|
25
|
-
import type DIVEToolbox from '../../toolbox/Toolbox';
|
|
26
|
-
import type DIVEOrbitControls from '../../controls/OrbitControls';
|
|
27
|
-
import { type DIVERenderer } from '../../renderer/Renderer';
|
|
28
|
-
import {
|
|
29
|
-
type COMGroup,
|
|
30
|
-
type COMEntity,
|
|
31
|
-
type COMEntityType,
|
|
32
|
-
type COMLight,
|
|
33
|
-
type COMModel,
|
|
34
|
-
type COMPov,
|
|
35
|
-
} from '../types';
|
|
36
|
-
import { type DIVESceneObject } from '../../types';
|
|
37
|
-
|
|
38
|
-
const mockModule: Record<string, any> = {
|
|
39
|
-
get: jest.fn().mockReturnValue(Promise.resolve({})),
|
|
40
|
-
};
|
|
41
|
-
jest.mock('../../module/Module', () => {
|
|
42
|
-
return {
|
|
43
|
-
DIVEModule: jest.fn().mockImplementation(() => {
|
|
44
|
-
return mockModule;
|
|
45
|
-
}),
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
jest.mock('../../mediacreator/MediaCreator', () => {
|
|
50
|
-
return {
|
|
51
|
-
DIVEMediaCreator: jest.fn().mockImplementation(() => {
|
|
52
|
-
return {
|
|
53
|
-
GenerateMedia: jest.fn(),
|
|
54
|
-
};
|
|
55
|
-
}),
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
jest.mock('../../io/IO', () => {
|
|
60
|
-
return {
|
|
61
|
-
DIVEIO: jest.fn().mockImplementation(() => {
|
|
62
|
-
return {
|
|
63
|
-
Import: jest.fn(),
|
|
64
|
-
Export: jest.fn(),
|
|
65
|
-
};
|
|
66
|
-
}),
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
jest.mock('../../ar/AR', () => {
|
|
71
|
-
return {
|
|
72
|
-
DIVEAR: jest.fn().mockImplementation(() => {
|
|
73
|
-
return {
|
|
74
|
-
Launch: jest.fn(),
|
|
75
|
-
};
|
|
76
|
-
}),
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
jest.mock('../../toolbox/select/SelectTool', () => {
|
|
81
|
-
return {
|
|
82
|
-
isSelectTool: jest.fn().mockReturnValue(true),
|
|
83
|
-
DIVESelectTool: jest.fn().mockImplementation(() => {
|
|
84
|
-
return {
|
|
85
|
-
AttachGizmo: jest.fn(),
|
|
86
|
-
DetachGizmo: jest.fn(),
|
|
87
|
-
};
|
|
88
|
-
}),
|
|
89
|
-
};
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const mockRenderer = {
|
|
93
|
-
render: jest.fn(),
|
|
94
|
-
OnResize: jest.fn(),
|
|
95
|
-
StartRenderer: jest.fn(),
|
|
96
|
-
} as unknown as DIVERenderer;
|
|
97
|
-
|
|
98
|
-
const mockScene = {
|
|
99
|
-
SetBackground: jest.fn(),
|
|
100
|
-
AddSceneObject: jest.fn(),
|
|
101
|
-
UpdateSceneObject: jest.fn(),
|
|
102
|
-
DeleteSceneObject: jest.fn(),
|
|
103
|
-
PlaceOnFloor: jest.fn(),
|
|
104
|
-
GetSceneObject: jest.fn().mockReturnValue({
|
|
105
|
-
attach: jest.fn(),
|
|
106
|
-
DropIt: jest.fn(),
|
|
107
|
-
}),
|
|
108
|
-
background: {
|
|
109
|
-
getHexString: jest.fn().mockReturnValue('ffffff'),
|
|
110
|
-
},
|
|
111
|
-
Root: {
|
|
112
|
-
attach: jest.fn(),
|
|
113
|
-
},
|
|
114
|
-
Floor: {
|
|
115
|
-
isFloor: true,
|
|
116
|
-
visible: true,
|
|
117
|
-
material: {
|
|
118
|
-
color: {
|
|
119
|
-
getHexString: jest.fn().mockReturnValue('ffffff'),
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
SetVisibility: jest.fn(),
|
|
123
|
-
SetColor: jest.fn(),
|
|
124
|
-
},
|
|
125
|
-
Grid: {
|
|
126
|
-
SetVisibility: jest.fn(),
|
|
127
|
-
},
|
|
128
|
-
ComputeSceneBB: jest.fn(),
|
|
129
|
-
} as unknown as DIVEScene;
|
|
130
|
-
|
|
131
|
-
const mockController = {
|
|
132
|
-
enableDamping: true,
|
|
133
|
-
dampingFactor: 0.25,
|
|
134
|
-
enableZoom: true,
|
|
135
|
-
enablePan: true,
|
|
136
|
-
minPolarAngle: 0,
|
|
137
|
-
maxPolarAngle: Math.PI,
|
|
138
|
-
minDistance: 0,
|
|
139
|
-
maxDistance: Infinity,
|
|
140
|
-
rotateSpeed: 0.5,
|
|
141
|
-
panSpeed: 0.5,
|
|
142
|
-
zoomSpeed: 0.5,
|
|
143
|
-
keyPanSpeed: 0.5,
|
|
144
|
-
screenSpacePanning: true,
|
|
145
|
-
autoRotate: false,
|
|
146
|
-
autoRotateSpeed: 2.0,
|
|
147
|
-
enableKeys: true,
|
|
148
|
-
keys: {
|
|
149
|
-
LEFT: 37,
|
|
150
|
-
UP: 38,
|
|
151
|
-
RIGHT: 39,
|
|
152
|
-
BOTTOM: 40,
|
|
153
|
-
},
|
|
154
|
-
mouseButtons: {
|
|
155
|
-
LEFT: 0,
|
|
156
|
-
MIDDLE: 1,
|
|
157
|
-
RIGHT: 2,
|
|
158
|
-
},
|
|
159
|
-
target: {
|
|
160
|
-
x: 4,
|
|
161
|
-
y: 5,
|
|
162
|
-
z: 6,
|
|
163
|
-
set: jest.fn(),
|
|
164
|
-
clone: jest.fn().mockReturnValue({ x: 4, y: 5, z: 6 }),
|
|
165
|
-
copy: jest.fn(),
|
|
166
|
-
},
|
|
167
|
-
update: jest.fn(),
|
|
168
|
-
dispose: jest.fn(),
|
|
169
|
-
ZoomIn: jest.fn(),
|
|
170
|
-
ZoomOut: jest.fn(),
|
|
171
|
-
object: {
|
|
172
|
-
position: {
|
|
173
|
-
x: 1,
|
|
174
|
-
y: 2,
|
|
175
|
-
z: 3,
|
|
176
|
-
clone: jest.fn().mockReturnValue({ x: 1, y: 2, z: 3 }),
|
|
177
|
-
copy: jest.fn(),
|
|
178
|
-
},
|
|
179
|
-
quaternion: {
|
|
180
|
-
x: 1,
|
|
181
|
-
y: 2,
|
|
182
|
-
z: 3,
|
|
183
|
-
w: 4,
|
|
184
|
-
clone: jest.fn().mockReturnValue({ x: 1, y: 2, z: 3, w: 4 }),
|
|
185
|
-
copy: jest.fn(),
|
|
186
|
-
},
|
|
187
|
-
SetCameraLayer: jest.fn(),
|
|
188
|
-
OnResize: jest.fn(),
|
|
189
|
-
layers: {
|
|
190
|
-
mask: 1,
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
MoveTo: jest.fn(),
|
|
194
|
-
RevertLast: jest.fn(),
|
|
195
|
-
ComputeEncompassingView: jest.fn().mockReturnValue({
|
|
196
|
-
position: { x: 1, y: 2, z: 3 },
|
|
197
|
-
target: { x: 4, y: 5, z: 6 },
|
|
198
|
-
}),
|
|
199
|
-
} as unknown as DIVEOrbitControls;
|
|
200
|
-
|
|
201
|
-
const mockToolBox = {
|
|
202
|
-
UseTool: jest.fn(),
|
|
203
|
-
GetActiveTool: jest.fn().mockReturnValue({
|
|
204
|
-
AttachGizmo: jest.fn(),
|
|
205
|
-
DetachGizmo: jest.fn(),
|
|
206
|
-
}),
|
|
207
|
-
SetGizmoMode: jest.fn(),
|
|
208
|
-
SetGizmoVisibility: jest.fn(),
|
|
209
|
-
SetGizmoScaleLinked: jest.fn(),
|
|
210
|
-
} as unknown as DIVEToolbox;
|
|
211
|
-
|
|
212
|
-
let testCom: DIVECommunication;
|
|
213
|
-
|
|
214
|
-
describe('dive/communication/DIVECommunication', () => {
|
|
215
|
-
beforeEach(() => {
|
|
216
|
-
jest.clearAllMocks();
|
|
217
|
-
testCom = new DIVECommunication(
|
|
218
|
-
mockRenderer,
|
|
219
|
-
mockScene,
|
|
220
|
-
mockController,
|
|
221
|
-
mockToolBox,
|
|
222
|
-
);
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
afterEach(() => {
|
|
226
|
-
testCom.DestroyInstance();
|
|
227
|
-
jest.clearAllMocks();
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it('should instantiate', () => {
|
|
231
|
-
expect(testCom).toBeDefined();
|
|
232
|
-
expect(DIVECommunication['__instances']).toHaveLength(1);
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it('should get instance', () => {
|
|
236
|
-
expect(testCom).toBeDefined();
|
|
237
|
-
expect(DIVECommunication.get(testCom.id)).toBeDefined();
|
|
238
|
-
|
|
239
|
-
testCom.PerformAction('ADD_OBJECT', {
|
|
240
|
-
id: 'someID',
|
|
241
|
-
} as COMModel);
|
|
242
|
-
expect(DIVECommunication.get('someID')).toBeDefined();
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('should destroy instance', () => {
|
|
246
|
-
expect(testCom).toBeDefined();
|
|
247
|
-
testCom.DestroyInstance();
|
|
248
|
-
expect(DIVECommunication['__instances']).toBeDefined();
|
|
249
|
-
expect(DIVECommunication['__instances']).toHaveLength(0);
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it('should subscribe, listen and unsubscribe from action', () => {
|
|
253
|
-
const listener = jest.fn();
|
|
254
|
-
const unsub = testCom.Subscribe('GET_ALL_OBJECTS', listener);
|
|
255
|
-
expect(unsub).toBeDefined();
|
|
256
|
-
expect(unsub).toBeInstanceOf(Function);
|
|
257
|
-
const objects0 = testCom.PerformAction('GET_ALL_OBJECTS', new Map());
|
|
258
|
-
expect(objects0).toBeDefined();
|
|
259
|
-
expect(objects0.size).toBeDefined();
|
|
260
|
-
expect(objects0.size).toBe(0);
|
|
261
|
-
unsub();
|
|
262
|
-
testCom.PerformAction('GET_ALL_OBJECTS', new Map());
|
|
263
|
-
expect(listener).toHaveBeenCalledTimes(1);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
it('should not unsubscribe twice', () => {
|
|
267
|
-
const unsub = testCom.Subscribe('GET_ALL_OBJECTS', () => {});
|
|
268
|
-
expect(unsub()).toBe(true);
|
|
269
|
-
expect(unsub()).toBe(false);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it('should not unsubscribe if listener does not exist anymore', () => {
|
|
273
|
-
const unsub = testCom.Subscribe('GET_ALL_OBJECTS', () => {});
|
|
274
|
-
testCom['listeners'].clear();
|
|
275
|
-
expect(unsub()).toBe(false);
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
it('should tigger onChange callback', () => {
|
|
279
|
-
const payload = {
|
|
280
|
-
name: 'name',
|
|
281
|
-
entityType: 'light',
|
|
282
|
-
id: 'ambient00',
|
|
283
|
-
type: 'ambient',
|
|
284
|
-
intensity: 0.5,
|
|
285
|
-
color: 'white',
|
|
286
|
-
} as COMLight;
|
|
287
|
-
expect(() =>
|
|
288
|
-
testCom.PerformAction('ADD_OBJECT', payload),
|
|
289
|
-
).not.toThrow();
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it('should perform action START_RENDER', () => {
|
|
293
|
-
const success = testCom.PerformAction('START_RENDER');
|
|
294
|
-
expect(mockRenderer.StartRenderer).toHaveBeenCalledTimes(1);
|
|
295
|
-
expect(success).toBe(true);
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
it('should perform action ADD_OBJECT', () => {
|
|
299
|
-
const payload = {
|
|
300
|
-
entityType: 'light',
|
|
301
|
-
id: 'ambient00',
|
|
302
|
-
type: 'ambient',
|
|
303
|
-
intensity: 0.5,
|
|
304
|
-
color: 'white',
|
|
305
|
-
} as COMLight;
|
|
306
|
-
const success = testCom.PerformAction('ADD_OBJECT', payload);
|
|
307
|
-
expect(mockScene.AddSceneObject).toHaveBeenCalledTimes(1);
|
|
308
|
-
expect(success).toBe(true);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
it('should not perform action ADD_OBJECT with same object', () => {
|
|
312
|
-
const payload = {
|
|
313
|
-
entityType: 'light',
|
|
314
|
-
id: 'ambient00',
|
|
315
|
-
type: 'ambient',
|
|
316
|
-
intensity: 0.5,
|
|
317
|
-
color: 'white',
|
|
318
|
-
} as COMLight;
|
|
319
|
-
expect(testCom.PerformAction('ADD_OBJECT', payload)).toBe(true);
|
|
320
|
-
expect(testCom.PerformAction('ADD_OBJECT', payload)).toBe(false);
|
|
321
|
-
expect(mockScene.AddSceneObject).toHaveBeenCalledTimes(1);
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it('should perform action UPDATE_OBJECT with existing oject', () => {
|
|
325
|
-
const payload = {
|
|
326
|
-
entityType: 'light',
|
|
327
|
-
id: 'ambient00',
|
|
328
|
-
type: 'ambient',
|
|
329
|
-
intensity: 0.5,
|
|
330
|
-
color: 'white',
|
|
331
|
-
} as COMLight;
|
|
332
|
-
|
|
333
|
-
testCom.PerformAction('ADD_OBJECT', payload);
|
|
334
|
-
|
|
335
|
-
const successUpdate = testCom.PerformAction('UPDATE_OBJECT', payload);
|
|
336
|
-
expect(mockScene.UpdateSceneObject).toHaveBeenCalledTimes(1);
|
|
337
|
-
expect(successUpdate).toBe(true);
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
it('should perform action UPDATE_OBJECT without existing oject', () => {
|
|
341
|
-
const payload = {
|
|
342
|
-
entityType: 'light',
|
|
343
|
-
id: 'ambient00',
|
|
344
|
-
type: 'ambient',
|
|
345
|
-
intensity: 0.5,
|
|
346
|
-
color: 'white',
|
|
347
|
-
} as COMLight;
|
|
348
|
-
const successUpdate = testCom.PerformAction('UPDATE_OBJECT', payload);
|
|
349
|
-
expect(mockScene.UpdateSceneObject).toHaveBeenCalledTimes(0);
|
|
350
|
-
expect(successUpdate).toBe(false);
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
it('should perform action DELETE_OBJECT with existing object', () => {
|
|
354
|
-
const payload = {
|
|
355
|
-
entityType: 'group',
|
|
356
|
-
id: 'group00',
|
|
357
|
-
} as COMGroup;
|
|
358
|
-
|
|
359
|
-
testCom.PerformAction('ADD_OBJECT', payload);
|
|
360
|
-
|
|
361
|
-
// additionally add a child to the group
|
|
362
|
-
testCom.PerformAction('ADD_OBJECT', {
|
|
363
|
-
entityType: 'light',
|
|
364
|
-
id: 'ambient00',
|
|
365
|
-
type: 'ambient',
|
|
366
|
-
intensity: 0.5,
|
|
367
|
-
color: 'white',
|
|
368
|
-
parentId: 'group00',
|
|
369
|
-
} as COMLight);
|
|
370
|
-
|
|
371
|
-
// and one child that has NO parent
|
|
372
|
-
testCom.PerformAction('ADD_OBJECT', {
|
|
373
|
-
entityType: 'light',
|
|
374
|
-
id: 'ambient01',
|
|
375
|
-
type: 'ambient',
|
|
376
|
-
intensity: 0.5,
|
|
377
|
-
color: 'white',
|
|
378
|
-
} as COMLight);
|
|
379
|
-
|
|
380
|
-
// and one child that has A DIFFERENT parent
|
|
381
|
-
testCom.PerformAction('ADD_OBJECT', {
|
|
382
|
-
entityType: 'light',
|
|
383
|
-
id: 'ambient02',
|
|
384
|
-
type: 'ambient',
|
|
385
|
-
intensity: 0.5,
|
|
386
|
-
color: 'white',
|
|
387
|
-
parentId: 'group01',
|
|
388
|
-
} as COMLight);
|
|
389
|
-
|
|
390
|
-
const successDelete = testCom.PerformAction('DELETE_OBJECT', payload);
|
|
391
|
-
expect(mockScene.DeleteSceneObject).toHaveBeenCalledTimes(1);
|
|
392
|
-
expect(successDelete).toBe(true);
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
it('should perform action DELETE_OBJECT without existing object', () => {
|
|
396
|
-
const payload = {
|
|
397
|
-
entityType: 'light',
|
|
398
|
-
id: 'ambient00',
|
|
399
|
-
type: 'ambient',
|
|
400
|
-
intensity: 0.5,
|
|
401
|
-
color: 'white',
|
|
402
|
-
} as COMLight;
|
|
403
|
-
const successDelete = testCom.PerformAction('DELETE_OBJECT', payload);
|
|
404
|
-
expect(mockScene.DeleteSceneObject).toHaveBeenCalledTimes(0);
|
|
405
|
-
expect(successDelete).toBe(false);
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
it('should perform action SET_BACKGROUND', () => {
|
|
409
|
-
const payload = {
|
|
410
|
-
color: 'white',
|
|
411
|
-
};
|
|
412
|
-
const successSet = testCom.PerformAction('SET_BACKGROUND', payload);
|
|
413
|
-
expect(mockScene.SetBackground).toHaveBeenCalledTimes(1);
|
|
414
|
-
expect(successSet).toBe(true);
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
it('should perform action DROP_IT with existing model', () => {
|
|
418
|
-
const payload = {
|
|
419
|
-
entityType: 'model',
|
|
420
|
-
id: 'model',
|
|
421
|
-
position: { x: 0, y: 0, z: 0 },
|
|
422
|
-
rotation: { x: 0, y: 0, z: 0 },
|
|
423
|
-
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
424
|
-
|
|
425
|
-
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
426
|
-
} as COMModel;
|
|
427
|
-
|
|
428
|
-
testCom.PerformAction('ADD_OBJECT', payload);
|
|
429
|
-
|
|
430
|
-
const placeSpy = jest.spyOn(mockScene, 'GetSceneObject');
|
|
431
|
-
|
|
432
|
-
const successPlace = testCom.PerformAction('DROP_IT', payload);
|
|
433
|
-
expect(successPlace).toBe(true);
|
|
434
|
-
expect(placeSpy).toHaveBeenCalledTimes(1);
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
it('should perform action DROP_IT without existing model', () => {
|
|
438
|
-
const payload = {
|
|
439
|
-
entityType: 'model',
|
|
440
|
-
id: 'model',
|
|
441
|
-
position: { x: 0, y: 0, z: 0 },
|
|
442
|
-
rotation: { x: 0, y: 0, z: 0 },
|
|
443
|
-
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
444
|
-
|
|
445
|
-
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
446
|
-
};
|
|
447
|
-
const placeSpy = jest.spyOn(mockScene, 'GetSceneObject');
|
|
448
|
-
|
|
449
|
-
const successPlace = testCom.PerformAction('DROP_IT', payload);
|
|
450
|
-
expect(successPlace).toBe(false);
|
|
451
|
-
expect(placeSpy).toHaveBeenCalledTimes(0);
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
it('should perform action PLACE_ON_FLOOR with existing model', () => {
|
|
455
|
-
const payload = {
|
|
456
|
-
entityType: 'model',
|
|
457
|
-
id: 'model',
|
|
458
|
-
position: { x: 0, y: 0, z: 0 },
|
|
459
|
-
rotation: { x: 0, y: 0, z: 0 },
|
|
460
|
-
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
461
|
-
|
|
462
|
-
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
463
|
-
} as COMModel;
|
|
464
|
-
|
|
465
|
-
testCom.PerformAction('ADD_OBJECT', payload);
|
|
466
|
-
|
|
467
|
-
const placeSpy = jest.spyOn(mockScene, 'PlaceOnFloor');
|
|
468
|
-
|
|
469
|
-
const successPlace = testCom.PerformAction('PLACE_ON_FLOOR', payload);
|
|
470
|
-
expect(successPlace).toBe(true);
|
|
471
|
-
expect(placeSpy).toHaveBeenCalledTimes(1);
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
it('should perform action PLACE_ON_FLOOR without existing model', () => {
|
|
475
|
-
const payload = {
|
|
476
|
-
entityType: 'model' as COMEntityType,
|
|
477
|
-
id: 'model',
|
|
478
|
-
position: { x: 0, y: 0, z: 0 },
|
|
479
|
-
rotation: { x: 0, y: 0, z: 0 },
|
|
480
|
-
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
481
|
-
|
|
482
|
-
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
483
|
-
};
|
|
484
|
-
const placeSpy = jest.spyOn(mockScene, 'PlaceOnFloor');
|
|
485
|
-
|
|
486
|
-
const successPlace = testCom.PerformAction('PLACE_ON_FLOOR', payload);
|
|
487
|
-
expect(successPlace).toBe(false);
|
|
488
|
-
expect(placeSpy).toHaveBeenCalledTimes(0);
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
it('should perform action GET_ALL_OBJECTS', () => {
|
|
492
|
-
const payload = {
|
|
493
|
-
entityType: 'model',
|
|
494
|
-
id: 'model',
|
|
495
|
-
position: { x: 0, y: 0, z: 0 },
|
|
496
|
-
rotation: { x: 0, y: 0, z: 0 },
|
|
497
|
-
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
498
|
-
|
|
499
|
-
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
500
|
-
} as COMModel;
|
|
501
|
-
|
|
502
|
-
const objects0 = testCom.PerformAction('GET_ALL_OBJECTS', new Map());
|
|
503
|
-
expect(objects0).toBeDefined();
|
|
504
|
-
expect(objects0.size).toBeDefined();
|
|
505
|
-
expect(objects0.size).toBe(0);
|
|
506
|
-
|
|
507
|
-
testCom.PerformAction('ADD_OBJECT', payload);
|
|
508
|
-
|
|
509
|
-
const objects1 = testCom.PerformAction('GET_ALL_OBJECTS', new Map());
|
|
510
|
-
expect(objects1).toBeDefined();
|
|
511
|
-
expect(objects1.size).toBeDefined();
|
|
512
|
-
expect(objects1.size).toBe(1);
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
it('should perform action MOVE_CAMERA', () => {
|
|
516
|
-
const payload = {
|
|
517
|
-
position: { x: 0, y: 0, z: 0 },
|
|
518
|
-
target: { x: 0, y: 0, z: 0 },
|
|
519
|
-
duration: 1000,
|
|
520
|
-
locked: true,
|
|
521
|
-
};
|
|
522
|
-
const successSet = testCom.PerformAction('MOVE_CAMERA', payload);
|
|
523
|
-
const moveToSpy = jest.spyOn(mockController, 'MoveTo');
|
|
524
|
-
expect(moveToSpy).toHaveBeenCalledTimes(1);
|
|
525
|
-
expect(successSet).toBe(true);
|
|
526
|
-
|
|
527
|
-
moveToSpy.mockClear();
|
|
528
|
-
testCom.PerformAction('ADD_OBJECT', {
|
|
529
|
-
entityType: 'pov',
|
|
530
|
-
id: 'pov',
|
|
531
|
-
position: { x: 0, y: 0, z: 0 },
|
|
532
|
-
target: { x: 0, y: 0, z: 0 },
|
|
533
|
-
} as COMPov);
|
|
534
|
-
|
|
535
|
-
const payloadId = {
|
|
536
|
-
id: 'pov',
|
|
537
|
-
locked: true,
|
|
538
|
-
duration: 1000,
|
|
539
|
-
};
|
|
540
|
-
const successSet1 = testCom.PerformAction('MOVE_CAMERA', payloadId);
|
|
541
|
-
expect(moveToSpy).toHaveBeenCalledTimes(1);
|
|
542
|
-
expect(successSet1).toBe(true);
|
|
543
|
-
});
|
|
544
|
-
|
|
545
|
-
it('should perform action RESET_CAMERA', () => {
|
|
546
|
-
const payload = {
|
|
547
|
-
duration: 1000,
|
|
548
|
-
};
|
|
549
|
-
const successSet = testCom.PerformAction('RESET_CAMERA', payload);
|
|
550
|
-
expect(mockController.RevertLast).toHaveBeenCalledTimes(1);
|
|
551
|
-
expect(successSet).toBe(true);
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
it('should perform action COMPUTE_ENCOMPASSING_VIEW', () => {
|
|
555
|
-
const payload = {};
|
|
556
|
-
const transform = testCom.PerformAction(
|
|
557
|
-
'COMPUTE_ENCOMPASSING_VIEW',
|
|
558
|
-
payload,
|
|
559
|
-
);
|
|
560
|
-
expect(transform).toStrictEqual({
|
|
561
|
-
position: { x: 1, y: 2, z: 3 },
|
|
562
|
-
target: { x: 4, y: 5, z: 6 },
|
|
563
|
-
});
|
|
564
|
-
expect(payload).toStrictEqual({
|
|
565
|
-
position: { x: 1, y: 2, z: 3 },
|
|
566
|
-
target: { x: 4, y: 5, z: 6 },
|
|
567
|
-
});
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
it('should perform action GET_ALL_SCENE_DATA', () => {
|
|
571
|
-
testCom.PerformAction('ADD_OBJECT', {
|
|
572
|
-
entityType: 'pov',
|
|
573
|
-
id: 'pov',
|
|
574
|
-
position: { x: 0, y: 0, z: 0 },
|
|
575
|
-
target: { x: 0, y: 0, z: 0 },
|
|
576
|
-
} as COMPov);
|
|
577
|
-
|
|
578
|
-
testCom.PerformAction('ADD_OBJECT', {
|
|
579
|
-
entityType: 'model',
|
|
580
|
-
id: 'model',
|
|
581
|
-
position: { x: 0, y: 0, z: 0 },
|
|
582
|
-
rotation: { x: 0, y: 0, z: 0 },
|
|
583
|
-
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
584
|
-
|
|
585
|
-
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
586
|
-
} as COMModel);
|
|
587
|
-
|
|
588
|
-
testCom.PerformAction('ADD_OBJECT', {
|
|
589
|
-
entityType: 'light',
|
|
590
|
-
id: 'ambient00',
|
|
591
|
-
type: 'ambient',
|
|
592
|
-
intensity: 0.5,
|
|
593
|
-
color: 'white',
|
|
594
|
-
} as COMLight);
|
|
595
|
-
|
|
596
|
-
testCom.PerformAction('ADD_OBJECT', {
|
|
597
|
-
entityType: 'group',
|
|
598
|
-
id: 'group1',
|
|
599
|
-
position: { x: 0, y: 0, z: 0 },
|
|
600
|
-
rotation: { x: 0, y: 0, z: 0 },
|
|
601
|
-
parentId: null,
|
|
602
|
-
} as COMGroup);
|
|
603
|
-
|
|
604
|
-
const success = testCom.PerformAction('GET_ALL_SCENE_DATA', {});
|
|
605
|
-
expect(success).toStrictEqual({
|
|
606
|
-
backgroundColor: '#ffffff',
|
|
607
|
-
cameras: [
|
|
608
|
-
{
|
|
609
|
-
entityType: 'pov',
|
|
610
|
-
id: 'pov',
|
|
611
|
-
position: { x: 0, y: 0, z: 0 },
|
|
612
|
-
target: { x: 0, y: 0, z: 0 },
|
|
613
|
-
parentId: null,
|
|
614
|
-
},
|
|
615
|
-
],
|
|
616
|
-
floorColor: '#ffffff',
|
|
617
|
-
floorEnabled: true,
|
|
618
|
-
lights: [
|
|
619
|
-
{
|
|
620
|
-
entityType: 'light',
|
|
621
|
-
id: 'ambient00',
|
|
622
|
-
type: 'ambient',
|
|
623
|
-
intensity: 0.5,
|
|
624
|
-
color: 'white',
|
|
625
|
-
parentId: null,
|
|
626
|
-
},
|
|
627
|
-
],
|
|
628
|
-
mediaItem: null,
|
|
629
|
-
name: undefined,
|
|
630
|
-
objects: [
|
|
631
|
-
{
|
|
632
|
-
entityType: 'model',
|
|
633
|
-
id: 'model',
|
|
634
|
-
position: { x: 0, y: 0, z: 0 },
|
|
635
|
-
rotation: { x: 0, y: 0, z: 0 },
|
|
636
|
-
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
637
|
-
parentId: null,
|
|
638
|
-
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
639
|
-
},
|
|
640
|
-
],
|
|
641
|
-
primitives: [],
|
|
642
|
-
spotmarks: [],
|
|
643
|
-
userCamera: {
|
|
644
|
-
position: { x: 1, y: 2, z: 3 },
|
|
645
|
-
target: { x: 4, y: 5, z: 6 },
|
|
646
|
-
},
|
|
647
|
-
groups: [
|
|
648
|
-
{
|
|
649
|
-
entityType: 'group',
|
|
650
|
-
id: 'group1',
|
|
651
|
-
position: { x: 0, y: 0, z: 0 },
|
|
652
|
-
rotation: { x: 0, y: 0, z: 0 },
|
|
653
|
-
parentId: null,
|
|
654
|
-
},
|
|
655
|
-
],
|
|
656
|
-
});
|
|
657
|
-
});
|
|
658
|
-
|
|
659
|
-
it('should perform action GET_OBJECTS', () => {
|
|
660
|
-
const mock0 = {
|
|
661
|
-
entityType: 'pov',
|
|
662
|
-
id: 'test0',
|
|
663
|
-
position: { x: 0, y: 0, z: 0 },
|
|
664
|
-
target: { x: 0, y: 0, z: 0 },
|
|
665
|
-
} as COMPov;
|
|
666
|
-
testCom.PerformAction('ADD_OBJECT', mock0);
|
|
667
|
-
|
|
668
|
-
const mock1 = {
|
|
669
|
-
entityType: 'pov',
|
|
670
|
-
id: 'test1',
|
|
671
|
-
position: { x: 0, y: 0, z: 0 },
|
|
672
|
-
target: { x: 0, y: 0, z: 0 },
|
|
673
|
-
} as COMPov;
|
|
674
|
-
testCom.PerformAction('ADD_OBJECT', mock1);
|
|
675
|
-
|
|
676
|
-
const successWithoutIds = testCom.PerformAction('GET_OBJECTS', {
|
|
677
|
-
ids: [],
|
|
678
|
-
});
|
|
679
|
-
expect(Array.from(successWithoutIds.values())).toStrictEqual([]);
|
|
680
|
-
|
|
681
|
-
const successWithIds = testCom.PerformAction('GET_OBJECTS', {
|
|
682
|
-
ids: ['test1'],
|
|
683
|
-
});
|
|
684
|
-
expect(Array.from(successWithIds.values())).toStrictEqual([
|
|
685
|
-
{
|
|
686
|
-
entityType: 'pov',
|
|
687
|
-
id: 'test1',
|
|
688
|
-
position: { x: 0, y: 0, z: 0 },
|
|
689
|
-
target: { x: 0, y: 0, z: 0 },
|
|
690
|
-
parentId: null,
|
|
691
|
-
},
|
|
692
|
-
]);
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
it('should perform action SELECT_OBJECT', () => {
|
|
696
|
-
const success0 = testCom.PerformAction('SELECT_OBJECT', {
|
|
697
|
-
id: 'test0',
|
|
698
|
-
});
|
|
699
|
-
expect(success0).toBe(false);
|
|
700
|
-
|
|
701
|
-
const mock0 = {
|
|
702
|
-
entityType: 'pov',
|
|
703
|
-
id: 'test0',
|
|
704
|
-
position: { x: 0, y: 0, z: 0 },
|
|
705
|
-
target: { x: 0, y: 0, z: 0 },
|
|
706
|
-
} as COMPov;
|
|
707
|
-
testCom.PerformAction('ADD_OBJECT', mock0);
|
|
708
|
-
|
|
709
|
-
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(undefined);
|
|
710
|
-
const success1 = testCom.PerformAction('SELECT_OBJECT', {
|
|
711
|
-
id: 'test0',
|
|
712
|
-
});
|
|
713
|
-
expect(success1).toBe(false);
|
|
714
|
-
|
|
715
|
-
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(
|
|
716
|
-
{} as unknown as DIVESceneObject,
|
|
717
|
-
);
|
|
718
|
-
const success2 = testCom.PerformAction('SELECT_OBJECT', {
|
|
719
|
-
id: 'test0',
|
|
720
|
-
});
|
|
721
|
-
expect(success2).toBe(false);
|
|
722
|
-
|
|
723
|
-
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce({
|
|
724
|
-
isSelectable: true,
|
|
725
|
-
} as unknown as DIVESceneObject);
|
|
726
|
-
const success3 = testCom.PerformAction('SELECT_OBJECT', {
|
|
727
|
-
id: 'test0',
|
|
728
|
-
});
|
|
729
|
-
expect(success3).toBe(true);
|
|
730
|
-
});
|
|
731
|
-
|
|
732
|
-
it('should perform action DESELECT_OBJECT', () => {
|
|
733
|
-
const success0 = testCom.PerformAction('DESELECT_OBJECT', {
|
|
734
|
-
id: 'test0',
|
|
735
|
-
});
|
|
736
|
-
expect(success0).toBe(false);
|
|
737
|
-
|
|
738
|
-
const mock0 = {
|
|
739
|
-
entityType: 'pov',
|
|
740
|
-
id: 'test0',
|
|
741
|
-
position: { x: 0, y: 0, z: 0 },
|
|
742
|
-
target: { x: 0, y: 0, z: 0 },
|
|
743
|
-
} as COMPov;
|
|
744
|
-
testCom.PerformAction('ADD_OBJECT', mock0);
|
|
745
|
-
|
|
746
|
-
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(undefined);
|
|
747
|
-
const success1 = testCom.PerformAction('DESELECT_OBJECT', {
|
|
748
|
-
id: 'test0',
|
|
749
|
-
});
|
|
750
|
-
expect(success1).toBe(false);
|
|
751
|
-
|
|
752
|
-
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(
|
|
753
|
-
{} as unknown as DIVESceneObject,
|
|
754
|
-
);
|
|
755
|
-
const success2 = testCom.PerformAction('DESELECT_OBJECT', {
|
|
756
|
-
id: 'test0',
|
|
757
|
-
});
|
|
758
|
-
expect(success2).toBe(false);
|
|
759
|
-
|
|
760
|
-
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce({
|
|
761
|
-
isSelectable: true,
|
|
762
|
-
} as unknown as DIVESceneObject);
|
|
763
|
-
const success3 = testCom.PerformAction('DESELECT_OBJECT', {
|
|
764
|
-
id: 'test0',
|
|
765
|
-
});
|
|
766
|
-
expect(success3).toBe(true);
|
|
767
|
-
});
|
|
768
|
-
|
|
769
|
-
it('should perform action SET_CAMERA_TRANSFORM', () => {
|
|
770
|
-
const success = testCom.PerformAction('SET_CAMERA_TRANSFORM', {
|
|
771
|
-
position: { x: 0, y: 0, z: 0 },
|
|
772
|
-
target: { x: 0, y: 0, z: 0 },
|
|
773
|
-
});
|
|
774
|
-
expect(success).toBe(true);
|
|
775
|
-
});
|
|
776
|
-
|
|
777
|
-
it('should perform action GET_CAMERA_TRANSFORM', () => {
|
|
778
|
-
const success = testCom.PerformAction('GET_CAMERA_TRANSFORM', {});
|
|
779
|
-
expect(success).toStrictEqual({
|
|
780
|
-
position: { x: 1, y: 2, z: 3 },
|
|
781
|
-
target: { x: 4, y: 5, z: 6 },
|
|
782
|
-
});
|
|
783
|
-
});
|
|
784
|
-
|
|
785
|
-
it('should perform action SET_CAMERA_LAYER', () => {
|
|
786
|
-
const success = testCom.PerformAction('SET_CAMERA_LAYER', {
|
|
787
|
-
layer: 'EDITOR',
|
|
788
|
-
});
|
|
789
|
-
expect(success).toBe(true);
|
|
790
|
-
});
|
|
791
|
-
|
|
792
|
-
it('should perform action ZOOM_CAMERA', () => {
|
|
793
|
-
const success0 = testCom.PerformAction('ZOOM_CAMERA', {
|
|
794
|
-
direction: 'IN',
|
|
795
|
-
by: 10,
|
|
796
|
-
});
|
|
797
|
-
expect(success0).toBe(true);
|
|
798
|
-
const success1 = testCom.PerformAction('ZOOM_CAMERA', {
|
|
799
|
-
direction: 'OUT',
|
|
800
|
-
by: 10,
|
|
801
|
-
});
|
|
802
|
-
expect(success1).toBe(true);
|
|
803
|
-
});
|
|
804
|
-
|
|
805
|
-
it('should perform action SET_GIZMO_MODE', () => {
|
|
806
|
-
const success = testCom.PerformAction('SET_GIZMO_MODE', {
|
|
807
|
-
mode: 'translate',
|
|
808
|
-
});
|
|
809
|
-
expect(success).toBe(true);
|
|
810
|
-
});
|
|
811
|
-
|
|
812
|
-
it('should perform action SET_GIZMO_VISIBILITY', () => {
|
|
813
|
-
let visibility = testCom.PerformAction('SET_GIZMO_VISIBILITY', true);
|
|
814
|
-
expect(visibility).toBe(true);
|
|
815
|
-
|
|
816
|
-
visibility = testCom.PerformAction('SET_GIZMO_VISIBILITY', false);
|
|
817
|
-
expect(visibility).toBe(false);
|
|
818
|
-
});
|
|
819
|
-
|
|
820
|
-
it('should perform action SET_GIZMO_SCALE_LINKED', () => {
|
|
821
|
-
const success = testCom.PerformAction('SET_GIZMO_SCALE_LINKED', true);
|
|
822
|
-
expect(success).toBe(true);
|
|
823
|
-
});
|
|
824
|
-
|
|
825
|
-
it('should perform action USE_TOOL', () => {
|
|
826
|
-
let success = testCom.PerformAction('USE_TOOL', { tool: 'select' });
|
|
827
|
-
expect(success).toBe(true);
|
|
828
|
-
|
|
829
|
-
success = testCom.PerformAction('USE_TOOL', { tool: 'none' });
|
|
830
|
-
expect(success).toBe(true);
|
|
831
|
-
});
|
|
832
|
-
|
|
833
|
-
it('should perform action MODEL_LOADED', () => {
|
|
834
|
-
const payload = {
|
|
835
|
-
entityType: 'model',
|
|
836
|
-
id: 'modelID',
|
|
837
|
-
position: { x: 0, y: 0, z: 0 },
|
|
838
|
-
rotation: { x: 0, y: 0, z: 0 },
|
|
839
|
-
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
840
|
-
|
|
841
|
-
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
842
|
-
} as COMModel;
|
|
843
|
-
testCom.PerformAction('ADD_OBJECT', payload);
|
|
844
|
-
const success = testCom.PerformAction('MODEL_LOADED', {
|
|
845
|
-
id: 'modelID',
|
|
846
|
-
});
|
|
847
|
-
expect(success).toBe(true);
|
|
848
|
-
});
|
|
849
|
-
|
|
850
|
-
it('should perform action UPDATE_SCENE', () => {
|
|
851
|
-
const success0 = testCom.PerformAction('UPDATE_SCENE', {
|
|
852
|
-
name: 'scene name',
|
|
853
|
-
backgroundColor: 'ffffff',
|
|
854
|
-
floorEnabled: true,
|
|
855
|
-
floorColor: 'ffffff',
|
|
856
|
-
gridEnabled: true,
|
|
857
|
-
});
|
|
858
|
-
expect(success0).toBe(true);
|
|
859
|
-
|
|
860
|
-
const success1 = testCom.PerformAction('UPDATE_SCENE', {
|
|
861
|
-
name: undefined,
|
|
862
|
-
backgroundColor: undefined,
|
|
863
|
-
floorEnabled: undefined,
|
|
864
|
-
floorColor: undefined,
|
|
865
|
-
gridEnabled: undefined,
|
|
866
|
-
});
|
|
867
|
-
expect(success1).toBe(true);
|
|
868
|
-
});
|
|
869
|
-
|
|
870
|
-
it('should perform action GENERATE_MEDIA', async () => {
|
|
871
|
-
const blobUri = 'blob:http://localhost:3000/1234';
|
|
872
|
-
jest.spyOn(mockModule, 'get').mockResolvedValue({
|
|
873
|
-
GenerateMedia: jest.fn(),
|
|
874
|
-
});
|
|
875
|
-
const mediaGeneratorModule = await testCom['_mediaGenerator'].get();
|
|
876
|
-
|
|
877
|
-
jest.spyOn(mediaGeneratorModule, 'GenerateMedia').mockReturnValue(
|
|
878
|
-
blobUri,
|
|
879
|
-
);
|
|
880
|
-
|
|
881
|
-
const mock1 = {
|
|
882
|
-
entityType: 'pov',
|
|
883
|
-
id: 'test1',
|
|
884
|
-
position: { x: 0, y: 0, z: 0 },
|
|
885
|
-
target: { x: 0, y: 0, z: 0 },
|
|
886
|
-
} as COMPov;
|
|
887
|
-
testCom.PerformAction('ADD_OBJECT', mock1);
|
|
888
|
-
|
|
889
|
-
const success0 = await testCom.PerformAction('GENERATE_MEDIA', {
|
|
890
|
-
id: 'test1',
|
|
891
|
-
width: 800,
|
|
892
|
-
height: 600,
|
|
893
|
-
});
|
|
894
|
-
expect(success0).toBe(blobUri);
|
|
895
|
-
|
|
896
|
-
const success1 = await testCom.PerformAction('GENERATE_MEDIA', {
|
|
897
|
-
position: { x: 0, y: 0, z: 0 },
|
|
898
|
-
target: { x: 0, y: 0, z: 0 },
|
|
899
|
-
width: 800,
|
|
900
|
-
height: 600,
|
|
901
|
-
});
|
|
902
|
-
expect(success1).toBe(blobUri);
|
|
903
|
-
|
|
904
|
-
jest.restoreAllMocks();
|
|
905
|
-
});
|
|
906
|
-
|
|
907
|
-
it('should perform action SET_PARENT', () => {
|
|
908
|
-
const object = {
|
|
909
|
-
id: 'object',
|
|
910
|
-
} as COMEntity;
|
|
911
|
-
testCom.PerformAction('ADD_OBJECT', object);
|
|
912
|
-
|
|
913
|
-
const objectNotRegistered = {
|
|
914
|
-
id: 'objectNotRegistered',
|
|
915
|
-
} as COMEntity;
|
|
916
|
-
|
|
917
|
-
const parent0 = {
|
|
918
|
-
id: 'parent0',
|
|
919
|
-
} as COMEntity;
|
|
920
|
-
testCom.PerformAction('ADD_OBJECT', parent0);
|
|
921
|
-
|
|
922
|
-
const parent1 = {
|
|
923
|
-
id: 'parent1',
|
|
924
|
-
} as COMEntity;
|
|
925
|
-
testCom.PerformAction('ADD_OBJECT', parent1);
|
|
926
|
-
|
|
927
|
-
const parentNotRegistered = {
|
|
928
|
-
id: 'parentNotRegistered',
|
|
929
|
-
} as COMEntity;
|
|
930
|
-
|
|
931
|
-
const attachNotRegisteredObject = testCom.PerformAction('SET_PARENT', {
|
|
932
|
-
object: objectNotRegistered,
|
|
933
|
-
parent: null,
|
|
934
|
-
});
|
|
935
|
-
expect(attachNotRegisteredObject).toBe(false);
|
|
936
|
-
|
|
937
|
-
jest.spyOn(mockScene, 'GetSceneObject').mockImplementationOnce(() => {
|
|
938
|
-
return undefined;
|
|
939
|
-
});
|
|
940
|
-
const attachNonSceneObject = testCom.PerformAction('SET_PARENT', {
|
|
941
|
-
object: object,
|
|
942
|
-
parent: null,
|
|
943
|
-
});
|
|
944
|
-
expect(attachNonSceneObject).toBe(false);
|
|
945
|
-
|
|
946
|
-
const attachToNull = testCom.PerformAction('SET_PARENT', {
|
|
947
|
-
object: object,
|
|
948
|
-
parent: null,
|
|
949
|
-
});
|
|
950
|
-
expect(attachToNull).toBe(true);
|
|
951
|
-
|
|
952
|
-
const attachToItself = testCom.PerformAction('SET_PARENT', {
|
|
953
|
-
object: object,
|
|
954
|
-
parent: object,
|
|
955
|
-
});
|
|
956
|
-
expect(attachToItself).toBe(false);
|
|
957
|
-
|
|
958
|
-
const attachToNotRegsiteredParent = testCom.PerformAction(
|
|
959
|
-
'SET_PARENT',
|
|
960
|
-
{
|
|
961
|
-
object: object,
|
|
962
|
-
parent: parentNotRegistered,
|
|
963
|
-
},
|
|
964
|
-
);
|
|
965
|
-
expect(attachToNotRegsiteredParent).toBe(true);
|
|
966
|
-
|
|
967
|
-
jest.spyOn(mockScene, 'GetSceneObject')
|
|
968
|
-
.mockImplementationOnce(() => {
|
|
969
|
-
return {
|
|
970
|
-
DropIt: jest.fn(),
|
|
971
|
-
attach: jest.fn(),
|
|
972
|
-
} as unknown as DIVESceneObject;
|
|
973
|
-
})
|
|
974
|
-
.mockImplementationOnce(() => {
|
|
975
|
-
return undefined;
|
|
976
|
-
});
|
|
977
|
-
|
|
978
|
-
const attachtoNonSceneParent = testCom.PerformAction('SET_PARENT', {
|
|
979
|
-
object: object,
|
|
980
|
-
parent: parent1,
|
|
981
|
-
});
|
|
982
|
-
expect(attachtoNonSceneParent).toBe(true);
|
|
983
|
-
|
|
984
|
-
const attachToValidParent = testCom.PerformAction('SET_PARENT', {
|
|
985
|
-
object: object,
|
|
986
|
-
parent: parent1,
|
|
987
|
-
});
|
|
988
|
-
expect(attachToValidParent).toBe(true);
|
|
989
|
-
});
|
|
990
|
-
|
|
991
|
-
it('should perform action EXPORT_SCENE', async () => {
|
|
992
|
-
const url = 'https://example.com';
|
|
993
|
-
jest.spyOn(mockModule, 'get').mockResolvedValue({
|
|
994
|
-
Export: jest.fn(),
|
|
995
|
-
});
|
|
996
|
-
const ioModule = await testCom['_io'].get();
|
|
997
|
-
|
|
998
|
-
jest.spyOn(ioModule, 'Export').mockResolvedValueOnce(url);
|
|
999
|
-
|
|
1000
|
-
const result = await testCom.PerformAction('EXPORT_SCENE', {
|
|
1001
|
-
type: 'glb',
|
|
1002
|
-
});
|
|
1003
|
-
expect(result).toBe(url);
|
|
1004
|
-
});
|
|
1005
|
-
|
|
1006
|
-
it('should perform action LAUNCH_AR', async () => {
|
|
1007
|
-
jest.spyOn(mockModule, 'get').mockResolvedValue({
|
|
1008
|
-
Launch: jest.fn(),
|
|
1009
|
-
});
|
|
1010
|
-
const arModule = await testCom['_ar'].get();
|
|
1011
|
-
const arLaunchSpy = jest
|
|
1012
|
-
.spyOn(arModule, 'Launch')
|
|
1013
|
-
.mockResolvedValueOnce();
|
|
1014
|
-
|
|
1015
|
-
const result = await testCom.PerformAction('LAUNCH_AR', undefined);
|
|
1016
|
-
expect(arLaunchSpy).toHaveBeenCalledTimes(1);
|
|
1017
|
-
});
|
|
1018
|
-
|
|
1019
|
-
it('should warn of action is of invalid type ', () => {
|
|
1020
|
-
jest.spyOn(console, 'warn').mockImplementationOnce(() => {});
|
|
1021
|
-
testCom.PerformAction('INVALID_ACTION' as keyof Actions, {});
|
|
1022
|
-
expect(console.warn).toHaveBeenCalledTimes(1);
|
|
1023
|
-
});
|
|
1024
|
-
});
|