@shopware-ag/dive 1.17.2 → 1.18.0
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 +56 -22
- package/build/dive.cjs +11 -7
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +3 -4
- package/build/dive.d.ts +3 -4
- package/build/dive.js +9 -5
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/__test__/DIVE.test.ts +0 -40
- package/src/animation/__test__/AnimationSystem.test.ts +0 -7
- package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +0 -140
- package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -140
- package/src/axiscamera/__test__/AxisCamera.test.ts +0 -76
- package/src/com/__test__/Communication.test.ts +0 -6
- package/src/controls/__test__/OrbitControls.test.ts +0 -87
- package/src/dive.ts +3 -3
- package/src/exporters/usdz/__test__/USDZExporter.test.ts +57 -0
- package/src/group/Group.ts +6 -1
- package/src/group/__test__/Group.test.ts +6 -3
- package/src/io/gltf/__test__/GLTFIO.test.ts +0 -77
- package/src/light/PointLight.ts +1 -1
- package/src/light/__test__/AmbientLight.test.ts +0 -24
- package/src/light/__test__/PointLight.test.ts +0 -61
- package/src/light/__test__/SceneLight.test.ts +0 -89
- package/src/loadingmanager/LoadingManager.ts +2 -1
- package/src/loadingmanager/__test__/LoadingManager.test.ts +0 -30
- package/src/math/degToRad/__test__/degToRad.test.ts +0 -7
- package/src/math/radToDeg/__test__/radToDeg.test.ts +0 -7
- package/src/model/Model.ts +1 -1
- package/src/model/__test__/Model.test.ts +5 -155
- package/src/node/__test__/Node.test.ts +0 -149
- package/src/primitive/__test__/Primitive.test.ts +6 -199
- package/src/primitive/floor/__test__/Floor.test.ts +0 -3
- package/src/renderer/__test__/Renderer.test.ts +16 -46
- package/src/scene/__test__/Scene.test.ts +6 -16
- package/src/scene/root/Root.ts +4 -4
- package/src/scene/root/__test__/Root.test.ts +6 -188
- package/src/toolbox/__test__/BaseTool.test.ts +34 -38
- package/src/toolbox/select/__test__/SelectTool.test.ts +16 -89
- package/src/toolbox/transform/__test__/TransformTool.test.ts +14 -82
|
@@ -2,83 +2,6 @@ import { Object3D } from 'three';
|
|
|
2
2
|
import { DIVEGLTFIO } from '../GLTFIO';
|
|
3
3
|
|
|
4
4
|
import { type GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
5
|
-
import { GLTFExporterOptions } from 'three/examples/jsm/exporters/GLTFExporter';
|
|
6
|
-
|
|
7
|
-
jest.mock('three', () => {
|
|
8
|
-
return {
|
|
9
|
-
Object3D: jest.fn(function () {
|
|
10
|
-
this.clear = jest.fn();
|
|
11
|
-
this.color = {};
|
|
12
|
-
this.intensity = 0;
|
|
13
|
-
this.layers = {
|
|
14
|
-
mask: 0,
|
|
15
|
-
};
|
|
16
|
-
this.shadow = {
|
|
17
|
-
radius: 0,
|
|
18
|
-
mapSize: { width: 0, height: 0 },
|
|
19
|
-
bias: 0,
|
|
20
|
-
camera: {
|
|
21
|
-
near: 0,
|
|
22
|
-
far: 0,
|
|
23
|
-
fov: 0,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
this.add = jest.fn();
|
|
27
|
-
this.sub = jest.fn();
|
|
28
|
-
this.children = [
|
|
29
|
-
{
|
|
30
|
-
visible: true,
|
|
31
|
-
material: {
|
|
32
|
-
color: {},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
this.userData = {};
|
|
37
|
-
this.traverse = jest.fn((callback) => {
|
|
38
|
-
callback(this.children[0]);
|
|
39
|
-
});
|
|
40
|
-
return this;
|
|
41
|
-
}),
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
jest.mock('three/examples/jsm/loaders/GLTFLoader', () => {
|
|
46
|
-
return {
|
|
47
|
-
GLTFLoader: jest.fn(function () {
|
|
48
|
-
this.loadAsync = (
|
|
49
|
-
uri: string,
|
|
50
|
-
progEvent: (p: ProgressEvent<EventTarget>) => void,
|
|
51
|
-
) =>
|
|
52
|
-
new Promise<void>((resolve) => {
|
|
53
|
-
progEvent({
|
|
54
|
-
loaded: 0,
|
|
55
|
-
total: 1,
|
|
56
|
-
} as ProgressEvent<EventTarget>);
|
|
57
|
-
|
|
58
|
-
resolve();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
return this;
|
|
62
|
-
}),
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
jest.mock('three/examples/jsm/exporters/GLTFExporter', () => {
|
|
67
|
-
return {
|
|
68
|
-
GLTFExporter: jest.fn(function () {
|
|
69
|
-
this.parseAsync = (
|
|
70
|
-
object: Object3D,
|
|
71
|
-
options?: GLTFExporterOptions,
|
|
72
|
-
) =>
|
|
73
|
-
new Promise<ArrayBuffer | { [key: string]: unknown }>(
|
|
74
|
-
(resolve) => {
|
|
75
|
-
resolve(new ArrayBuffer(0));
|
|
76
|
-
},
|
|
77
|
-
);
|
|
78
|
-
return this;
|
|
79
|
-
}),
|
|
80
|
-
};
|
|
81
|
-
});
|
|
82
5
|
|
|
83
6
|
let testGLTFIO: DIVEGLTFIO;
|
|
84
7
|
|
package/src/light/PointLight.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from '../constant/VisibilityLayerMask';
|
|
15
15
|
import { DIVEMovable } from '../interface/Movable';
|
|
16
16
|
import { DIVESelectable } from '../interface/Selectable';
|
|
17
|
-
import type { TransformControls } from 'three/examples/jsm/
|
|
17
|
+
import type { TransformControls } from 'three/examples/jsm/controls/TransformControls';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* A basic point light.
|
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
import { AmbientLight, Color, Object3D } from 'three';
|
|
2
2
|
import DIVEAmbientLight from '../AmbientLight';
|
|
3
3
|
|
|
4
|
-
jest.mock('three', () => {
|
|
5
|
-
return {
|
|
6
|
-
Color: jest.fn(function () {
|
|
7
|
-
return {};
|
|
8
|
-
}),
|
|
9
|
-
AmbientLight: jest.fn(function () {
|
|
10
|
-
this.color = {};
|
|
11
|
-
this.intensity = 0;
|
|
12
|
-
this.layers = {
|
|
13
|
-
mask: 0,
|
|
14
|
-
};
|
|
15
|
-
this.removeFromParent = jest.fn();
|
|
16
|
-
return this;
|
|
17
|
-
}),
|
|
18
|
-
Object3D: jest.fn(function () {
|
|
19
|
-
this.children = [];
|
|
20
|
-
this.add = (obj: Object3D) => {
|
|
21
|
-
this.children.push(obj);
|
|
22
|
-
};
|
|
23
|
-
return this;
|
|
24
|
-
}),
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
|
|
28
4
|
describe('dive/light/DIVEAmbientLight', () => {
|
|
29
5
|
it('should instantiate', () => {
|
|
30
6
|
const testLight = new DIVEAmbientLight();
|
|
@@ -2,67 +2,6 @@ import DIVEPointLight from '../PointLight.ts';
|
|
|
2
2
|
import { DIVECommunication } from '../../com/Communication.ts';
|
|
3
3
|
import { Color, MeshBasicMaterial, Object3D, PointLight } from 'three';
|
|
4
4
|
|
|
5
|
-
const mockAdd = jest.fn();
|
|
6
|
-
|
|
7
|
-
jest.mock('three', () => {
|
|
8
|
-
return {
|
|
9
|
-
Color: jest.fn(function () {
|
|
10
|
-
return {};
|
|
11
|
-
}),
|
|
12
|
-
PointLight: jest.fn(function () {
|
|
13
|
-
this.visible = true;
|
|
14
|
-
this.color = {};
|
|
15
|
-
this.intensity = 0;
|
|
16
|
-
this.layers = {
|
|
17
|
-
mask: 0,
|
|
18
|
-
};
|
|
19
|
-
this.shadow = {
|
|
20
|
-
radius: 0,
|
|
21
|
-
mapSize: { width: 0, height: 0 },
|
|
22
|
-
bias: 0,
|
|
23
|
-
camera: {
|
|
24
|
-
near: 0,
|
|
25
|
-
far: 0,
|
|
26
|
-
fov: 0,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
this.add = mockAdd;
|
|
30
|
-
this.children = [
|
|
31
|
-
{
|
|
32
|
-
material: {
|
|
33
|
-
color: {},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
return this;
|
|
38
|
-
}),
|
|
39
|
-
SphereGeometry: jest.fn(function () {
|
|
40
|
-
return this;
|
|
41
|
-
}),
|
|
42
|
-
MeshBasicMaterial: jest.fn(function () {
|
|
43
|
-
this.opacity = 1.0;
|
|
44
|
-
this.color = new Color();
|
|
45
|
-
return this;
|
|
46
|
-
}),
|
|
47
|
-
Mesh: jest.fn(function () {
|
|
48
|
-
this.layers = {
|
|
49
|
-
mask: 0,
|
|
50
|
-
};
|
|
51
|
-
this.visible = true;
|
|
52
|
-
this.material = new MeshBasicMaterial();
|
|
53
|
-
return this;
|
|
54
|
-
}),
|
|
55
|
-
Object3D: jest.fn(function () {
|
|
56
|
-
this.children = [];
|
|
57
|
-
this.add = (obj: Object3D) => {
|
|
58
|
-
this.children.push(obj);
|
|
59
|
-
};
|
|
60
|
-
this.userData = {};
|
|
61
|
-
return this;
|
|
62
|
-
}),
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
|
|
66
5
|
jest.mock('../../com/Communication.ts', () => {
|
|
67
6
|
return {
|
|
68
7
|
DIVECommunication: {
|
|
@@ -14,95 +14,6 @@ jest.mock('../../com/Communication.ts', () => {
|
|
|
14
14
|
};
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
const mockAdd = jest.fn();
|
|
18
|
-
|
|
19
|
-
jest.mock('three', () => {
|
|
20
|
-
return {
|
|
21
|
-
Color: jest.fn(function () {
|
|
22
|
-
return {};
|
|
23
|
-
}),
|
|
24
|
-
PointLight: jest.fn(function () {
|
|
25
|
-
this.color = {};
|
|
26
|
-
this.intensity = 0;
|
|
27
|
-
this.layers = {
|
|
28
|
-
mask: 0,
|
|
29
|
-
};
|
|
30
|
-
this.shadow = {
|
|
31
|
-
radius: 0,
|
|
32
|
-
mapSize: { width: 0, height: 0 },
|
|
33
|
-
bias: 0,
|
|
34
|
-
camera: {
|
|
35
|
-
near: 0,
|
|
36
|
-
far: 0,
|
|
37
|
-
fov: 0,
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
this.add = mockAdd;
|
|
41
|
-
this.children = [
|
|
42
|
-
{
|
|
43
|
-
material: {
|
|
44
|
-
color: {},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
];
|
|
48
|
-
this.userData = {};
|
|
49
|
-
return this;
|
|
50
|
-
}),
|
|
51
|
-
SphereGeometry: jest.fn(function () {
|
|
52
|
-
return this;
|
|
53
|
-
}),
|
|
54
|
-
MeshBasicMaterial: jest.fn(function () {
|
|
55
|
-
return this;
|
|
56
|
-
}),
|
|
57
|
-
Mesh: jest.fn(function () {
|
|
58
|
-
this.layers = {
|
|
59
|
-
mask: 0,
|
|
60
|
-
};
|
|
61
|
-
return this;
|
|
62
|
-
}),
|
|
63
|
-
Object3D: jest.fn(function () {
|
|
64
|
-
this.children = [];
|
|
65
|
-
this.add = (obj: Object3D) => {
|
|
66
|
-
this.children.push(obj);
|
|
67
|
-
};
|
|
68
|
-
return this;
|
|
69
|
-
}),
|
|
70
|
-
HemisphereLight: jest.fn(function () {
|
|
71
|
-
this.visible = true;
|
|
72
|
-
this.layers = {
|
|
73
|
-
mask: 0,
|
|
74
|
-
};
|
|
75
|
-
this.position = {
|
|
76
|
-
set: jest.fn(),
|
|
77
|
-
};
|
|
78
|
-
this.removeFromParent = mockAdd;
|
|
79
|
-
return this;
|
|
80
|
-
}),
|
|
81
|
-
DirectionalLight: jest.fn(function () {
|
|
82
|
-
this.visible = true;
|
|
83
|
-
this.layers = {
|
|
84
|
-
mask: 0,
|
|
85
|
-
};
|
|
86
|
-
this.position = {
|
|
87
|
-
set: jest.fn(),
|
|
88
|
-
multiplyScalar: jest.fn(),
|
|
89
|
-
};
|
|
90
|
-
this.shadow = {
|
|
91
|
-
radius: 0,
|
|
92
|
-
mapSize: { width: 0, height: 0 },
|
|
93
|
-
bias: 0,
|
|
94
|
-
camera: {
|
|
95
|
-
near: 0,
|
|
96
|
-
far: 0,
|
|
97
|
-
fov: 0,
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
this.removeFromParent = mockAdd;
|
|
101
|
-
return this;
|
|
102
|
-
}),
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
|
|
106
17
|
jest.spyOn(DIVECommunication, 'get').mockReturnValue({
|
|
107
18
|
PerformAction: jest.fn(),
|
|
108
19
|
} as unknown as DIVECommunication);
|
|
@@ -1,39 +1,9 @@
|
|
|
1
1
|
import { DIVELoadingManager } from '../LoadingManager';
|
|
2
2
|
|
|
3
|
-
const mock_setDRACOLoader = jest.fn();
|
|
4
|
-
const mock_setDecoderPath = jest.fn();
|
|
5
|
-
|
|
6
|
-
jest.mock('three/examples/jsm/Addons.js', () => {
|
|
7
|
-
return {
|
|
8
|
-
GLTFLoader: jest.fn(function () {
|
|
9
|
-
this.loadAsync = (
|
|
10
|
-
uri: string,
|
|
11
|
-
progEvent: (p: ProgressEvent<EventTarget>) => void,
|
|
12
|
-
) =>
|
|
13
|
-
new Promise<void>((resolve) => {
|
|
14
|
-
progEvent({
|
|
15
|
-
loaded: 0,
|
|
16
|
-
total: 1,
|
|
17
|
-
} as ProgressEvent<EventTarget>);
|
|
18
|
-
resolve();
|
|
19
|
-
});
|
|
20
|
-
this.setDRACOLoader = mock_setDRACOLoader;
|
|
21
|
-
return this;
|
|
22
|
-
}),
|
|
23
|
-
DRACOLoader: jest.fn(() => {
|
|
24
|
-
return {
|
|
25
|
-
setDecoderPath: mock_setDecoderPath,
|
|
26
|
-
};
|
|
27
|
-
}),
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
|
|
31
3
|
describe('dive/loadingmanager/DIVELoadingManager', () => {
|
|
32
4
|
it('should instantiate', () => {
|
|
33
5
|
const testLight = new DIVELoadingManager();
|
|
34
6
|
expect(testLight).toBeDefined();
|
|
35
|
-
expect(mock_setDecoderPath).toHaveBeenCalledTimes(1);
|
|
36
|
-
expect(mock_setDRACOLoader).toHaveBeenCalledTimes(1);
|
|
37
7
|
});
|
|
38
8
|
|
|
39
9
|
it('should return GLTF promise', () => {
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import degToRad from '../degToRad';
|
|
2
2
|
import { MathUtils } from 'three';
|
|
3
3
|
|
|
4
|
-
// Mock the 'three' module, specifically MathUtils.degToRad
|
|
5
|
-
jest.mock('three', () => ({
|
|
6
|
-
MathUtils: {
|
|
7
|
-
degToRad: jest.fn(),
|
|
8
|
-
},
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
4
|
// Type assertion for the mocked MathUtils.degToRad
|
|
12
5
|
const mockedDegToRad = MathUtils.degToRad as jest.Mock;
|
|
13
6
|
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import radToDeg from '../radToDeg';
|
|
2
2
|
import { MathUtils } from 'three';
|
|
3
3
|
|
|
4
|
-
// Mock the 'three' module, specifically MathUtils.radToDeg
|
|
5
|
-
jest.mock('three', () => ({
|
|
6
|
-
MathUtils: {
|
|
7
|
-
radToDeg: jest.fn(),
|
|
8
|
-
},
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
4
|
// Type assertion for the mocked MathUtils.radToDeg
|
|
12
5
|
const mockedRadToDeg = MathUtils.radToDeg as jest.Mock;
|
|
13
6
|
|
package/src/model/Model.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Mesh, MeshStandardMaterial, Raycaster, Vector3 } from 'three';
|
|
2
2
|
import { PRODUCT_LAYER_MASK } from '../constant/VisibilityLayerMask';
|
|
3
|
-
import type { GLTF } from 'three/examples/jsm/
|
|
3
|
+
import type { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
4
4
|
import { findSceneRecursive } from '../helper/findSceneRecursive/findSceneRecursive';
|
|
5
5
|
import { type COMMaterial } from '../com/types';
|
|
6
6
|
import { DIVENode } from '../node/Node';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { RaycasterIntersectObjectMock } from '../../../__mocks__/three';
|
|
2
|
+
|
|
1
3
|
import { DIVEModel } from '../Model';
|
|
2
4
|
import { DIVECommunication } from '../../com/Communication';
|
|
3
|
-
import { GLTF } from 'three/examples/jsm/
|
|
5
|
+
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
4
6
|
import { DIVEScene } from '../../scene/Scene';
|
|
5
7
|
import {
|
|
6
8
|
Vector3,
|
|
@@ -8,163 +10,10 @@ import {
|
|
|
8
10
|
Mesh,
|
|
9
11
|
MeshStandardMaterial,
|
|
10
12
|
type Texture,
|
|
11
|
-
Color,
|
|
12
13
|
Object3D,
|
|
13
14
|
} from 'three';
|
|
14
15
|
import { type COMMaterial } from '../../com/types';
|
|
15
16
|
|
|
16
|
-
const intersectObjectsMock = jest.fn();
|
|
17
|
-
|
|
18
|
-
jest.mock('three', () => {
|
|
19
|
-
return {
|
|
20
|
-
Vector3: jest.fn(function (
|
|
21
|
-
x: number = 0,
|
|
22
|
-
y: number = 0,
|
|
23
|
-
z: number = 0,
|
|
24
|
-
) {
|
|
25
|
-
this.x = x;
|
|
26
|
-
this.y = y;
|
|
27
|
-
this.z = z;
|
|
28
|
-
this.copy = jest.fn((vec3: Vector3) => {
|
|
29
|
-
this.x = vec3.x;
|
|
30
|
-
this.y = vec3.y;
|
|
31
|
-
this.z = vec3.z;
|
|
32
|
-
return this;
|
|
33
|
-
});
|
|
34
|
-
this.set = jest.fn((x: number, y: number, z: number) => {
|
|
35
|
-
this.x = x;
|
|
36
|
-
this.y = y;
|
|
37
|
-
this.z = z;
|
|
38
|
-
return this;
|
|
39
|
-
});
|
|
40
|
-
this.multiply = jest.fn((vec3: Vector3) => {
|
|
41
|
-
this.x *= vec3.x;
|
|
42
|
-
this.y *= vec3.y;
|
|
43
|
-
this.z *= vec3.z;
|
|
44
|
-
return this;
|
|
45
|
-
});
|
|
46
|
-
this.clone = jest.fn(() => {
|
|
47
|
-
return new Vector3(this.x, this.y, this.z);
|
|
48
|
-
});
|
|
49
|
-
this.setY = jest.fn((y: number) => {
|
|
50
|
-
this.y = y;
|
|
51
|
-
return this;
|
|
52
|
-
});
|
|
53
|
-
this.add = jest.fn((vec3: Vector3) => {
|
|
54
|
-
this.x += vec3.x;
|
|
55
|
-
this.y += vec3.y;
|
|
56
|
-
this.z += vec3.z;
|
|
57
|
-
return this;
|
|
58
|
-
});
|
|
59
|
-
this.sub = jest.fn((vec3: Vector3) => {
|
|
60
|
-
this.x -= vec3.x;
|
|
61
|
-
this.y -= vec3.y;
|
|
62
|
-
this.z -= vec3.z;
|
|
63
|
-
return this;
|
|
64
|
-
});
|
|
65
|
-
return this;
|
|
66
|
-
}),
|
|
67
|
-
Object3D: jest.fn(function () {
|
|
68
|
-
this.clear = jest.fn();
|
|
69
|
-
this.color = {};
|
|
70
|
-
this.intensity = 0;
|
|
71
|
-
this.layers = {
|
|
72
|
-
mask: 0,
|
|
73
|
-
};
|
|
74
|
-
this.shadow = {
|
|
75
|
-
radius: 0,
|
|
76
|
-
mapSize: { width: 0, height: 0 },
|
|
77
|
-
bias: 0,
|
|
78
|
-
camera: {
|
|
79
|
-
near: 0,
|
|
80
|
-
far: 0,
|
|
81
|
-
fov: 0,
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
this.add = jest.fn();
|
|
85
|
-
this.sub = jest.fn();
|
|
86
|
-
this.children = [];
|
|
87
|
-
this.userData = {};
|
|
88
|
-
this.position = new Vector3();
|
|
89
|
-
this.rotation = {
|
|
90
|
-
x: 0,
|
|
91
|
-
y: 0,
|
|
92
|
-
z: 0,
|
|
93
|
-
setFromVector3: jest.fn(),
|
|
94
|
-
};
|
|
95
|
-
this.scale = {
|
|
96
|
-
x: 1,
|
|
97
|
-
y: 1,
|
|
98
|
-
z: 1,
|
|
99
|
-
set: jest.fn(),
|
|
100
|
-
};
|
|
101
|
-
this.localToWorld = jest.fn((vec3: Vector3) => {
|
|
102
|
-
return vec3;
|
|
103
|
-
});
|
|
104
|
-
this.traverse = jest.fn((callback) => {
|
|
105
|
-
callback(this);
|
|
106
|
-
this.children.forEach((child: Object3D) => {
|
|
107
|
-
callback(child);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
this.getWorldPosition = jest.fn(() => {
|
|
111
|
-
return this.position.clone();
|
|
112
|
-
});
|
|
113
|
-
return this;
|
|
114
|
-
}),
|
|
115
|
-
Box3: jest.fn(function () {
|
|
116
|
-
this.min = new Vector3(Infinity, Infinity, Infinity);
|
|
117
|
-
this.max = new Vector3(-Infinity, -Infinity, -Infinity);
|
|
118
|
-
this.getCenter = jest.fn(() => {
|
|
119
|
-
return new Vector3(0, 0, 0);
|
|
120
|
-
});
|
|
121
|
-
this.expandByObject = jest.fn();
|
|
122
|
-
this.makeEmpty = jest.fn();
|
|
123
|
-
|
|
124
|
-
return this;
|
|
125
|
-
}),
|
|
126
|
-
Raycaster: jest.fn(function () {
|
|
127
|
-
this.intersectObjects = intersectObjectsMock;
|
|
128
|
-
this.layers = {
|
|
129
|
-
mask: 0,
|
|
130
|
-
};
|
|
131
|
-
return this;
|
|
132
|
-
}),
|
|
133
|
-
Mesh: jest.fn(function () {
|
|
134
|
-
this.isMesh = true;
|
|
135
|
-
this.geometry = {
|
|
136
|
-
computeBoundingBox: jest.fn(),
|
|
137
|
-
boundingBox: new Box3(),
|
|
138
|
-
};
|
|
139
|
-
this.material = new MeshStandardMaterial();
|
|
140
|
-
this.castShadow = true;
|
|
141
|
-
this.receiveShadow = true;
|
|
142
|
-
this.layers = {
|
|
143
|
-
mask: 0,
|
|
144
|
-
};
|
|
145
|
-
this.updateWorldMatrix = jest.fn();
|
|
146
|
-
this.traverse = jest.fn();
|
|
147
|
-
this.removeFromParent = jest.fn();
|
|
148
|
-
this.localToWorld = jest.fn((vec3: Vector3) => {
|
|
149
|
-
return vec3;
|
|
150
|
-
});
|
|
151
|
-
return this;
|
|
152
|
-
}),
|
|
153
|
-
MeshStandardMaterial: jest.fn(function () {
|
|
154
|
-
this.color = new Color();
|
|
155
|
-
this.roughness = 1;
|
|
156
|
-
this.roughnessMap = undefined;
|
|
157
|
-
this.metalness = 0;
|
|
158
|
-
this.metalnessMap = undefined;
|
|
159
|
-
return this;
|
|
160
|
-
}),
|
|
161
|
-
Color: jest.fn(function () {
|
|
162
|
-
this.set = jest.fn();
|
|
163
|
-
return this;
|
|
164
|
-
}),
|
|
165
|
-
};
|
|
166
|
-
});
|
|
167
|
-
|
|
168
17
|
jest.mock('../../com/Communication.ts', () => {
|
|
169
18
|
return {
|
|
170
19
|
DIVECommunication: {
|
|
@@ -195,6 +44,7 @@ let model: DIVEModel;
|
|
|
195
44
|
describe('dive/model/DIVEModel', () => {
|
|
196
45
|
beforeEach(() => {
|
|
197
46
|
jest.clearAllMocks();
|
|
47
|
+
RaycasterIntersectObjectMock.mockClear();
|
|
198
48
|
model = new DIVEModel();
|
|
199
49
|
});
|
|
200
50
|
|
|
@@ -272,7 +122,7 @@ describe('dive/model/DIVEModel', () => {
|
|
|
272
122
|
const hitObject = new Mesh();
|
|
273
123
|
hitObject.geometry.boundingBox = new Box3();
|
|
274
124
|
hitObject.geometry.boundingBox.max = new Vector3(0, 2, 0);
|
|
275
|
-
|
|
125
|
+
RaycasterIntersectObjectMock.mockReturnValue([
|
|
276
126
|
{
|
|
277
127
|
object: hitObject,
|
|
278
128
|
},
|