@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,116 +0,0 @@
|
|
|
1
|
-
import { DIVEIO } from '../IO';
|
|
2
|
-
import { DIVEScene } from '../../scene/Scene';
|
|
3
|
-
|
|
4
|
-
import { type GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
5
|
-
|
|
6
|
-
jest.mock('../gltf/GLTFIO', () => {
|
|
7
|
-
return {
|
|
8
|
-
DIVEGLTFIO: jest.fn(function () {
|
|
9
|
-
this.Import = jest.fn();
|
|
10
|
-
this.Export = jest.fn();
|
|
11
|
-
return this;
|
|
12
|
-
}),
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
jest.mock('../../scene/Scene.ts', () => {
|
|
17
|
-
return {
|
|
18
|
-
DIVEScene: jest.fn(function () {
|
|
19
|
-
this.add = jest.fn();
|
|
20
|
-
this.isObject3D = true;
|
|
21
|
-
this.parent = null;
|
|
22
|
-
this.dispatchEvent = jest.fn();
|
|
23
|
-
this.position = {
|
|
24
|
-
set: jest.fn(),
|
|
25
|
-
};
|
|
26
|
-
this.SetIntensity = jest.fn();
|
|
27
|
-
this.SetEnabled = jest.fn();
|
|
28
|
-
this.SetColor = jest.fn();
|
|
29
|
-
this.userData = {
|
|
30
|
-
id: undefined,
|
|
31
|
-
};
|
|
32
|
-
this.removeFromParent = jest.fn();
|
|
33
|
-
return this;
|
|
34
|
-
}),
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
let testIO: DIVEIO;
|
|
39
|
-
|
|
40
|
-
describe('dive/io/DIVEIO', () => {
|
|
41
|
-
beforeEach(() => {
|
|
42
|
-
testIO = new DIVEIO(new DIVEScene());
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
afterEach(() => {
|
|
46
|
-
jest.clearAllMocks();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should instantiate', () => {
|
|
50
|
-
expect(testIO).toBeDefined();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should import from URL', async () => {
|
|
54
|
-
const mockGLTF = {} as GLTF;
|
|
55
|
-
jest.spyOn(testIO['_gltfIO'], 'Import').mockResolvedValueOnce(mockGLTF);
|
|
56
|
-
|
|
57
|
-
const result = await testIO.Import('glb', 'test.glb');
|
|
58
|
-
expect(result).toStrictEqual(mockGLTF);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should handle rejection from gltf io import', async () => {
|
|
62
|
-
jest.spyOn(console, 'error').mockImplementationOnce(() => {});
|
|
63
|
-
jest.spyOn(testIO['_gltfIO'], 'Import').mockRejectedValueOnce(
|
|
64
|
-
'THIS_IS_A_TEST_ERROR',
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
expect(testIO.Import('glb', 'test.glb')).resolves.toEqual(null);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should reject when importing with unsupported file type', async () => {
|
|
71
|
-
const spy = jest
|
|
72
|
-
.spyOn(console, 'error')
|
|
73
|
-
.mockImplementationOnce(() => {});
|
|
74
|
-
|
|
75
|
-
expect(
|
|
76
|
-
testIO.Import('THIS_IS_NOT_A_VALID_FILE_TYPE' as 'glb', 'test.glb'),
|
|
77
|
-
).rejects.not.toBeDefined();
|
|
78
|
-
expect(spy).toHaveBeenCalled();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should export to URL', async () => {
|
|
82
|
-
const mockObject = {};
|
|
83
|
-
const mockURL = 'blob://mockURL';
|
|
84
|
-
jest.spyOn(testIO['_gltfIO'], 'Export').mockResolvedValueOnce(
|
|
85
|
-
mockObject,
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
URL.createObjectURL = jest.fn().mockReturnValueOnce(mockURL);
|
|
89
|
-
|
|
90
|
-
const result = await testIO.Export('glb');
|
|
91
|
-
expect(result).toBeDefined();
|
|
92
|
-
expect(console.error).not.toHaveBeenCalled();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should handle rejection from gltf io export', async () => {
|
|
96
|
-
const spy = jest
|
|
97
|
-
.spyOn(console, 'error')
|
|
98
|
-
.mockImplementationOnce(() => {});
|
|
99
|
-
jest.spyOn(testIO['_gltfIO'], 'Export').mockRejectedValueOnce(
|
|
100
|
-
'THIS_IS_A_TEST_ERROR',
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
expect(testIO.Export('glb')).resolves.toEqual(null);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('should reject when exporting with unsupported file type', async () => {
|
|
107
|
-
const spy = jest
|
|
108
|
-
.spyOn(console, 'error')
|
|
109
|
-
.mockImplementationOnce(() => {});
|
|
110
|
-
|
|
111
|
-
expect(
|
|
112
|
-
testIO.Export('THIS_IS_NOT_A_VALID_FILE_TYPE' as 'glb'),
|
|
113
|
-
).rejects.not.toBeDefined();
|
|
114
|
-
expect(spy).toHaveBeenCalled();
|
|
115
|
-
});
|
|
116
|
-
});
|
package/src/io/gltf/GLTFIO.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { GLTFLoader, type GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
2
|
-
import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter';
|
|
3
|
-
import { Object3D } from 'three';
|
|
4
|
-
|
|
5
|
-
export class DIVEGLTFIO {
|
|
6
|
-
private _importer: GLTFLoader;
|
|
7
|
-
private _exporter: GLTFExporter;
|
|
8
|
-
|
|
9
|
-
constructor() {
|
|
10
|
-
this._importer = new GLTFLoader();
|
|
11
|
-
this._exporter = new GLTFExporter();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public Import(
|
|
15
|
-
url: string,
|
|
16
|
-
onProgress?: (progress: number) => void,
|
|
17
|
-
): Promise<GLTF> {
|
|
18
|
-
return this._importer.loadAsync(url, (progress) => {
|
|
19
|
-
if (!onProgress) return;
|
|
20
|
-
|
|
21
|
-
onProgress(progress.loaded / progress.total);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public Export(
|
|
26
|
-
object: Object3D,
|
|
27
|
-
binary: true,
|
|
28
|
-
onlyVisible: boolean,
|
|
29
|
-
): Promise<ArrayBuffer>;
|
|
30
|
-
|
|
31
|
-
public Export(
|
|
32
|
-
object: Object3D,
|
|
33
|
-
binary: false,
|
|
34
|
-
onlyVisible: boolean,
|
|
35
|
-
): Promise<{ [key: string]: unknown }>;
|
|
36
|
-
|
|
37
|
-
public Export(
|
|
38
|
-
object: Object3D,
|
|
39
|
-
binary: boolean,
|
|
40
|
-
onlyVisible: boolean,
|
|
41
|
-
): Promise<ArrayBuffer | { [key: string]: unknown }> {
|
|
42
|
-
if (binary) {
|
|
43
|
-
// export as binary ArrayBuffer
|
|
44
|
-
return this._exporter.parseAsync(object, {
|
|
45
|
-
binary,
|
|
46
|
-
onlyVisible,
|
|
47
|
-
}) as unknown as Promise<ArrayBuffer>;
|
|
48
|
-
} else {
|
|
49
|
-
// export as JSON object
|
|
50
|
-
return this._exporter.parseAsync(object, {
|
|
51
|
-
binary,
|
|
52
|
-
onlyVisible,
|
|
53
|
-
}) as unknown as Promise<{ [key: string]: unknown }>;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { Object3D } from 'three';
|
|
2
|
-
import { DIVEGLTFIO } from '../GLTFIO';
|
|
3
|
-
|
|
4
|
-
import { type GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
5
|
-
|
|
6
|
-
let testGLTFIO: DIVEGLTFIO;
|
|
7
|
-
|
|
8
|
-
describe('dive/io/gltf/DIVEGLTFIO', () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
testGLTFIO = new DIVEGLTFIO();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
afterEach(() => {
|
|
14
|
-
jest.clearAllMocks();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should instantiate', () => {
|
|
18
|
-
expect(testGLTFIO).toBeDefined();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should import from URL', async () => {
|
|
22
|
-
const mockGLTF = {} as GLTF;
|
|
23
|
-
|
|
24
|
-
// test without progress callback
|
|
25
|
-
jest.spyOn(testGLTFIO['_importer'], 'loadAsync').mockImplementationOnce(
|
|
26
|
-
(
|
|
27
|
-
uri: string,
|
|
28
|
-
progEvent?: (p: ProgressEvent<EventTarget>) => void,
|
|
29
|
-
) =>
|
|
30
|
-
new Promise<GLTF>((resolve) => {
|
|
31
|
-
if (progEvent)
|
|
32
|
-
progEvent({
|
|
33
|
-
loaded: 0,
|
|
34
|
-
total: 1,
|
|
35
|
-
} as ProgressEvent<EventTarget>);
|
|
36
|
-
|
|
37
|
-
resolve(mockGLTF);
|
|
38
|
-
}),
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const resultWithoutProgress = await testGLTFIO.Import(
|
|
42
|
-
'test url',
|
|
43
|
-
undefined,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
expect(resultWithoutProgress).toStrictEqual(mockGLTF);
|
|
47
|
-
|
|
48
|
-
// test with progress callback
|
|
49
|
-
jest.spyOn(testGLTFIO['_importer'], 'loadAsync').mockImplementationOnce(
|
|
50
|
-
(
|
|
51
|
-
uri: string,
|
|
52
|
-
progEvent?: (p: ProgressEvent<EventTarget>) => void,
|
|
53
|
-
) =>
|
|
54
|
-
new Promise<GLTF>((resolve) => {
|
|
55
|
-
if (progEvent)
|
|
56
|
-
progEvent({
|
|
57
|
-
loaded: 0,
|
|
58
|
-
total: 1,
|
|
59
|
-
} as ProgressEvent<EventTarget>);
|
|
60
|
-
|
|
61
|
-
resolve(mockGLTF);
|
|
62
|
-
}),
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const onProgress = jest.fn();
|
|
66
|
-
|
|
67
|
-
const resultWithProgress = await testGLTFIO.Import(
|
|
68
|
-
'test url',
|
|
69
|
-
onProgress,
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
expect(resultWithProgress).toStrictEqual(mockGLTF);
|
|
73
|
-
expect(onProgress).toHaveBeenCalledTimes(1);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should export to URL', async () => {
|
|
77
|
-
const mockObject = new Object3D();
|
|
78
|
-
|
|
79
|
-
// export as JSON object
|
|
80
|
-
jest.spyOn(testGLTFIO['_exporter'], 'parseAsync').mockResolvedValueOnce(
|
|
81
|
-
{},
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const json = await testGLTFIO.Export(mockObject, false, false);
|
|
85
|
-
expect(json).toBeDefined();
|
|
86
|
-
|
|
87
|
-
// export as array buffer
|
|
88
|
-
jest.spyOn(testGLTFIO['_exporter'], 'parseAsync').mockResolvedValueOnce(
|
|
89
|
-
new ArrayBuffer(0),
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const binary = await testGLTFIO.Export(mockObject, true, false);
|
|
93
|
-
expect(binary).toBeDefined();
|
|
94
|
-
|
|
95
|
-
// export as array buffer (only visible)
|
|
96
|
-
|
|
97
|
-
jest.spyOn(testGLTFIO['_exporter'], 'parseAsync').mockResolvedValueOnce(
|
|
98
|
-
new ArrayBuffer(0),
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const binaryOnlyVisible = await testGLTFIO.Export(
|
|
102
|
-
mockObject,
|
|
103
|
-
true,
|
|
104
|
-
true,
|
|
105
|
-
);
|
|
106
|
-
expect(binaryOnlyVisible).toBeDefined();
|
|
107
|
-
});
|
|
108
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { AmbientLight, Color, Object3D } from 'three';
|
|
2
|
-
import { PRODUCT_LAYER_MASK } from '../constant/VisibilityLayerMask';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A basic ambient light.
|
|
6
|
-
*
|
|
7
|
-
* Can change the color, intensity, and visibility of the light.
|
|
8
|
-
*
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
export default class DIVEAmbientLight extends Object3D {
|
|
13
|
-
readonly isDIVELight: true = true;
|
|
14
|
-
readonly isDIVEAmbientLight: true = true;
|
|
15
|
-
|
|
16
|
-
private _light: AmbientLight;
|
|
17
|
-
|
|
18
|
-
constructor() {
|
|
19
|
-
super();
|
|
20
|
-
|
|
21
|
-
this.name = 'DIVEAmbientLight';
|
|
22
|
-
|
|
23
|
-
this._light = new AmbientLight(0xffffff, 1);
|
|
24
|
-
this._light.layers.mask = PRODUCT_LAYER_MASK;
|
|
25
|
-
this.add(this._light);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public SetColor(color: Color): void {
|
|
29
|
-
this._light.color = color;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public SetIntensity(intensity: number): void {
|
|
33
|
-
this._light.intensity = intensity;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public SetEnabled(enabled: boolean): void {
|
|
37
|
-
this._light.visible = enabled;
|
|
38
|
-
}
|
|
39
|
-
}
|
package/src/light/PointLight.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PointLight,
|
|
3
|
-
Color,
|
|
4
|
-
SphereGeometry,
|
|
5
|
-
MeshBasicMaterial,
|
|
6
|
-
Mesh,
|
|
7
|
-
FrontSide,
|
|
8
|
-
Object3D,
|
|
9
|
-
} from 'three';
|
|
10
|
-
import { DIVECommunication } from '../com/Communication';
|
|
11
|
-
import {
|
|
12
|
-
PRODUCT_LAYER_MASK,
|
|
13
|
-
UI_LAYER_MASK,
|
|
14
|
-
} from '../constant/VisibilityLayerMask';
|
|
15
|
-
import { DIVEMovable } from '../interface/Movable';
|
|
16
|
-
import { DIVESelectable } from '../interface/Selectable';
|
|
17
|
-
import type { TransformControls } from 'three/examples/jsm/controls/TransformControls';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A basic point light.
|
|
21
|
-
*
|
|
22
|
-
* Can change the color, intensity, and visibility of the light.
|
|
23
|
-
*
|
|
24
|
-
* Can be moved and selected.
|
|
25
|
-
*
|
|
26
|
-
* @module
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
export default class DIVEPointLight
|
|
30
|
-
extends Object3D
|
|
31
|
-
implements DIVESelectable, DIVEMovable
|
|
32
|
-
{
|
|
33
|
-
readonly isDIVELight: true = true;
|
|
34
|
-
readonly isDIVEPointLight: true = true;
|
|
35
|
-
readonly isMovable: true = true;
|
|
36
|
-
readonly isSelectable: true = true;
|
|
37
|
-
|
|
38
|
-
public gizmo: TransformControls | null = null;
|
|
39
|
-
|
|
40
|
-
private light: PointLight;
|
|
41
|
-
private mesh: Mesh;
|
|
42
|
-
|
|
43
|
-
constructor() {
|
|
44
|
-
super();
|
|
45
|
-
|
|
46
|
-
this.name = 'DIVEPointLight';
|
|
47
|
-
|
|
48
|
-
this.light = new PointLight(0xffffff, 1);
|
|
49
|
-
|
|
50
|
-
this.light.layers.mask = PRODUCT_LAYER_MASK;
|
|
51
|
-
|
|
52
|
-
this.light.castShadow = true;
|
|
53
|
-
this.light.shadow.mapSize.width = 512;
|
|
54
|
-
this.light.shadow.mapSize.height = 512;
|
|
55
|
-
this.add(this.light);
|
|
56
|
-
|
|
57
|
-
const geoSize = 0.1;
|
|
58
|
-
|
|
59
|
-
const geometry = new SphereGeometry(
|
|
60
|
-
geoSize,
|
|
61
|
-
geoSize * 320,
|
|
62
|
-
geoSize * 320,
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const material = new MeshBasicMaterial({
|
|
66
|
-
color: this.light.color,
|
|
67
|
-
transparent: true,
|
|
68
|
-
opacity: 0.8,
|
|
69
|
-
side: FrontSide,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
this.mesh = new Mesh(geometry, material);
|
|
73
|
-
this.mesh.layers.mask = UI_LAYER_MASK;
|
|
74
|
-
|
|
75
|
-
this.add(this.mesh);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public SetColor(color: Color): void {
|
|
79
|
-
this.light.color = color;
|
|
80
|
-
|
|
81
|
-
(this.mesh.material as MeshBasicMaterial).color = color;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
public SetIntensity(intensity: number): void {
|
|
85
|
-
this.light.intensity = intensity;
|
|
86
|
-
|
|
87
|
-
(this.mesh.material as MeshBasicMaterial).opacity =
|
|
88
|
-
intensity > 0.8 ? 0.8 : intensity * 0.8;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public SetEnabled(enabled: boolean): void {
|
|
92
|
-
this.light.visible = enabled;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public onMove(): void {
|
|
96
|
-
DIVECommunication.get(this.userData.id)?.PerformAction(
|
|
97
|
-
'UPDATE_OBJECT',
|
|
98
|
-
{ id: this.userData.id, position: this.position },
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
public onSelect(): void {
|
|
103
|
-
DIVECommunication.get(this.userData.id)?.PerformAction(
|
|
104
|
-
'SELECT_OBJECT',
|
|
105
|
-
{ id: this.userData.id },
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
public onDeselect(): void {
|
|
110
|
-
DIVECommunication.get(this.userData.id)?.PerformAction(
|
|
111
|
-
'DESELECT_OBJECT',
|
|
112
|
-
{ id: this.userData.id },
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
}
|
package/src/light/SceneLight.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { PRODUCT_LAYER_MASK } from '../constant/VisibilityLayerMask.ts';
|
|
2
|
-
import { Color, DirectionalLight, HemisphereLight, Object3D } from 'three';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A complex scene light.
|
|
6
|
-
*
|
|
7
|
-
* Can change the color, intensity, and visibility of the light.
|
|
8
|
-
*
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
export default class DIVESceneLight extends Object3D {
|
|
13
|
-
readonly isDIVELight: true = true;
|
|
14
|
-
readonly isDIVESceneLight: true = true;
|
|
15
|
-
|
|
16
|
-
private _hemiLight: HemisphereLight;
|
|
17
|
-
private _dirLight: DirectionalLight;
|
|
18
|
-
|
|
19
|
-
constructor() {
|
|
20
|
-
super();
|
|
21
|
-
|
|
22
|
-
this.name = 'DIVESceneLight';
|
|
23
|
-
|
|
24
|
-
this._hemiLight = new HemisphereLight(0xffffff, 0xffffff, 2);
|
|
25
|
-
this._hemiLight.layers.mask = PRODUCT_LAYER_MASK;
|
|
26
|
-
this._hemiLight.position.set(0, 50, 0);
|
|
27
|
-
this.add(this._hemiLight);
|
|
28
|
-
|
|
29
|
-
this._dirLight = new DirectionalLight(0xffffff, 3);
|
|
30
|
-
this._dirLight.layers.mask = PRODUCT_LAYER_MASK;
|
|
31
|
-
this._dirLight.position.set(1, 1.75, 1);
|
|
32
|
-
this._dirLight.position.multiplyScalar(30);
|
|
33
|
-
this._dirLight.castShadow = true;
|
|
34
|
-
|
|
35
|
-
this._dirLight.shadow.mapSize.width = 2048;
|
|
36
|
-
this._dirLight.shadow.mapSize.height = 2048;
|
|
37
|
-
|
|
38
|
-
const d = 5;
|
|
39
|
-
|
|
40
|
-
this._dirLight.shadow.camera.left = -d;
|
|
41
|
-
this._dirLight.shadow.camera.right = d;
|
|
42
|
-
this._dirLight.shadow.camera.top = d;
|
|
43
|
-
this._dirLight.shadow.camera.bottom = -d;
|
|
44
|
-
|
|
45
|
-
this._dirLight.shadow.camera.far = 3500;
|
|
46
|
-
this.add(this._dirLight);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public SetColor(color: Color): void {
|
|
50
|
-
this._hemiLight.color = color;
|
|
51
|
-
this._dirLight.color = color;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public SetIntensity(intensity: number): void {
|
|
55
|
-
this._hemiLight.intensity = intensity * 2;
|
|
56
|
-
this._dirLight.intensity = intensity * 3;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public SetEnabled(enabled: boolean): void {
|
|
60
|
-
this._hemiLight.visible = enabled;
|
|
61
|
-
this._dirLight.visible = enabled;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AmbientLight, Color, Object3D } from 'three';
|
|
2
|
-
import DIVEAmbientLight from '../AmbientLight';
|
|
3
|
-
|
|
4
|
-
describe('dive/light/DIVEAmbientLight', () => {
|
|
5
|
-
it('should instantiate', () => {
|
|
6
|
-
const testLight = new DIVEAmbientLight();
|
|
7
|
-
expect(testLight).toBeDefined();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should set intensity', () => {
|
|
11
|
-
const testLight = new DIVEAmbientLight();
|
|
12
|
-
testLight.SetIntensity(1.0);
|
|
13
|
-
expect((testLight.children[0] as AmbientLight).intensity).toBe(1.0);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('should set color', () => {
|
|
17
|
-
const testLight = new DIVEAmbientLight();
|
|
18
|
-
testLight.SetColor({ test: true } as unknown as Color);
|
|
19
|
-
expect((testLight.children[0] as AmbientLight).color).toEqual({
|
|
20
|
-
test: true,
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should set enabled', () => {
|
|
25
|
-
const testLight = new DIVEAmbientLight();
|
|
26
|
-
testLight.SetEnabled(false);
|
|
27
|
-
expect(testLight.children[0].visible).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import DIVEPointLight from '../PointLight.ts';
|
|
2
|
-
import { DIVECommunication } from '../../com/Communication.ts';
|
|
3
|
-
import { Color, MeshBasicMaterial, Object3D, PointLight } from 'three';
|
|
4
|
-
|
|
5
|
-
jest.mock('../../com/Communication.ts', () => {
|
|
6
|
-
return {
|
|
7
|
-
DIVECommunication: {
|
|
8
|
-
get: jest.fn(() => {
|
|
9
|
-
return {
|
|
10
|
-
PerformAction: jest.fn(),
|
|
11
|
-
};
|
|
12
|
-
}),
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe('dive/light/DIVEPointLight', () => {
|
|
18
|
-
it('should instantiate', () => {
|
|
19
|
-
const testLight = new DIVEPointLight();
|
|
20
|
-
testLight.userData.id = 'something';
|
|
21
|
-
expect(testLight).toBeDefined();
|
|
22
|
-
expect(testLight.userData.id).toBe('something');
|
|
23
|
-
expect(testLight.children).toHaveLength(2);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should set intensity', () => {
|
|
27
|
-
const testLight = new DIVEPointLight();
|
|
28
|
-
testLight.SetIntensity(1.0);
|
|
29
|
-
expect((testLight.children[0] as PointLight).intensity).toBe(1.0);
|
|
30
|
-
testLight.SetIntensity(0.6);
|
|
31
|
-
expect((testLight.children[0] as PointLight).intensity).toBe(0.6);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should set color', () => {
|
|
35
|
-
const testLight = new DIVEPointLight();
|
|
36
|
-
testLight.SetColor({ test: true } as unknown as Color);
|
|
37
|
-
expect((testLight.children[0] as PointLight).color).toEqual({
|
|
38
|
-
test: true,
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should set enabled', () => {
|
|
43
|
-
const testLight = new DIVEPointLight();
|
|
44
|
-
testLight.SetEnabled(false);
|
|
45
|
-
expect(testLight.children[0].visible).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should onMove', () => {
|
|
49
|
-
const testLight = new DIVEPointLight();
|
|
50
|
-
testLight.userData.id = 'something';
|
|
51
|
-
expect(() => testLight.onMove()).not.toThrow();
|
|
52
|
-
|
|
53
|
-
jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
|
|
54
|
-
expect(() => testLight.onMove()).not.toThrow();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('should onSelect', () => {
|
|
58
|
-
const testLight = new DIVEPointLight();
|
|
59
|
-
testLight.userData.id = 'something';
|
|
60
|
-
expect(() => testLight.onSelect()).not.toThrow();
|
|
61
|
-
|
|
62
|
-
jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
|
|
63
|
-
expect(() => testLight.onSelect()).not.toThrow();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('should onDeselect', () => {
|
|
67
|
-
const testLight = new DIVEPointLight();
|
|
68
|
-
testLight.userData.id = 'something';
|
|
69
|
-
expect(() => testLight.onDeselect()).not.toThrow();
|
|
70
|
-
|
|
71
|
-
jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
|
|
72
|
-
expect(() => testLight.onDeselect()).not.toThrow();
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import DIVESceneLight from '../SceneLight';
|
|
2
|
-
import { DIVECommunication } from '../../com/Communication';
|
|
3
|
-
import { Color, Object3D } from 'three';
|
|
4
|
-
|
|
5
|
-
jest.mock('../../com/Communication.ts', () => {
|
|
6
|
-
return {
|
|
7
|
-
DIVECommunication: {
|
|
8
|
-
get: jest.fn(() => {
|
|
9
|
-
return {
|
|
10
|
-
PerformAction: jest.fn(),
|
|
11
|
-
};
|
|
12
|
-
}),
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
jest.spyOn(DIVECommunication, 'get').mockReturnValue({
|
|
18
|
-
PerformAction: jest.fn(),
|
|
19
|
-
} as unknown as DIVECommunication);
|
|
20
|
-
|
|
21
|
-
describe('dive/light/DIVESceneLight', () => {
|
|
22
|
-
it('should instantiate', () => {
|
|
23
|
-
const testLight = new DIVESceneLight();
|
|
24
|
-
expect(testLight).toBeDefined();
|
|
25
|
-
expect(testLight.children).toHaveLength(2);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should set intensity', () => {
|
|
29
|
-
const testLight = new DIVESceneLight();
|
|
30
|
-
expect(() => testLight.SetIntensity(1.0)).not.toThrow();
|
|
31
|
-
expect(() => testLight.SetIntensity(0.6)).not.toThrow();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should set color', () => {
|
|
35
|
-
const testLight = new DIVESceneLight();
|
|
36
|
-
expect(() =>
|
|
37
|
-
testLight.SetColor({ test: true } as unknown as Color),
|
|
38
|
-
).not.toThrow();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should set enabled', () => {
|
|
42
|
-
const testLight = new DIVESceneLight();
|
|
43
|
-
testLight.SetEnabled(false);
|
|
44
|
-
expect(testLight.children[0].visible).toBe(false);
|
|
45
|
-
expect(testLight.children[1].visible).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader';
|
|
2
|
-
import { GLTF, GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A basic loading manager.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export class DIVELoadingManager {
|
|
11
|
-
private gltfloader: GLTFLoader;
|
|
12
|
-
private dracoloader: DRACOLoader;
|
|
13
|
-
// ... maybe extend with other loaders later
|
|
14
|
-
|
|
15
|
-
constructor() {
|
|
16
|
-
this.gltfloader = new GLTFLoader();
|
|
17
|
-
this.dracoloader = new DRACOLoader();
|
|
18
|
-
this.dracoloader.setDecoderPath(
|
|
19
|
-
'https://www.gstatic.com/draco/v1/decoders/',
|
|
20
|
-
);
|
|
21
|
-
this.gltfloader.setDRACOLoader(this.dracoloader);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
private progress: Map<string, number> = new Map<string, number>();
|
|
25
|
-
|
|
26
|
-
public async LoadGLTF(uri: string): Promise<GLTF> {
|
|
27
|
-
const progEvent = (p: ProgressEvent<EventTarget>): void => {
|
|
28
|
-
this.progress.set(uri, p.loaded / p.total);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
this.progress.set(uri, 0);
|
|
32
|
-
|
|
33
|
-
return new Promise<GLTF>((resolve, reject) => {
|
|
34
|
-
this.gltfloader
|
|
35
|
-
.loadAsync(uri, progEvent)
|
|
36
|
-
.then(resolve)
|
|
37
|
-
.catch(reject);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public PollProgress(): number {
|
|
42
|
-
let total = 0;
|
|
43
|
-
this.progress.forEach((progress: number) => {
|
|
44
|
-
total += progress;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
if (this.progress.size === 0) return 1;
|
|
48
|
-
return total / this.progress.size;
|
|
49
|
-
}
|
|
50
|
-
}
|