@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
|
@@ -3,155 +3,6 @@ import { DIVECommunication } from '../../com/Communication';
|
|
|
3
3
|
import { Vector3, Box3, Mesh, Color, Euler } from 'three';
|
|
4
4
|
import { type DIVEGroup } from '../../group/Group';
|
|
5
5
|
|
|
6
|
-
const intersectObjectsMock = jest.fn();
|
|
7
|
-
|
|
8
|
-
jest.mock('three', () => {
|
|
9
|
-
return {
|
|
10
|
-
Vector3: jest.fn(function (
|
|
11
|
-
x: number = 0,
|
|
12
|
-
y: number = 0,
|
|
13
|
-
z: number = 0,
|
|
14
|
-
) {
|
|
15
|
-
this.x = x;
|
|
16
|
-
this.y = y;
|
|
17
|
-
this.z = z;
|
|
18
|
-
this.copy = (vec3: Vector3) => {
|
|
19
|
-
this.x = vec3.x;
|
|
20
|
-
this.y = vec3.y;
|
|
21
|
-
this.z = vec3.z;
|
|
22
|
-
return this;
|
|
23
|
-
};
|
|
24
|
-
this.set = (x: number, y: number, z: number) => {
|
|
25
|
-
this.x = x;
|
|
26
|
-
this.y = y;
|
|
27
|
-
this.z = z;
|
|
28
|
-
return this;
|
|
29
|
-
};
|
|
30
|
-
this.multiply = (vec3: Vector3) => {
|
|
31
|
-
this.x *= vec3.x;
|
|
32
|
-
this.y *= vec3.y;
|
|
33
|
-
this.z *= vec3.z;
|
|
34
|
-
return this;
|
|
35
|
-
};
|
|
36
|
-
this.clone = () => {
|
|
37
|
-
return new Vector3(this.x, this.y, this.z);
|
|
38
|
-
};
|
|
39
|
-
this.setY = (y: number) => {
|
|
40
|
-
this.y = y;
|
|
41
|
-
return this;
|
|
42
|
-
};
|
|
43
|
-
this.add = (vec3: Vector3) => {
|
|
44
|
-
this.x += vec3.x;
|
|
45
|
-
this.y += vec3.y;
|
|
46
|
-
this.z += vec3.z;
|
|
47
|
-
return this;
|
|
48
|
-
};
|
|
49
|
-
this.sub = (vec3: Vector3) => {
|
|
50
|
-
this.x -= vec3.x;
|
|
51
|
-
this.y -= vec3.y;
|
|
52
|
-
this.z -= vec3.z;
|
|
53
|
-
return this;
|
|
54
|
-
};
|
|
55
|
-
return this;
|
|
56
|
-
}),
|
|
57
|
-
Euler: jest.fn(function () {
|
|
58
|
-
this.set = jest.fn();
|
|
59
|
-
return this;
|
|
60
|
-
}),
|
|
61
|
-
Object3D: jest.fn(function () {
|
|
62
|
-
this.clear = jest.fn();
|
|
63
|
-
this.color = {};
|
|
64
|
-
this.intensity = 0;
|
|
65
|
-
this.layers = {
|
|
66
|
-
mask: 0,
|
|
67
|
-
};
|
|
68
|
-
this.shadow = {
|
|
69
|
-
radius: 0,
|
|
70
|
-
mapSize: { width: 0, height: 0 },
|
|
71
|
-
bias: 0,
|
|
72
|
-
camera: {
|
|
73
|
-
near: 0,
|
|
74
|
-
far: 0,
|
|
75
|
-
fov: 0,
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
this.add = jest.fn();
|
|
79
|
-
this.sub = jest.fn();
|
|
80
|
-
this.children = [
|
|
81
|
-
{
|
|
82
|
-
visible: true,
|
|
83
|
-
material: {
|
|
84
|
-
color: {},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
];
|
|
88
|
-
this.userData = {};
|
|
89
|
-
this.position = new Vector3();
|
|
90
|
-
this.rotation = new Euler();
|
|
91
|
-
this.scale = new Vector3(1, 1, 1);
|
|
92
|
-
this.localToWorld = (vec3: Vector3) => {
|
|
93
|
-
return vec3;
|
|
94
|
-
};
|
|
95
|
-
this.mesh = new Mesh();
|
|
96
|
-
this.traverse = jest.fn((callback) => {
|
|
97
|
-
callback(this.children[0]);
|
|
98
|
-
});
|
|
99
|
-
this.getWorldPosition = jest.fn(() => {
|
|
100
|
-
return new Vector3();
|
|
101
|
-
});
|
|
102
|
-
return this;
|
|
103
|
-
}),
|
|
104
|
-
Box3: jest.fn(function () {
|
|
105
|
-
this.min = new Vector3(Infinity, Infinity, Infinity);
|
|
106
|
-
this.max = new Vector3(-Infinity, -Infinity, -Infinity);
|
|
107
|
-
this.getCenter = jest.fn(() => {
|
|
108
|
-
return new Vector3(0, 0, 0);
|
|
109
|
-
});
|
|
110
|
-
this.expandByObject = jest.fn();
|
|
111
|
-
|
|
112
|
-
return this;
|
|
113
|
-
}),
|
|
114
|
-
Raycaster: jest.fn(function () {
|
|
115
|
-
this.intersectObjects = intersectObjectsMock;
|
|
116
|
-
this.layers = {
|
|
117
|
-
mask: 0,
|
|
118
|
-
};
|
|
119
|
-
return this;
|
|
120
|
-
}),
|
|
121
|
-
Mesh: jest.fn(function () {
|
|
122
|
-
this.geometry = {
|
|
123
|
-
computeBoundingBox: jest.fn(),
|
|
124
|
-
boundingBox: new Box3(),
|
|
125
|
-
};
|
|
126
|
-
this.material = {};
|
|
127
|
-
this.castShadow = true;
|
|
128
|
-
this.receiveShadow = true;
|
|
129
|
-
this.layers = {
|
|
130
|
-
mask: 0,
|
|
131
|
-
};
|
|
132
|
-
this.updateWorldMatrix = jest.fn();
|
|
133
|
-
this.traverse = jest.fn();
|
|
134
|
-
this.removeFromParent = jest.fn();
|
|
135
|
-
this.localToWorld = (vec3: Vector3) => {
|
|
136
|
-
return vec3;
|
|
137
|
-
};
|
|
138
|
-
return this;
|
|
139
|
-
}),
|
|
140
|
-
MeshStandardMaterial: jest.fn(function () {
|
|
141
|
-
this.color = new Color();
|
|
142
|
-
this.roughness = 1;
|
|
143
|
-
this.roughnessMap = undefined;
|
|
144
|
-
this.metalness = 0;
|
|
145
|
-
this.metalnessMap = undefined;
|
|
146
|
-
return this;
|
|
147
|
-
}),
|
|
148
|
-
Color: jest.fn(function () {
|
|
149
|
-
this.set = jest.fn();
|
|
150
|
-
return this;
|
|
151
|
-
}),
|
|
152
|
-
};
|
|
153
|
-
});
|
|
154
|
-
|
|
155
6
|
jest.mock('../../com/Communication.ts', () => {
|
|
156
7
|
return {
|
|
157
8
|
DIVECommunication: {
|
|
@@ -13,204 +13,7 @@ import {
|
|
|
13
13
|
type COMGeometry,
|
|
14
14
|
type COMGeometryType,
|
|
15
15
|
} from '../../com/types';
|
|
16
|
-
|
|
17
|
-
const intersectObjectsMock = jest.fn();
|
|
18
|
-
|
|
19
|
-
jest.mock('three', () => {
|
|
20
|
-
return {
|
|
21
|
-
Vector3: jest.fn(function (
|
|
22
|
-
x: number = 0,
|
|
23
|
-
y: number = 0,
|
|
24
|
-
z: number = 0,
|
|
25
|
-
) {
|
|
26
|
-
this.x = x;
|
|
27
|
-
this.y = y;
|
|
28
|
-
this.z = z;
|
|
29
|
-
this.copy = (vec3: Vector3) => {
|
|
30
|
-
this.x = vec3.x;
|
|
31
|
-
this.y = vec3.y;
|
|
32
|
-
this.z = vec3.z;
|
|
33
|
-
return this;
|
|
34
|
-
};
|
|
35
|
-
this.set = (x: number, y: number, z: number) => {
|
|
36
|
-
this.x = x;
|
|
37
|
-
this.y = y;
|
|
38
|
-
this.z = z;
|
|
39
|
-
return this;
|
|
40
|
-
};
|
|
41
|
-
this.multiply = (vec3: Vector3) => {
|
|
42
|
-
this.x *= vec3.x;
|
|
43
|
-
this.y *= vec3.y;
|
|
44
|
-
this.z *= vec3.z;
|
|
45
|
-
return this;
|
|
46
|
-
};
|
|
47
|
-
this.clone = () => {
|
|
48
|
-
return new Vector3(this.x, this.y, this.z);
|
|
49
|
-
};
|
|
50
|
-
this.setY = (y: number) => {
|
|
51
|
-
this.y = y;
|
|
52
|
-
return this;
|
|
53
|
-
};
|
|
54
|
-
this.add = (vec3: Vector3) => {
|
|
55
|
-
this.x += vec3.x;
|
|
56
|
-
this.y += vec3.y;
|
|
57
|
-
this.z += vec3.z;
|
|
58
|
-
return this;
|
|
59
|
-
};
|
|
60
|
-
this.sub = (vec3: Vector3) => {
|
|
61
|
-
this.x -= vec3.x;
|
|
62
|
-
this.y -= vec3.y;
|
|
63
|
-
this.z -= vec3.z;
|
|
64
|
-
return this;
|
|
65
|
-
};
|
|
66
|
-
return this;
|
|
67
|
-
}),
|
|
68
|
-
Object3D: jest.fn(function () {
|
|
69
|
-
this.clear = jest.fn();
|
|
70
|
-
this.color = {};
|
|
71
|
-
this.intensity = 0;
|
|
72
|
-
this.layers = {
|
|
73
|
-
mask: 0,
|
|
74
|
-
};
|
|
75
|
-
this.shadow = {
|
|
76
|
-
radius: 0,
|
|
77
|
-
mapSize: { width: 0, height: 0 },
|
|
78
|
-
bias: 0,
|
|
79
|
-
camera: {
|
|
80
|
-
near: 0,
|
|
81
|
-
far: 0,
|
|
82
|
-
fov: 0,
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
this.add = jest.fn();
|
|
86
|
-
this.sub = jest.fn();
|
|
87
|
-
this.children = [
|
|
88
|
-
{
|
|
89
|
-
visible: true,
|
|
90
|
-
material: {
|
|
91
|
-
color: {},
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
];
|
|
95
|
-
this.userData = {};
|
|
96
|
-
this.position = new Vector3();
|
|
97
|
-
this.rotation = {
|
|
98
|
-
x: 0,
|
|
99
|
-
y: 0,
|
|
100
|
-
z: 0,
|
|
101
|
-
setFromVector3: jest.fn(),
|
|
102
|
-
};
|
|
103
|
-
this.scale = {
|
|
104
|
-
x: 1,
|
|
105
|
-
y: 1,
|
|
106
|
-
z: 1,
|
|
107
|
-
set: jest.fn(),
|
|
108
|
-
};
|
|
109
|
-
this.localToWorld = (vec3: Vector3) => {
|
|
110
|
-
return vec3;
|
|
111
|
-
};
|
|
112
|
-
this.mesh = new Mesh();
|
|
113
|
-
this.traverse = jest.fn((callback) => {
|
|
114
|
-
callback(this.children[0]);
|
|
115
|
-
});
|
|
116
|
-
this.getWorldPosition = jest.fn(() => {
|
|
117
|
-
return this.position.clone();
|
|
118
|
-
});
|
|
119
|
-
return this;
|
|
120
|
-
}),
|
|
121
|
-
Box3: jest.fn(function () {
|
|
122
|
-
this.min = new Vector3(Infinity, Infinity, Infinity);
|
|
123
|
-
this.max = new Vector3(-Infinity, -Infinity, -Infinity);
|
|
124
|
-
this.getCenter = jest.fn(() => {
|
|
125
|
-
return new Vector3(0, 0, 0);
|
|
126
|
-
});
|
|
127
|
-
this.expandByObject = jest.fn();
|
|
128
|
-
this.setFromObject = jest.fn();
|
|
129
|
-
|
|
130
|
-
return this;
|
|
131
|
-
}),
|
|
132
|
-
Raycaster: jest.fn(function () {
|
|
133
|
-
this.intersectObjects = intersectObjectsMock;
|
|
134
|
-
this.layers = {
|
|
135
|
-
mask: 0,
|
|
136
|
-
};
|
|
137
|
-
return this;
|
|
138
|
-
}),
|
|
139
|
-
Mesh: jest.fn(function () {
|
|
140
|
-
this.geometry = {
|
|
141
|
-
computeBoundingBox: jest.fn(),
|
|
142
|
-
boundingBox: {
|
|
143
|
-
min: new Vector3(0, 2, 0),
|
|
144
|
-
max: new Vector3(2, 4, 2),
|
|
145
|
-
getCenter: jest.fn(() => {
|
|
146
|
-
return new Vector3(0, 0, 0);
|
|
147
|
-
}),
|
|
148
|
-
expandByObject: jest.fn(),
|
|
149
|
-
setFromObject: jest.fn(),
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
this.material = {};
|
|
153
|
-
this.castShadow = true;
|
|
154
|
-
this.receiveShadow = true;
|
|
155
|
-
this.layers = {
|
|
156
|
-
mask: 0,
|
|
157
|
-
};
|
|
158
|
-
this.updateWorldMatrix = jest.fn();
|
|
159
|
-
this.traverse = jest.fn();
|
|
160
|
-
this.removeFromParent = jest.fn();
|
|
161
|
-
this.localToWorld = (vec3: Vector3) => {
|
|
162
|
-
return vec3;
|
|
163
|
-
};
|
|
164
|
-
return this;
|
|
165
|
-
}),
|
|
166
|
-
BufferGeometry: jest.fn(function () {
|
|
167
|
-
this.setAttribute = jest.fn();
|
|
168
|
-
this.setIndex = jest.fn();
|
|
169
|
-
this.translate = jest.fn();
|
|
170
|
-
this.computeVertexNormals = jest.fn();
|
|
171
|
-
this.computeBoundingBox = jest.fn();
|
|
172
|
-
this.computeBoundingSphere = jest.fn();
|
|
173
|
-
return this;
|
|
174
|
-
}),
|
|
175
|
-
BufferAttribute: jest.fn(function () {
|
|
176
|
-
return this;
|
|
177
|
-
}),
|
|
178
|
-
CylinderGeometry: jest.fn(function () {
|
|
179
|
-
this.translate = jest.fn();
|
|
180
|
-
return this;
|
|
181
|
-
}),
|
|
182
|
-
SphereGeometry: jest.fn(function () {
|
|
183
|
-
this.translate = jest.fn();
|
|
184
|
-
return this;
|
|
185
|
-
}),
|
|
186
|
-
BoxGeometry: jest.fn(function () {
|
|
187
|
-
this.translate = jest.fn();
|
|
188
|
-
return this;
|
|
189
|
-
}),
|
|
190
|
-
ConeGeometry: jest.fn(function () {
|
|
191
|
-
this.rotateY = jest.fn();
|
|
192
|
-
this.translate = jest.fn();
|
|
193
|
-
return this;
|
|
194
|
-
}),
|
|
195
|
-
Float32BufferAttribute: jest.fn(function () {
|
|
196
|
-
return this;
|
|
197
|
-
}),
|
|
198
|
-
Uint32BufferAttribute: jest.fn(function () {
|
|
199
|
-
return this;
|
|
200
|
-
}),
|
|
201
|
-
MeshStandardMaterial: jest.fn(function () {
|
|
202
|
-
this.color = {};
|
|
203
|
-
this.roughness = 0;
|
|
204
|
-
this.roughnessMap = undefined;
|
|
205
|
-
this.metalness = 0;
|
|
206
|
-
this.metalnessMap = undefined;
|
|
207
|
-
return this;
|
|
208
|
-
}),
|
|
209
|
-
Color: jest.fn(function () {
|
|
210
|
-
return this;
|
|
211
|
-
}),
|
|
212
|
-
};
|
|
213
|
-
});
|
|
16
|
+
import { RaycasterIntersectObjectMock } from '../../../__mocks__/three';
|
|
214
17
|
|
|
215
18
|
jest.mock('../../com/Communication.ts', () => {
|
|
216
19
|
return {
|
|
@@ -265,6 +68,10 @@ describe('dive/primitive/DIVEPrimitive', () => {
|
|
|
265
68
|
const com = DIVECommunication.get('id')!;
|
|
266
69
|
const spyPerformAction = jest.spyOn(com, 'PerformAction');
|
|
267
70
|
|
|
71
|
+
jest.spyOn(primitive['_mesh']!, 'localToWorld').mockReturnValueOnce(
|
|
72
|
+
new Vector3(0, 2, 0),
|
|
73
|
+
);
|
|
74
|
+
|
|
268
75
|
primitive.userData.id = 'something';
|
|
269
76
|
primitive.position.set(0, 2, 0);
|
|
270
77
|
primitive['_boundingBox'] = {
|
|
@@ -324,7 +131,7 @@ describe('dive/primitive/DIVEPrimitive', () => {
|
|
|
324
131
|
const hitObject = new Mesh();
|
|
325
132
|
hitObject.geometry.boundingBox = new Box3();
|
|
326
133
|
hitObject.geometry.boundingBox.max = new Vector3(0, 2, 0);
|
|
327
|
-
|
|
134
|
+
RaycasterIntersectObjectMock.mockReturnValue([
|
|
328
135
|
{
|
|
329
136
|
object: hitObject,
|
|
330
137
|
},
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WebGLRendererRenderMock,
|
|
3
|
+
WebGLRendererSetSizeMock,
|
|
4
|
+
} from '../../../__mocks__/three';
|
|
1
5
|
import type DIVEPerspectiveCamera from '../../camera/PerspectiveCamera';
|
|
2
6
|
import { type DIVEScene } from '../../scene/Scene';
|
|
3
7
|
import { DIVERenderer, DIVERendererDefaultSettings } from '../Renderer';
|
|
@@ -6,41 +10,7 @@ import { DIVERenderer, DIVERendererDefaultSettings } from '../Renderer';
|
|
|
6
10
|
* @jest-environment jsdom
|
|
7
11
|
*/
|
|
8
12
|
|
|
9
|
-
const test_uuid = '
|
|
10
|
-
|
|
11
|
-
const mock_render = jest.fn();
|
|
12
|
-
const mock_setSize = jest.fn();
|
|
13
|
-
|
|
14
|
-
jest.mock('three', () => {
|
|
15
|
-
return {
|
|
16
|
-
WebGLRenderer: jest.fn(function () {
|
|
17
|
-
this.domElement = {
|
|
18
|
-
style: {
|
|
19
|
-
position: 'absolute',
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
this.dispose = jest.fn();
|
|
23
|
-
this.debug = {
|
|
24
|
-
checkShaderErrors: true,
|
|
25
|
-
};
|
|
26
|
-
this.setSize = mock_setSize;
|
|
27
|
-
this.setPixelRatio = jest.fn();
|
|
28
|
-
this.render = mock_render;
|
|
29
|
-
this.setAnimationLoop = jest.fn((callback: (() => void) | null) => {
|
|
30
|
-
if (callback) callback();
|
|
31
|
-
});
|
|
32
|
-
this.shadowMap = {
|
|
33
|
-
enabled: false,
|
|
34
|
-
};
|
|
35
|
-
return this;
|
|
36
|
-
}),
|
|
37
|
-
MathUtils: {
|
|
38
|
-
generateUUID: () => {
|
|
39
|
-
return test_uuid;
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
});
|
|
13
|
+
const test_uuid = 'test_uuid';
|
|
44
14
|
|
|
45
15
|
let renderer: DIVERenderer;
|
|
46
16
|
|
|
@@ -112,11 +82,11 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
112
82
|
expect(() => {
|
|
113
83
|
renderer.OnResize(500, 500);
|
|
114
84
|
}).not.toThrow();
|
|
115
|
-
expect(
|
|
85
|
+
expect(WebGLRendererSetSizeMock).toHaveBeenCalledTimes(1);
|
|
116
86
|
});
|
|
117
87
|
|
|
118
88
|
it('should render', () => {
|
|
119
|
-
expect(
|
|
89
|
+
expect(WebGLRendererRenderMock).toHaveBeenCalledTimes(0);
|
|
120
90
|
|
|
121
91
|
renderer.StartRenderer({} as DIVEScene, {} as DIVEPerspectiveCamera);
|
|
122
92
|
expect(() => {
|
|
@@ -127,7 +97,7 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
127
97
|
{} as XRFrame,
|
|
128
98
|
);
|
|
129
99
|
}).not.toThrow();
|
|
130
|
-
expect(
|
|
100
|
+
expect(WebGLRendererRenderMock).toHaveBeenCalledTimes(1);
|
|
131
101
|
});
|
|
132
102
|
|
|
133
103
|
it('should force render', () => {
|
|
@@ -137,14 +107,14 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
137
107
|
});
|
|
138
108
|
|
|
139
109
|
it('should not render when not started', () => {
|
|
140
|
-
expect(
|
|
110
|
+
expect(WebGLRendererRenderMock).toHaveBeenCalledTimes(0);
|
|
141
111
|
renderer['internal_render'](
|
|
142
112
|
{} as DIVEScene,
|
|
143
113
|
{} as DIVEPerspectiveCamera,
|
|
144
114
|
0.016,
|
|
145
115
|
{} as XRFrame,
|
|
146
116
|
);
|
|
147
|
-
expect(
|
|
117
|
+
expect(WebGLRendererRenderMock).toHaveBeenCalledTimes(0);
|
|
148
118
|
});
|
|
149
119
|
|
|
150
120
|
it('should not render when stopped', () => {
|
|
@@ -155,7 +125,7 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
155
125
|
0.016,
|
|
156
126
|
{} as XRFrame,
|
|
157
127
|
);
|
|
158
|
-
expect(
|
|
128
|
+
expect(WebGLRendererRenderMock).toHaveBeenCalledTimes(1);
|
|
159
129
|
|
|
160
130
|
renderer.StopRenderer();
|
|
161
131
|
renderer['internal_render'](
|
|
@@ -164,7 +134,7 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
164
134
|
0.016,
|
|
165
135
|
{} as XRFrame,
|
|
166
136
|
);
|
|
167
|
-
expect(
|
|
137
|
+
expect(WebGLRendererRenderMock).toHaveBeenCalledTimes(1);
|
|
168
138
|
});
|
|
169
139
|
|
|
170
140
|
it('should not render when paused', () => {
|
|
@@ -175,7 +145,7 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
175
145
|
0.016,
|
|
176
146
|
{} as XRFrame,
|
|
177
147
|
);
|
|
178
|
-
expect(
|
|
148
|
+
expect(WebGLRendererRenderMock).toHaveBeenCalledTimes(1);
|
|
179
149
|
|
|
180
150
|
renderer.PauseRenderer();
|
|
181
151
|
renderer['internal_render'](
|
|
@@ -184,7 +154,7 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
184
154
|
0.016,
|
|
185
155
|
{} as XRFrame,
|
|
186
156
|
);
|
|
187
|
-
expect(
|
|
157
|
+
expect(WebGLRendererRenderMock).toHaveBeenCalledTimes(1);
|
|
188
158
|
});
|
|
189
159
|
|
|
190
160
|
it('should resume render when running', () => {
|
|
@@ -196,7 +166,7 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
196
166
|
0.016,
|
|
197
167
|
{} as XRFrame,
|
|
198
168
|
);
|
|
199
|
-
expect(
|
|
169
|
+
expect(WebGLRendererRenderMock).toHaveBeenCalledTimes(0);
|
|
200
170
|
|
|
201
171
|
renderer.ResumeRenderer();
|
|
202
172
|
renderer['internal_render'](
|
|
@@ -205,7 +175,7 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
205
175
|
0.016,
|
|
206
176
|
{} as XRFrame,
|
|
207
177
|
);
|
|
208
|
-
expect(
|
|
178
|
+
expect(WebGLRendererRenderMock).toHaveBeenCalledTimes(1);
|
|
209
179
|
});
|
|
210
180
|
|
|
211
181
|
it('should add pre render callback', () => {
|
|
@@ -50,84 +50,74 @@ jest.mock('../../renderer/Renderer.ts', () => {
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
const mockRenderer = new DIVERenderer();
|
|
53
|
+
let scene: DIVEScene;
|
|
53
54
|
|
|
54
55
|
describe('dive/scene/DIVEScene', () => {
|
|
56
|
+
beforeEach(() => {
|
|
57
|
+
scene = new DIVEScene();
|
|
58
|
+
});
|
|
59
|
+
|
|
55
60
|
afterEach(() => {
|
|
56
61
|
jest.clearAllMocks();
|
|
57
62
|
});
|
|
58
63
|
|
|
59
64
|
it('should instantiate', () => {
|
|
60
|
-
const scene = new DIVEScene();
|
|
61
65
|
expect(scene).toBeDefined();
|
|
62
66
|
});
|
|
63
67
|
|
|
64
68
|
it('should have Root', () => {
|
|
65
|
-
const scene = new DIVEScene();
|
|
66
69
|
expect(scene.Root).toBeDefined();
|
|
67
70
|
});
|
|
68
71
|
|
|
69
72
|
it('should have XRRoot', () => {
|
|
70
|
-
const scene = new DIVEScene();
|
|
71
73
|
expect(scene.XRRoot).toBeDefined();
|
|
72
74
|
});
|
|
73
75
|
|
|
74
76
|
it('should have Floor', () => {
|
|
75
|
-
const scene = new DIVEScene();
|
|
76
77
|
expect(scene.Floor).toBeDefined();
|
|
77
78
|
});
|
|
78
79
|
|
|
79
80
|
it('should have Grid', () => {
|
|
80
|
-
const scene = new DIVEScene();
|
|
81
81
|
expect(scene.Grid).toBeDefined();
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
it('should InitXR', () => {
|
|
85
|
-
const scene = new DIVEScene();
|
|
86
85
|
expect(() => scene.InitXR(mockRenderer)).not.toThrow();
|
|
87
86
|
});
|
|
88
87
|
|
|
89
88
|
it('should DisposeXR', () => {
|
|
90
|
-
const scene = new DIVEScene();
|
|
91
89
|
expect(() => scene.DisposeXR()).not.toThrow();
|
|
92
90
|
});
|
|
93
91
|
|
|
94
92
|
it('should set background color', () => {
|
|
95
|
-
|
|
96
|
-
scene.SetBackground(0x123456);
|
|
97
|
-
expect((scene.background as Color).getHex()).toBe(0x123456);
|
|
93
|
+
expect(() => scene.SetBackground(0x123456)).not.toThrow();
|
|
98
94
|
});
|
|
99
95
|
|
|
100
96
|
it('should ComputeSceneBB', () => {
|
|
101
|
-
const scene = new DIVEScene();
|
|
102
97
|
expect(() => scene.ComputeSceneBB()).not.toThrow();
|
|
103
98
|
});
|
|
104
99
|
|
|
105
100
|
it('should add object', () => {
|
|
106
|
-
const scene = new DIVEScene();
|
|
107
101
|
scene.AddSceneObject({} as COMEntity);
|
|
108
102
|
expect(mock_AddSceneObject).toHaveBeenCalledTimes(1);
|
|
109
103
|
});
|
|
110
104
|
|
|
111
105
|
it('should update object', () => {
|
|
112
|
-
const scene = new DIVEScene();
|
|
113
106
|
scene.UpdateSceneObject({} as COMEntity);
|
|
114
107
|
expect(mock_UpdateSceneObject).toHaveBeenCalledTimes(1);
|
|
115
108
|
});
|
|
116
109
|
|
|
117
110
|
it('should remove object', () => {
|
|
118
|
-
const scene = new DIVEScene();
|
|
119
111
|
scene.DeleteSceneObject({} as COMEntity);
|
|
120
112
|
expect(mock_DeleteSceneObject).toHaveBeenCalledTimes(1);
|
|
121
113
|
});
|
|
122
114
|
|
|
123
115
|
it('should place object on floor', () => {
|
|
124
|
-
const scene = new DIVEScene();
|
|
125
116
|
scene.PlaceOnFloor({} as COMEntity);
|
|
126
117
|
expect(mock_PlaceOnFloor).toHaveBeenCalledTimes(1);
|
|
127
118
|
});
|
|
128
119
|
|
|
129
120
|
it('should get scene object', () => {
|
|
130
|
-
const scene = new DIVEScene();
|
|
131
121
|
scene.GetSceneObject({} as COMEntity);
|
|
132
122
|
expect(mock_GetSceneObject).toHaveBeenCalledTimes(1);
|
|
133
123
|
});
|
package/src/scene/root/Root.ts
CHANGED
|
@@ -306,13 +306,13 @@ export class DIVERoot extends Object3D {
|
|
|
306
306
|
|
|
307
307
|
if (group.name !== undefined) sceneObject.name = group.name;
|
|
308
308
|
if (group.position !== undefined)
|
|
309
|
-
(sceneObject as
|
|
309
|
+
(sceneObject as DIVEGroup).SetPosition(group.position);
|
|
310
310
|
if (group.rotation !== undefined)
|
|
311
|
-
(sceneObject as
|
|
311
|
+
(sceneObject as DIVEGroup).SetRotation(group.rotation);
|
|
312
312
|
if (group.scale !== undefined)
|
|
313
|
-
(sceneObject as
|
|
313
|
+
(sceneObject as DIVEGroup).SetScale(group.scale);
|
|
314
314
|
if (group.visible !== undefined)
|
|
315
|
-
(sceneObject as
|
|
315
|
+
(sceneObject as DIVEGroup).SetVisibility(group.visible);
|
|
316
316
|
if (group.bbVisible !== undefined)
|
|
317
317
|
(sceneObject as DIVEGroup).SetLinesVisibility(group.bbVisible);
|
|
318
318
|
if (group.parentId !== undefined)
|