@shopware-ag/dive 1.19.0 → 1.19.1-beta.1
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/build/dive.cjs +388 -220
- package/build/dive.cjs.map +1 -1
- package/build/dive.js +395 -21946
- package/build/dive.js.map +1 -1
- package/build/dive.mjs +28206 -0
- package/build/dive.mjs.map +1 -0
- package/build/src/ar/AR.d.ts +37 -14
- package/build/src/ar/arquicklook/ARQuickLook.d.ts +5 -6
- package/build/src/ar/sceneviewer/SceneViewer.d.ts +42 -6
- package/build/src/com/actions/scene/launchar.d.ts +5 -2
- package/build/src/converter/Converter.d.ts +21 -0
- package/build/src/dive.d.ts +3 -2
- package/build/src/exporter/Exporter.d.ts +11 -0
- package/build/src/helper/applyMixins/applyMixins.d.ts +22 -6
- package/build/src/info/Info.d.ts +37 -13
- package/build/src/interface/Movable.d.ts +5 -5
- package/build/src/interface/Selectable.d.ts +4 -4
- package/build/src/loader/Loader.d.ts +11 -0
- package/build/src/model/Model.d.ts +2 -2
- package/build/src/node/Node.d.ts +3 -3
- package/build/src/scene/root/Root.d.ts +1 -1
- package/build/src/types/ExporterOptions.d.ts +15 -0
- package/build/src/types/FileTypes.d.ts +27 -0
- package/build/src/types/index.d.ts +4 -0
- package/build/src/types/info/index.d.ts +66 -0
- package/package.json +17 -3
- package/build/src/exporters/usdz/USDZExporter.d.ts +0 -15
- package/build/src/loadingmanager/LoadingManager.d.ts +0 -14
- package/src/__test__/DIVE.test.ts +0 -274
- package/src/animation/AnimationSystem.ts +0 -34
- package/src/animation/__test__/AnimationSystem.test.ts +0 -40
- package/src/ar/AR.ts +0 -98
- package/src/ar/__test__/AR.test.ts +0 -187
- package/src/ar/arquicklook/ARQuickLook.ts +0 -93
- package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +0 -93
- package/src/ar/sceneviewer/SceneViewer.ts +0 -74
- package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -93
- package/src/ar/webxr/WebXR.ts +0 -176
- package/src/ar/webxr/controller/WebXRController.ts +0 -340
- package/src/ar/webxr/crosshair/WebXRCrosshair.ts +0 -35
- package/src/ar/webxr/origin/WebXROrigin.ts +0 -192
- package/src/ar/webxr/overlay/Overlay.ts +0 -50
- package/src/ar/webxr/raycaster/WebXRRaycaster.ts +0 -131
- package/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts +0 -102
- package/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts +0 -49
- package/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts +0 -356
- package/src/axiscamera/AxisCamera.ts +0 -108
- package/src/axiscamera/__test__/AxisCamera.test.ts +0 -150
- package/src/camera/PerspectiveCamera.ts +0 -63
- package/src/camera/__test__/PerspectiveCamera.test.ts +0 -36
- package/src/com/Communication.ts +0 -808
- package/src/com/__test__/Communication.test.ts +0 -1024
- package/src/com/actions/camera/computeencompassingview.ts +0 -10
- package/src/com/actions/camera/getcameratransform.ts +0 -10
- package/src/com/actions/camera/movecamera.ts +0 -18
- package/src/com/actions/camera/resetcamera.ts +0 -5
- package/src/com/actions/camera/setcameralayer.ts +0 -5
- package/src/com/actions/camera/setcameratransform.ts +0 -10
- package/src/com/actions/camera/zoomcamera.ts +0 -5
- package/src/com/actions/index.ts +0 -61
- package/src/com/actions/media/generatemedia.ts +0 -18
- package/src/com/actions/object/addobject.ts +0 -7
- package/src/com/actions/object/deleteobject.ts +0 -7
- package/src/com/actions/object/deselectobject.ts +0 -7
- package/src/com/actions/object/getallobjects.ts +0 -7
- package/src/com/actions/object/getobjects.ts +0 -7
- package/src/com/actions/object/model/dropit.ts +0 -5
- package/src/com/actions/object/model/modelloaded.ts +0 -5
- package/src/com/actions/object/model/placeonfloor.ts +0 -5
- package/src/com/actions/object/selectobject.ts +0 -7
- package/src/com/actions/object/setparent.ts +0 -10
- package/src/com/actions/object/updateobject.ts +0 -7
- package/src/com/actions/renderer/startrender.ts +0 -5
- package/src/com/actions/scene/exportscene.ts +0 -7
- package/src/com/actions/scene/getallscenedata.ts +0 -7
- package/src/com/actions/scene/launchar.ts +0 -7
- package/src/com/actions/scene/setbackground.ts +0 -5
- package/src/com/actions/scene/updatescene.ts +0 -11
- package/src/com/actions/toolbox/select/setgizmomode.ts +0 -5
- package/src/com/actions/toolbox/transform/setgizmoscalelinked.ts +0 -5
- package/src/com/actions/toolbox/transform/setgizmovisible.ts +0 -5
- package/src/com/actions/toolbox/usetool.ts +0 -7
- package/src/com/types/COMBaseEntity.ts +0 -9
- package/src/com/types/COMEntity.ts +0 -7
- package/src/com/types/COMEntityType.ts +0 -1
- package/src/com/types/COMGeometry.ts +0 -8
- package/src/com/types/COMGeometryType.ts +0 -9
- package/src/com/types/COMGroup.ts +0 -9
- package/src/com/types/COMLight.ts +0 -11
- package/src/com/types/COMMaterial.ts +0 -12
- package/src/com/types/COMModel.ts +0 -12
- package/src/com/types/COMPov.ts +0 -8
- package/src/com/types/COMPrimitive.ts +0 -12
- package/src/com/types/index.ts +0 -23
- package/src/constant/AxisHelperColors.ts +0 -7
- package/src/constant/GridColors.ts +0 -2
- package/src/constant/VisibilityLayerMask.ts +0 -5
- package/src/controls/OrbitControls.ts +0 -211
- package/src/controls/__test__/OrbitControls.test.ts +0 -256
- package/src/dive.ts +0 -363
- package/src/events/EventExecutor.ts +0 -35
- package/src/exporters/usdz/USDZExporter.ts +0 -21
- package/src/exporters/usdz/__test__/USDZExporter.test.ts +0 -57
- package/src/gizmo/Gizmo.ts +0 -144
- package/src/gizmo/handles/AxisHandle.ts +0 -153
- package/src/gizmo/handles/RadialHandle.ts +0 -149
- package/src/gizmo/handles/ScaleHandle.ts +0 -195
- package/src/gizmo/plane/GizmoPlane.ts +0 -84
- package/src/gizmo/rotate/RotateGizmo.ts +0 -143
- package/src/gizmo/scale/ScaleGizmo.ts +0 -125
- package/src/gizmo/translate/TranslateGizmo.ts +0 -114
- package/src/grid/Grid.ts +0 -34
- package/src/grid/__test__/Grid.test.ts +0 -28
- package/src/group/Group.ts +0 -184
- package/src/group/__test__/Group.test.ts +0 -212
- package/src/helper/applyMixins/__test__/applyMixins.test.ts +0 -30
- package/src/helper/applyMixins/applyMixins.ts +0 -18
- package/src/helper/findInterface/__test__/findInterface.test.ts +0 -63
- package/src/helper/findInterface/findInterface.ts +0 -13
- package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +0 -40
- package/src/helper/findSceneRecursive/findSceneRecursive.ts +0 -16
- package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +0 -186
- package/src/helper/getObjectDelta/getObjectDelta.ts +0 -105
- package/src/helper/isInterface/__test__/implementsInterface.test.ts +0 -19
- package/src/helper/isInterface/implementsInterface.ts +0 -9
- package/src/info/Info.ts +0 -154
- package/src/info/__test__/Info.test.ts +0 -338
- package/src/interface/Draggable.ts +0 -14
- package/src/interface/Hoverable.ts +0 -14
- package/src/interface/Movable.ts +0 -12
- package/src/interface/Rotatable.ts +0 -10
- package/src/interface/Scalable.ts +0 -10
- package/src/interface/Selectable.ts +0 -11
- package/src/io/IO.ts +0 -62
- package/src/io/__test__/IO.test.ts +0 -116
- package/src/io/gltf/GLTFIO.ts +0 -56
- package/src/io/gltf/__test__/GLTFIO.test.ts +0 -108
- package/src/light/AmbientLight.ts +0 -39
- package/src/light/PointLight.ts +0 -115
- package/src/light/SceneLight.ts +0 -63
- package/src/light/__test__/AmbientLight.test.ts +0 -29
- package/src/light/__test__/PointLight.test.ts +0 -74
- package/src/light/__test__/SceneLight.test.ts +0 -47
- package/src/loadingmanager/LoadingManager.ts +0 -50
- package/src/loadingmanager/__test__/LoadingManager.test.ts +0 -27
- package/src/math/__test__/DIVEMath.test.ts +0 -12
- package/src/math/ceil/__test__/ceilExp.test.ts +0 -12
- package/src/math/ceil/ceilExp.ts +0 -6
- package/src/math/degToRad/__test__/degToRad.test.ts +0 -172
- package/src/math/degToRad/degToRad.ts +0 -5
- package/src/math/floor/__test__/floorExp.test.ts +0 -14
- package/src/math/floor/floorExp.ts +0 -6
- package/src/math/helper/__test__/shift.test.ts +0 -12
- package/src/math/helper/shift.ts +0 -4
- package/src/math/index.ts +0 -28
- package/src/math/radToDeg/__test__/radToDeg.test.ts +0 -155
- package/src/math/radToDeg/radToDeg.ts +0 -5
- package/src/math/round/__test__/roundExp.test.ts +0 -14
- package/src/math/round/roundExp.ts +0 -10
- package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +0 -20
- package/src/math/signedAngleTo/signedAngleTo.ts +0 -20
- package/src/math/toFixed/__test__/toFixedExp.test.ts +0 -14
- package/src/math/toFixed/toFixedExp.ts +0 -9
- package/src/math/truncate/__test__/truncateExp.test.ts +0 -14
- package/src/math/truncate/truncateExp.ts +0 -9
- package/src/mediacreator/MediaCreator.ts +0 -75
- package/src/mediacreator/__test__/MediaCreator.test.ts +0 -155
- package/src/model/Model.ts +0 -185
- package/src/model/__test__/Model.test.ts +0 -222
- package/src/module/Module.ts +0 -45
- package/src/module/__test__/Module.test.ts +0 -54
- package/src/node/Node.ts +0 -98
- package/src/node/__test__/Node.test.ts +0 -120
- package/src/primitive/Primitive.ts +0 -299
- package/src/primitive/__test__/Primitive.test.ts +0 -281
- package/src/primitive/floor/Floor.ts +0 -45
- package/src/primitive/floor/__test__/Floor.test.ts +0 -24
- package/src/renderer/Renderer.ts +0 -215
- package/src/renderer/__test__/Renderer.test.ts +0 -228
- package/src/scene/Scene.ts +0 -106
- package/src/scene/__test__/Scene.test.ts +0 -124
- package/src/scene/root/Root.ts +0 -426
- package/src/scene/root/__test__/Root.test.ts +0 -903
- package/src/scene/xrroot/XRRoot.ts +0 -56
- package/src/scene/xrroot/xrlightroot/XRLightRoot.ts +0 -80
- package/src/toolbox/BaseTool.ts +0 -319
- package/src/toolbox/Toolbox.ts +0 -129
- package/src/toolbox/__test__/BaseTool.test.ts +0 -627
- package/src/toolbox/__test__/Toolbox.test.ts +0 -143
- package/src/toolbox/select/SelectTool.ts +0 -92
- package/src/toolbox/select/__test__/SelectTool.test.ts +0 -237
- package/src/toolbox/transform/TransformTool.ts +0 -166
- package/src/toolbox/transform/__test__/TransformTool.test.ts +0 -147
- package/src/types/SceneData.ts +0 -26
- package/src/types/SceneObjects.ts +0 -14
- package/src/types/SceneType.ts +0 -14
- package/src/types/index.ts +0 -5
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import { DIVEPrimitive } from '../Primitive';
|
|
2
|
-
import { DIVECommunication } from '../../com/Communication';
|
|
3
|
-
import {
|
|
4
|
-
Vector3,
|
|
5
|
-
Box3,
|
|
6
|
-
Mesh,
|
|
7
|
-
type Texture,
|
|
8
|
-
type MeshStandardMaterial,
|
|
9
|
-
} from 'three';
|
|
10
|
-
import type { DIVEScene } from '../../scene/Scene';
|
|
11
|
-
import {
|
|
12
|
-
type COMMaterial,
|
|
13
|
-
type COMGeometry,
|
|
14
|
-
type COMGeometryType,
|
|
15
|
-
} from '../../com/types';
|
|
16
|
-
import { RaycasterIntersectObjectMock } from '../../../__mocks__/three';
|
|
17
|
-
|
|
18
|
-
jest.mock('../../com/Communication.ts', () => {
|
|
19
|
-
return {
|
|
20
|
-
DIVECommunication: {
|
|
21
|
-
get: jest.fn(() => {
|
|
22
|
-
return {
|
|
23
|
-
PerformAction: jest.fn(),
|
|
24
|
-
};
|
|
25
|
-
}),
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
jest.spyOn(DIVECommunication, 'get').mockReturnValue({
|
|
31
|
-
PerformAction: jest.fn(),
|
|
32
|
-
} as unknown as DIVECommunication);
|
|
33
|
-
|
|
34
|
-
let primitive: DIVEPrimitive;
|
|
35
|
-
|
|
36
|
-
describe('dive/primitive/DIVEPrimitive', () => {
|
|
37
|
-
beforeEach(() => {
|
|
38
|
-
primitive = new DIVEPrimitive();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
afterEach(() => {
|
|
42
|
-
jest.clearAllMocks();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should instantiate', () => {
|
|
46
|
-
expect(primitive).toBeDefined();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should set geometry', () => {
|
|
50
|
-
jest.spyOn(console, 'warn');
|
|
51
|
-
const geometry = {
|
|
52
|
-
name: 'cube' as COMGeometryType,
|
|
53
|
-
} as COMGeometry;
|
|
54
|
-
expect(() => primitive.SetGeometry(geometry)).not.toThrow();
|
|
55
|
-
expect(console.warn).not.toHaveBeenCalled();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should warn when geometry is invalid', () => {
|
|
59
|
-
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
60
|
-
const geometry = {
|
|
61
|
-
name: 'INVALID' as COMGeometryType,
|
|
62
|
-
} as COMGeometry;
|
|
63
|
-
expect(() => primitive.SetGeometry(geometry)).not.toThrow();
|
|
64
|
-
expect(console.warn).toHaveBeenCalled();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should place on floor', () => {
|
|
68
|
-
const com = DIVECommunication.get('id')!;
|
|
69
|
-
const spyPerformAction = jest.spyOn(com, 'PerformAction');
|
|
70
|
-
|
|
71
|
-
jest.spyOn(primitive['_mesh']!, 'localToWorld').mockReturnValueOnce(
|
|
72
|
-
new Vector3(0, 2, 0),
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
primitive.userData.id = 'something';
|
|
76
|
-
primitive.position.set(0, 2, 0);
|
|
77
|
-
primitive['_boundingBox'] = {
|
|
78
|
-
min: new Vector3(0, -2, 0),
|
|
79
|
-
setFromObject: jest.fn(),
|
|
80
|
-
} as unknown as Box3;
|
|
81
|
-
|
|
82
|
-
const scene = {
|
|
83
|
-
parent: null,
|
|
84
|
-
Root: {
|
|
85
|
-
children: [
|
|
86
|
-
primitive,
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
} as unknown as DIVEScene;
|
|
90
|
-
scene.Root.parent = scene;
|
|
91
|
-
|
|
92
|
-
primitive.parent = scene.Root;
|
|
93
|
-
|
|
94
|
-
expect(() => primitive.PlaceOnFloor()).not.toThrow();
|
|
95
|
-
expect(spyPerformAction).toHaveBeenCalledWith(
|
|
96
|
-
'UPDATE_OBJECT',
|
|
97
|
-
expect.objectContaining({
|
|
98
|
-
position: expect.objectContaining({
|
|
99
|
-
y: 0,
|
|
100
|
-
}),
|
|
101
|
-
}),
|
|
102
|
-
);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should drop it', () => {
|
|
106
|
-
const comMock = {
|
|
107
|
-
PerformAction: jest.fn(),
|
|
108
|
-
} as unknown as DIVECommunication;
|
|
109
|
-
jest.spyOn(DIVECommunication, 'get').mockReturnValue(comMock);
|
|
110
|
-
|
|
111
|
-
const spy = jest
|
|
112
|
-
.spyOn(primitive, 'onMove')
|
|
113
|
-
.mockImplementation(() => {});
|
|
114
|
-
|
|
115
|
-
const size = {
|
|
116
|
-
x: 1,
|
|
117
|
-
y: 1,
|
|
118
|
-
z: 1,
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
primitive.userData.id = 'something';
|
|
122
|
-
primitive.position.set(0, 4, 0);
|
|
123
|
-
primitive['_boundingBox'] = {
|
|
124
|
-
min: new Vector3(-size.x / 2, -size.y / 2, -size.z / 2),
|
|
125
|
-
max: new Vector3(size.x / 2, size.y / 2, size.z / 2),
|
|
126
|
-
getCenter: jest.fn(() => {
|
|
127
|
-
return new Vector3(0, 0, 0);
|
|
128
|
-
}),
|
|
129
|
-
} as unknown as Box3;
|
|
130
|
-
|
|
131
|
-
const hitObject = new Mesh();
|
|
132
|
-
hitObject.geometry.boundingBox = new Box3();
|
|
133
|
-
hitObject.geometry.boundingBox.max = new Vector3(0, 2, 0);
|
|
134
|
-
RaycasterIntersectObjectMock.mockReturnValue([
|
|
135
|
-
{
|
|
136
|
-
object: hitObject,
|
|
137
|
-
},
|
|
138
|
-
]);
|
|
139
|
-
|
|
140
|
-
const scene = {
|
|
141
|
-
parent: null,
|
|
142
|
-
Root: {
|
|
143
|
-
children: [
|
|
144
|
-
primitive,
|
|
145
|
-
],
|
|
146
|
-
},
|
|
147
|
-
} as unknown as DIVEScene;
|
|
148
|
-
scene.Root.parent = scene;
|
|
149
|
-
|
|
150
|
-
// test when parent is not set
|
|
151
|
-
console.warn = jest.fn();
|
|
152
|
-
expect(() => primitive.DropIt()).not.toThrow();
|
|
153
|
-
expect(console.warn).toHaveBeenCalledTimes(1);
|
|
154
|
-
|
|
155
|
-
primitive.parent = scene.Root;
|
|
156
|
-
|
|
157
|
-
expect(() => primitive.DropIt()).not.toThrow();
|
|
158
|
-
expect(primitive.position.y).toBe(2.5);
|
|
159
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
160
|
-
|
|
161
|
-
expect(() => primitive.DropIt()).not.toThrow();
|
|
162
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
163
|
-
|
|
164
|
-
// alter position so onMove will be called again
|
|
165
|
-
primitive.position.y = 2;
|
|
166
|
-
jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
|
|
167
|
-
expect(() => primitive.DropIt()).not.toThrow();
|
|
168
|
-
expect(spy).toHaveBeenCalledTimes(2);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it('should set geometry', () => {
|
|
172
|
-
primitive.userData.id = 'something';
|
|
173
|
-
|
|
174
|
-
// cylinder
|
|
175
|
-
const cylinder = {
|
|
176
|
-
name: 'cylinder',
|
|
177
|
-
width: 1,
|
|
178
|
-
height: 1.5,
|
|
179
|
-
depth: 1,
|
|
180
|
-
} as COMGeometry;
|
|
181
|
-
expect(() => primitive.SetGeometry(cylinder)).not.toThrow();
|
|
182
|
-
|
|
183
|
-
// sphere
|
|
184
|
-
const sphere = {
|
|
185
|
-
name: 'sphere',
|
|
186
|
-
width: 1,
|
|
187
|
-
height: 1,
|
|
188
|
-
depth: 1,
|
|
189
|
-
} as COMGeometry;
|
|
190
|
-
expect(() => primitive.SetGeometry(sphere)).not.toThrow();
|
|
191
|
-
|
|
192
|
-
// pyramid
|
|
193
|
-
const pyramid = {
|
|
194
|
-
name: 'pyramid',
|
|
195
|
-
width: 1,
|
|
196
|
-
height: 1.5,
|
|
197
|
-
depth: 1,
|
|
198
|
-
} as COMGeometry;
|
|
199
|
-
expect(() => primitive.SetGeometry(pyramid)).not.toThrow();
|
|
200
|
-
|
|
201
|
-
// box
|
|
202
|
-
const box = {
|
|
203
|
-
name: 'box',
|
|
204
|
-
width: 1,
|
|
205
|
-
height: 1,
|
|
206
|
-
depth: 1,
|
|
207
|
-
} as COMGeometry;
|
|
208
|
-
expect(() => primitive.SetGeometry(box)).not.toThrow();
|
|
209
|
-
|
|
210
|
-
// cone
|
|
211
|
-
const cone = {
|
|
212
|
-
name: 'cone',
|
|
213
|
-
width: 1,
|
|
214
|
-
height: 1.5,
|
|
215
|
-
depth: 1,
|
|
216
|
-
} as COMGeometry;
|
|
217
|
-
expect(() => primitive.SetGeometry(cone)).not.toThrow();
|
|
218
|
-
|
|
219
|
-
// wall
|
|
220
|
-
const wall = {
|
|
221
|
-
name: 'wall',
|
|
222
|
-
width: 1,
|
|
223
|
-
height: 1.5,
|
|
224
|
-
depth: 0.1,
|
|
225
|
-
} as COMGeometry;
|
|
226
|
-
expect(() => primitive.SetGeometry(wall)).not.toThrow();
|
|
227
|
-
|
|
228
|
-
const wallWithoutDepth = {
|
|
229
|
-
name: 'wall',
|
|
230
|
-
width: 1,
|
|
231
|
-
height: 1.5,
|
|
232
|
-
} as COMGeometry;
|
|
233
|
-
expect(() => primitive.SetGeometry(wallWithoutDepth)).not.toThrow();
|
|
234
|
-
|
|
235
|
-
// plane
|
|
236
|
-
const plane = {
|
|
237
|
-
name: 'plane',
|
|
238
|
-
width: 1,
|
|
239
|
-
height: 0.1,
|
|
240
|
-
depth: 1,
|
|
241
|
-
} as COMGeometry;
|
|
242
|
-
expect(() => primitive.SetGeometry(plane)).not.toThrow();
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('should set material', () => {
|
|
246
|
-
const material = primitive['_mesh'].material as MeshStandardMaterial;
|
|
247
|
-
|
|
248
|
-
// apply invalid material should not crash
|
|
249
|
-
expect(() => primitive.SetMaterial({} as COMMaterial)).not.toThrow();
|
|
250
|
-
expect(material).toBeDefined();
|
|
251
|
-
|
|
252
|
-
expect(() =>
|
|
253
|
-
primitive.SetMaterial({
|
|
254
|
-
color: 0xffffff,
|
|
255
|
-
roughness: 0,
|
|
256
|
-
metalness: 1,
|
|
257
|
-
} as COMMaterial),
|
|
258
|
-
).not.toThrow();
|
|
259
|
-
expect((material as MeshStandardMaterial).roughness).toBe(0);
|
|
260
|
-
expect((material as MeshStandardMaterial).roughnessMap).toBeUndefined();
|
|
261
|
-
expect((material as MeshStandardMaterial).metalness).toBe(1);
|
|
262
|
-
expect((material as MeshStandardMaterial).metalnessMap).toBeUndefined();
|
|
263
|
-
|
|
264
|
-
expect(() =>
|
|
265
|
-
primitive.SetMaterial({
|
|
266
|
-
color: 0xff00ff,
|
|
267
|
-
vertexColors: true,
|
|
268
|
-
map: 'This_Is_A_Texture' as unknown as Texture,
|
|
269
|
-
normalMap: 'This_Is_A_Texture' as unknown as Texture,
|
|
270
|
-
roughness: 0,
|
|
271
|
-
roughnessMap: 'This_Is_A_Texture' as unknown as Texture,
|
|
272
|
-
metalness: 1,
|
|
273
|
-
metalnessMap: 'This_Is_A_Texture' as unknown as Texture,
|
|
274
|
-
} as COMMaterial),
|
|
275
|
-
).not.toThrow();
|
|
276
|
-
expect((material as MeshStandardMaterial).roughness).toBe(1);
|
|
277
|
-
expect((material as MeshStandardMaterial).roughnessMap).toBeDefined();
|
|
278
|
-
expect((material as MeshStandardMaterial).metalness).toBe(0);
|
|
279
|
-
expect((material as MeshStandardMaterial).metalnessMap).toBeDefined();
|
|
280
|
-
});
|
|
281
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Color,
|
|
3
|
-
ColorRepresentation,
|
|
4
|
-
Mesh,
|
|
5
|
-
MeshStandardMaterial,
|
|
6
|
-
PlaneGeometry,
|
|
7
|
-
} from 'three';
|
|
8
|
-
import { PRODUCT_LAYER_MASK } from '../../constant/VisibilityLayerMask.ts';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A basic floor geometry.
|
|
12
|
-
*
|
|
13
|
-
* Can change the color and visibility of the floor.
|
|
14
|
-
*
|
|
15
|
-
* @module
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export class DIVEFloor extends Mesh {
|
|
19
|
-
public isFloor: true = true;
|
|
20
|
-
|
|
21
|
-
constructor() {
|
|
22
|
-
super(
|
|
23
|
-
new PlaneGeometry(10000, 10000),
|
|
24
|
-
new MeshStandardMaterial({
|
|
25
|
-
color: new Color(150 / 255, 150 / 255, 150 / 255),
|
|
26
|
-
}),
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
this.name = 'Floor';
|
|
30
|
-
|
|
31
|
-
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
32
|
-
|
|
33
|
-
this.receiveShadow = true;
|
|
34
|
-
|
|
35
|
-
this.rotateX(-Math.PI / 2);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public SetVisibility(visible: boolean): void {
|
|
39
|
-
this.visible = visible;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public SetColor(color: ColorRepresentation): void {
|
|
43
|
-
(this.material as MeshStandardMaterial).color = new Color(color);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MeshStandardMaterial } from 'three';
|
|
2
|
-
import { DIVEFloor } from '../Floor';
|
|
3
|
-
|
|
4
|
-
describe('dive/primitive/floor/DIVEFloor', () => {
|
|
5
|
-
it('should instantiate', () => {
|
|
6
|
-
const floor = new DIVEFloor();
|
|
7
|
-
expect(floor).toBeDefined();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should set visibility', () => {
|
|
11
|
-
const floor = new DIVEFloor();
|
|
12
|
-
expect(() => {
|
|
13
|
-
floor.SetVisibility(false);
|
|
14
|
-
}).not.toThrow();
|
|
15
|
-
expect(floor.visible).toBe(false);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should set color', () => {
|
|
19
|
-
const floor = new DIVEFloor();
|
|
20
|
-
expect(() => {
|
|
21
|
-
floor.SetColor('#ff00ff');
|
|
22
|
-
}).not.toThrow();
|
|
23
|
-
});
|
|
24
|
-
});
|
package/src/renderer/Renderer.ts
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Camera,
|
|
3
|
-
MathUtils,
|
|
4
|
-
NoToneMapping,
|
|
5
|
-
PCFSoftShadowMap,
|
|
6
|
-
Scene,
|
|
7
|
-
ShadowMapType,
|
|
8
|
-
ToneMapping,
|
|
9
|
-
WebGLRenderer,
|
|
10
|
-
} from 'three';
|
|
11
|
-
|
|
12
|
-
export type DIVERendererSettings = {
|
|
13
|
-
antialias: boolean;
|
|
14
|
-
alpha: boolean;
|
|
15
|
-
stencil: boolean;
|
|
16
|
-
shadowMapEnabled: boolean;
|
|
17
|
-
shadowMapType: ShadowMapType;
|
|
18
|
-
toneMapping: ToneMapping;
|
|
19
|
-
canvas?: HTMLCanvasElement;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const DIVERendererDefaultSettings: DIVERendererSettings = {
|
|
23
|
-
antialias: true,
|
|
24
|
-
alpha: true,
|
|
25
|
-
stencil: false,
|
|
26
|
-
shadowMapEnabled: true,
|
|
27
|
-
shadowMapType: PCFSoftShadowMap,
|
|
28
|
-
toneMapping: NoToneMapping,
|
|
29
|
-
canvas: undefined,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type DIVERenderCallback = (
|
|
33
|
-
time: DOMHighResTimeStamp,
|
|
34
|
-
frame: XRFrame,
|
|
35
|
-
) => void;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A changed version of the WebGLRenderer.
|
|
39
|
-
*
|
|
40
|
-
* Has to be started manually by calling StartRenderer().
|
|
41
|
-
*
|
|
42
|
-
* @module
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
export class DIVERenderer extends WebGLRenderer {
|
|
46
|
-
// basic functionality members
|
|
47
|
-
private paused: boolean = false;
|
|
48
|
-
private running: boolean = false;
|
|
49
|
-
private force: boolean = false;
|
|
50
|
-
|
|
51
|
-
// pre- and post-render callbacks
|
|
52
|
-
private preRenderCallbacks: Map<string, DIVERenderCallback> = new Map<
|
|
53
|
-
string,
|
|
54
|
-
DIVERenderCallback
|
|
55
|
-
>();
|
|
56
|
-
private postRenderCallbacks: Map<string, DIVERenderCallback> = new Map<
|
|
57
|
-
string,
|
|
58
|
-
DIVERenderCallback
|
|
59
|
-
>();
|
|
60
|
-
|
|
61
|
-
constructor(
|
|
62
|
-
rendererSettings: Partial<DIVERendererSettings> = DIVERendererDefaultSettings,
|
|
63
|
-
) {
|
|
64
|
-
super({
|
|
65
|
-
antialias:
|
|
66
|
-
rendererSettings.antialias ||
|
|
67
|
-
DIVERendererDefaultSettings.antialias,
|
|
68
|
-
alpha: rendererSettings.alpha || DIVERendererDefaultSettings.alpha,
|
|
69
|
-
preserveDrawingBuffer: true,
|
|
70
|
-
canvas: rendererSettings.canvas,
|
|
71
|
-
});
|
|
72
|
-
this.setPixelRatio(window.devicePixelRatio);
|
|
73
|
-
|
|
74
|
-
this.shadowMap.enabled =
|
|
75
|
-
rendererSettings.shadowMapEnabled ||
|
|
76
|
-
DIVERendererDefaultSettings.shadowMapEnabled;
|
|
77
|
-
this.shadowMap.type =
|
|
78
|
-
rendererSettings.shadowMapType ||
|
|
79
|
-
DIVERendererDefaultSettings.shadowMapType;
|
|
80
|
-
|
|
81
|
-
this.toneMapping =
|
|
82
|
-
rendererSettings.toneMapping ||
|
|
83
|
-
DIVERendererDefaultSettings.toneMapping;
|
|
84
|
-
|
|
85
|
-
this.debug.checkShaderErrors = false;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Stops renderings and disposes the renderer.
|
|
89
|
-
public Dispose(): void {
|
|
90
|
-
this.StopRenderer();
|
|
91
|
-
this.dispose();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Starts the renderer with the given scene and camera.
|
|
95
|
-
public StartRenderer(scene: Scene, cam: Camera): void {
|
|
96
|
-
this.setAnimationLoop((time: DOMHighResTimeStamp, frame: XRFrame) => {
|
|
97
|
-
this.internal_render(scene, cam, time, frame);
|
|
98
|
-
});
|
|
99
|
-
this.running = true;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Pauses the renderer.
|
|
103
|
-
public PauseRenderer(): void {
|
|
104
|
-
this.paused = true;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Resumes the renderer after pausing.
|
|
108
|
-
public ResumeRenderer(): void {
|
|
109
|
-
this.paused = false;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Stops the renderer completely. Has to be started again with StartRenderer().
|
|
113
|
-
public StopRenderer(): void {
|
|
114
|
-
this.setAnimationLoop(null);
|
|
115
|
-
this.running = false;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Resizes the renderer to the given width and height.
|
|
119
|
-
public OnResize(width: number, height: number): void {
|
|
120
|
-
this.setSize(width, height);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Adds a callback to the render loop before actual render call.
|
|
125
|
-
* @param callback Executed before rendering.
|
|
126
|
-
* @returns uuid to remove the callback.
|
|
127
|
-
*/
|
|
128
|
-
public AddPreRenderCallback(callback: DIVERenderCallback): string {
|
|
129
|
-
// add callback to renderloop
|
|
130
|
-
const newUUID = MathUtils.generateUUID();
|
|
131
|
-
this.preRenderCallbacks.set(newUUID, callback);
|
|
132
|
-
|
|
133
|
-
return newUUID;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Removes a callback from the render loop before actual render call.
|
|
138
|
-
* @param uuid of callback to remove.
|
|
139
|
-
* @returns if removing was successful.
|
|
140
|
-
*/
|
|
141
|
-
public RemovePreRenderCallback(uuid: string): boolean {
|
|
142
|
-
// check if callback exists
|
|
143
|
-
if (!this.preRenderCallbacks.has(uuid)) return false;
|
|
144
|
-
|
|
145
|
-
// remove callback from renderloop
|
|
146
|
-
this.preRenderCallbacks.delete(uuid);
|
|
147
|
-
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Adds a callback to the render loop after actual render call.
|
|
153
|
-
* @param callback Executed after rendering.
|
|
154
|
-
* @returns uuid to remove the callback.
|
|
155
|
-
*/
|
|
156
|
-
public AddPostRenderCallback(callback: DIVERenderCallback): string {
|
|
157
|
-
// add callback to renderloop
|
|
158
|
-
const newUUID = MathUtils.generateUUID();
|
|
159
|
-
this.postRenderCallbacks.set(newUUID, callback);
|
|
160
|
-
|
|
161
|
-
return newUUID;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Removes a callback from the render loop after actual render call.
|
|
166
|
-
* @param uuid of callback to remove.
|
|
167
|
-
* @returns if removing was successful.
|
|
168
|
-
*/
|
|
169
|
-
public RemovePostRenderCallback(uuid: string): boolean {
|
|
170
|
-
// check if callback exists
|
|
171
|
-
if (!this.postRenderCallbacks.has(uuid)) return false;
|
|
172
|
-
|
|
173
|
-
// remove callback from renderloop
|
|
174
|
-
this.postRenderCallbacks.delete(uuid);
|
|
175
|
-
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Forces the renderer to render the next frame.
|
|
181
|
-
*/
|
|
182
|
-
public ForceRendering(): void {
|
|
183
|
-
this.force = true;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Internal render loop.
|
|
188
|
-
*
|
|
189
|
-
* To control renderloop you can add callbacks via AddPreRenderCallback() and AddPostRenderCallback().
|
|
190
|
-
* @param scene Scene to render.
|
|
191
|
-
* @param cam Camera to render with.
|
|
192
|
-
*/
|
|
193
|
-
private internal_render(
|
|
194
|
-
scene: Scene,
|
|
195
|
-
cam: Camera,
|
|
196
|
-
time: DOMHighResTimeStamp,
|
|
197
|
-
frame: XRFrame,
|
|
198
|
-
): void {
|
|
199
|
-
// execute background render loop callbacks
|
|
200
|
-
if ((this.paused || !this.running) && !this.force) return;
|
|
201
|
-
|
|
202
|
-
// execute render loop callbacks
|
|
203
|
-
this.preRenderCallbacks.forEach((callback) => {
|
|
204
|
-
callback(time, frame);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
this.render(scene, cam);
|
|
208
|
-
|
|
209
|
-
this.postRenderCallbacks.forEach((callback) => {
|
|
210
|
-
callback(time, frame);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
this.force = false;
|
|
214
|
-
}
|
|
215
|
-
}
|