@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
|
@@ -25,13 +25,21 @@ import type { DIVEScene } from '../../scene/Scene';
|
|
|
25
25
|
import type DIVEToolbox from '../../toolbox/Toolbox';
|
|
26
26
|
import type DIVEOrbitControls from '../../controls/OrbitControls';
|
|
27
27
|
import { type DIVERenderer } from '../../renderer/Renderer';
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
type COMGroup,
|
|
30
|
+
type COMEntity,
|
|
31
|
+
type COMEntityType,
|
|
32
|
+
type COMLight,
|
|
33
|
+
type COMModel,
|
|
34
|
+
type COMPov,
|
|
35
|
+
type COMPrimitive,
|
|
36
|
+
} from '../types';
|
|
29
37
|
import { type DIVESceneObject } from '../../types';
|
|
30
38
|
|
|
31
39
|
jest.mock('three/src/math/MathUtils', () => {
|
|
32
40
|
return {
|
|
33
41
|
generateUUID: jest.fn().mockReturnValue('uuid'),
|
|
34
|
-
}
|
|
42
|
+
};
|
|
35
43
|
});
|
|
36
44
|
|
|
37
45
|
jest.mock('../../mediacreator/MediaCreator', () => {
|
|
@@ -41,7 +49,7 @@ jest.mock('../../mediacreator/MediaCreator', () => {
|
|
|
41
49
|
|
|
42
50
|
return this;
|
|
43
51
|
}),
|
|
44
|
-
}
|
|
52
|
+
};
|
|
45
53
|
});
|
|
46
54
|
|
|
47
55
|
jest.mock('../../io/IO', () => {
|
|
@@ -51,7 +59,7 @@ jest.mock('../../io/IO', () => {
|
|
|
51
59
|
this.Export = jest.fn();
|
|
52
60
|
return this;
|
|
53
61
|
}),
|
|
54
|
-
}
|
|
62
|
+
};
|
|
55
63
|
});
|
|
56
64
|
|
|
57
65
|
jest.mock('../../toolbox/select/SelectTool', () => {
|
|
@@ -63,7 +71,7 @@ jest.mock('../../toolbox/select/SelectTool', () => {
|
|
|
63
71
|
DetachGizmo: jest.fn(),
|
|
64
72
|
};
|
|
65
73
|
}),
|
|
66
|
-
}
|
|
74
|
+
};
|
|
67
75
|
});
|
|
68
76
|
|
|
69
77
|
const mockRenderer = {
|
|
@@ -170,7 +178,7 @@ const mockController = {
|
|
|
170
178
|
RevertLast: jest.fn(),
|
|
171
179
|
ComputeEncompassingView: jest.fn().mockReturnValue({
|
|
172
180
|
position: { x: 1, y: 2, z: 3 },
|
|
173
|
-
target: { x: 4, y: 5, z: 6 }
|
|
181
|
+
target: { x: 4, y: 5, z: 6 },
|
|
174
182
|
}),
|
|
175
183
|
} as unknown as DIVEOrbitControls;
|
|
176
184
|
|
|
@@ -186,10 +194,14 @@ const mockToolBox = {
|
|
|
186
194
|
|
|
187
195
|
let testCom: DIVECommunication;
|
|
188
196
|
|
|
189
|
-
|
|
190
197
|
describe('dive/communication/DIVECommunication', () => {
|
|
191
198
|
beforeEach(() => {
|
|
192
|
-
testCom = new DIVECommunication(
|
|
199
|
+
testCom = new DIVECommunication(
|
|
200
|
+
mockRenderer,
|
|
201
|
+
mockScene,
|
|
202
|
+
mockController,
|
|
203
|
+
mockToolBox,
|
|
204
|
+
);
|
|
193
205
|
});
|
|
194
206
|
|
|
195
207
|
afterEach(() => {
|
|
@@ -234,13 +246,13 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
234
246
|
});
|
|
235
247
|
|
|
236
248
|
it('should not unsubscribe twice', () => {
|
|
237
|
-
const unsub = testCom.Subscribe('GET_ALL_OBJECTS', () => {
|
|
249
|
+
const unsub = testCom.Subscribe('GET_ALL_OBJECTS', () => {});
|
|
238
250
|
expect(unsub()).toBe(true);
|
|
239
251
|
expect(unsub()).toBe(false);
|
|
240
252
|
});
|
|
241
253
|
|
|
242
254
|
it('should not unsubscribe if listener does not exist anymore', () => {
|
|
243
|
-
const unsub = testCom.Subscribe('GET_ALL_OBJECTS', () => {
|
|
255
|
+
const unsub = testCom.Subscribe('GET_ALL_OBJECTS', () => {});
|
|
244
256
|
testCom['listeners'].clear();
|
|
245
257
|
expect(unsub()).toBe(false);
|
|
246
258
|
});
|
|
@@ -248,20 +260,22 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
248
260
|
it('should tigger onChange callback', () => {
|
|
249
261
|
const payload = {
|
|
250
262
|
name: 'name',
|
|
251
|
-
entityType:
|
|
252
|
-
id:
|
|
253
|
-
type:
|
|
263
|
+
entityType: 'light',
|
|
264
|
+
id: 'ambient00',
|
|
265
|
+
type: 'ambient',
|
|
254
266
|
intensity: 0.5,
|
|
255
267
|
color: 'white',
|
|
256
268
|
} as COMLight;
|
|
257
|
-
expect(() =>
|
|
269
|
+
expect(() =>
|
|
270
|
+
testCom.PerformAction('ADD_OBJECT', payload),
|
|
271
|
+
).not.toThrow();
|
|
258
272
|
});
|
|
259
273
|
|
|
260
274
|
it('should perform action ADD_OBJECT', () => {
|
|
261
275
|
const payload = {
|
|
262
|
-
entityType:
|
|
263
|
-
id:
|
|
264
|
-
type:
|
|
276
|
+
entityType: 'light',
|
|
277
|
+
id: 'ambient00',
|
|
278
|
+
type: 'ambient',
|
|
265
279
|
intensity: 0.5,
|
|
266
280
|
color: 'white',
|
|
267
281
|
} as COMLight;
|
|
@@ -272,9 +286,9 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
272
286
|
|
|
273
287
|
it('should not perform action ADD_OBJECT with same object', () => {
|
|
274
288
|
const payload = {
|
|
275
|
-
entityType:
|
|
276
|
-
id:
|
|
277
|
-
type:
|
|
289
|
+
entityType: 'light',
|
|
290
|
+
id: 'ambient00',
|
|
291
|
+
type: 'ambient',
|
|
278
292
|
intensity: 0.5,
|
|
279
293
|
color: 'white',
|
|
280
294
|
} as COMLight;
|
|
@@ -285,9 +299,9 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
285
299
|
|
|
286
300
|
it('should perform action UPDATE_OBJECT with existing oject', () => {
|
|
287
301
|
const payload = {
|
|
288
|
-
entityType:
|
|
289
|
-
id:
|
|
290
|
-
type:
|
|
302
|
+
entityType: 'light',
|
|
303
|
+
id: 'ambient00',
|
|
304
|
+
type: 'ambient',
|
|
291
305
|
intensity: 0.5,
|
|
292
306
|
color: 'white',
|
|
293
307
|
} as COMLight;
|
|
@@ -301,9 +315,9 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
301
315
|
|
|
302
316
|
it('should perform action UPDATE_OBJECT without existing oject', () => {
|
|
303
317
|
const payload = {
|
|
304
|
-
entityType:
|
|
305
|
-
id:
|
|
306
|
-
type:
|
|
318
|
+
entityType: 'light',
|
|
319
|
+
id: 'ambient00',
|
|
320
|
+
type: 'ambient',
|
|
307
321
|
intensity: 0.5,
|
|
308
322
|
color: 'white',
|
|
309
323
|
} as COMLight;
|
|
@@ -314,9 +328,9 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
314
328
|
|
|
315
329
|
it('should perform action DELETE_OBJECT with existing object', () => {
|
|
316
330
|
const payload = {
|
|
317
|
-
entityType:
|
|
318
|
-
id:
|
|
319
|
-
type:
|
|
331
|
+
entityType: 'light',
|
|
332
|
+
id: 'ambient00',
|
|
333
|
+
type: 'ambient',
|
|
320
334
|
intensity: 0.5,
|
|
321
335
|
color: 'white',
|
|
322
336
|
} as COMLight;
|
|
@@ -330,9 +344,9 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
330
344
|
|
|
331
345
|
it('should perform action DELETE_OBJECT without existing object', () => {
|
|
332
346
|
const payload = {
|
|
333
|
-
entityType:
|
|
334
|
-
id:
|
|
335
|
-
type:
|
|
347
|
+
entityType: 'light',
|
|
348
|
+
id: 'ambient00',
|
|
349
|
+
type: 'ambient',
|
|
336
350
|
intensity: 0.5,
|
|
337
351
|
color: 'white',
|
|
338
352
|
} as COMLight;
|
|
@@ -352,13 +366,13 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
352
366
|
|
|
353
367
|
it('should perform action DROP_IT with existing model', () => {
|
|
354
368
|
const payload = {
|
|
355
|
-
entityType:
|
|
356
|
-
id:
|
|
369
|
+
entityType: 'model',
|
|
370
|
+
id: 'model',
|
|
357
371
|
position: { x: 0, y: 0, z: 0 },
|
|
358
372
|
rotation: { x: 0, y: 0, z: 0 },
|
|
359
373
|
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
360
374
|
|
|
361
|
-
uri:
|
|
375
|
+
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
362
376
|
} as COMModel;
|
|
363
377
|
|
|
364
378
|
testCom.PerformAction('ADD_OBJECT', payload);
|
|
@@ -372,13 +386,13 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
372
386
|
|
|
373
387
|
it('should perform action DROP_IT without existing model', () => {
|
|
374
388
|
const payload = {
|
|
375
|
-
entityType:
|
|
376
|
-
id:
|
|
389
|
+
entityType: 'model',
|
|
390
|
+
id: 'model',
|
|
377
391
|
position: { x: 0, y: 0, z: 0 },
|
|
378
392
|
rotation: { x: 0, y: 0, z: 0 },
|
|
379
393
|
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
380
394
|
|
|
381
|
-
uri:
|
|
395
|
+
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
382
396
|
};
|
|
383
397
|
const placeSpy = jest.spyOn(mockScene, 'GetSceneObject');
|
|
384
398
|
|
|
@@ -389,13 +403,13 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
389
403
|
|
|
390
404
|
it('should perform action PLACE_ON_FLOOR with existing model', () => {
|
|
391
405
|
const payload = {
|
|
392
|
-
entityType:
|
|
393
|
-
id:
|
|
406
|
+
entityType: 'model',
|
|
407
|
+
id: 'model',
|
|
394
408
|
position: { x: 0, y: 0, z: 0 },
|
|
395
409
|
rotation: { x: 0, y: 0, z: 0 },
|
|
396
410
|
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
397
411
|
|
|
398
|
-
uri:
|
|
412
|
+
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
399
413
|
} as COMModel;
|
|
400
414
|
|
|
401
415
|
testCom.PerformAction('ADD_OBJECT', payload);
|
|
@@ -409,13 +423,13 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
409
423
|
|
|
410
424
|
it('should perform action PLACE_ON_FLOOR without existing model', () => {
|
|
411
425
|
const payload = {
|
|
412
|
-
entityType:
|
|
413
|
-
id:
|
|
426
|
+
entityType: 'model' as COMEntityType,
|
|
427
|
+
id: 'model',
|
|
414
428
|
position: { x: 0, y: 0, z: 0 },
|
|
415
429
|
rotation: { x: 0, y: 0, z: 0 },
|
|
416
430
|
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
417
431
|
|
|
418
|
-
uri:
|
|
432
|
+
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
419
433
|
};
|
|
420
434
|
const placeSpy = jest.spyOn(mockScene, 'PlaceOnFloor');
|
|
421
435
|
|
|
@@ -426,13 +440,13 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
426
440
|
|
|
427
441
|
it('should perform action GET_ALL_OBJECTS', () => {
|
|
428
442
|
const payload = {
|
|
429
|
-
entityType:
|
|
430
|
-
id:
|
|
443
|
+
entityType: 'model',
|
|
444
|
+
id: 'model',
|
|
431
445
|
position: { x: 0, y: 0, z: 0 },
|
|
432
446
|
rotation: { x: 0, y: 0, z: 0 },
|
|
433
447
|
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
434
448
|
|
|
435
|
-
uri:
|
|
449
|
+
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
436
450
|
} as COMModel;
|
|
437
451
|
|
|
438
452
|
const objects0 = testCom.PerformAction('GET_ALL_OBJECTS', new Map());
|
|
@@ -462,8 +476,8 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
462
476
|
|
|
463
477
|
moveToSpy.mockClear();
|
|
464
478
|
testCom.PerformAction('ADD_OBJECT', {
|
|
465
|
-
entityType:
|
|
466
|
-
id:
|
|
479
|
+
entityType: 'pov',
|
|
480
|
+
id: 'pov',
|
|
467
481
|
position: { x: 0, y: 0, z: 0 },
|
|
468
482
|
target: { x: 0, y: 0, z: 0 },
|
|
469
483
|
} as COMPov);
|
|
@@ -489,46 +503,49 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
489
503
|
|
|
490
504
|
it('should perform action COMPUTE_ENCOMPASSING_VIEW', () => {
|
|
491
505
|
const payload = {};
|
|
492
|
-
const transform = testCom.PerformAction(
|
|
506
|
+
const transform = testCom.PerformAction(
|
|
507
|
+
'COMPUTE_ENCOMPASSING_VIEW',
|
|
508
|
+
payload,
|
|
509
|
+
);
|
|
493
510
|
expect(transform).toStrictEqual({
|
|
494
511
|
position: { x: 1, y: 2, z: 3 },
|
|
495
|
-
target: { x: 4, y: 5, z: 6 }
|
|
512
|
+
target: { x: 4, y: 5, z: 6 },
|
|
496
513
|
});
|
|
497
514
|
expect(payload).toStrictEqual({
|
|
498
515
|
position: { x: 1, y: 2, z: 3 },
|
|
499
|
-
target: { x: 4, y: 5, z: 6 }
|
|
516
|
+
target: { x: 4, y: 5, z: 6 },
|
|
500
517
|
});
|
|
501
518
|
});
|
|
502
519
|
|
|
503
520
|
it('should perform action GET_ALL_SCENE_DATA', () => {
|
|
504
521
|
testCom.PerformAction('ADD_OBJECT', {
|
|
505
|
-
entityType:
|
|
506
|
-
id:
|
|
522
|
+
entityType: 'pov',
|
|
523
|
+
id: 'pov',
|
|
507
524
|
position: { x: 0, y: 0, z: 0 },
|
|
508
525
|
target: { x: 0, y: 0, z: 0 },
|
|
509
526
|
} as COMPov);
|
|
510
527
|
|
|
511
528
|
testCom.PerformAction('ADD_OBJECT', {
|
|
512
|
-
entityType:
|
|
513
|
-
id:
|
|
529
|
+
entityType: 'model',
|
|
530
|
+
id: 'model',
|
|
514
531
|
position: { x: 0, y: 0, z: 0 },
|
|
515
532
|
rotation: { x: 0, y: 0, z: 0 },
|
|
516
533
|
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
517
534
|
|
|
518
|
-
uri:
|
|
535
|
+
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
519
536
|
} as COMModel);
|
|
520
537
|
|
|
521
538
|
testCom.PerformAction('ADD_OBJECT', {
|
|
522
|
-
entityType:
|
|
523
|
-
id:
|
|
524
|
-
type:
|
|
539
|
+
entityType: 'light',
|
|
540
|
+
id: 'ambient00',
|
|
541
|
+
type: 'ambient',
|
|
525
542
|
intensity: 0.5,
|
|
526
543
|
color: 'white',
|
|
527
544
|
} as COMLight);
|
|
528
545
|
|
|
529
546
|
testCom.PerformAction('ADD_OBJECT', {
|
|
530
|
-
entityType:
|
|
531
|
-
id:
|
|
547
|
+
entityType: 'group',
|
|
548
|
+
id: 'group1',
|
|
532
549
|
position: { x: 0, y: 0, z: 0 },
|
|
533
550
|
rotation: { x: 0, y: 0, z: 0 },
|
|
534
551
|
parentId: null,
|
|
@@ -536,122 +553,166 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
536
553
|
|
|
537
554
|
const success = testCom.PerformAction('GET_ALL_SCENE_DATA', {});
|
|
538
555
|
expect(success).toStrictEqual({
|
|
539
|
-
backgroundColor:
|
|
540
|
-
cameras: [
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
556
|
+
backgroundColor: '#ffffff',
|
|
557
|
+
cameras: [
|
|
558
|
+
{
|
|
559
|
+
entityType: 'pov',
|
|
560
|
+
id: 'pov',
|
|
561
|
+
position: { x: 0, y: 0, z: 0 },
|
|
562
|
+
target: { x: 0, y: 0, z: 0 },
|
|
563
|
+
parentId: null,
|
|
564
|
+
},
|
|
565
|
+
],
|
|
566
|
+
floorColor: '#ffffff',
|
|
548
567
|
floorEnabled: true,
|
|
549
|
-
lights: [
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
568
|
+
lights: [
|
|
569
|
+
{
|
|
570
|
+
entityType: 'light',
|
|
571
|
+
id: 'ambient00',
|
|
572
|
+
type: 'ambient',
|
|
573
|
+
intensity: 0.5,
|
|
574
|
+
color: 'white',
|
|
575
|
+
parentId: null,
|
|
576
|
+
},
|
|
577
|
+
],
|
|
557
578
|
mediaItem: null,
|
|
558
579
|
name: undefined,
|
|
559
|
-
objects: [
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
580
|
+
objects: [
|
|
581
|
+
{
|
|
582
|
+
entityType: 'model',
|
|
583
|
+
id: 'model',
|
|
584
|
+
position: { x: 0, y: 0, z: 0 },
|
|
585
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
586
|
+
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
587
|
+
parentId: null,
|
|
588
|
+
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
589
|
+
},
|
|
590
|
+
],
|
|
568
591
|
primitives: [],
|
|
569
592
|
spotmarks: [],
|
|
570
593
|
userCamera: {
|
|
571
594
|
position: { x: 1, y: 2, z: 3 },
|
|
572
595
|
target: { x: 4, y: 5, z: 6 },
|
|
573
596
|
},
|
|
574
|
-
groups: [
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
597
|
+
groups: [
|
|
598
|
+
{
|
|
599
|
+
entityType: 'group',
|
|
600
|
+
id: 'group1',
|
|
601
|
+
position: { x: 0, y: 0, z: 0 },
|
|
602
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
603
|
+
parentId: null,
|
|
604
|
+
},
|
|
605
|
+
],
|
|
581
606
|
});
|
|
582
607
|
});
|
|
583
608
|
|
|
584
609
|
it('should perform action GET_OBJECTS', () => {
|
|
585
610
|
const mock0 = {
|
|
586
|
-
entityType:
|
|
587
|
-
id:
|
|
611
|
+
entityType: 'pov',
|
|
612
|
+
id: 'test0',
|
|
588
613
|
position: { x: 0, y: 0, z: 0 },
|
|
589
614
|
target: { x: 0, y: 0, z: 0 },
|
|
590
615
|
} as COMPov;
|
|
591
616
|
testCom.PerformAction('ADD_OBJECT', mock0);
|
|
592
617
|
|
|
593
618
|
const mock1 = {
|
|
594
|
-
entityType:
|
|
595
|
-
id:
|
|
619
|
+
entityType: 'pov',
|
|
620
|
+
id: 'test1',
|
|
596
621
|
position: { x: 0, y: 0, z: 0 },
|
|
597
622
|
target: { x: 0, y: 0, z: 0 },
|
|
598
623
|
} as COMPov;
|
|
599
624
|
testCom.PerformAction('ADD_OBJECT', mock1);
|
|
600
625
|
|
|
601
|
-
const successWithoutIds = testCom.PerformAction('GET_OBJECTS', {
|
|
626
|
+
const successWithoutIds = testCom.PerformAction('GET_OBJECTS', {
|
|
627
|
+
ids: [],
|
|
628
|
+
});
|
|
602
629
|
expect(Array.from(successWithoutIds.values())).toStrictEqual([]);
|
|
603
630
|
|
|
604
|
-
const successWithIds = testCom.PerformAction('GET_OBJECTS', {
|
|
605
|
-
|
|
631
|
+
const successWithIds = testCom.PerformAction('GET_OBJECTS', {
|
|
632
|
+
ids: ['test1'],
|
|
633
|
+
});
|
|
634
|
+
expect(Array.from(successWithIds.values())).toStrictEqual([
|
|
635
|
+
{
|
|
636
|
+
entityType: 'pov',
|
|
637
|
+
id: 'test1',
|
|
638
|
+
position: { x: 0, y: 0, z: 0 },
|
|
639
|
+
target: { x: 0, y: 0, z: 0 },
|
|
640
|
+
parentId: null,
|
|
641
|
+
},
|
|
642
|
+
]);
|
|
606
643
|
});
|
|
607
644
|
|
|
608
645
|
it('should perform action SELECT_OBJECT', () => {
|
|
609
|
-
const success0 = testCom.PerformAction('SELECT_OBJECT', {
|
|
646
|
+
const success0 = testCom.PerformAction('SELECT_OBJECT', {
|
|
647
|
+
id: 'test0',
|
|
648
|
+
});
|
|
610
649
|
expect(success0).toBe(false);
|
|
611
650
|
|
|
612
651
|
const mock0 = {
|
|
613
|
-
entityType:
|
|
614
|
-
id:
|
|
652
|
+
entityType: 'pov',
|
|
653
|
+
id: 'test0',
|
|
615
654
|
position: { x: 0, y: 0, z: 0 },
|
|
616
655
|
target: { x: 0, y: 0, z: 0 },
|
|
617
656
|
} as COMPov;
|
|
618
657
|
testCom.PerformAction('ADD_OBJECT', mock0);
|
|
619
658
|
|
|
620
659
|
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(undefined);
|
|
621
|
-
const success1 = testCom.PerformAction('SELECT_OBJECT', {
|
|
660
|
+
const success1 = testCom.PerformAction('SELECT_OBJECT', {
|
|
661
|
+
id: 'test0',
|
|
662
|
+
});
|
|
622
663
|
expect(success1).toBe(false);
|
|
623
664
|
|
|
624
|
-
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(
|
|
625
|
-
|
|
665
|
+
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(
|
|
666
|
+
{} as unknown as DIVESceneObject,
|
|
667
|
+
);
|
|
668
|
+
const success2 = testCom.PerformAction('SELECT_OBJECT', {
|
|
669
|
+
id: 'test0',
|
|
670
|
+
});
|
|
626
671
|
expect(success2).toBe(false);
|
|
627
672
|
|
|
628
|
-
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce({
|
|
629
|
-
|
|
673
|
+
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce({
|
|
674
|
+
isSelectable: true,
|
|
675
|
+
} as unknown as DIVESceneObject);
|
|
676
|
+
const success3 = testCom.PerformAction('SELECT_OBJECT', {
|
|
677
|
+
id: 'test0',
|
|
678
|
+
});
|
|
630
679
|
expect(success3).toBe(true);
|
|
631
680
|
});
|
|
632
681
|
|
|
633
682
|
it('should perform action DESELECT_OBJECT', () => {
|
|
634
|
-
const success0 = testCom.PerformAction('DESELECT_OBJECT', {
|
|
683
|
+
const success0 = testCom.PerformAction('DESELECT_OBJECT', {
|
|
684
|
+
id: 'test0',
|
|
685
|
+
});
|
|
635
686
|
expect(success0).toBe(false);
|
|
636
687
|
|
|
637
688
|
const mock0 = {
|
|
638
|
-
entityType:
|
|
639
|
-
id:
|
|
689
|
+
entityType: 'pov',
|
|
690
|
+
id: 'test0',
|
|
640
691
|
position: { x: 0, y: 0, z: 0 },
|
|
641
692
|
target: { x: 0, y: 0, z: 0 },
|
|
642
693
|
} as COMPov;
|
|
643
694
|
testCom.PerformAction('ADD_OBJECT', mock0);
|
|
644
695
|
|
|
645
696
|
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(undefined);
|
|
646
|
-
const success1 = testCom.PerformAction('DESELECT_OBJECT', {
|
|
697
|
+
const success1 = testCom.PerformAction('DESELECT_OBJECT', {
|
|
698
|
+
id: 'test0',
|
|
699
|
+
});
|
|
647
700
|
expect(success1).toBe(false);
|
|
648
701
|
|
|
649
|
-
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(
|
|
650
|
-
|
|
702
|
+
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(
|
|
703
|
+
{} as unknown as DIVESceneObject,
|
|
704
|
+
);
|
|
705
|
+
const success2 = testCom.PerformAction('DESELECT_OBJECT', {
|
|
706
|
+
id: 'test0',
|
|
707
|
+
});
|
|
651
708
|
expect(success2).toBe(false);
|
|
652
709
|
|
|
653
|
-
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce({
|
|
654
|
-
|
|
710
|
+
jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce({
|
|
711
|
+
isSelectable: true,
|
|
712
|
+
} as unknown as DIVESceneObject);
|
|
713
|
+
const success3 = testCom.PerformAction('DESELECT_OBJECT', {
|
|
714
|
+
id: 'test0',
|
|
715
|
+
});
|
|
655
716
|
expect(success3).toBe(true);
|
|
656
717
|
});
|
|
657
718
|
|
|
@@ -716,13 +777,13 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
716
777
|
|
|
717
778
|
it('should perform action MODEL_LOADED', () => {
|
|
718
779
|
const payload = {
|
|
719
|
-
entityType:
|
|
720
|
-
id:
|
|
780
|
+
entityType: 'model',
|
|
781
|
+
id: 'modelID',
|
|
721
782
|
position: { x: 0, y: 0, z: 0 },
|
|
722
783
|
rotation: { x: 0, y: 0, z: 0 },
|
|
723
784
|
scale: { x: 0.01, y: 0.01, z: 0.01 },
|
|
724
785
|
|
|
725
|
-
uri:
|
|
786
|
+
uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
|
|
726
787
|
} as COMModel;
|
|
727
788
|
testCom.PerformAction('ADD_OBJECT', payload);
|
|
728
789
|
const success = testCom.PerformAction('MODEL_LOADED', {
|
|
@@ -753,8 +814,8 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
753
814
|
|
|
754
815
|
it('should perform action GENERATE_MEDIA', () => {
|
|
755
816
|
const mock1 = {
|
|
756
|
-
entityType:
|
|
757
|
-
id:
|
|
817
|
+
entityType: 'pov',
|
|
818
|
+
id: 'test1',
|
|
758
819
|
position: { x: 0, y: 0, z: 0 },
|
|
759
820
|
target: { x: 0, y: 0, z: 0 },
|
|
760
821
|
} as COMPov;
|
|
@@ -780,26 +841,26 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
780
841
|
|
|
781
842
|
it('should perform action SET_PARENT', () => {
|
|
782
843
|
const object = {
|
|
783
|
-
id:
|
|
844
|
+
id: 'object',
|
|
784
845
|
} as COMEntity;
|
|
785
846
|
testCom.PerformAction('ADD_OBJECT', object);
|
|
786
847
|
|
|
787
848
|
const objectNotRegistered = {
|
|
788
|
-
id:
|
|
849
|
+
id: 'objectNotRegistered',
|
|
789
850
|
} as COMEntity;
|
|
790
851
|
|
|
791
852
|
const parent0 = {
|
|
792
|
-
id:
|
|
853
|
+
id: 'parent0',
|
|
793
854
|
} as COMEntity;
|
|
794
855
|
testCom.PerformAction('ADD_OBJECT', parent0);
|
|
795
856
|
|
|
796
857
|
const parent1 = {
|
|
797
|
-
id:
|
|
858
|
+
id: 'parent1',
|
|
798
859
|
} as COMEntity;
|
|
799
860
|
testCom.PerformAction('ADD_OBJECT', parent1);
|
|
800
861
|
|
|
801
862
|
const parentNotRegistered = {
|
|
802
|
-
id:
|
|
863
|
+
id: 'parentNotRegistered',
|
|
803
864
|
} as COMEntity;
|
|
804
865
|
|
|
805
866
|
const attachNotRegisteredObject = testCom.PerformAction('SET_PARENT', {
|
|
@@ -810,7 +871,7 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
810
871
|
|
|
811
872
|
jest.spyOn(mockScene, 'GetSceneObject').mockImplementationOnce(() => {
|
|
812
873
|
return undefined;
|
|
813
|
-
})
|
|
874
|
+
});
|
|
814
875
|
const attachNonSceneObject = testCom.PerformAction('SET_PARENT', {
|
|
815
876
|
object: object,
|
|
816
877
|
parent: null,
|
|
@@ -829,20 +890,25 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
829
890
|
});
|
|
830
891
|
expect(attachToItself).toBe(false);
|
|
831
892
|
|
|
832
|
-
const attachToNotRegsiteredParent = testCom.PerformAction(
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
893
|
+
const attachToNotRegsiteredParent = testCom.PerformAction(
|
|
894
|
+
'SET_PARENT',
|
|
895
|
+
{
|
|
896
|
+
object: object,
|
|
897
|
+
parent: parentNotRegistered,
|
|
898
|
+
},
|
|
899
|
+
);
|
|
836
900
|
expect(attachToNotRegsiteredParent).toBe(true);
|
|
837
901
|
|
|
838
|
-
jest.spyOn(mockScene, 'GetSceneObject')
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
902
|
+
jest.spyOn(mockScene, 'GetSceneObject')
|
|
903
|
+
.mockImplementationOnce(() => {
|
|
904
|
+
return {
|
|
905
|
+
DropIt: jest.fn(),
|
|
906
|
+
attach: jest.fn(),
|
|
907
|
+
} as unknown as DIVESceneObject;
|
|
908
|
+
})
|
|
909
|
+
.mockImplementationOnce(() => {
|
|
910
|
+
return undefined;
|
|
911
|
+
});
|
|
846
912
|
|
|
847
913
|
const attachtoNonSceneParent = testCom.PerformAction('SET_PARENT', {
|
|
848
914
|
object: object,
|