@shopware-ag/dive 1.16.0 → 1.16.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 (143) hide show
  1. package/README.md +271 -40
  2. package/build/dive.cjs +575 -159
  3. package/build/dive.cjs.map +1 -1
  4. package/build/dive.d.cts +83 -57
  5. package/build/dive.d.ts +83 -57
  6. package/build/dive.js +614 -164
  7. package/build/dive.js.map +1 -1
  8. package/package.json +72 -60
  9. package/src/__test__/DIVE.test.ts +35 -31
  10. package/src/animation/AnimationSystem.ts +4 -4
  11. package/src/animation/__test__/AnimationSystem.test.ts +3 -3
  12. package/src/axiscamera/AxisCamera.ts +31 -11
  13. package/src/axiscamera/__test__/AxisCamera.test.ts +18 -10
  14. package/src/camera/PerspectiveCamera.ts +28 -13
  15. package/src/camera/__test__/PerspectiveCamera.test.ts +2 -2
  16. package/src/com/Communication.ts +282 -100
  17. package/src/com/__test__/Communication.test.ts +207 -141
  18. package/src/com/actions/camera/computeencompassingview.ts +8 -7
  19. package/src/com/actions/camera/getcameratransform.ts +8 -7
  20. package/src/com/actions/camera/movecamera.ts +16 -13
  21. package/src/com/actions/camera/resetcamera.ts +4 -3
  22. package/src/com/actions/camera/setcameralayer.ts +4 -3
  23. package/src/com/actions/camera/setcameratransform.ts +8 -7
  24. package/src/com/actions/camera/zoomcamera.ts +4 -3
  25. package/src/com/actions/index.ts +54 -54
  26. package/src/com/actions/media/generatemedia.ts +17 -13
  27. package/src/com/actions/object/addobject.ts +5 -4
  28. package/src/com/actions/object/deleteobject.ts +5 -4
  29. package/src/com/actions/object/deselectobject.ts +5 -4
  30. package/src/com/actions/object/getallobjects.ts +5 -4
  31. package/src/com/actions/object/getobjects.ts +5 -4
  32. package/src/com/actions/object/model/dropit.ts +4 -3
  33. package/src/com/actions/object/model/modelloaded.ts +4 -3
  34. package/src/com/actions/object/model/placeonfloor.ts +4 -3
  35. package/src/com/actions/object/selectobject.ts +5 -4
  36. package/src/com/actions/object/setparent.ts +8 -7
  37. package/src/com/actions/object/updateobject.ts +5 -4
  38. package/src/com/actions/scene/exportscene.ts +5 -4
  39. package/src/com/actions/scene/getallscenedata.ts +24 -18
  40. package/src/com/actions/scene/setbackground.ts +4 -3
  41. package/src/com/actions/scene/updatescene.ts +10 -9
  42. package/src/com/actions/toolbox/select/setgizmomode.ts +4 -3
  43. package/src/com/actions/toolbox/transform/setgizmovisible.ts +4 -3
  44. package/src/com/actions/toolbox/usetool.ts +5 -4
  45. package/src/com/types/COMBaseEntity.ts +2 -2
  46. package/src/com/types/COMEntity.ts +6 -6
  47. package/src/com/types/COMEntityType.ts +1 -1
  48. package/src/com/types/COMGeometry.ts +2 -2
  49. package/src/com/types/COMGroup.ts +3 -3
  50. package/src/com/types/COMLight.ts +3 -3
  51. package/src/com/types/COMMaterial.ts +2 -2
  52. package/src/com/types/COMModel.ts +4 -4
  53. package/src/com/types/COMPov.ts +3 -3
  54. package/src/com/types/COMPrimitive.ts +5 -5
  55. package/src/com/types/index.ts +10 -10
  56. package/src/constant/AxisHelperColors.ts +1 -1
  57. package/src/constant/GridColors.ts +1 -1
  58. package/src/controls/OrbitControls.ts +62 -29
  59. package/src/controls/__test__/OrbitControls.test.ts +133 -39
  60. package/src/dive.ts +82 -36
  61. package/src/gizmo/Gizmo.ts +21 -13
  62. package/src/gizmo/handles/AxisHandle.ts +40 -17
  63. package/src/gizmo/handles/RadialHandle.ts +39 -15
  64. package/src/gizmo/handles/ScaleHandle.ts +62 -25
  65. package/src/gizmo/plane/GizmoPlane.ts +5 -6
  66. package/src/gizmo/rotate/RotateGizmo.ts +58 -16
  67. package/src/gizmo/scale/ScaleGizmo.ts +37 -15
  68. package/src/gizmo/translate/TranslateGizmo.ts +34 -14
  69. package/src/grid/Grid.ts +13 -5
  70. package/src/grid/__test__/Grid.test.ts +5 -3
  71. package/src/group/Group.ts +9 -7
  72. package/src/group/__test__/Group.test.ts +8 -6
  73. package/src/helper/applyMixins/__test__/applyMixins.test.ts +9 -6
  74. package/src/helper/applyMixins/applyMixins.ts +6 -3
  75. package/src/helper/findInterface/__test__/findInterface.test.ts +28 -18
  76. package/src/helper/findInterface/findInterface.ts +7 -4
  77. package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +1 -1
  78. package/src/helper/findSceneRecursive/findSceneRecursive.ts +1 -1
  79. package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +43 -7
  80. package/src/helper/getObjectDelta/getObjectDelta.ts +13 -9
  81. package/src/helper/isInterface/__test__/implementsInterface.test.ts +1 -1
  82. package/src/helper/isInterface/implementsInterface.ts +6 -3
  83. package/src/info/Info.ts +20 -16
  84. package/src/info/__test__/Info.test.ts +67 -36
  85. package/src/interface/Draggable.ts +2 -2
  86. package/src/interface/Hoverable.ts +2 -2
  87. package/src/interface/Movable.ts +1 -1
  88. package/src/interface/Rotatable.ts +1 -1
  89. package/src/interface/Scalable.ts +1 -1
  90. package/src/io/IO.ts +21 -43
  91. package/src/io/__test__/IO.test.ts +16 -62
  92. package/src/io/gltf/GLTFIO.ts +34 -31
  93. package/src/io/gltf/__test__/GLTFIO.test.ts +88 -78
  94. package/src/light/PointLight.ts +42 -9
  95. package/src/light/SceneLight.ts +5 -5
  96. package/src/light/__test__/AmbientLight.test.ts +5 -4
  97. package/src/light/__test__/PointLight.test.ts +14 -10
  98. package/src/light/__test__/SceneLight.test.ts +19 -13
  99. package/src/loadingmanager/LoadingManager.ts +11 -6
  100. package/src/loadingmanager/__test__/LoadingManager.test.ts +14 -9
  101. package/src/math/__test__/DIVEMath.test.ts +1 -1
  102. package/src/math/ceil/__test__/ceilExp.test.ts +1 -1
  103. package/src/math/ceil/ceilExp.ts +2 -2
  104. package/src/math/floor/__test__/floorExp.test.ts +1 -1
  105. package/src/math/floor/floorExp.ts +2 -2
  106. package/src/math/helper/__test__/shift.test.ts +1 -1
  107. package/src/math/helper/shift.ts +1 -1
  108. package/src/math/index.ts +7 -7
  109. package/src/math/round/__test__/roundExp.test.ts +1 -1
  110. package/src/math/round/roundExp.ts +6 -3
  111. package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +10 -4
  112. package/src/math/signedAngleTo/signedAngleTo.ts +11 -4
  113. package/src/math/toFixed/__test__/toFixedExp.test.ts +9 -9
  114. package/src/math/toFixed/toFixedExp.ts +6 -3
  115. package/src/math/truncate/__test__/truncateExp.test.ts +1 -1
  116. package/src/math/truncate/truncateExp.ts +6 -3
  117. package/src/mediacreator/MediaCreator.ts +20 -10
  118. package/src/mediacreator/__test__/MediaCreator.test.ts +27 -12
  119. package/src/model/Model.ts +35 -7
  120. package/src/model/__test__/Model.test.ts +71 -44
  121. package/src/node/Node.ts +34 -12
  122. package/src/node/__test__/Node.test.ts +17 -13
  123. package/src/primitive/Primitive.ts +78 -13
  124. package/src/primitive/__test__/Primitive.test.ts +49 -38
  125. package/src/primitive/floor/Floor.ts +14 -3
  126. package/src/primitive/floor/__test__/Floor.test.ts +10 -4
  127. package/src/renderer/Renderer.ts +46 -15
  128. package/src/renderer/__test__/Renderer.test.ts +74 -24
  129. package/src/scene/Scene.ts +9 -3
  130. package/src/scene/__test__/Scene.test.ts +2 -2
  131. package/src/scene/root/Root.ts +142 -75
  132. package/src/scene/root/__test__/Root.test.ts +439 -111
  133. package/src/toolbox/BaseTool.ts +69 -33
  134. package/src/toolbox/Toolbox.ts +37 -17
  135. package/src/toolbox/__test__/BaseTool.test.ts +324 -160
  136. package/src/toolbox/__test__/Toolbox.test.ts +31 -14
  137. package/src/toolbox/select/SelectTool.ts +24 -19
  138. package/src/toolbox/select/__test__/SelectTool.test.ts +95 -59
  139. package/src/toolbox/transform/TransformTool.ts +40 -17
  140. package/src/toolbox/transform/__test__/TransformTool.test.ts +22 -15
  141. package/src/types/SceneObjects.ts +8 -8
  142. package/src/types/SceneType.ts +3 -3
  143. package/src/types/index.ts +3 -6
@@ -4,142 +4,96 @@ import { DIVEScene } from '../../scene/Scene';
4
4
  import { type GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
5
5
 
6
6
  jest.mock('../gltf/GLTFIO', () => {
7
-
8
7
  return {
9
-
10
8
  DIVEGLTFIO: jest.fn(function () {
11
-
12
9
  this.Import = jest.fn();
13
-
14
10
  this.Export = jest.fn();
15
-
16
11
  return this;
17
-
18
- })
19
-
12
+ }),
20
13
  };
21
-
22
14
  });
23
15
 
24
16
  jest.mock('../../scene/Scene.ts', () => {
25
-
26
17
  return {
27
-
28
18
  DIVEScene: jest.fn(function () {
29
-
30
19
  this.add = jest.fn();
31
-
32
20
  this.isObject3D = true;
33
-
34
21
  this.parent = null;
35
-
36
22
  this.dispatchEvent = jest.fn();
37
-
38
23
  this.position = {
39
-
40
24
  set: jest.fn(),
41
-
42
- }
43
-
25
+ };
44
26
  this.SetIntensity = jest.fn();
45
-
46
27
  this.SetEnabled = jest.fn();
47
-
48
28
  this.SetColor = jest.fn();
49
-
50
29
  this.userData = {
51
-
52
30
  id: undefined,
53
-
54
- }
55
-
31
+ };
56
32
  this.removeFromParent = jest.fn();
57
-
58
33
  return this;
59
- })
60
-
34
+ }),
61
35
  };
62
-
63
36
  });
64
37
 
65
38
  let testIO: DIVEIO;
66
39
 
67
40
  describe('dive/io/DIVEIO', () => {
68
41
  beforeEach(() => {
69
-
70
42
  testIO = new DIVEIO(new DIVEScene());
71
-
72
43
  });
73
44
 
74
45
  afterEach(() => {
75
-
76
46
  jest.clearAllMocks();
77
-
78
47
  });
79
48
 
80
49
  it('should instantiate', () => {
81
-
82
50
  expect(testIO).toBeDefined();
83
-
84
51
  });
85
52
 
86
53
  it('should import from URL', async () => {
87
-
88
54
  const mockGLTF = {} as GLTF;
89
-
90
55
  jest.spyOn(testIO['_gltfIO'], 'Import').mockResolvedValueOnce(mockGLTF);
91
56
 
92
57
  const result = await testIO.Import('glb', 'test.glb');
93
-
94
58
  expect(result).toStrictEqual(mockGLTF);
95
-
96
59
  });
97
60
 
98
61
  it('should reject when importing with unsupported file type', async () => {
62
+ jest.spyOn(console, 'error').mockImplementationOnce(() => {});
99
63
 
100
- jest.spyOn(console, 'error').mockImplementationOnce(() => { });
101
-
102
- const result = await testIO.Import('unsupported file type' as "glb", 'test.glb');
64
+ const result = await testIO.Import(
65
+ 'unsupported file type' as 'glb',
66
+ 'test.glb',
67
+ );
103
68
 
104
69
  expect(result).toStrictEqual(null);
105
-
106
70
  });
107
71
 
108
72
  it('should export to URL', async () => {
109
-
110
73
  const mockObject = {};
111
-
112
74
  const mockURL = 'blob://mockURL';
113
-
114
- jest.spyOn(testIO['_gltfIO'], 'Export').mockResolvedValueOnce(mockObject);
75
+ jest.spyOn(testIO['_gltfIO'], 'Export').mockResolvedValueOnce(
76
+ mockObject,
77
+ );
115
78
 
116
79
  URL.createObjectURL = jest.fn().mockReturnValueOnce(mockURL);
117
80
 
118
81
  const result = await testIO.Export('glb');
119
-
120
82
  expect(result).toBeDefined();
121
-
122
83
  });
123
84
 
124
85
  it('should handle rejection from gltf io', async () => {
125
-
126
- jest.spyOn(console, 'error').mockImplementationOnce(() => { });
127
-
86
+ jest.spyOn(console, 'error').mockImplementationOnce(() => {});
128
87
  jest.spyOn(testIO['_gltfIO'], 'Export').mockRejectedValueOnce('Error');
129
88
 
130
89
  const result = await testIO.Export('glb');
131
-
132
90
  expect(result).toBeDefined();
133
-
134
91
  });
135
92
 
136
93
  it('should reject when exporting with unsupported file type', async () => {
94
+ jest.spyOn(console, 'error').mockImplementationOnce(() => {});
137
95
 
138
- jest.spyOn(console, 'error').mockImplementationOnce(() => { });
139
-
140
- const result = await testIO.Export('unsupported file type' as "glb");
141
-
96
+ const result = await testIO.Export('unsupported file type' as 'glb');
142
97
  expect(result).toStrictEqual(null);
143
-
144
98
  });
145
- });
99
+ });
@@ -1,53 +1,56 @@
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";
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
4
 
5
5
  export class DIVEGLTFIO {
6
-
7
6
  private _importer: GLTFLoader;
8
-
9
7
  private _exporter: GLTFExporter;
10
8
 
11
9
  constructor() {
12
-
13
10
  this._importer = new GLTFLoader();
14
-
15
11
  this._exporter = new GLTFExporter();
16
-
17
12
  }
18
13
 
19
- public Import(url: string, onProgress?: (progress: number) => void): Promise<GLTF> {
20
-
14
+ public Import(
15
+ url: string,
16
+ onProgress?: (progress: number) => void,
17
+ ): Promise<GLTF> {
21
18
  return this._importer.loadAsync(url, (progress) => {
22
-
23
19
  if (!onProgress) return;
24
20
 
25
21
  onProgress(progress.loaded / progress.total);
26
-
27
22
  });
28
-
29
23
  }
30
24
 
31
- public Export(object: Object3D, binary: true, onlyVisible: boolean): Promise<ArrayBuffer>;
32
-
33
- public Export(object: Object3D, binary: false, onlyVisible: boolean): Promise<{ [key: string]: unknown }>;
34
-
35
- public Export(object: Object3D, binary: boolean, onlyVisible: boolean): Promise<ArrayBuffer | { [key: string]: unknown }> {
36
-
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 }> {
37
42
  if (binary) {
38
-
39
43
  // export as binary ArrayBuffer
40
-
41
- return this._exporter.parseAsync(object, { binary, onlyVisible }) as unknown as Promise<ArrayBuffer>;
42
-
44
+ return this._exporter.parseAsync(object, {
45
+ binary,
46
+ onlyVisible,
47
+ }) as unknown as Promise<ArrayBuffer>;
43
48
  } else {
44
-
45
49
  // export as JSON object
46
-
47
- return this._exporter.parseAsync(object, { binary, onlyVisible }) as unknown as Promise<{ [key: string]: unknown; }>;
48
-
50
+ return this._exporter.parseAsync(object, {
51
+ binary,
52
+ onlyVisible,
53
+ }) as unknown as Promise<{ [key: string]: unknown }>;
49
54
  }
50
-
51
- };
52
-
53
- }
55
+ }
56
+ }
@@ -22,154 +22,164 @@ jest.mock('three', () => {
22
22
  far: 0,
23
23
  fov: 0,
24
24
  },
25
- }
25
+ };
26
26
  this.add = jest.fn();
27
27
  this.sub = jest.fn();
28
- this.children = [{
29
- visible: true,
30
- material: {
31
- color: {},
28
+ this.children = [
29
+ {
30
+ visible: true,
31
+ material: {
32
+ color: {},
33
+ },
32
34
  },
33
- }];
35
+ ];
34
36
  this.userData = {};
35
37
  this.traverse = jest.fn((callback) => {
36
- callback(this.children[0])
38
+ callback(this.children[0]);
37
39
  });
38
40
  return this;
39
41
  }),
40
- }
42
+ };
41
43
  });
42
44
 
43
45
  jest.mock('three/examples/jsm/loaders/GLTFLoader', () => {
44
46
  return {
45
47
  GLTFLoader: jest.fn(function () {
46
-
47
- this.loadAsync = (uri: string, progEvent: (p: ProgressEvent<EventTarget>) => void) => new Promise<void>((resolve) => {
48
-
49
- progEvent({ loaded: 0, total: 1 } as ProgressEvent<EventTarget>);
50
-
51
- resolve();
52
-
53
- });
48
+ this.loadAsync = (
49
+ uri: string,
50
+ progEvent: (p: ProgressEvent<EventTarget>) => void,
51
+ ) =>
52
+ new Promise<void>((resolve) => {
53
+ progEvent({
54
+ loaded: 0,
55
+ total: 1,
56
+ } as ProgressEvent<EventTarget>);
57
+
58
+ resolve();
59
+ });
54
60
 
55
61
  return this;
56
62
  }),
57
- }
63
+ };
58
64
  });
59
65
 
60
66
  jest.mock('three/examples/jsm/exporters/GLTFExporter', () => {
61
-
62
67
  return {
63
-
64
68
  GLTFExporter: jest.fn(function () {
65
-
66
- this.parseAsync = (object: Object3D, options?: GLTFExporterOptions) => new Promise<ArrayBuffer | { [key: string]: unknown }>((resolve) => {
67
-
68
- resolve(new ArrayBuffer(0));
69
-
70
- });
71
-
69
+ this.parseAsync = (
70
+ object: Object3D,
71
+ options?: GLTFExporterOptions,
72
+ ) =>
73
+ new Promise<ArrayBuffer | { [key: string]: unknown }>(
74
+ (resolve) => {
75
+ resolve(new ArrayBuffer(0));
76
+ },
77
+ );
72
78
  return this;
73
-
74
- })
75
- }
76
-
79
+ }),
80
+ };
77
81
  });
78
82
 
79
83
  let testGLTFIO: DIVEGLTFIO;
80
84
 
81
85
  describe('dive/io/gltf/DIVEGLTFIO', () => {
82
86
  beforeEach(() => {
83
-
84
87
  testGLTFIO = new DIVEGLTFIO();
85
-
86
88
  });
87
89
 
88
90
  afterEach(() => {
89
-
90
91
  jest.clearAllMocks();
91
-
92
92
  });
93
93
 
94
94
  it('should instantiate', () => {
95
-
96
95
  expect(testGLTFIO).toBeDefined();
97
-
98
96
  });
99
97
 
100
98
  it('should import from URL', async () => {
101
-
102
99
  const mockGLTF = {} as GLTF;
103
100
 
104
-
105
-
106
101
  // test without progress callback
107
-
108
- jest.spyOn(testGLTFIO['_importer'], 'loadAsync').mockImplementationOnce((uri: string, progEvent?: (p: ProgressEvent<EventTarget>) => void) => new Promise<GLTF>((resolve) => {
109
-
110
- if (progEvent) progEvent({ loaded: 0, total: 1 } as ProgressEvent<EventTarget>);
111
-
112
- resolve(mockGLTF);
113
-
114
- }));
115
-
116
- const resultWithoutProgress = await testGLTFIO.Import('test url', undefined);
102
+ jest.spyOn(testGLTFIO['_importer'], 'loadAsync').mockImplementationOnce(
103
+ (
104
+ uri: string,
105
+ progEvent?: (p: ProgressEvent<EventTarget>) => void,
106
+ ) =>
107
+ new Promise<GLTF>((resolve) => {
108
+ if (progEvent)
109
+ progEvent({
110
+ loaded: 0,
111
+ total: 1,
112
+ } as ProgressEvent<EventTarget>);
113
+
114
+ resolve(mockGLTF);
115
+ }),
116
+ );
117
+
118
+ const resultWithoutProgress = await testGLTFIO.Import(
119
+ 'test url',
120
+ undefined,
121
+ );
117
122
 
118
123
  expect(resultWithoutProgress).toStrictEqual(mockGLTF);
119
124
 
120
-
121
-
122
125
  // test with progress callback
123
-
124
- jest.spyOn(testGLTFIO['_importer'], 'loadAsync').mockImplementationOnce((uri: string, progEvent?: (p: ProgressEvent<EventTarget>) => void) => new Promise<GLTF>((resolve) => {
125
-
126
- if (progEvent) progEvent({ loaded: 0, total: 1 } as ProgressEvent<EventTarget>);
127
-
128
- resolve(mockGLTF);
129
-
130
- }));
126
+ jest.spyOn(testGLTFIO['_importer'], 'loadAsync').mockImplementationOnce(
127
+ (
128
+ uri: string,
129
+ progEvent?: (p: ProgressEvent<EventTarget>) => void,
130
+ ) =>
131
+ new Promise<GLTF>((resolve) => {
132
+ if (progEvent)
133
+ progEvent({
134
+ loaded: 0,
135
+ total: 1,
136
+ } as ProgressEvent<EventTarget>);
137
+
138
+ resolve(mockGLTF);
139
+ }),
140
+ );
131
141
 
132
142
  const onProgress = jest.fn();
133
143
 
134
- const resultWithProgress = await testGLTFIO.Import('test url', onProgress);
144
+ const resultWithProgress = await testGLTFIO.Import(
145
+ 'test url',
146
+ onProgress,
147
+ );
135
148
 
136
149
  expect(resultWithProgress).toStrictEqual(mockGLTF);
137
-
138
150
  expect(onProgress).toHaveBeenCalledTimes(1);
139
-
140
151
  });
141
152
 
142
153
  it('should export to URL', async () => {
143
-
144
154
  const mockObject = new Object3D();
145
155
 
146
156
  // export as JSON object
147
-
148
- jest.spyOn(testGLTFIO['_exporter'], 'parseAsync').mockResolvedValueOnce({});
157
+ jest.spyOn(testGLTFIO['_exporter'], 'parseAsync').mockResolvedValueOnce(
158
+ {},
159
+ );
149
160
 
150
161
  const json = await testGLTFIO.Export(mockObject, false, false);
151
-
152
162
  expect(json).toBeDefined();
153
163
 
154
-
155
-
156
164
  // export as array buffer
157
-
158
- jest.spyOn(testGLTFIO['_exporter'], 'parseAsync').mockResolvedValueOnce(new ArrayBuffer(0));
165
+ jest.spyOn(testGLTFIO['_exporter'], 'parseAsync').mockResolvedValueOnce(
166
+ new ArrayBuffer(0),
167
+ );
159
168
 
160
169
  const binary = await testGLTFIO.Export(mockObject, true, false);
161
-
162
170
  expect(binary).toBeDefined();
163
171
 
164
-
165
-
166
172
  // export as array buffer (only visible)
167
173
 
168
- jest.spyOn(testGLTFIO['_exporter'], 'parseAsync').mockResolvedValueOnce(new ArrayBuffer(0));
169
-
170
- const binaryOnlyVisible = await testGLTFIO.Export(mockObject, true, true);
174
+ jest.spyOn(testGLTFIO['_exporter'], 'parseAsync').mockResolvedValueOnce(
175
+ new ArrayBuffer(0),
176
+ );
171
177
 
178
+ const binaryOnlyVisible = await testGLTFIO.Export(
179
+ mockObject,
180
+ true,
181
+ true,
182
+ );
172
183
  expect(binaryOnlyVisible).toBeDefined();
173
-
174
184
  });
175
- });
185
+ });
@@ -1,6 +1,17 @@
1
- import { PointLight, Color, SphereGeometry, MeshBasicMaterial, Mesh, FrontSide, Object3D } from 'three';
1
+ import {
2
+ PointLight,
3
+ Color,
4
+ SphereGeometry,
5
+ MeshBasicMaterial,
6
+ Mesh,
7
+ FrontSide,
8
+ Object3D,
9
+ } from 'three';
2
10
  import { DIVECommunication } from '../com/Communication';
3
- import { PRODUCT_LAYER_MASK, UI_LAYER_MASK } from '../constant/VisibilityLayerMask';
11
+ import {
12
+ PRODUCT_LAYER_MASK,
13
+ UI_LAYER_MASK,
14
+ } from '../constant/VisibilityLayerMask';
4
15
  import { DIVEMovable } from '../interface/Movable';
5
16
  import { DIVESelectable } from '../interface/Selectable';
6
17
  import type { TransformControls } from 'three/examples/jsm/Addons.js';
@@ -15,7 +26,10 @@ import type { TransformControls } from 'three/examples/jsm/Addons.js';
15
26
  * @module
16
27
  */
17
28
 
18
- export default class DIVEPointLight extends Object3D implements DIVESelectable, DIVEMovable {
29
+ export default class DIVEPointLight
30
+ extends Object3D
31
+ implements DIVESelectable, DIVEMovable
32
+ {
19
33
  readonly isDIVELight: true = true;
20
34
  readonly isDIVEPointLight: true = true;
21
35
  readonly isMovable: true = true;
@@ -42,9 +56,18 @@ export default class DIVEPointLight extends Object3D implements DIVESelectable,
42
56
 
43
57
  const geoSize = 0.1;
44
58
 
45
- const geometry = new SphereGeometry(geoSize, geoSize * 320, geoSize * 320);
59
+ const geometry = new SphereGeometry(
60
+ geoSize,
61
+ geoSize * 320,
62
+ geoSize * 320,
63
+ );
46
64
 
47
- const material = new MeshBasicMaterial({ color: this.light.color, transparent: true, opacity: 0.8, side: FrontSide });
65
+ const material = new MeshBasicMaterial({
66
+ color: this.light.color,
67
+ transparent: true,
68
+ opacity: 0.8,
69
+ side: FrontSide,
70
+ });
48
71
 
49
72
  this.mesh = new Mesh(geometry, material);
50
73
  this.mesh.layers.mask = UI_LAYER_MASK;
@@ -61,7 +84,8 @@ export default class DIVEPointLight extends Object3D implements DIVESelectable,
61
84
  public SetIntensity(intensity: number): void {
62
85
  this.light.intensity = intensity;
63
86
 
64
- (this.mesh.material as MeshBasicMaterial).opacity = intensity > 0.8 ? 0.8 : intensity * 0.8;
87
+ (this.mesh.material as MeshBasicMaterial).opacity =
88
+ intensity > 0.8 ? 0.8 : intensity * 0.8;
65
89
  }
66
90
 
67
91
  public SetEnabled(enabled: boolean): void {
@@ -69,14 +93,23 @@ export default class DIVEPointLight extends Object3D implements DIVESelectable,
69
93
  }
70
94
 
71
95
  public onMove(): void {
72
- DIVECommunication.get(this.userData.id)?.PerformAction('UPDATE_OBJECT', { id: this.userData.id, position: this.position });
96
+ DIVECommunication.get(this.userData.id)?.PerformAction(
97
+ 'UPDATE_OBJECT',
98
+ { id: this.userData.id, position: this.position },
99
+ );
73
100
  }
74
101
 
75
102
  public onSelect(): void {
76
- DIVECommunication.get(this.userData.id)?.PerformAction('SELECT_OBJECT', { id: this.userData.id });
103
+ DIVECommunication.get(this.userData.id)?.PerformAction(
104
+ 'SELECT_OBJECT',
105
+ { id: this.userData.id },
106
+ );
77
107
  }
78
108
 
79
109
  public onDeselect(): void {
80
- DIVECommunication.get(this.userData.id)?.PerformAction('DESELECT_OBJECT', { id: this.userData.id });
110
+ DIVECommunication.get(this.userData.id)?.PerformAction(
111
+ 'DESELECT_OBJECT',
112
+ { id: this.userData.id },
113
+ );
81
114
  }
82
115
  }
@@ -1,5 +1,5 @@
1
- import { PRODUCT_LAYER_MASK } from "../constant/VisibilityLayerMask.ts";
2
- import { Color, DirectionalLight, HemisphereLight, Object3D } from "three";
1
+ import { PRODUCT_LAYER_MASK } from '../constant/VisibilityLayerMask.ts';
2
+ import { Color, DirectionalLight, HemisphereLight, Object3D } from 'three';
3
3
 
4
4
  /**
5
5
  * A complex scene light.
@@ -37,10 +37,10 @@ export default class DIVESceneLight extends Object3D {
37
37
 
38
38
  const d = 5;
39
39
 
40
- this._dirLight.shadow.camera.left = - d;
40
+ this._dirLight.shadow.camera.left = -d;
41
41
  this._dirLight.shadow.camera.right = d;
42
42
  this._dirLight.shadow.camera.top = d;
43
- this._dirLight.shadow.camera.bottom = - d;
43
+ this._dirLight.shadow.camera.bottom = -d;
44
44
 
45
45
  this._dirLight.shadow.camera.far = 3500;
46
46
  this.add(this._dirLight);
@@ -60,4 +60,4 @@ export default class DIVESceneLight extends Object3D {
60
60
  this._hemiLight.visible = enabled;
61
61
  this._dirLight.visible = enabled;
62
62
  }
63
- }
63
+ }
@@ -22,10 +22,9 @@ jest.mock('three', () => {
22
22
  };
23
23
  return this;
24
24
  }),
25
- }
25
+ };
26
26
  });
27
27
 
28
-
29
28
  describe('dive/light/DIVEAmbientLight', () => {
30
29
  it('should instantiate', () => {
31
30
  const testLight = new DIVEAmbientLight();
@@ -41,7 +40,9 @@ describe('dive/light/DIVEAmbientLight', () => {
41
40
  it('should set color', () => {
42
41
  const testLight = new DIVEAmbientLight();
43
42
  testLight.SetColor({ test: true } as unknown as Color);
44
- expect((testLight.children[0] as AmbientLight).color).toEqual({ test: true });
43
+ expect((testLight.children[0] as AmbientLight).color).toEqual({
44
+ test: true,
45
+ });
45
46
  });
46
47
 
47
48
  it('should set enabled', () => {
@@ -49,4 +50,4 @@ describe('dive/light/DIVEAmbientLight', () => {
49
50
  testLight.SetEnabled(false);
50
51
  expect(testLight.children[0].visible).toBe(false);
51
52
  });
52
- });
53
+ });