@shopware-ag/dive 1.16.0 → 1.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +271 -40
- package/build/dive.cjs +575 -159
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +83 -57
- package/build/dive.d.ts +83 -57
- package/build/dive.js +614 -164
- package/build/dive.js.map +1 -1
- package/package.json +72 -60
- package/src/__test__/DIVE.test.ts +35 -31
- package/src/animation/AnimationSystem.ts +4 -4
- package/src/animation/__test__/AnimationSystem.test.ts +3 -3
- package/src/axiscamera/AxisCamera.ts +31 -11
- package/src/axiscamera/__test__/AxisCamera.test.ts +18 -10
- package/src/camera/PerspectiveCamera.ts +28 -13
- package/src/camera/__test__/PerspectiveCamera.test.ts +2 -2
- package/src/com/Communication.ts +282 -100
- package/src/com/__test__/Communication.test.ts +207 -141
- package/src/com/actions/camera/computeencompassingview.ts +8 -7
- package/src/com/actions/camera/getcameratransform.ts +8 -7
- package/src/com/actions/camera/movecamera.ts +16 -13
- package/src/com/actions/camera/resetcamera.ts +4 -3
- package/src/com/actions/camera/setcameralayer.ts +4 -3
- package/src/com/actions/camera/setcameratransform.ts +8 -7
- package/src/com/actions/camera/zoomcamera.ts +4 -3
- package/src/com/actions/index.ts +54 -54
- package/src/com/actions/media/generatemedia.ts +17 -13
- package/src/com/actions/object/addobject.ts +5 -4
- package/src/com/actions/object/deleteobject.ts +5 -4
- package/src/com/actions/object/deselectobject.ts +5 -4
- package/src/com/actions/object/getallobjects.ts +5 -4
- package/src/com/actions/object/getobjects.ts +5 -4
- package/src/com/actions/object/model/dropit.ts +4 -3
- package/src/com/actions/object/model/modelloaded.ts +4 -3
- package/src/com/actions/object/model/placeonfloor.ts +4 -3
- package/src/com/actions/object/selectobject.ts +5 -4
- package/src/com/actions/object/setparent.ts +8 -7
- package/src/com/actions/object/updateobject.ts +5 -4
- package/src/com/actions/scene/exportscene.ts +5 -4
- package/src/com/actions/scene/getallscenedata.ts +24 -18
- package/src/com/actions/scene/setbackground.ts +4 -3
- package/src/com/actions/scene/updatescene.ts +10 -9
- package/src/com/actions/toolbox/select/setgizmomode.ts +4 -3
- package/src/com/actions/toolbox/transform/setgizmovisible.ts +4 -3
- package/src/com/actions/toolbox/usetool.ts +5 -4
- package/src/com/types/COMBaseEntity.ts +2 -2
- package/src/com/types/COMEntity.ts +6 -6
- package/src/com/types/COMEntityType.ts +1 -1
- package/src/com/types/COMGeometry.ts +2 -2
- package/src/com/types/COMGroup.ts +3 -3
- package/src/com/types/COMLight.ts +3 -3
- package/src/com/types/COMMaterial.ts +2 -2
- package/src/com/types/COMModel.ts +4 -4
- package/src/com/types/COMPov.ts +3 -3
- package/src/com/types/COMPrimitive.ts +5 -5
- package/src/com/types/index.ts +10 -10
- package/src/constant/AxisHelperColors.ts +1 -1
- package/src/constant/GridColors.ts +1 -1
- package/src/controls/OrbitControls.ts +62 -29
- package/src/controls/__test__/OrbitControls.test.ts +133 -39
- package/src/dive.ts +82 -36
- package/src/gizmo/Gizmo.ts +21 -13
- package/src/gizmo/handles/AxisHandle.ts +40 -17
- package/src/gizmo/handles/RadialHandle.ts +39 -15
- package/src/gizmo/handles/ScaleHandle.ts +62 -25
- package/src/gizmo/plane/GizmoPlane.ts +5 -6
- package/src/gizmo/rotate/RotateGizmo.ts +58 -16
- package/src/gizmo/scale/ScaleGizmo.ts +37 -15
- package/src/gizmo/translate/TranslateGizmo.ts +34 -14
- package/src/grid/Grid.ts +13 -5
- package/src/grid/__test__/Grid.test.ts +5 -3
- package/src/group/Group.ts +9 -7
- package/src/group/__test__/Group.test.ts +8 -6
- package/src/helper/applyMixins/__test__/applyMixins.test.ts +9 -6
- package/src/helper/applyMixins/applyMixins.ts +6 -3
- package/src/helper/findInterface/__test__/findInterface.test.ts +28 -18
- package/src/helper/findInterface/findInterface.ts +7 -4
- package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +1 -1
- package/src/helper/findSceneRecursive/findSceneRecursive.ts +1 -1
- package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +43 -7
- package/src/helper/getObjectDelta/getObjectDelta.ts +13 -9
- package/src/helper/isInterface/__test__/implementsInterface.test.ts +1 -1
- package/src/helper/isInterface/implementsInterface.ts +6 -3
- package/src/info/Info.ts +20 -16
- package/src/info/__test__/Info.test.ts +67 -36
- package/src/interface/Draggable.ts +2 -2
- package/src/interface/Hoverable.ts +2 -2
- package/src/interface/Movable.ts +1 -1
- package/src/interface/Rotatable.ts +1 -1
- package/src/interface/Scalable.ts +1 -1
- package/src/io/IO.ts +21 -43
- package/src/io/__test__/IO.test.ts +16 -62
- package/src/io/gltf/GLTFIO.ts +34 -31
- package/src/io/gltf/__test__/GLTFIO.test.ts +88 -78
- package/src/light/PointLight.ts +42 -9
- package/src/light/SceneLight.ts +5 -5
- package/src/light/__test__/AmbientLight.test.ts +5 -4
- package/src/light/__test__/PointLight.test.ts +14 -10
- package/src/light/__test__/SceneLight.test.ts +19 -13
- package/src/loadingmanager/LoadingManager.ts +11 -6
- package/src/loadingmanager/__test__/LoadingManager.test.ts +14 -9
- package/src/math/__test__/DIVEMath.test.ts +1 -1
- package/src/math/ceil/__test__/ceilExp.test.ts +1 -1
- package/src/math/ceil/ceilExp.ts +2 -2
- package/src/math/floor/__test__/floorExp.test.ts +1 -1
- package/src/math/floor/floorExp.ts +2 -2
- package/src/math/helper/__test__/shift.test.ts +1 -1
- package/src/math/helper/shift.ts +1 -1
- package/src/math/index.ts +7 -7
- package/src/math/round/__test__/roundExp.test.ts +1 -1
- package/src/math/round/roundExp.ts +6 -3
- package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +10 -4
- package/src/math/signedAngleTo/signedAngleTo.ts +11 -4
- package/src/math/toFixed/__test__/toFixedExp.test.ts +9 -9
- package/src/math/toFixed/toFixedExp.ts +6 -3
- package/src/math/truncate/__test__/truncateExp.test.ts +1 -1
- package/src/math/truncate/truncateExp.ts +6 -3
- package/src/mediacreator/MediaCreator.ts +20 -10
- package/src/mediacreator/__test__/MediaCreator.test.ts +27 -12
- package/src/model/Model.ts +35 -7
- package/src/model/__test__/Model.test.ts +71 -44
- package/src/node/Node.ts +34 -12
- package/src/node/__test__/Node.test.ts +17 -13
- package/src/primitive/Primitive.ts +78 -13
- package/src/primitive/__test__/Primitive.test.ts +49 -38
- package/src/primitive/floor/Floor.ts +14 -3
- package/src/primitive/floor/__test__/Floor.test.ts +10 -4
- package/src/renderer/Renderer.ts +46 -15
- package/src/renderer/__test__/Renderer.test.ts +74 -24
- package/src/scene/Scene.ts +9 -3
- package/src/scene/__test__/Scene.test.ts +2 -2
- package/src/scene/root/Root.ts +142 -75
- package/src/scene/root/__test__/Root.test.ts +439 -111
- package/src/toolbox/BaseTool.ts +69 -33
- package/src/toolbox/Toolbox.ts +37 -17
- package/src/toolbox/__test__/BaseTool.test.ts +324 -160
- package/src/toolbox/__test__/Toolbox.test.ts +31 -14
- package/src/toolbox/select/SelectTool.ts +24 -19
- package/src/toolbox/select/__test__/SelectTool.test.ts +95 -59
- package/src/toolbox/transform/TransformTool.ts +40 -17
- package/src/toolbox/transform/__test__/TransformTool.test.ts +22 -15
- package/src/types/SceneObjects.ts +8 -8
- package/src/types/SceneType.ts +3 -3
- package/src/types/index.ts +3 -6
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { DIVERoot } from '../Root';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type COMPrimitive,
|
|
4
|
+
type COMLight,
|
|
5
|
+
type COMModel,
|
|
6
|
+
type COMPov,
|
|
7
|
+
type COMEntity,
|
|
8
|
+
type COMGeometry,
|
|
9
|
+
COMGroup,
|
|
10
|
+
} from '../../../com/types';
|
|
3
11
|
import { type DIVEScene } from '../../Scene';
|
|
4
12
|
import { DIVECommunication } from '../../../com/Communication';
|
|
5
13
|
import { type DIVESceneObject } from '../../../types';
|
|
@@ -35,7 +43,7 @@ jest.mock('three', () => {
|
|
|
35
43
|
this.setY = (y: number) => {
|
|
36
44
|
this.y = y;
|
|
37
45
|
return this;
|
|
38
|
-
}
|
|
46
|
+
};
|
|
39
47
|
this.add = (vec3: Vector3) => {
|
|
40
48
|
this.x += vec3.x;
|
|
41
49
|
this.y += vec3.y;
|
|
@@ -68,20 +76,20 @@ jest.mock('three', () => {
|
|
|
68
76
|
far: 0,
|
|
69
77
|
fov: 0,
|
|
70
78
|
},
|
|
71
|
-
}
|
|
79
|
+
};
|
|
72
80
|
this.add = jest.fn();
|
|
73
81
|
this.attach = jest.fn();
|
|
74
82
|
this.remove = jest.fn();
|
|
75
83
|
this.sub = jest.fn();
|
|
76
|
-
this.children = [
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
this.children = [
|
|
85
|
+
{
|
|
86
|
+
visible: true,
|
|
87
|
+
material: {
|
|
88
|
+
color: {},
|
|
89
|
+
},
|
|
90
|
+
userData: {},
|
|
83
91
|
},
|
|
84
|
-
|
|
92
|
+
];
|
|
85
93
|
this.userData = {};
|
|
86
94
|
this.position = new Vector3();
|
|
87
95
|
this.rotation = {
|
|
@@ -188,7 +196,7 @@ jest.mock('three', () => {
|
|
|
188
196
|
Color: jest.fn(function () {
|
|
189
197
|
return this;
|
|
190
198
|
}),
|
|
191
|
-
}
|
|
199
|
+
};
|
|
192
200
|
});
|
|
193
201
|
|
|
194
202
|
jest.mock('../../../com/Communication.ts', () => {
|
|
@@ -197,9 +205,9 @@ jest.mock('../../../com/Communication.ts', () => {
|
|
|
197
205
|
get: jest.fn(() => {
|
|
198
206
|
return {
|
|
199
207
|
PerformAction: jest.fn(),
|
|
200
|
-
}
|
|
208
|
+
};
|
|
201
209
|
}),
|
|
202
|
-
}
|
|
210
|
+
},
|
|
203
211
|
};
|
|
204
212
|
});
|
|
205
213
|
|
|
@@ -209,7 +217,7 @@ jest.mock('../../../loadingmanager/LoadingManager.ts', () => {
|
|
|
209
217
|
DIVELoadingManager: jest.fn(function () {
|
|
210
218
|
this.LoadGLTF = mock_LoadGLTF;
|
|
211
219
|
return this;
|
|
212
|
-
})
|
|
220
|
+
}),
|
|
213
221
|
};
|
|
214
222
|
});
|
|
215
223
|
|
|
@@ -242,7 +250,7 @@ jest.mock('../../../light/AmbientLight.ts', () => {
|
|
|
242
250
|
this.dispatchEvent = jest.fn();
|
|
243
251
|
this.position = {
|
|
244
252
|
set: jest.fn(),
|
|
245
|
-
}
|
|
253
|
+
};
|
|
246
254
|
this.parent = {
|
|
247
255
|
attach: jest.fn(),
|
|
248
256
|
};
|
|
@@ -255,7 +263,7 @@ jest.mock('../../../light/AmbientLight.ts', () => {
|
|
|
255
263
|
this.SetColor = jest.fn();
|
|
256
264
|
this.userData = {
|
|
257
265
|
id: undefined,
|
|
258
|
-
}
|
|
266
|
+
};
|
|
259
267
|
this.removeFromParent = jest.fn();
|
|
260
268
|
return this;
|
|
261
269
|
});
|
|
@@ -268,7 +276,7 @@ jest.mock('../../../light/PointLight.ts', () => {
|
|
|
268
276
|
this.dispatchEvent = jest.fn();
|
|
269
277
|
this.position = {
|
|
270
278
|
set: jest.fn(),
|
|
271
|
-
}
|
|
279
|
+
};
|
|
272
280
|
this.parent = {
|
|
273
281
|
attach: jest.fn(),
|
|
274
282
|
};
|
|
@@ -281,7 +289,7 @@ jest.mock('../../../light/PointLight.ts', () => {
|
|
|
281
289
|
this.SetColor = jest.fn();
|
|
282
290
|
this.userData = {
|
|
283
291
|
id: undefined,
|
|
284
|
-
}
|
|
292
|
+
};
|
|
285
293
|
this.removeFromParent = jest.fn();
|
|
286
294
|
return this;
|
|
287
295
|
});
|
|
@@ -294,7 +302,7 @@ jest.mock('../../../light/SceneLight.ts', () => {
|
|
|
294
302
|
this.dispatchEvent = jest.fn();
|
|
295
303
|
this.position = {
|
|
296
304
|
set: jest.fn(),
|
|
297
|
-
}
|
|
305
|
+
};
|
|
298
306
|
this.parent = {
|
|
299
307
|
attach: jest.fn(),
|
|
300
308
|
};
|
|
@@ -307,7 +315,7 @@ jest.mock('../../../light/SceneLight.ts', () => {
|
|
|
307
315
|
this.SetColor = jest.fn();
|
|
308
316
|
this.userData = {
|
|
309
317
|
id: undefined,
|
|
310
|
-
}
|
|
318
|
+
};
|
|
311
319
|
this.removeFromParent = jest.fn();
|
|
312
320
|
return this;
|
|
313
321
|
});
|
|
@@ -338,7 +346,7 @@ jest.mock('../../../model/Model.ts', () => {
|
|
|
338
346
|
this.PlaceOnFloor = jest.fn();
|
|
339
347
|
this.removeFromParent = jest.fn();
|
|
340
348
|
return this;
|
|
341
|
-
})
|
|
349
|
+
}),
|
|
342
350
|
};
|
|
343
351
|
});
|
|
344
352
|
|
|
@@ -367,7 +375,7 @@ jest.mock('../../../primitive/Primitive.ts', () => {
|
|
|
367
375
|
this.PlaceOnFloor = jest.fn();
|
|
368
376
|
this.removeFromParent = jest.fn();
|
|
369
377
|
return this;
|
|
370
|
-
})
|
|
378
|
+
}),
|
|
371
379
|
};
|
|
372
380
|
});
|
|
373
381
|
|
|
@@ -398,13 +406,13 @@ jest.mock('../../../group/Group.ts', () => {
|
|
|
398
406
|
this.PlaceOnFloor = jest.fn();
|
|
399
407
|
this.removeFromParent = jest.fn();
|
|
400
408
|
return this;
|
|
401
|
-
})
|
|
409
|
+
}),
|
|
402
410
|
};
|
|
403
411
|
});
|
|
404
412
|
|
|
405
413
|
let root: DIVERoot;
|
|
406
414
|
|
|
407
|
-
jest.spyOn(console, 'warn').mockImplementation(() => {
|
|
415
|
+
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
408
416
|
|
|
409
417
|
describe('DIVE/scene/root/DIVERoot', () => {
|
|
410
418
|
beforeEach(() => {
|
|
@@ -425,51 +433,166 @@ describe('DIVE/scene/root/DIVERoot', () => {
|
|
|
425
433
|
});
|
|
426
434
|
|
|
427
435
|
it('should get scene object', async () => {
|
|
428
|
-
root.children = [
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
436
|
+
root.children = [
|
|
437
|
+
{
|
|
438
|
+
userData: {
|
|
439
|
+
id: 'different_id',
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
] as unknown as DIVESceneObject[];
|
|
433
443
|
expect(root.GetSceneObject({ id: 'test_id' })).toBeUndefined();
|
|
434
444
|
|
|
435
|
-
expect(() =>
|
|
436
|
-
|
|
437
|
-
name: 'test',
|
|
438
|
-
entityType: 'primitive',
|
|
439
|
-
position: { x: 1, y: 2, z: 3 },
|
|
440
|
-
rotation: { x: 1, y: 2, z: 3 },
|
|
441
|
-
scale: { x: 1, y: 2, z: 3 },
|
|
442
|
-
geometry: {} as COMGeometry,
|
|
443
|
-
visible: true,
|
|
444
|
-
parentId: null,
|
|
445
|
-
})).not.toThrow();
|
|
446
|
-
root.children = [{
|
|
447
|
-
userData: {
|
|
445
|
+
expect(() =>
|
|
446
|
+
root.AddSceneObject({
|
|
448
447
|
id: 'test_id',
|
|
449
|
-
|
|
450
|
-
|
|
448
|
+
name: 'test',
|
|
449
|
+
entityType: 'primitive',
|
|
450
|
+
position: { x: 1, y: 2, z: 3 },
|
|
451
|
+
rotation: { x: 1, y: 2, z: 3 },
|
|
452
|
+
scale: { x: 1, y: 2, z: 3 },
|
|
453
|
+
geometry: {} as COMGeometry,
|
|
454
|
+
visible: true,
|
|
455
|
+
parentId: null,
|
|
456
|
+
}),
|
|
457
|
+
).not.toThrow();
|
|
458
|
+
root.children = [
|
|
459
|
+
{
|
|
460
|
+
userData: {
|
|
461
|
+
id: 'test_id',
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
] as unknown as DIVESceneObject[];
|
|
451
465
|
expect(root.GetSceneObject({ id: 'test_id' })).toBeDefined();
|
|
452
466
|
});
|
|
453
467
|
|
|
454
468
|
it('should add object', () => {
|
|
455
|
-
expect(() =>
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
expect(() =>
|
|
469
|
+
expect(() =>
|
|
470
|
+
root.AddSceneObject({
|
|
471
|
+
id: 'id',
|
|
472
|
+
name: 'pov',
|
|
473
|
+
entityType: 'pov',
|
|
474
|
+
visible: true,
|
|
475
|
+
} as COMPov),
|
|
476
|
+
).not.toThrow();
|
|
477
|
+
|
|
478
|
+
expect(() =>
|
|
479
|
+
root.AddSceneObject({
|
|
480
|
+
id: 'id',
|
|
481
|
+
name: 'light',
|
|
482
|
+
entityType: 'light',
|
|
483
|
+
visible: true,
|
|
484
|
+
} as COMLight),
|
|
485
|
+
).not.toThrow();
|
|
486
|
+
expect(() =>
|
|
487
|
+
root.AddSceneObject({
|
|
488
|
+
id: 'id_scene',
|
|
489
|
+
name: 'light',
|
|
490
|
+
entityType: 'light',
|
|
491
|
+
visible: true,
|
|
492
|
+
type: 'scene',
|
|
493
|
+
} as COMLight),
|
|
494
|
+
).not.toThrow();
|
|
495
|
+
expect(() =>
|
|
496
|
+
root.AddSceneObject({
|
|
497
|
+
id: 'id_ambient',
|
|
498
|
+
name: 'light',
|
|
499
|
+
entityType: 'light',
|
|
500
|
+
visible: true,
|
|
501
|
+
type: 'ambient',
|
|
502
|
+
} as COMLight),
|
|
503
|
+
).not.toThrow();
|
|
504
|
+
expect(() =>
|
|
505
|
+
root.AddSceneObject({
|
|
506
|
+
id: 'id_point',
|
|
507
|
+
name: 'light',
|
|
508
|
+
entityType: 'light',
|
|
509
|
+
visible: true,
|
|
510
|
+
type: 'point',
|
|
511
|
+
position: { x: 0, y: 0, z: 0 },
|
|
512
|
+
intensity: 1,
|
|
513
|
+
enabled: false,
|
|
514
|
+
color: 0xffffff,
|
|
515
|
+
parentId: 'id',
|
|
516
|
+
} as COMLight),
|
|
517
|
+
).not.toThrow();
|
|
518
|
+
|
|
519
|
+
expect(() =>
|
|
520
|
+
root.AddSceneObject({
|
|
521
|
+
id: 'id',
|
|
522
|
+
name: 'model',
|
|
523
|
+
entityType: 'model',
|
|
524
|
+
visible: true,
|
|
525
|
+
} as COMModel),
|
|
526
|
+
).not.toThrow();
|
|
527
|
+
expect(() =>
|
|
528
|
+
root.AddSceneObject({
|
|
529
|
+
id: 'id_uri0',
|
|
530
|
+
name: 'model',
|
|
531
|
+
entityType: 'model',
|
|
532
|
+
visible: true,
|
|
533
|
+
uri: 'uri',
|
|
534
|
+
position: { x: 0, y: 0, z: 0 },
|
|
535
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
536
|
+
scale: { x: 1, y: 1, z: 1 },
|
|
537
|
+
material: {},
|
|
538
|
+
parentId: 'id',
|
|
539
|
+
} as COMModel),
|
|
540
|
+
).not.toThrow();
|
|
465
541
|
jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
|
|
466
|
-
expect(() =>
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
542
|
+
expect(() =>
|
|
543
|
+
root.AddSceneObject({
|
|
544
|
+
id: 'id_uri1',
|
|
545
|
+
name: 'model',
|
|
546
|
+
entityType: 'model',
|
|
547
|
+
visible: true,
|
|
548
|
+
uri: 'uri',
|
|
549
|
+
position: { x: 0, y: 0, z: 0 },
|
|
550
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
551
|
+
scale: { x: 1, y: 1, z: 1 },
|
|
552
|
+
material: {},
|
|
553
|
+
} as COMModel),
|
|
554
|
+
).not.toThrow();
|
|
555
|
+
|
|
556
|
+
expect(() =>
|
|
557
|
+
root.AddSceneObject({
|
|
558
|
+
id: 'id0',
|
|
559
|
+
name: 'primitive',
|
|
560
|
+
entityType: 'primitive',
|
|
561
|
+
visible: true,
|
|
562
|
+
} as COMPrimitive),
|
|
563
|
+
).not.toThrow();
|
|
564
|
+
expect(() =>
|
|
565
|
+
root.AddSceneObject({
|
|
566
|
+
id: 'id1',
|
|
567
|
+
name: 'primitive',
|
|
568
|
+
entityType: 'primitive',
|
|
569
|
+
visible: true,
|
|
570
|
+
material: {},
|
|
571
|
+
parentId: 'id',
|
|
572
|
+
} as COMPrimitive),
|
|
573
|
+
).not.toThrow();
|
|
574
|
+
|
|
575
|
+
expect(() =>
|
|
576
|
+
root.AddSceneObject({
|
|
577
|
+
id: 'id0',
|
|
578
|
+
name: 'Group',
|
|
579
|
+
entityType: 'group',
|
|
580
|
+
visible: true,
|
|
581
|
+
} as COMGroup),
|
|
582
|
+
).not.toThrow();
|
|
583
|
+
expect(() =>
|
|
584
|
+
root.AddSceneObject({
|
|
585
|
+
id: 'id0',
|
|
586
|
+
name: 'Group',
|
|
587
|
+
entityType: 'group',
|
|
588
|
+
visible: true,
|
|
589
|
+
position: { x: 0, y: 0, z: 0 },
|
|
590
|
+
rotation: { x: 0, y: 0, z: 0 },
|
|
591
|
+
scale: { x: 1, y: 1, z: 1 },
|
|
592
|
+
bbVisible: true,
|
|
593
|
+
parentId: 'id',
|
|
594
|
+
} as COMGroup),
|
|
595
|
+
).not.toThrow();
|
|
473
596
|
});
|
|
474
597
|
|
|
475
598
|
it('should update object', () => {
|
|
@@ -508,19 +631,88 @@ describe('DIVE/scene/root/DIVERoot', () => {
|
|
|
508
631
|
remove: jest.fn(),
|
|
509
632
|
},
|
|
510
633
|
children: [],
|
|
511
|
-
} as unknown as Object3D
|
|
634
|
+
} as unknown as Object3D,
|
|
512
635
|
];
|
|
513
|
-
expect(() =>
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
expect(() =>
|
|
522
|
-
|
|
523
|
-
|
|
636
|
+
expect(() =>
|
|
637
|
+
root.UpdateSceneObject({
|
|
638
|
+
id: 'id',
|
|
639
|
+
name: 'pov',
|
|
640
|
+
entityType: 'pov',
|
|
641
|
+
visible: true,
|
|
642
|
+
} as COMPov),
|
|
643
|
+
).not.toThrow();
|
|
644
|
+
expect(() =>
|
|
645
|
+
root.UpdateSceneObject({
|
|
646
|
+
id: 'id',
|
|
647
|
+
name: 'light',
|
|
648
|
+
entityType: 'light',
|
|
649
|
+
visible: true,
|
|
650
|
+
} as COMLight),
|
|
651
|
+
).not.toThrow();
|
|
652
|
+
expect(() =>
|
|
653
|
+
root.UpdateSceneObject({
|
|
654
|
+
id: 'id',
|
|
655
|
+
name: 'model',
|
|
656
|
+
entityType: 'model',
|
|
657
|
+
visible: true,
|
|
658
|
+
} as COMModel),
|
|
659
|
+
).not.toThrow();
|
|
660
|
+
expect(() =>
|
|
661
|
+
root.UpdateSceneObject({
|
|
662
|
+
id: 'id',
|
|
663
|
+
name: 'primitive',
|
|
664
|
+
entityType: 'primitive',
|
|
665
|
+
visible: true,
|
|
666
|
+
} as COMPrimitive),
|
|
667
|
+
).not.toThrow();
|
|
668
|
+
expect(() =>
|
|
669
|
+
root.UpdateSceneObject({
|
|
670
|
+
id: 'id',
|
|
671
|
+
name: 'group',
|
|
672
|
+
entityType: 'group',
|
|
673
|
+
visible: true,
|
|
674
|
+
} as COMGroup),
|
|
675
|
+
).not.toThrow();
|
|
676
|
+
|
|
677
|
+
expect(() =>
|
|
678
|
+
root.AddSceneObject({
|
|
679
|
+
id: 'id_groupparent',
|
|
680
|
+
name: 'Group',
|
|
681
|
+
entityType: 'group',
|
|
682
|
+
} as COMGroup),
|
|
683
|
+
).not.toThrow();
|
|
684
|
+
expect(() =>
|
|
685
|
+
root.UpdateSceneObject({
|
|
686
|
+
id: 'id_groupchild',
|
|
687
|
+
name: 'group',
|
|
688
|
+
entityType: 'group',
|
|
689
|
+
parentId: 'id_groupparent',
|
|
690
|
+
} as COMGroup),
|
|
691
|
+
).not.toThrow();
|
|
692
|
+
expect(() =>
|
|
693
|
+
root.UpdateSceneObject({
|
|
694
|
+
id: 'id_groupchild',
|
|
695
|
+
name: 'group',
|
|
696
|
+
entityType: 'group',
|
|
697
|
+
parentId: null,
|
|
698
|
+
} as COMGroup),
|
|
699
|
+
).not.toThrow();
|
|
700
|
+
expect(() =>
|
|
701
|
+
root.UpdateSceneObject({
|
|
702
|
+
id: 'id_groupchild',
|
|
703
|
+
name: 'group',
|
|
704
|
+
entityType: 'group',
|
|
705
|
+
parentId: 'id_modelparent',
|
|
706
|
+
} as COMGroup),
|
|
707
|
+
).not.toThrow();
|
|
708
|
+
expect(() =>
|
|
709
|
+
root.UpdateSceneObject({
|
|
710
|
+
id: 'id_groupchild',
|
|
711
|
+
name: 'group',
|
|
712
|
+
entityType: 'group',
|
|
713
|
+
parentId: 'does_not_exist',
|
|
714
|
+
} as COMGroup),
|
|
715
|
+
).not.toThrow();
|
|
524
716
|
});
|
|
525
717
|
|
|
526
718
|
it('should delete object', () => {
|
|
@@ -531,9 +723,9 @@ describe('DIVE/scene/root/DIVERoot', () => {
|
|
|
531
723
|
{
|
|
532
724
|
isTransformControls: true,
|
|
533
725
|
detach: jest.fn(),
|
|
534
|
-
}
|
|
726
|
+
},
|
|
535
727
|
],
|
|
536
|
-
}
|
|
728
|
+
};
|
|
537
729
|
root.parent = sceneParent as unknown as DIVEScene;
|
|
538
730
|
|
|
539
731
|
root.children = [
|
|
@@ -544,35 +736,115 @@ describe('DIVE/scene/root/DIVERoot', () => {
|
|
|
544
736
|
SetVisibility: jest.fn(),
|
|
545
737
|
parent: root,
|
|
546
738
|
children: [],
|
|
547
|
-
} as unknown as Object3D
|
|
739
|
+
} as unknown as Object3D,
|
|
548
740
|
];
|
|
549
741
|
|
|
550
|
-
expect(() =>
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
742
|
+
expect(() =>
|
|
743
|
+
root.DeleteSceneObject({
|
|
744
|
+
id: 'does_not_exist',
|
|
745
|
+
name: 'pov',
|
|
746
|
+
entityType: 'pov',
|
|
747
|
+
visible: true,
|
|
748
|
+
} as COMPov),
|
|
749
|
+
).not.toThrow();
|
|
750
|
+
expect(() =>
|
|
751
|
+
root.DeleteSceneObject({
|
|
752
|
+
id: 'id',
|
|
753
|
+
name: 'pov',
|
|
754
|
+
entityType: 'pov',
|
|
755
|
+
visible: true,
|
|
756
|
+
} as COMPov),
|
|
757
|
+
).not.toThrow();
|
|
758
|
+
|
|
759
|
+
expect(() =>
|
|
760
|
+
root.DeleteSceneObject({
|
|
761
|
+
id: 'does_not_exist',
|
|
762
|
+
name: 'light',
|
|
763
|
+
entityType: 'light',
|
|
764
|
+
visible: true,
|
|
765
|
+
type: 'scene',
|
|
766
|
+
} as COMLight),
|
|
767
|
+
).not.toThrow();
|
|
768
|
+
expect(() =>
|
|
769
|
+
root.DeleteSceneObject({
|
|
770
|
+
id: 'id',
|
|
771
|
+
name: 'light',
|
|
772
|
+
entityType: 'light',
|
|
773
|
+
visible: true,
|
|
774
|
+
type: 'scene',
|
|
775
|
+
} as COMLight),
|
|
776
|
+
).not.toThrow();
|
|
777
|
+
|
|
778
|
+
expect(() =>
|
|
779
|
+
root.DeleteSceneObject({
|
|
780
|
+
id: 'does_not_exist',
|
|
781
|
+
name: 'model',
|
|
782
|
+
entityType: 'model',
|
|
783
|
+
visible: true,
|
|
784
|
+
} as COMModel),
|
|
785
|
+
).not.toThrow();
|
|
786
|
+
expect(() =>
|
|
787
|
+
root.DeleteSceneObject({
|
|
788
|
+
id: 'id',
|
|
789
|
+
name: 'model',
|
|
790
|
+
entityType: 'model',
|
|
791
|
+
visible: true,
|
|
792
|
+
} as COMModel),
|
|
793
|
+
).not.toThrow();
|
|
794
|
+
|
|
795
|
+
expect(() =>
|
|
796
|
+
root.DeleteSceneObject({
|
|
797
|
+
id: 'does_not_exist',
|
|
798
|
+
name: 'primitive',
|
|
799
|
+
entityType: 'primitive',
|
|
800
|
+
visible: true,
|
|
801
|
+
} as COMPrimitive),
|
|
802
|
+
).not.toThrow();
|
|
803
|
+
expect(() =>
|
|
804
|
+
root.DeleteSceneObject({
|
|
805
|
+
id: 'id',
|
|
806
|
+
name: 'primitive',
|
|
807
|
+
entityType: 'primitive',
|
|
808
|
+
visible: true,
|
|
809
|
+
} as COMPrimitive),
|
|
810
|
+
).not.toThrow();
|
|
811
|
+
|
|
812
|
+
expect(() =>
|
|
813
|
+
root.DeleteSceneObject({
|
|
814
|
+
id: 'does_not_exist',
|
|
815
|
+
name: 'group',
|
|
816
|
+
entityType: 'group',
|
|
817
|
+
visible: true,
|
|
818
|
+
} as COMGroup),
|
|
819
|
+
).not.toThrow();
|
|
820
|
+
expect(() =>
|
|
821
|
+
root.DeleteSceneObject({
|
|
822
|
+
id: 'id',
|
|
823
|
+
name: 'group',
|
|
824
|
+
entityType: 'group',
|
|
825
|
+
visible: true,
|
|
826
|
+
} as COMGroup),
|
|
827
|
+
).not.toThrow();
|
|
564
828
|
|
|
565
829
|
const firstFind = root.GetSceneObject({ id: 'id' });
|
|
566
|
-
jest.spyOn(root, 'GetSceneObject')
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
830
|
+
jest.spyOn(root, 'GetSceneObject').mockReturnValueOnce({
|
|
831
|
+
...firstFind,
|
|
832
|
+
parent: sceneParent,
|
|
833
|
+
children: [
|
|
834
|
+
{
|
|
571
835
|
isObject3D: true,
|
|
572
|
-
}
|
|
573
|
-
|
|
836
|
+
},
|
|
837
|
+
],
|
|
838
|
+
} as unknown as DIVESceneObject);
|
|
574
839
|
|
|
575
|
-
expect(() =>
|
|
840
|
+
expect(() =>
|
|
841
|
+
root.DeleteSceneObject({
|
|
842
|
+
id: 'id',
|
|
843
|
+
name: 'group',
|
|
844
|
+
entityType: 'group',
|
|
845
|
+
visible: true,
|
|
846
|
+
} as COMGroup),
|
|
847
|
+
).not.toThrow();
|
|
576
848
|
});
|
|
577
849
|
|
|
578
850
|
it('should place object on floor', () => {
|
|
@@ -585,19 +857,75 @@ describe('DIVE/scene/root/DIVERoot', () => {
|
|
|
585
857
|
PlaceOnFloor: jest.fn(),
|
|
586
858
|
parent: root,
|
|
587
859
|
children: [],
|
|
588
|
-
} as unknown as Object3D
|
|
860
|
+
} as unknown as Object3D,
|
|
589
861
|
];
|
|
590
862
|
|
|
591
|
-
expect(() =>
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
863
|
+
expect(() =>
|
|
864
|
+
root.PlaceOnFloor({
|
|
865
|
+
id: 'does_not_exist',
|
|
866
|
+
name: 'pov',
|
|
867
|
+
entityType: 'pov',
|
|
868
|
+
visible: true,
|
|
869
|
+
} as COMPov),
|
|
870
|
+
).not.toThrow();
|
|
871
|
+
expect(() =>
|
|
872
|
+
root.PlaceOnFloor({
|
|
873
|
+
id: 'id',
|
|
874
|
+
name: 'pov',
|
|
875
|
+
entityType: 'pov',
|
|
876
|
+
visible: true,
|
|
877
|
+
} as COMPov),
|
|
878
|
+
).not.toThrow();
|
|
879
|
+
|
|
880
|
+
expect(() =>
|
|
881
|
+
root.PlaceOnFloor({
|
|
882
|
+
id: 'does_not_exist',
|
|
883
|
+
name: 'light',
|
|
884
|
+
entityType: 'light',
|
|
885
|
+
visible: true,
|
|
886
|
+
} as COMLight),
|
|
887
|
+
).not.toThrow();
|
|
888
|
+
expect(() =>
|
|
889
|
+
root.PlaceOnFloor({
|
|
890
|
+
id: 'id',
|
|
891
|
+
name: 'light',
|
|
892
|
+
entityType: 'light',
|
|
893
|
+
visible: true,
|
|
894
|
+
} as COMLight),
|
|
895
|
+
).not.toThrow();
|
|
896
|
+
|
|
897
|
+
expect(() =>
|
|
898
|
+
root.PlaceOnFloor({
|
|
899
|
+
id: 'does_not_exist',
|
|
900
|
+
name: 'model',
|
|
901
|
+
entityType: 'model',
|
|
902
|
+
visible: true,
|
|
903
|
+
} as COMModel),
|
|
904
|
+
).not.toThrow();
|
|
905
|
+
expect(() =>
|
|
906
|
+
root.PlaceOnFloor({
|
|
907
|
+
id: 'id',
|
|
908
|
+
name: 'model',
|
|
909
|
+
entityType: 'model',
|
|
910
|
+
visible: true,
|
|
911
|
+
} as COMModel),
|
|
912
|
+
).not.toThrow();
|
|
913
|
+
|
|
914
|
+
expect(() =>
|
|
915
|
+
root.PlaceOnFloor({
|
|
916
|
+
id: 'does_not_exist',
|
|
917
|
+
name: 'primitive',
|
|
918
|
+
entityType: 'primitive',
|
|
919
|
+
visible: true,
|
|
920
|
+
} as COMPrimitive),
|
|
921
|
+
).not.toThrow();
|
|
922
|
+
expect(() =>
|
|
923
|
+
root.PlaceOnFloor({
|
|
924
|
+
id: 'id',
|
|
925
|
+
name: 'primitive',
|
|
926
|
+
entityType: 'primitive',
|
|
927
|
+
visible: true,
|
|
928
|
+
} as COMPrimitive),
|
|
929
|
+
).not.toThrow();
|
|
602
930
|
});
|
|
603
931
|
});
|