@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,1030 +0,0 @@
1
- import { DIVECommunication } from '../Communication';
2
- import '../types';
3
- import { type Actions } from '../actions';
4
- import '../actions/camera/movecamera';
5
- import '../actions/camera/resetcamera';
6
- import '../actions/camera/setcameralayer';
7
- import '../actions/camera/setcameratransform';
8
- import '../actions/camera/zoomcamera';
9
- import '../actions/media/generatemedia';
10
- import '../actions/object/addobject';
11
- import '../actions/object/deleteobject';
12
- import '../actions/object/getallobjects';
13
- import '../actions/object/getobjects';
14
- import '../actions/object/selectobject';
15
- import '../actions/object/updateobject';
16
- import '../actions/object/model/modelloaded';
17
- import '../actions/object/model/placeonfloor';
18
- import '../actions/scene/getallscenedata';
19
- import '../actions/scene/setbackground';
20
- import '../actions/scene/updatescene';
21
- import '../actions/toolbox/select/setgizmomode';
22
- import '../actions/toolbox/transform/setgizmovisible';
23
- import '../actions/camera/getcameratransform';
24
- import { type DIVEScene } from '../../scene/Scene';
25
- import type DIVEToolbox from '../../toolbox/Toolbox';
26
- import type DIVEOrbitControls from '../../controls/OrbitControls';
27
- import { type DIVERenderer } from '../../renderer/Renderer';
28
- import {
29
- type COMGroup,
30
- type COMEntity,
31
- type COMEntityType,
32
- type COMLight,
33
- type COMModel,
34
- type COMPov,
35
- } from '../types';
36
- import { type DIVESceneObject } from '../../types';
37
- import { type ARSystemOptions } from '../../ar/AR';
38
-
39
- const mockModule: Record<string, any> = {
40
- get: jest.fn().mockReturnValue(Promise.resolve({})),
41
- };
42
- jest.mock('../../module/Module', () => {
43
- return {
44
- DIVEModule: jest.fn().mockImplementation(() => {
45
- return mockModule;
46
- }),
47
- };
48
- });
49
-
50
- jest.mock('../../mediacreator/MediaCreator', () => {
51
- return {
52
- DIVEMediaCreator: jest.fn().mockImplementation(() => {
53
- return {
54
- GenerateMedia: jest.fn(),
55
- };
56
- }),
57
- };
58
- });
59
-
60
- jest.mock('../../io/IO', () => {
61
- return {
62
- DIVEIO: jest.fn().mockImplementation(() => {
63
- return {
64
- Import: jest.fn(),
65
- Export: jest.fn(),
66
- };
67
- }),
68
- };
69
- });
70
-
71
- jest.mock('../../ar/AR', () => {
72
- return {
73
- DIVEAR: jest.fn().mockImplementation(() => {
74
- return {
75
- Launch: jest.fn(),
76
- };
77
- }),
78
- };
79
- });
80
-
81
- jest.mock('../../toolbox/select/SelectTool', () => {
82
- return {
83
- isSelectTool: jest.fn().mockReturnValue(true),
84
- DIVESelectTool: jest.fn().mockImplementation(() => {
85
- return {
86
- AttachGizmo: jest.fn(),
87
- DetachGizmo: jest.fn(),
88
- };
89
- }),
90
- };
91
- });
92
-
93
- const mockRenderer = {
94
- render: jest.fn(),
95
- OnResize: jest.fn(),
96
- StartRenderer: jest.fn(),
97
- } as unknown as DIVERenderer;
98
-
99
- const mockScene = {
100
- SetBackground: jest.fn(),
101
- AddSceneObject: jest.fn(),
102
- UpdateSceneObject: jest.fn(),
103
- DeleteSceneObject: jest.fn(),
104
- PlaceOnFloor: jest.fn(),
105
- GetSceneObject: jest.fn().mockReturnValue({
106
- attach: jest.fn(),
107
- DropIt: jest.fn(),
108
- }),
109
- background: {
110
- getHexString: jest.fn().mockReturnValue('ffffff'),
111
- },
112
- Root: {
113
- attach: jest.fn(),
114
- },
115
- Floor: {
116
- isFloor: true,
117
- visible: true,
118
- material: {
119
- color: {
120
- getHexString: jest.fn().mockReturnValue('ffffff'),
121
- },
122
- },
123
- SetVisibility: jest.fn(),
124
- SetColor: jest.fn(),
125
- },
126
- Grid: {
127
- SetVisibility: jest.fn(),
128
- },
129
- ComputeSceneBB: jest.fn(),
130
- } as unknown as DIVEScene;
131
-
132
- const mockController = {
133
- enableDamping: true,
134
- dampingFactor: 0.25,
135
- enableZoom: true,
136
- enablePan: true,
137
- minPolarAngle: 0,
138
- maxPolarAngle: Math.PI,
139
- minDistance: 0,
140
- maxDistance: Infinity,
141
- rotateSpeed: 0.5,
142
- panSpeed: 0.5,
143
- zoomSpeed: 0.5,
144
- keyPanSpeed: 0.5,
145
- screenSpacePanning: true,
146
- autoRotate: false,
147
- autoRotateSpeed: 2.0,
148
- enableKeys: true,
149
- keys: {
150
- LEFT: 37,
151
- UP: 38,
152
- RIGHT: 39,
153
- BOTTOM: 40,
154
- },
155
- mouseButtons: {
156
- LEFT: 0,
157
- MIDDLE: 1,
158
- RIGHT: 2,
159
- },
160
- target: {
161
- x: 4,
162
- y: 5,
163
- z: 6,
164
- set: jest.fn(),
165
- clone: jest.fn().mockReturnValue({ x: 4, y: 5, z: 6 }),
166
- copy: jest.fn(),
167
- },
168
- update: jest.fn(),
169
- dispose: jest.fn(),
170
- ZoomIn: jest.fn(),
171
- ZoomOut: jest.fn(),
172
- object: {
173
- position: {
174
- x: 1,
175
- y: 2,
176
- z: 3,
177
- clone: jest.fn().mockReturnValue({ x: 1, y: 2, z: 3 }),
178
- copy: jest.fn(),
179
- },
180
- quaternion: {
181
- x: 1,
182
- y: 2,
183
- z: 3,
184
- w: 4,
185
- clone: jest.fn().mockReturnValue({ x: 1, y: 2, z: 3, w: 4 }),
186
- copy: jest.fn(),
187
- },
188
- SetCameraLayer: jest.fn(),
189
- OnResize: jest.fn(),
190
- layers: {
191
- mask: 1,
192
- },
193
- },
194
- MoveTo: jest.fn(),
195
- RevertLast: jest.fn(),
196
- ComputeEncompassingView: jest.fn().mockReturnValue({
197
- position: { x: 1, y: 2, z: 3 },
198
- target: { x: 4, y: 5, z: 6 },
199
- }),
200
- } as unknown as DIVEOrbitControls;
201
-
202
- const mockToolBox = {
203
- UseTool: jest.fn(),
204
- GetActiveTool: jest.fn().mockReturnValue({
205
- AttachGizmo: jest.fn(),
206
- DetachGizmo: jest.fn(),
207
- }),
208
- SetGizmoMode: jest.fn(),
209
- SetGizmoVisibility: jest.fn(),
210
- SetGizmoScaleLinked: jest.fn(),
211
- } as unknown as DIVEToolbox;
212
-
213
- let testCom: DIVECommunication;
214
-
215
- describe('dive/communication/DIVECommunication', () => {
216
- beforeEach(() => {
217
- jest.clearAllMocks();
218
- testCom = new DIVECommunication(
219
- mockRenderer,
220
- mockScene,
221
- mockController,
222
- mockToolBox,
223
- );
224
- });
225
-
226
- afterEach(() => {
227
- testCom.DestroyInstance();
228
- jest.clearAllMocks();
229
- });
230
-
231
- it('should instantiate', () => {
232
- expect(testCom).toBeDefined();
233
- expect(DIVECommunication['__instances']).toHaveLength(1);
234
- });
235
-
236
- it('should get instance', () => {
237
- expect(testCom).toBeDefined();
238
- expect(DIVECommunication.get(testCom.id)).toBeDefined();
239
-
240
- testCom.PerformAction('ADD_OBJECT', {
241
- id: 'someID',
242
- } as COMModel);
243
- expect(DIVECommunication.get('someID')).toBeDefined();
244
- });
245
-
246
- it('should destroy instance', () => {
247
- expect(testCom).toBeDefined();
248
- testCom.DestroyInstance();
249
- expect(DIVECommunication['__instances']).toBeDefined();
250
- expect(DIVECommunication['__instances']).toHaveLength(0);
251
- });
252
-
253
- it('should subscribe, listen and unsubscribe from action', () => {
254
- const listener = jest.fn();
255
- const unsub = testCom.Subscribe('GET_ALL_OBJECTS', listener);
256
- expect(unsub).toBeDefined();
257
- expect(unsub).toBeInstanceOf(Function);
258
- const objects0 = testCom.PerformAction('GET_ALL_OBJECTS', new Map());
259
- expect(objects0).toBeDefined();
260
- expect(objects0.size).toBeDefined();
261
- expect(objects0.size).toBe(0);
262
- unsub();
263
- testCom.PerformAction('GET_ALL_OBJECTS', new Map());
264
- expect(listener).toHaveBeenCalledTimes(1);
265
- });
266
-
267
- it('should not unsubscribe twice', () => {
268
- const unsub = testCom.Subscribe('GET_ALL_OBJECTS', () => {});
269
- expect(unsub()).toBe(true);
270
- expect(unsub()).toBe(false);
271
- });
272
-
273
- it('should not unsubscribe if listener does not exist anymore', () => {
274
- const unsub = testCom.Subscribe('GET_ALL_OBJECTS', () => {});
275
- testCom['listeners'].clear();
276
- expect(unsub()).toBe(false);
277
- });
278
-
279
- it('should tigger onChange callback', () => {
280
- const payload = {
281
- name: 'name',
282
- entityType: 'light',
283
- id: 'ambient00',
284
- type: 'ambient',
285
- intensity: 0.5,
286
- color: 'white',
287
- } as COMLight;
288
- expect(() =>
289
- testCom.PerformAction('ADD_OBJECT', payload),
290
- ).not.toThrow();
291
- });
292
-
293
- it('should perform action START_RENDER', () => {
294
- const success = testCom.PerformAction('START_RENDER');
295
- expect(mockRenderer.StartRenderer).toHaveBeenCalledTimes(1);
296
- expect(success).toBe(true);
297
- });
298
-
299
- it('should perform action ADD_OBJECT', () => {
300
- const payload = {
301
- entityType: 'light',
302
- id: 'ambient00',
303
- type: 'ambient',
304
- intensity: 0.5,
305
- color: 'white',
306
- } as COMLight;
307
- const success = testCom.PerformAction('ADD_OBJECT', payload);
308
- expect(mockScene.AddSceneObject).toHaveBeenCalledTimes(1);
309
- expect(success).toBe(true);
310
- });
311
-
312
- it('should not perform action ADD_OBJECT with same object', () => {
313
- const payload = {
314
- entityType: 'light',
315
- id: 'ambient00',
316
- type: 'ambient',
317
- intensity: 0.5,
318
- color: 'white',
319
- } as COMLight;
320
- expect(testCom.PerformAction('ADD_OBJECT', payload)).toBe(true);
321
- expect(testCom.PerformAction('ADD_OBJECT', payload)).toBe(false);
322
- expect(mockScene.AddSceneObject).toHaveBeenCalledTimes(1);
323
- });
324
-
325
- it('should perform action UPDATE_OBJECT with existing oject', () => {
326
- const payload = {
327
- entityType: 'light',
328
- id: 'ambient00',
329
- type: 'ambient',
330
- intensity: 0.5,
331
- color: 'white',
332
- } as COMLight;
333
-
334
- testCom.PerformAction('ADD_OBJECT', payload);
335
-
336
- const successUpdate = testCom.PerformAction('UPDATE_OBJECT', payload);
337
- expect(mockScene.UpdateSceneObject).toHaveBeenCalledTimes(1);
338
- expect(successUpdate).toBe(true);
339
- });
340
-
341
- it('should perform action UPDATE_OBJECT without existing oject', () => {
342
- const payload = {
343
- entityType: 'light',
344
- id: 'ambient00',
345
- type: 'ambient',
346
- intensity: 0.5,
347
- color: 'white',
348
- } as COMLight;
349
- const successUpdate = testCom.PerformAction('UPDATE_OBJECT', payload);
350
- expect(mockScene.UpdateSceneObject).toHaveBeenCalledTimes(0);
351
- expect(successUpdate).toBe(false);
352
- });
353
-
354
- it('should perform action DELETE_OBJECT with existing object', () => {
355
- const payload = {
356
- entityType: 'group',
357
- id: 'group00',
358
- } as COMGroup;
359
-
360
- testCom.PerformAction('ADD_OBJECT', payload);
361
-
362
- // additionally add a child to the group
363
- testCom.PerformAction('ADD_OBJECT', {
364
- entityType: 'light',
365
- id: 'ambient00',
366
- type: 'ambient',
367
- intensity: 0.5,
368
- color: 'white',
369
- parentId: 'group00',
370
- } as COMLight);
371
-
372
- // and one child that has NO parent
373
- testCom.PerformAction('ADD_OBJECT', {
374
- entityType: 'light',
375
- id: 'ambient01',
376
- type: 'ambient',
377
- intensity: 0.5,
378
- color: 'white',
379
- } as COMLight);
380
-
381
- // and one child that has A DIFFERENT parent
382
- testCom.PerformAction('ADD_OBJECT', {
383
- entityType: 'light',
384
- id: 'ambient02',
385
- type: 'ambient',
386
- intensity: 0.5,
387
- color: 'white',
388
- parentId: 'group01',
389
- } as COMLight);
390
-
391
- const successDelete = testCom.PerformAction('DELETE_OBJECT', payload);
392
- expect(mockScene.DeleteSceneObject).toHaveBeenCalledTimes(1);
393
- expect(successDelete).toBe(true);
394
- });
395
-
396
- it('should perform action DELETE_OBJECT without existing object', () => {
397
- const payload = {
398
- entityType: 'light',
399
- id: 'ambient00',
400
- type: 'ambient',
401
- intensity: 0.5,
402
- color: 'white',
403
- } as COMLight;
404
- const successDelete = testCom.PerformAction('DELETE_OBJECT', payload);
405
- expect(mockScene.DeleteSceneObject).toHaveBeenCalledTimes(0);
406
- expect(successDelete).toBe(false);
407
- });
408
-
409
- it('should perform action SET_BACKGROUND', () => {
410
- const payload = {
411
- color: 'white',
412
- };
413
- const successSet = testCom.PerformAction('SET_BACKGROUND', payload);
414
- expect(mockScene.SetBackground).toHaveBeenCalledTimes(1);
415
- expect(successSet).toBe(true);
416
- });
417
-
418
- it('should perform action DROP_IT with existing model', () => {
419
- const payload = {
420
- entityType: 'model',
421
- id: 'model',
422
- position: { x: 0, y: 0, z: 0 },
423
- rotation: { x: 0, y: 0, z: 0 },
424
- scale: { x: 0.01, y: 0.01, z: 0.01 },
425
-
426
- uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
427
- } as COMModel;
428
-
429
- testCom.PerformAction('ADD_OBJECT', payload);
430
-
431
- const placeSpy = jest.spyOn(mockScene, 'GetSceneObject');
432
-
433
- const successPlace = testCom.PerformAction('DROP_IT', payload);
434
- expect(successPlace).toBe(true);
435
- expect(placeSpy).toHaveBeenCalledTimes(1);
436
- });
437
-
438
- it('should perform action DROP_IT without existing model', () => {
439
- const payload = {
440
- entityType: 'model',
441
- id: 'model',
442
- position: { x: 0, y: 0, z: 0 },
443
- rotation: { x: 0, y: 0, z: 0 },
444
- scale: { x: 0.01, y: 0.01, z: 0.01 },
445
-
446
- uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
447
- };
448
- const placeSpy = jest.spyOn(mockScene, 'GetSceneObject');
449
-
450
- const successPlace = testCom.PerformAction('DROP_IT', payload);
451
- expect(successPlace).toBe(false);
452
- expect(placeSpy).toHaveBeenCalledTimes(0);
453
- });
454
-
455
- it('should perform action PLACE_ON_FLOOR with existing model', () => {
456
- const payload = {
457
- entityType: 'model',
458
- id: 'model',
459
- position: { x: 0, y: 0, z: 0 },
460
- rotation: { x: 0, y: 0, z: 0 },
461
- scale: { x: 0.01, y: 0.01, z: 0.01 },
462
-
463
- uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
464
- } as COMModel;
465
-
466
- testCom.PerformAction('ADD_OBJECT', payload);
467
-
468
- const placeSpy = jest.spyOn(mockScene, 'PlaceOnFloor');
469
-
470
- const successPlace = testCom.PerformAction('PLACE_ON_FLOOR', payload);
471
- expect(successPlace).toBe(true);
472
- expect(placeSpy).toHaveBeenCalledTimes(1);
473
- });
474
-
475
- it('should perform action PLACE_ON_FLOOR without existing model', () => {
476
- const payload = {
477
- entityType: 'model' as COMEntityType,
478
- id: 'model',
479
- position: { x: 0, y: 0, z: 0 },
480
- rotation: { x: 0, y: 0, z: 0 },
481
- scale: { x: 0.01, y: 0.01, z: 0.01 },
482
-
483
- uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
484
- };
485
- const placeSpy = jest.spyOn(mockScene, 'PlaceOnFloor');
486
-
487
- const successPlace = testCom.PerformAction('PLACE_ON_FLOOR', payload);
488
- expect(successPlace).toBe(false);
489
- expect(placeSpy).toHaveBeenCalledTimes(0);
490
- });
491
-
492
- it('should perform action GET_ALL_OBJECTS', () => {
493
- const payload = {
494
- entityType: 'model',
495
- id: 'model',
496
- position: { x: 0, y: 0, z: 0 },
497
- rotation: { x: 0, y: 0, z: 0 },
498
- scale: { x: 0.01, y: 0.01, z: 0.01 },
499
-
500
- uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
501
- } as COMModel;
502
-
503
- const objects0 = testCom.PerformAction('GET_ALL_OBJECTS', new Map());
504
- expect(objects0).toBeDefined();
505
- expect(objects0.size).toBeDefined();
506
- expect(objects0.size).toBe(0);
507
-
508
- testCom.PerformAction('ADD_OBJECT', payload);
509
-
510
- const objects1 = testCom.PerformAction('GET_ALL_OBJECTS', new Map());
511
- expect(objects1).toBeDefined();
512
- expect(objects1.size).toBeDefined();
513
- expect(objects1.size).toBe(1);
514
- });
515
-
516
- it('should perform action MOVE_CAMERA', () => {
517
- const payload = {
518
- position: { x: 0, y: 0, z: 0 },
519
- target: { x: 0, y: 0, z: 0 },
520
- duration: 1000,
521
- locked: true,
522
- };
523
- const successSet = testCom.PerformAction('MOVE_CAMERA', payload);
524
- const moveToSpy = jest.spyOn(mockController, 'MoveTo');
525
- expect(moveToSpy).toHaveBeenCalledTimes(1);
526
- expect(successSet).toBe(true);
527
-
528
- moveToSpy.mockClear();
529
- testCom.PerformAction('ADD_OBJECT', {
530
- entityType: 'pov',
531
- id: 'pov',
532
- position: { x: 0, y: 0, z: 0 },
533
- target: { x: 0, y: 0, z: 0 },
534
- } as COMPov);
535
-
536
- const payloadId = {
537
- id: 'pov',
538
- locked: true,
539
- duration: 1000,
540
- };
541
- const successSet1 = testCom.PerformAction('MOVE_CAMERA', payloadId);
542
- expect(moveToSpy).toHaveBeenCalledTimes(1);
543
- expect(successSet1).toBe(true);
544
- });
545
-
546
- it('should perform action RESET_CAMERA', () => {
547
- const payload = {
548
- duration: 1000,
549
- };
550
- const successSet = testCom.PerformAction('RESET_CAMERA', payload);
551
- expect(mockController.RevertLast).toHaveBeenCalledTimes(1);
552
- expect(successSet).toBe(true);
553
- });
554
-
555
- it('should perform action COMPUTE_ENCOMPASSING_VIEW', () => {
556
- const payload = {};
557
- const transform = testCom.PerformAction(
558
- 'COMPUTE_ENCOMPASSING_VIEW',
559
- payload,
560
- );
561
- expect(transform).toStrictEqual({
562
- position: { x: 1, y: 2, z: 3 },
563
- target: { x: 4, y: 5, z: 6 },
564
- });
565
- expect(payload).toStrictEqual({
566
- position: { x: 1, y: 2, z: 3 },
567
- target: { x: 4, y: 5, z: 6 },
568
- });
569
- });
570
-
571
- it('should perform action GET_ALL_SCENE_DATA', () => {
572
- testCom.PerformAction('ADD_OBJECT', {
573
- entityType: 'pov',
574
- id: 'pov',
575
- position: { x: 0, y: 0, z: 0 },
576
- target: { x: 0, y: 0, z: 0 },
577
- } as COMPov);
578
-
579
- testCom.PerformAction('ADD_OBJECT', {
580
- entityType: 'model',
581
- id: 'model',
582
- position: { x: 0, y: 0, z: 0 },
583
- rotation: { x: 0, y: 0, z: 0 },
584
- scale: { x: 0.01, y: 0.01, z: 0.01 },
585
-
586
- uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
587
- } as COMModel);
588
-
589
- testCom.PerformAction('ADD_OBJECT', {
590
- entityType: 'light',
591
- id: 'ambient00',
592
- type: 'ambient',
593
- intensity: 0.5,
594
- color: 'white',
595
- } as COMLight);
596
-
597
- testCom.PerformAction('ADD_OBJECT', {
598
- entityType: 'group',
599
- id: 'group1',
600
- position: { x: 0, y: 0, z: 0 },
601
- rotation: { x: 0, y: 0, z: 0 },
602
- parentId: null,
603
- } as COMGroup);
604
-
605
- const success = testCom.PerformAction('GET_ALL_SCENE_DATA', {});
606
- expect(success).toStrictEqual({
607
- backgroundColor: '#ffffff',
608
- cameras: [
609
- {
610
- entityType: 'pov',
611
- id: 'pov',
612
- position: { x: 0, y: 0, z: 0 },
613
- target: { x: 0, y: 0, z: 0 },
614
- parentId: null,
615
- },
616
- ],
617
- floorColor: '#ffffff',
618
- floorEnabled: true,
619
- lights: [
620
- {
621
- entityType: 'light',
622
- id: 'ambient00',
623
- type: 'ambient',
624
- intensity: 0.5,
625
- color: 'white',
626
- parentId: null,
627
- },
628
- ],
629
- mediaItem: null,
630
- name: undefined,
631
- objects: [
632
- {
633
- entityType: 'model',
634
- id: 'model',
635
- position: { x: 0, y: 0, z: 0 },
636
- rotation: { x: 0, y: 0, z: 0 },
637
- scale: { x: 0.01, y: 0.01, z: 0.01 },
638
- parentId: null,
639
- uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
640
- },
641
- ],
642
- primitives: [],
643
- spotmarks: [],
644
- userCamera: {
645
- position: { x: 1, y: 2, z: 3 },
646
- target: { x: 4, y: 5, z: 6 },
647
- },
648
- groups: [
649
- {
650
- entityType: 'group',
651
- id: 'group1',
652
- position: { x: 0, y: 0, z: 0 },
653
- rotation: { x: 0, y: 0, z: 0 },
654
- parentId: null,
655
- },
656
- ],
657
- });
658
- });
659
-
660
- it('should perform action GET_OBJECTS', () => {
661
- const mock0 = {
662
- entityType: 'pov',
663
- id: 'test0',
664
- position: { x: 0, y: 0, z: 0 },
665
- target: { x: 0, y: 0, z: 0 },
666
- } as COMPov;
667
- testCom.PerformAction('ADD_OBJECT', mock0);
668
-
669
- const mock1 = {
670
- entityType: 'pov',
671
- id: 'test1',
672
- position: { x: 0, y: 0, z: 0 },
673
- target: { x: 0, y: 0, z: 0 },
674
- } as COMPov;
675
- testCom.PerformAction('ADD_OBJECT', mock1);
676
-
677
- const successWithoutIds = testCom.PerformAction('GET_OBJECTS', {
678
- ids: [],
679
- });
680
- expect(Array.from(successWithoutIds.values())).toStrictEqual([]);
681
-
682
- const successWithIds = testCom.PerformAction('GET_OBJECTS', {
683
- ids: ['test1'],
684
- });
685
- expect(Array.from(successWithIds.values())).toStrictEqual([
686
- {
687
- entityType: 'pov',
688
- id: 'test1',
689
- position: { x: 0, y: 0, z: 0 },
690
- target: { x: 0, y: 0, z: 0 },
691
- parentId: null,
692
- },
693
- ]);
694
- });
695
-
696
- it('should perform action SELECT_OBJECT', () => {
697
- const success0 = testCom.PerformAction('SELECT_OBJECT', {
698
- id: 'test0',
699
- });
700
- expect(success0).toBe(false);
701
-
702
- const mock0 = {
703
- entityType: 'pov',
704
- id: 'test0',
705
- position: { x: 0, y: 0, z: 0 },
706
- target: { x: 0, y: 0, z: 0 },
707
- } as COMPov;
708
- testCom.PerformAction('ADD_OBJECT', mock0);
709
-
710
- jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(undefined);
711
- const success1 = testCom.PerformAction('SELECT_OBJECT', {
712
- id: 'test0',
713
- });
714
- expect(success1).toBe(false);
715
-
716
- jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(
717
- {} as unknown as DIVESceneObject,
718
- );
719
- const success2 = testCom.PerformAction('SELECT_OBJECT', {
720
- id: 'test0',
721
- });
722
- expect(success2).toBe(false);
723
-
724
- jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce({
725
- isSelectable: true,
726
- } as unknown as DIVESceneObject);
727
- const success3 = testCom.PerformAction('SELECT_OBJECT', {
728
- id: 'test0',
729
- });
730
- expect(success3).toBe(true);
731
- });
732
-
733
- it('should perform action DESELECT_OBJECT', () => {
734
- const success0 = testCom.PerformAction('DESELECT_OBJECT', {
735
- id: 'test0',
736
- });
737
- expect(success0).toBe(false);
738
-
739
- const mock0 = {
740
- entityType: 'pov',
741
- id: 'test0',
742
- position: { x: 0, y: 0, z: 0 },
743
- target: { x: 0, y: 0, z: 0 },
744
- } as COMPov;
745
- testCom.PerformAction('ADD_OBJECT', mock0);
746
-
747
- jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(undefined);
748
- const success1 = testCom.PerformAction('DESELECT_OBJECT', {
749
- id: 'test0',
750
- });
751
- expect(success1).toBe(false);
752
-
753
- jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce(
754
- {} as unknown as DIVESceneObject,
755
- );
756
- const success2 = testCom.PerformAction('DESELECT_OBJECT', {
757
- id: 'test0',
758
- });
759
- expect(success2).toBe(false);
760
-
761
- jest.spyOn(mockScene, 'GetSceneObject').mockReturnValueOnce({
762
- isSelectable: true,
763
- } as unknown as DIVESceneObject);
764
- const success3 = testCom.PerformAction('DESELECT_OBJECT', {
765
- id: 'test0',
766
- });
767
- expect(success3).toBe(true);
768
- });
769
-
770
- it('should perform action SET_CAMERA_TRANSFORM', () => {
771
- const success = testCom.PerformAction('SET_CAMERA_TRANSFORM', {
772
- position: { x: 0, y: 0, z: 0 },
773
- target: { x: 0, y: 0, z: 0 },
774
- });
775
- expect(success).toBe(true);
776
- });
777
-
778
- it('should perform action GET_CAMERA_TRANSFORM', () => {
779
- const success = testCom.PerformAction('GET_CAMERA_TRANSFORM', {});
780
- expect(success).toStrictEqual({
781
- position: { x: 1, y: 2, z: 3 },
782
- target: { x: 4, y: 5, z: 6 },
783
- });
784
- });
785
-
786
- it('should perform action SET_CAMERA_LAYER', () => {
787
- const success = testCom.PerformAction('SET_CAMERA_LAYER', {
788
- layer: 'EDITOR',
789
- });
790
- expect(success).toBe(true);
791
- });
792
-
793
- it('should perform action ZOOM_CAMERA', () => {
794
- const success0 = testCom.PerformAction('ZOOM_CAMERA', {
795
- direction: 'IN',
796
- by: 10,
797
- });
798
- expect(success0).toBe(true);
799
- const success1 = testCom.PerformAction('ZOOM_CAMERA', {
800
- direction: 'OUT',
801
- by: 10,
802
- });
803
- expect(success1).toBe(true);
804
- });
805
-
806
- it('should perform action SET_GIZMO_MODE', () => {
807
- const success = testCom.PerformAction('SET_GIZMO_MODE', {
808
- mode: 'translate',
809
- });
810
- expect(success).toBe(true);
811
- });
812
-
813
- it('should perform action SET_GIZMO_VISIBILITY', () => {
814
- let visibility = testCom.PerformAction('SET_GIZMO_VISIBILITY', true);
815
- expect(visibility).toBe(true);
816
-
817
- visibility = testCom.PerformAction('SET_GIZMO_VISIBILITY', false);
818
- expect(visibility).toBe(false);
819
- });
820
-
821
- it('should perform action SET_GIZMO_SCALE_LINKED', () => {
822
- const success = testCom.PerformAction('SET_GIZMO_SCALE_LINKED', true);
823
- expect(success).toBe(true);
824
- });
825
-
826
- it('should perform action USE_TOOL', () => {
827
- let success = testCom.PerformAction('USE_TOOL', { tool: 'select' });
828
- expect(success).toBe(true);
829
-
830
- success = testCom.PerformAction('USE_TOOL', { tool: 'none' });
831
- expect(success).toBe(true);
832
- });
833
-
834
- it('should perform action MODEL_LOADED', () => {
835
- const payload = {
836
- entityType: 'model',
837
- id: 'modelID',
838
- position: { x: 0, y: 0, z: 0 },
839
- rotation: { x: 0, y: 0, z: 0 },
840
- scale: { x: 0.01, y: 0.01, z: 0.01 },
841
-
842
- uri: 'https://threejs.org/examples/models/gltf/LittlestTokyo.glb',
843
- } as COMModel;
844
- testCom.PerformAction('ADD_OBJECT', payload);
845
- const success = testCom.PerformAction('MODEL_LOADED', {
846
- id: 'modelID',
847
- });
848
- expect(success).toBe(true);
849
- });
850
-
851
- it('should perform action UPDATE_SCENE', () => {
852
- const success0 = testCom.PerformAction('UPDATE_SCENE', {
853
- name: 'scene name',
854
- backgroundColor: 'ffffff',
855
- floorEnabled: true,
856
- floorColor: 'ffffff',
857
- gridEnabled: true,
858
- });
859
- expect(success0).toBe(true);
860
-
861
- const success1 = testCom.PerformAction('UPDATE_SCENE', {
862
- name: undefined,
863
- backgroundColor: undefined,
864
- floorEnabled: undefined,
865
- floorColor: undefined,
866
- gridEnabled: undefined,
867
- });
868
- expect(success1).toBe(true);
869
- });
870
-
871
- it('should perform action GENERATE_MEDIA', async () => {
872
- const blobUri = 'blob:http://localhost:3000/1234';
873
- jest.spyOn(mockModule, 'get').mockResolvedValue({
874
- GenerateMedia: jest.fn(),
875
- });
876
- const mediaGeneratorModule = await testCom['_mediaGenerator'].get();
877
-
878
- jest.spyOn(mediaGeneratorModule, 'GenerateMedia').mockReturnValue(
879
- blobUri,
880
- );
881
-
882
- const mock1 = {
883
- entityType: 'pov',
884
- id: 'test1',
885
- position: { x: 0, y: 0, z: 0 },
886
- target: { x: 0, y: 0, z: 0 },
887
- } as COMPov;
888
- testCom.PerformAction('ADD_OBJECT', mock1);
889
-
890
- const success0 = await testCom.PerformAction('GENERATE_MEDIA', {
891
- id: 'test1',
892
- width: 800,
893
- height: 600,
894
- });
895
- expect(success0).toBe(blobUri);
896
-
897
- const success1 = await testCom.PerformAction('GENERATE_MEDIA', {
898
- position: { x: 0, y: 0, z: 0 },
899
- target: { x: 0, y: 0, z: 0 },
900
- width: 800,
901
- height: 600,
902
- });
903
- expect(success1).toBe(blobUri);
904
-
905
- jest.restoreAllMocks();
906
- });
907
-
908
- it('should perform action SET_PARENT', () => {
909
- const object = {
910
- id: 'object',
911
- } as COMEntity;
912
- testCom.PerformAction('ADD_OBJECT', object);
913
-
914
- const objectNotRegistered = {
915
- id: 'objectNotRegistered',
916
- } as COMEntity;
917
-
918
- const parent0 = {
919
- id: 'parent0',
920
- } as COMEntity;
921
- testCom.PerformAction('ADD_OBJECT', parent0);
922
-
923
- const parent1 = {
924
- id: 'parent1',
925
- } as COMEntity;
926
- testCom.PerformAction('ADD_OBJECT', parent1);
927
-
928
- const parentNotRegistered = {
929
- id: 'parentNotRegistered',
930
- } as COMEntity;
931
-
932
- const attachNotRegisteredObject = testCom.PerformAction('SET_PARENT', {
933
- object: objectNotRegistered,
934
- parent: null,
935
- });
936
- expect(attachNotRegisteredObject).toBe(false);
937
-
938
- jest.spyOn(mockScene, 'GetSceneObject').mockImplementationOnce(() => {
939
- return undefined;
940
- });
941
- const attachNonSceneObject = testCom.PerformAction('SET_PARENT', {
942
- object: object,
943
- parent: null,
944
- });
945
- expect(attachNonSceneObject).toBe(false);
946
-
947
- const attachToNull = testCom.PerformAction('SET_PARENT', {
948
- object: object,
949
- parent: null,
950
- });
951
- expect(attachToNull).toBe(true);
952
-
953
- const attachToItself = testCom.PerformAction('SET_PARENT', {
954
- object: object,
955
- parent: object,
956
- });
957
- expect(attachToItself).toBe(false);
958
-
959
- const attachToNotRegsiteredParent = testCom.PerformAction(
960
- 'SET_PARENT',
961
- {
962
- object: object,
963
- parent: parentNotRegistered,
964
- },
965
- );
966
- expect(attachToNotRegsiteredParent).toBe(true);
967
-
968
- jest.spyOn(mockScene, 'GetSceneObject')
969
- .mockImplementationOnce(() => {
970
- return {
971
- DropIt: jest.fn(),
972
- attach: jest.fn(),
973
- } as unknown as DIVESceneObject;
974
- })
975
- .mockImplementationOnce(() => {
976
- return undefined;
977
- });
978
-
979
- const attachtoNonSceneParent = testCom.PerformAction('SET_PARENT', {
980
- object: object,
981
- parent: parent1,
982
- });
983
- expect(attachtoNonSceneParent).toBe(true);
984
-
985
- const attachToValidParent = testCom.PerformAction('SET_PARENT', {
986
- object: object,
987
- parent: parent1,
988
- });
989
- expect(attachToValidParent).toBe(true);
990
- });
991
-
992
- it('should perform action EXPORT_SCENE', async () => {
993
- const url = 'https://example.com';
994
- jest.spyOn(mockModule, 'get').mockResolvedValue({
995
- Export: jest.fn(),
996
- });
997
- const ioModule = await testCom['_io'].get();
998
-
999
- jest.spyOn(ioModule, 'Export').mockResolvedValueOnce(url);
1000
-
1001
- const result = await testCom.PerformAction('EXPORT_SCENE', {
1002
- type: 'glb',
1003
- });
1004
- expect(result).toBe(url);
1005
- });
1006
-
1007
- it('should perform action LAUNCH_AR', async () => {
1008
- jest.spyOn(mockModule, 'get').mockResolvedValue({
1009
- launch: jest.fn(),
1010
- });
1011
- const arModule = await testCom['_ar'].get();
1012
- const arLaunchSpy = jest
1013
- .spyOn(arModule, 'launch')
1014
- .mockResolvedValueOnce();
1015
-
1016
- const result = await testCom.PerformAction('LAUNCH_AR', {
1017
- uri: 'https://example.com',
1018
- options: {
1019
- arPlacement: 'horizontal',
1020
- } as ARSystemOptions,
1021
- });
1022
- expect(arLaunchSpy).toHaveBeenCalledTimes(1);
1023
- });
1024
-
1025
- it('should warn of action is of invalid type ', () => {
1026
- jest.spyOn(console, 'warn').mockImplementationOnce(() => {});
1027
- testCom.PerformAction('INVALID_ACTION' as keyof Actions, {});
1028
- expect(console.warn).toHaveBeenCalledTimes(1);
1029
- });
1030
- });