@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.
Files changed (143) hide show
  1. package/README.md +271 -40
  2. package/build/dive.cjs +575 -159
  3. package/build/dive.cjs.map +1 -1
  4. package/build/dive.d.cts +83 -57
  5. package/build/dive.d.ts +83 -57
  6. package/build/dive.js +614 -164
  7. package/build/dive.js.map +1 -1
  8. package/package.json +72 -60
  9. package/src/__test__/DIVE.test.ts +35 -31
  10. package/src/animation/AnimationSystem.ts +4 -4
  11. package/src/animation/__test__/AnimationSystem.test.ts +3 -3
  12. package/src/axiscamera/AxisCamera.ts +31 -11
  13. package/src/axiscamera/__test__/AxisCamera.test.ts +18 -10
  14. package/src/camera/PerspectiveCamera.ts +28 -13
  15. package/src/camera/__test__/PerspectiveCamera.test.ts +2 -2
  16. package/src/com/Communication.ts +282 -100
  17. package/src/com/__test__/Communication.test.ts +207 -141
  18. package/src/com/actions/camera/computeencompassingview.ts +8 -7
  19. package/src/com/actions/camera/getcameratransform.ts +8 -7
  20. package/src/com/actions/camera/movecamera.ts +16 -13
  21. package/src/com/actions/camera/resetcamera.ts +4 -3
  22. package/src/com/actions/camera/setcameralayer.ts +4 -3
  23. package/src/com/actions/camera/setcameratransform.ts +8 -7
  24. package/src/com/actions/camera/zoomcamera.ts +4 -3
  25. package/src/com/actions/index.ts +54 -54
  26. package/src/com/actions/media/generatemedia.ts +17 -13
  27. package/src/com/actions/object/addobject.ts +5 -4
  28. package/src/com/actions/object/deleteobject.ts +5 -4
  29. package/src/com/actions/object/deselectobject.ts +5 -4
  30. package/src/com/actions/object/getallobjects.ts +5 -4
  31. package/src/com/actions/object/getobjects.ts +5 -4
  32. package/src/com/actions/object/model/dropit.ts +4 -3
  33. package/src/com/actions/object/model/modelloaded.ts +4 -3
  34. package/src/com/actions/object/model/placeonfloor.ts +4 -3
  35. package/src/com/actions/object/selectobject.ts +5 -4
  36. package/src/com/actions/object/setparent.ts +8 -7
  37. package/src/com/actions/object/updateobject.ts +5 -4
  38. package/src/com/actions/scene/exportscene.ts +5 -4
  39. package/src/com/actions/scene/getallscenedata.ts +24 -18
  40. package/src/com/actions/scene/setbackground.ts +4 -3
  41. package/src/com/actions/scene/updatescene.ts +10 -9
  42. package/src/com/actions/toolbox/select/setgizmomode.ts +4 -3
  43. package/src/com/actions/toolbox/transform/setgizmovisible.ts +4 -3
  44. package/src/com/actions/toolbox/usetool.ts +5 -4
  45. package/src/com/types/COMBaseEntity.ts +2 -2
  46. package/src/com/types/COMEntity.ts +6 -6
  47. package/src/com/types/COMEntityType.ts +1 -1
  48. package/src/com/types/COMGeometry.ts +2 -2
  49. package/src/com/types/COMGroup.ts +3 -3
  50. package/src/com/types/COMLight.ts +3 -3
  51. package/src/com/types/COMMaterial.ts +2 -2
  52. package/src/com/types/COMModel.ts +4 -4
  53. package/src/com/types/COMPov.ts +3 -3
  54. package/src/com/types/COMPrimitive.ts +5 -5
  55. package/src/com/types/index.ts +10 -10
  56. package/src/constant/AxisHelperColors.ts +1 -1
  57. package/src/constant/GridColors.ts +1 -1
  58. package/src/controls/OrbitControls.ts +62 -29
  59. package/src/controls/__test__/OrbitControls.test.ts +133 -39
  60. package/src/dive.ts +82 -36
  61. package/src/gizmo/Gizmo.ts +21 -13
  62. package/src/gizmo/handles/AxisHandle.ts +40 -17
  63. package/src/gizmo/handles/RadialHandle.ts +39 -15
  64. package/src/gizmo/handles/ScaleHandle.ts +62 -25
  65. package/src/gizmo/plane/GizmoPlane.ts +5 -6
  66. package/src/gizmo/rotate/RotateGizmo.ts +58 -16
  67. package/src/gizmo/scale/ScaleGizmo.ts +37 -15
  68. package/src/gizmo/translate/TranslateGizmo.ts +34 -14
  69. package/src/grid/Grid.ts +13 -5
  70. package/src/grid/__test__/Grid.test.ts +5 -3
  71. package/src/group/Group.ts +9 -7
  72. package/src/group/__test__/Group.test.ts +8 -6
  73. package/src/helper/applyMixins/__test__/applyMixins.test.ts +9 -6
  74. package/src/helper/applyMixins/applyMixins.ts +6 -3
  75. package/src/helper/findInterface/__test__/findInterface.test.ts +28 -18
  76. package/src/helper/findInterface/findInterface.ts +7 -4
  77. package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +1 -1
  78. package/src/helper/findSceneRecursive/findSceneRecursive.ts +1 -1
  79. package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +43 -7
  80. package/src/helper/getObjectDelta/getObjectDelta.ts +13 -9
  81. package/src/helper/isInterface/__test__/implementsInterface.test.ts +1 -1
  82. package/src/helper/isInterface/implementsInterface.ts +6 -3
  83. package/src/info/Info.ts +20 -16
  84. package/src/info/__test__/Info.test.ts +67 -36
  85. package/src/interface/Draggable.ts +2 -2
  86. package/src/interface/Hoverable.ts +2 -2
  87. package/src/interface/Movable.ts +1 -1
  88. package/src/interface/Rotatable.ts +1 -1
  89. package/src/interface/Scalable.ts +1 -1
  90. package/src/io/IO.ts +21 -43
  91. package/src/io/__test__/IO.test.ts +16 -62
  92. package/src/io/gltf/GLTFIO.ts +34 -31
  93. package/src/io/gltf/__test__/GLTFIO.test.ts +88 -78
  94. package/src/light/PointLight.ts +42 -9
  95. package/src/light/SceneLight.ts +5 -5
  96. package/src/light/__test__/AmbientLight.test.ts +5 -4
  97. package/src/light/__test__/PointLight.test.ts +14 -10
  98. package/src/light/__test__/SceneLight.test.ts +19 -13
  99. package/src/loadingmanager/LoadingManager.ts +11 -6
  100. package/src/loadingmanager/__test__/LoadingManager.test.ts +14 -9
  101. package/src/math/__test__/DIVEMath.test.ts +1 -1
  102. package/src/math/ceil/__test__/ceilExp.test.ts +1 -1
  103. package/src/math/ceil/ceilExp.ts +2 -2
  104. package/src/math/floor/__test__/floorExp.test.ts +1 -1
  105. package/src/math/floor/floorExp.ts +2 -2
  106. package/src/math/helper/__test__/shift.test.ts +1 -1
  107. package/src/math/helper/shift.ts +1 -1
  108. package/src/math/index.ts +7 -7
  109. package/src/math/round/__test__/roundExp.test.ts +1 -1
  110. package/src/math/round/roundExp.ts +6 -3
  111. package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +10 -4
  112. package/src/math/signedAngleTo/signedAngleTo.ts +11 -4
  113. package/src/math/toFixed/__test__/toFixedExp.test.ts +9 -9
  114. package/src/math/toFixed/toFixedExp.ts +6 -3
  115. package/src/math/truncate/__test__/truncateExp.test.ts +1 -1
  116. package/src/math/truncate/truncateExp.ts +6 -3
  117. package/src/mediacreator/MediaCreator.ts +20 -10
  118. package/src/mediacreator/__test__/MediaCreator.test.ts +27 -12
  119. package/src/model/Model.ts +35 -7
  120. package/src/model/__test__/Model.test.ts +71 -44
  121. package/src/node/Node.ts +34 -12
  122. package/src/node/__test__/Node.test.ts +17 -13
  123. package/src/primitive/Primitive.ts +78 -13
  124. package/src/primitive/__test__/Primitive.test.ts +49 -38
  125. package/src/primitive/floor/Floor.ts +14 -3
  126. package/src/primitive/floor/__test__/Floor.test.ts +10 -4
  127. package/src/renderer/Renderer.ts +46 -15
  128. package/src/renderer/__test__/Renderer.test.ts +74 -24
  129. package/src/scene/Scene.ts +9 -3
  130. package/src/scene/__test__/Scene.test.ts +2 -2
  131. package/src/scene/root/Root.ts +142 -75
  132. package/src/scene/root/__test__/Root.test.ts +439 -111
  133. package/src/toolbox/BaseTool.ts +69 -33
  134. package/src/toolbox/Toolbox.ts +37 -17
  135. package/src/toolbox/__test__/BaseTool.test.ts +324 -160
  136. package/src/toolbox/__test__/Toolbox.test.ts +31 -14
  137. package/src/toolbox/select/SelectTool.ts +24 -19
  138. package/src/toolbox/select/__test__/SelectTool.test.ts +95 -59
  139. package/src/toolbox/transform/TransformTool.ts +40 -17
  140. package/src/toolbox/transform/__test__/TransformTool.test.ts +22 -15
  141. package/src/types/SceneObjects.ts +8 -8
  142. package/src/types/SceneType.ts +3 -3
  143. 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 { type COMGroup, type COMEntity, type COMEntityType, type COMLight, type COMModel, type COMPov, type COMPrimitive } from '../types';
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(mockRenderer, mockScene, mockController, mockToolBox);
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: "light",
252
- id: "ambient00",
253
- type: "ambient",
263
+ entityType: 'light',
264
+ id: 'ambient00',
265
+ type: 'ambient',
254
266
  intensity: 0.5,
255
267
  color: 'white',
256
268
  } as COMLight;
257
- expect(() => testCom.PerformAction('ADD_OBJECT', payload)).not.toThrow();
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: "light",
263
- id: "ambient00",
264
- type: "ambient",
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: "light",
276
- id: "ambient00",
277
- type: "ambient",
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: "light",
289
- id: "ambient00",
290
- type: "ambient",
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: "light",
305
- id: "ambient00",
306
- type: "ambient",
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: "light",
318
- id: "ambient00",
319
- type: "ambient",
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: "light",
334
- id: "ambient00",
335
- type: "ambient",
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: "model",
356
- id: "model",
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: "https://threejs.org/examples/models/gltf/LittlestTokyo.glb",
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: "model",
376
- id: "model",
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: "https://threejs.org/examples/models/gltf/LittlestTokyo.glb",
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: "model",
393
- id: "model",
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: "https://threejs.org/examples/models/gltf/LittlestTokyo.glb",
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: "model" as COMEntityType,
413
- id: "model",
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: "https://threejs.org/examples/models/gltf/LittlestTokyo.glb",
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: "model",
430
- id: "model",
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: "https://threejs.org/examples/models/gltf/LittlestTokyo.glb",
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: "pov",
466
- id: "pov",
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('COMPUTE_ENCOMPASSING_VIEW', payload);
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: "pov",
506
- id: "pov",
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: "model",
513
- id: "model",
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: "https://threejs.org/examples/models/gltf/LittlestTokyo.glb",
535
+ uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
519
536
  } as COMModel);
520
537
 
521
538
  testCom.PerformAction('ADD_OBJECT', {
522
- entityType: "light",
523
- id: "ambient00",
524
- type: "ambient",
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: "group",
531
- id: "group1",
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: "#ffffff",
540
- cameras: [{
541
- entityType: "pov",
542
- id: "pov",
543
- position: { x: 0, y: 0, z: 0 },
544
- target: { x: 0, y: 0, z: 0 },
545
- parentId: null,
546
- }],
547
- floorColor: "#ffffff",
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
- entityType: "light",
551
- id: "ambient00",
552
- type: "ambient",
553
- intensity: 0.5,
554
- color: 'white',
555
- parentId: null,
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
- entityType: "model",
561
- id: "model",
562
- position: { x: 0, y: 0, z: 0 },
563
- rotation: { x: 0, y: 0, z: 0 },
564
- scale: { x: 0.01, y: 0.01, z: 0.01 },
565
- parentId: null,
566
- uri: "https://threejs.org/examples/models/gltf/LittlestTokyo.glb",
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
- entityType: "group",
576
- id: "group1",
577
- position: { x: 0, y: 0, z: 0 },
578
- rotation: { x: 0, y: 0, z: 0 },
579
- parentId: null,
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: "pov",
587
- id: "test0",
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: "pov",
595
- id: "test1",
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', { ids: [] });
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', { ids: ['test1'] });
605
- expect(Array.from(successWithIds.values())).toStrictEqual([{ entityType: "pov", id: "test1", position: { x: 0, y: 0, z: 0 }, target: { x: 0, y: 0, z: 0 }, parentId: null }]);
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', { id: 'test0' });
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: "pov",
614
- id: "test0",
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', { id: 'test0' });
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({} as unknown as DIVESceneObject);
625
- const success2 = testCom.PerformAction('SELECT_OBJECT', { id: 'test0' });
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({ isSelectable: true } as unknown as DIVESceneObject);
629
- const success3 = testCom.PerformAction('SELECT_OBJECT', { id: 'test0' });
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', { id: 'test0' });
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: "pov",
639
- id: "test0",
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', { id: 'test0' });
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({} as unknown as DIVESceneObject);
650
- const success2 = testCom.PerformAction('DESELECT_OBJECT', { id: 'test0' });
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({ isSelectable: true } as unknown as DIVESceneObject);
654
- const success3 = testCom.PerformAction('DESELECT_OBJECT', { id: 'test0' });
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: "model",
720
- id: "modelID",
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: "https://threejs.org/examples/models/gltf/LittlestTokyo.glb",
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: "pov",
757
- id: "test1",
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: "object",
844
+ id: 'object',
784
845
  } as COMEntity;
785
846
  testCom.PerformAction('ADD_OBJECT', object);
786
847
 
787
848
  const objectNotRegistered = {
788
- id: "objectNotRegistered",
849
+ id: 'objectNotRegistered',
789
850
  } as COMEntity;
790
851
 
791
852
  const parent0 = {
792
- id: "parent0",
853
+ id: 'parent0',
793
854
  } as COMEntity;
794
855
  testCom.PerformAction('ADD_OBJECT', parent0);
795
856
 
796
857
  const parent1 = {
797
- id: "parent1",
858
+ id: 'parent1',
798
859
  } as COMEntity;
799
860
  testCom.PerformAction('ADD_OBJECT', parent1);
800
861
 
801
862
  const parentNotRegistered = {
802
- id: "parentNotRegistered",
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('SET_PARENT', {
833
- object: object,
834
- parent: parentNotRegistered,
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').mockImplementationOnce(() => {
839
- return {
840
- DropIt: jest.fn(),
841
- attach: jest.fn(),
842
- } as unknown as DIVESceneObject;
843
- }).mockImplementationOnce(() => {
844
- return undefined;
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,