@shopware-ag/dive 1.19.1-beta.0 → 1.19.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/build/dive.cjs +362 -199
  2. package/build/dive.cjs.map +1 -1
  3. package/build/dive.js +330 -167
  4. package/build/dive.js.map +1 -1
  5. package/build/dive.mjs +10803 -8714
  6. package/build/dive.mjs.map +1 -1
  7. package/build/src/converter/Converter.d.ts +3 -12
  8. package/build/src/dive.d.ts +1 -0
  9. package/build/src/exporter/Exporter.d.ts +20 -2
  10. package/build/src/loader/Loader.d.ts +0 -4
  11. package/build/src/types/error/index.d.ts +12 -0
  12. package/build/src/types/file/FileTypes.d.ts +17 -0
  13. package/build/src/types/file/index.d.ts +1 -0
  14. package/build/src/types/index.d.ts +5 -8
  15. package/package.json +2 -3
  16. package/build/src/types/ExporterOptions.d.ts +0 -15
  17. package/build/src/types/FileTypes.d.ts +0 -27
  18. package/src/__test__/DIVE.test.ts +0 -274
  19. package/src/animation/AnimationSystem.ts +0 -34
  20. package/src/animation/__test__/AnimationSystem.test.ts +0 -40
  21. package/src/ar/AR.ts +0 -101
  22. package/src/ar/__test__/AR.test.ts +0 -276
  23. package/src/ar/arquicklook/ARQuickLook.ts +0 -53
  24. package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +0 -144
  25. package/src/ar/sceneviewer/SceneViewer.ts +0 -119
  26. package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -190
  27. package/src/ar/webxr/WebXR.ts +0 -177
  28. package/src/ar/webxr/controller/WebXRController.ts +0 -340
  29. package/src/ar/webxr/crosshair/WebXRCrosshair.ts +0 -35
  30. package/src/ar/webxr/origin/WebXROrigin.ts +0 -192
  31. package/src/ar/webxr/overlay/Overlay.ts +0 -50
  32. package/src/ar/webxr/raycaster/WebXRRaycaster.ts +0 -131
  33. package/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts +0 -102
  34. package/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts +0 -49
  35. package/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts +0 -356
  36. package/src/axiscamera/AxisCamera.ts +0 -108
  37. package/src/axiscamera/__test__/AxisCamera.test.ts +0 -150
  38. package/src/camera/PerspectiveCamera.ts +0 -63
  39. package/src/camera/__test__/PerspectiveCamera.test.ts +0 -36
  40. package/src/com/Communication.ts +0 -806
  41. package/src/com/__test__/Communication.test.ts +0 -1030
  42. package/src/com/actions/camera/computeencompassingview.ts +0 -10
  43. package/src/com/actions/camera/getcameratransform.ts +0 -10
  44. package/src/com/actions/camera/movecamera.ts +0 -18
  45. package/src/com/actions/camera/resetcamera.ts +0 -5
  46. package/src/com/actions/camera/setcameralayer.ts +0 -5
  47. package/src/com/actions/camera/setcameratransform.ts +0 -10
  48. package/src/com/actions/camera/zoomcamera.ts +0 -5
  49. package/src/com/actions/index.ts +0 -61
  50. package/src/com/actions/media/generatemedia.ts +0 -18
  51. package/src/com/actions/object/addobject.ts +0 -7
  52. package/src/com/actions/object/deleteobject.ts +0 -7
  53. package/src/com/actions/object/deselectobject.ts +0 -7
  54. package/src/com/actions/object/getallobjects.ts +0 -7
  55. package/src/com/actions/object/getobjects.ts +0 -7
  56. package/src/com/actions/object/model/dropit.ts +0 -5
  57. package/src/com/actions/object/model/modelloaded.ts +0 -5
  58. package/src/com/actions/object/model/placeonfloor.ts +0 -5
  59. package/src/com/actions/object/selectobject.ts +0 -7
  60. package/src/com/actions/object/setparent.ts +0 -10
  61. package/src/com/actions/object/updateobject.ts +0 -7
  62. package/src/com/actions/renderer/startrender.ts +0 -5
  63. package/src/com/actions/scene/exportscene.ts +0 -7
  64. package/src/com/actions/scene/getallscenedata.ts +0 -7
  65. package/src/com/actions/scene/launchar.ts +0 -7
  66. package/src/com/actions/scene/setbackground.ts +0 -5
  67. package/src/com/actions/scene/updatescene.ts +0 -11
  68. package/src/com/actions/toolbox/select/setgizmomode.ts +0 -5
  69. package/src/com/actions/toolbox/transform/setgizmoscalelinked.ts +0 -5
  70. package/src/com/actions/toolbox/transform/setgizmovisible.ts +0 -5
  71. package/src/com/actions/toolbox/usetool.ts +0 -7
  72. package/src/com/types/COMBaseEntity.ts +0 -9
  73. package/src/com/types/COMEntity.ts +0 -7
  74. package/src/com/types/COMEntityType.ts +0 -1
  75. package/src/com/types/COMGeometry.ts +0 -8
  76. package/src/com/types/COMGeometryType.ts +0 -9
  77. package/src/com/types/COMGroup.ts +0 -9
  78. package/src/com/types/COMLight.ts +0 -11
  79. package/src/com/types/COMMaterial.ts +0 -12
  80. package/src/com/types/COMModel.ts +0 -12
  81. package/src/com/types/COMPov.ts +0 -8
  82. package/src/com/types/COMPrimitive.ts +0 -12
  83. package/src/com/types/index.ts +0 -23
  84. package/src/constant/AxisHelperColors.ts +0 -7
  85. package/src/constant/GridColors.ts +0 -2
  86. package/src/constant/VisibilityLayerMask.ts +0 -5
  87. package/src/controls/OrbitControls.ts +0 -211
  88. package/src/controls/__test__/OrbitControls.test.ts +0 -256
  89. package/src/converter/Converter.ts +0 -117
  90. package/src/dive.ts +0 -363
  91. package/src/events/EventExecutor.ts +0 -35
  92. package/src/exporter/Exporter.ts +0 -75
  93. package/src/gizmo/Gizmo.ts +0 -144
  94. package/src/gizmo/handles/AxisHandle.ts +0 -153
  95. package/src/gizmo/handles/RadialHandle.ts +0 -149
  96. package/src/gizmo/handles/ScaleHandle.ts +0 -195
  97. package/src/gizmo/plane/GizmoPlane.ts +0 -84
  98. package/src/gizmo/rotate/RotateGizmo.ts +0 -143
  99. package/src/gizmo/scale/ScaleGizmo.ts +0 -125
  100. package/src/gizmo/translate/TranslateGizmo.ts +0 -114
  101. package/src/grid/Grid.ts +0 -34
  102. package/src/grid/__test__/Grid.test.ts +0 -28
  103. package/src/group/Group.ts +0 -184
  104. package/src/group/__test__/Group.test.ts +0 -212
  105. package/src/helper/applyMixins/__test__/applyMixins.test.ts +0 -30
  106. package/src/helper/applyMixins/applyMixins.ts +0 -70
  107. package/src/helper/findInterface/__test__/findInterface.test.ts +0 -63
  108. package/src/helper/findInterface/findInterface.ts +0 -13
  109. package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +0 -40
  110. package/src/helper/findSceneRecursive/findSceneRecursive.ts +0 -16
  111. package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +0 -186
  112. package/src/helper/getObjectDelta/getObjectDelta.ts +0 -105
  113. package/src/helper/isInterface/__test__/implementsInterface.test.ts +0 -19
  114. package/src/helper/isInterface/implementsInterface.ts +0 -9
  115. package/src/info/Info.ts +0 -178
  116. package/src/info/__test__/Info.test.ts +0 -346
  117. package/src/interface/Draggable.ts +0 -14
  118. package/src/interface/Hoverable.ts +0 -14
  119. package/src/interface/Movable.ts +0 -12
  120. package/src/interface/Rotatable.ts +0 -10
  121. package/src/interface/Scalable.ts +0 -10
  122. package/src/interface/Selectable.ts +0 -11
  123. package/src/io/IO.ts +0 -62
  124. package/src/io/__test__/IO.test.ts +0 -116
  125. package/src/io/gltf/GLTFIO.ts +0 -56
  126. package/src/io/gltf/__test__/GLTFIO.test.ts +0 -108
  127. package/src/light/AmbientLight.ts +0 -39
  128. package/src/light/PointLight.ts +0 -115
  129. package/src/light/SceneLight.ts +0 -63
  130. package/src/light/__test__/AmbientLight.test.ts +0 -29
  131. package/src/light/__test__/PointLight.test.ts +0 -74
  132. package/src/light/__test__/SceneLight.test.ts +0 -47
  133. package/src/loader/Loader.ts +0 -48
  134. package/src/math/__test__/DIVEMath.test.ts +0 -12
  135. package/src/math/ceil/__test__/ceilExp.test.ts +0 -12
  136. package/src/math/ceil/ceilExp.ts +0 -6
  137. package/src/math/degToRad/__test__/degToRad.test.ts +0 -172
  138. package/src/math/degToRad/degToRad.ts +0 -5
  139. package/src/math/floor/__test__/floorExp.test.ts +0 -14
  140. package/src/math/floor/floorExp.ts +0 -6
  141. package/src/math/helper/__test__/shift.test.ts +0 -12
  142. package/src/math/helper/shift.ts +0 -4
  143. package/src/math/index.ts +0 -28
  144. package/src/math/radToDeg/__test__/radToDeg.test.ts +0 -155
  145. package/src/math/radToDeg/radToDeg.ts +0 -5
  146. package/src/math/round/__test__/roundExp.test.ts +0 -14
  147. package/src/math/round/roundExp.ts +0 -10
  148. package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +0 -20
  149. package/src/math/signedAngleTo/signedAngleTo.ts +0 -20
  150. package/src/math/toFixed/__test__/toFixedExp.test.ts +0 -14
  151. package/src/math/toFixed/toFixedExp.ts +0 -9
  152. package/src/math/truncate/__test__/truncateExp.test.ts +0 -14
  153. package/src/math/truncate/truncateExp.ts +0 -9
  154. package/src/mediacreator/MediaCreator.ts +0 -75
  155. package/src/mediacreator/__test__/MediaCreator.test.ts +0 -155
  156. package/src/model/Model.ts +0 -190
  157. package/src/model/__test__/Model.test.ts +0 -215
  158. package/src/module/Module.ts +0 -45
  159. package/src/module/__test__/Module.test.ts +0 -54
  160. package/src/node/Node.ts +0 -100
  161. package/src/node/__test__/Node.test.ts +0 -120
  162. package/src/primitive/Primitive.ts +0 -299
  163. package/src/primitive/__test__/Primitive.test.ts +0 -281
  164. package/src/primitive/floor/Floor.ts +0 -45
  165. package/src/primitive/floor/__test__/Floor.test.ts +0 -24
  166. package/src/renderer/Renderer.ts +0 -215
  167. package/src/renderer/__test__/Renderer.test.ts +0 -228
  168. package/src/scene/Scene.ts +0 -106
  169. package/src/scene/__test__/Scene.test.ts +0 -124
  170. package/src/scene/root/Root.ts +0 -426
  171. package/src/scene/root/__test__/Root.test.ts +0 -903
  172. package/src/scene/xrroot/XRRoot.ts +0 -56
  173. package/src/scene/xrroot/xrlightroot/XRLightRoot.ts +0 -80
  174. package/src/toolbox/BaseTool.ts +0 -319
  175. package/src/toolbox/Toolbox.ts +0 -129
  176. package/src/toolbox/__test__/BaseTool.test.ts +0 -627
  177. package/src/toolbox/__test__/Toolbox.test.ts +0 -143
  178. package/src/toolbox/select/SelectTool.ts +0 -92
  179. package/src/toolbox/select/__test__/SelectTool.test.ts +0 -237
  180. package/src/toolbox/transform/TransformTool.ts +0 -166
  181. package/src/toolbox/transform/__test__/TransformTool.test.ts +0 -147
  182. package/src/types/ExporterOptions.ts +0 -14
  183. package/src/types/FileTypes.ts +0 -37
  184. package/src/types/SceneData.ts +0 -26
  185. package/src/types/SceneObjects.ts +0 -14
  186. package/src/types/SceneType.ts +0 -14
  187. package/src/types/index.ts +0 -31
  188. package/src/types/info/index.ts +0 -76
@@ -1,12 +0,0 @@
1
- /**
2
- * Interface for objects that can be moved in the scene.
3
- *
4
- * @module
5
- */
6
-
7
- export class DIVEMovable {
8
- readonly isMovable: true = true;
9
- public onMoveStart?(): void;
10
- public onMove?(): void;
11
- public onMoveEnd?(): void;
12
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Interface for objects that can be rotated in the scene.
3
- *
4
- * @module
5
- */
6
-
7
- export interface DIVERotatable {
8
- isRotatable: true;
9
- onRotate?: () => void;
10
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Interface for objects that can be scaled in the scene.
3
- *
4
- * @module
5
- */
6
-
7
- export interface DIVEScalable {
8
- isScalable: true;
9
- onScale?: () => void;
10
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Interface for objects that can be selected in the scene.
3
- *
4
- * @module
5
- */
6
-
7
- export class DIVESelectable {
8
- readonly isSelectable: true = true;
9
- public onSelect?(): void;
10
- public onDeselect?(): void;
11
- }
package/src/io/IO.ts DELETED
@@ -1,62 +0,0 @@
1
- import { DIVEGLTFIO } from './gltf/GLTFIO';
2
-
3
- import { type DIVESceneFileType } from '../types';
4
- import { type DIVEScene } from '../scene/Scene';
5
-
6
- export class DIVEIO {
7
- private _scene: DIVEScene;
8
-
9
- private _gltfIO: DIVEGLTFIO;
10
-
11
- constructor(scene: DIVEScene) {
12
- this._scene = scene;
13
-
14
- this._gltfIO = new DIVEGLTFIO();
15
- }
16
-
17
- public Import<FileType extends keyof DIVESceneFileType>(
18
- type: FileType,
19
- url: string,
20
- ): Promise<DIVESceneFileType[FileType] | null> {
21
- switch (type) {
22
- case 'glb': {
23
- return this._gltfIO.Import(url).catch((error) => {
24
- console.error(error);
25
- return null;
26
- });
27
- }
28
-
29
- default: {
30
- console.error('DIVEIO.Import: Unsupported file type: ' + type);
31
- return Promise.reject();
32
- }
33
- }
34
- }
35
-
36
- public Export<FileType extends keyof DIVESceneFileType>(
37
- type: FileType,
38
- ): Promise<string | null> {
39
- switch (type) {
40
- case 'glb': {
41
- return this._gltfIO
42
- .Export(this._scene, true, true)
43
- .then((data) => {
44
- return this._createBlobURL(data);
45
- })
46
- .catch((error) => {
47
- console.error(error);
48
- return null;
49
- });
50
- }
51
-
52
- default: {
53
- console.error('DIVEIO.Export: Unsupported file type: ' + type);
54
- return Promise.reject();
55
- }
56
- }
57
- }
58
-
59
- private _createBlobURL(data: ArrayBuffer): string {
60
- return URL.createObjectURL(new Blob([data]));
61
- }
62
- }
@@ -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
- });
@@ -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
- }
@@ -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
- }
@@ -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
- });