@shopware-ag/dive 1.19.0 → 1.19.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/build/dive.cjs +388 -220
  2. package/build/dive.cjs.map +1 -1
  3. package/build/dive.js +395 -21946
  4. package/build/dive.js.map +1 -1
  5. package/build/dive.mjs +28206 -0
  6. package/build/dive.mjs.map +1 -0
  7. package/build/src/ar/AR.d.ts +37 -14
  8. package/build/src/ar/arquicklook/ARQuickLook.d.ts +5 -6
  9. package/build/src/ar/sceneviewer/SceneViewer.d.ts +42 -6
  10. package/build/src/com/actions/scene/launchar.d.ts +5 -2
  11. package/build/src/converter/Converter.d.ts +21 -0
  12. package/build/src/dive.d.ts +3 -2
  13. package/build/src/exporter/Exporter.d.ts +11 -0
  14. package/build/src/helper/applyMixins/applyMixins.d.ts +22 -6
  15. package/build/src/info/Info.d.ts +37 -13
  16. package/build/src/interface/Movable.d.ts +5 -5
  17. package/build/src/interface/Selectable.d.ts +4 -4
  18. package/build/src/loader/Loader.d.ts +11 -0
  19. package/build/src/model/Model.d.ts +2 -2
  20. package/build/src/node/Node.d.ts +3 -3
  21. package/build/src/scene/root/Root.d.ts +1 -1
  22. package/build/src/types/ExporterOptions.d.ts +15 -0
  23. package/build/src/types/FileTypes.d.ts +27 -0
  24. package/build/src/types/index.d.ts +4 -0
  25. package/build/src/types/info/index.d.ts +66 -0
  26. package/package.json +17 -3
  27. package/build/src/exporters/usdz/USDZExporter.d.ts +0 -15
  28. package/build/src/loadingmanager/LoadingManager.d.ts +0 -14
  29. package/src/__test__/DIVE.test.ts +0 -274
  30. package/src/animation/AnimationSystem.ts +0 -34
  31. package/src/animation/__test__/AnimationSystem.test.ts +0 -40
  32. package/src/ar/AR.ts +0 -98
  33. package/src/ar/__test__/AR.test.ts +0 -187
  34. package/src/ar/arquicklook/ARQuickLook.ts +0 -93
  35. package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +0 -93
  36. package/src/ar/sceneviewer/SceneViewer.ts +0 -74
  37. package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -93
  38. package/src/ar/webxr/WebXR.ts +0 -176
  39. package/src/ar/webxr/controller/WebXRController.ts +0 -340
  40. package/src/ar/webxr/crosshair/WebXRCrosshair.ts +0 -35
  41. package/src/ar/webxr/origin/WebXROrigin.ts +0 -192
  42. package/src/ar/webxr/overlay/Overlay.ts +0 -50
  43. package/src/ar/webxr/raycaster/WebXRRaycaster.ts +0 -131
  44. package/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts +0 -102
  45. package/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts +0 -49
  46. package/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts +0 -356
  47. package/src/axiscamera/AxisCamera.ts +0 -108
  48. package/src/axiscamera/__test__/AxisCamera.test.ts +0 -150
  49. package/src/camera/PerspectiveCamera.ts +0 -63
  50. package/src/camera/__test__/PerspectiveCamera.test.ts +0 -36
  51. package/src/com/Communication.ts +0 -808
  52. package/src/com/__test__/Communication.test.ts +0 -1024
  53. package/src/com/actions/camera/computeencompassingview.ts +0 -10
  54. package/src/com/actions/camera/getcameratransform.ts +0 -10
  55. package/src/com/actions/camera/movecamera.ts +0 -18
  56. package/src/com/actions/camera/resetcamera.ts +0 -5
  57. package/src/com/actions/camera/setcameralayer.ts +0 -5
  58. package/src/com/actions/camera/setcameratransform.ts +0 -10
  59. package/src/com/actions/camera/zoomcamera.ts +0 -5
  60. package/src/com/actions/index.ts +0 -61
  61. package/src/com/actions/media/generatemedia.ts +0 -18
  62. package/src/com/actions/object/addobject.ts +0 -7
  63. package/src/com/actions/object/deleteobject.ts +0 -7
  64. package/src/com/actions/object/deselectobject.ts +0 -7
  65. package/src/com/actions/object/getallobjects.ts +0 -7
  66. package/src/com/actions/object/getobjects.ts +0 -7
  67. package/src/com/actions/object/model/dropit.ts +0 -5
  68. package/src/com/actions/object/model/modelloaded.ts +0 -5
  69. package/src/com/actions/object/model/placeonfloor.ts +0 -5
  70. package/src/com/actions/object/selectobject.ts +0 -7
  71. package/src/com/actions/object/setparent.ts +0 -10
  72. package/src/com/actions/object/updateobject.ts +0 -7
  73. package/src/com/actions/renderer/startrender.ts +0 -5
  74. package/src/com/actions/scene/exportscene.ts +0 -7
  75. package/src/com/actions/scene/getallscenedata.ts +0 -7
  76. package/src/com/actions/scene/launchar.ts +0 -7
  77. package/src/com/actions/scene/setbackground.ts +0 -5
  78. package/src/com/actions/scene/updatescene.ts +0 -11
  79. package/src/com/actions/toolbox/select/setgizmomode.ts +0 -5
  80. package/src/com/actions/toolbox/transform/setgizmoscalelinked.ts +0 -5
  81. package/src/com/actions/toolbox/transform/setgizmovisible.ts +0 -5
  82. package/src/com/actions/toolbox/usetool.ts +0 -7
  83. package/src/com/types/COMBaseEntity.ts +0 -9
  84. package/src/com/types/COMEntity.ts +0 -7
  85. package/src/com/types/COMEntityType.ts +0 -1
  86. package/src/com/types/COMGeometry.ts +0 -8
  87. package/src/com/types/COMGeometryType.ts +0 -9
  88. package/src/com/types/COMGroup.ts +0 -9
  89. package/src/com/types/COMLight.ts +0 -11
  90. package/src/com/types/COMMaterial.ts +0 -12
  91. package/src/com/types/COMModel.ts +0 -12
  92. package/src/com/types/COMPov.ts +0 -8
  93. package/src/com/types/COMPrimitive.ts +0 -12
  94. package/src/com/types/index.ts +0 -23
  95. package/src/constant/AxisHelperColors.ts +0 -7
  96. package/src/constant/GridColors.ts +0 -2
  97. package/src/constant/VisibilityLayerMask.ts +0 -5
  98. package/src/controls/OrbitControls.ts +0 -211
  99. package/src/controls/__test__/OrbitControls.test.ts +0 -256
  100. package/src/dive.ts +0 -363
  101. package/src/events/EventExecutor.ts +0 -35
  102. package/src/exporters/usdz/USDZExporter.ts +0 -21
  103. package/src/exporters/usdz/__test__/USDZExporter.test.ts +0 -57
  104. package/src/gizmo/Gizmo.ts +0 -144
  105. package/src/gizmo/handles/AxisHandle.ts +0 -153
  106. package/src/gizmo/handles/RadialHandle.ts +0 -149
  107. package/src/gizmo/handles/ScaleHandle.ts +0 -195
  108. package/src/gizmo/plane/GizmoPlane.ts +0 -84
  109. package/src/gizmo/rotate/RotateGizmo.ts +0 -143
  110. package/src/gizmo/scale/ScaleGizmo.ts +0 -125
  111. package/src/gizmo/translate/TranslateGizmo.ts +0 -114
  112. package/src/grid/Grid.ts +0 -34
  113. package/src/grid/__test__/Grid.test.ts +0 -28
  114. package/src/group/Group.ts +0 -184
  115. package/src/group/__test__/Group.test.ts +0 -212
  116. package/src/helper/applyMixins/__test__/applyMixins.test.ts +0 -30
  117. package/src/helper/applyMixins/applyMixins.ts +0 -18
  118. package/src/helper/findInterface/__test__/findInterface.test.ts +0 -63
  119. package/src/helper/findInterface/findInterface.ts +0 -13
  120. package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +0 -40
  121. package/src/helper/findSceneRecursive/findSceneRecursive.ts +0 -16
  122. package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +0 -186
  123. package/src/helper/getObjectDelta/getObjectDelta.ts +0 -105
  124. package/src/helper/isInterface/__test__/implementsInterface.test.ts +0 -19
  125. package/src/helper/isInterface/implementsInterface.ts +0 -9
  126. package/src/info/Info.ts +0 -154
  127. package/src/info/__test__/Info.test.ts +0 -338
  128. package/src/interface/Draggable.ts +0 -14
  129. package/src/interface/Hoverable.ts +0 -14
  130. package/src/interface/Movable.ts +0 -12
  131. package/src/interface/Rotatable.ts +0 -10
  132. package/src/interface/Scalable.ts +0 -10
  133. package/src/interface/Selectable.ts +0 -11
  134. package/src/io/IO.ts +0 -62
  135. package/src/io/__test__/IO.test.ts +0 -116
  136. package/src/io/gltf/GLTFIO.ts +0 -56
  137. package/src/io/gltf/__test__/GLTFIO.test.ts +0 -108
  138. package/src/light/AmbientLight.ts +0 -39
  139. package/src/light/PointLight.ts +0 -115
  140. package/src/light/SceneLight.ts +0 -63
  141. package/src/light/__test__/AmbientLight.test.ts +0 -29
  142. package/src/light/__test__/PointLight.test.ts +0 -74
  143. package/src/light/__test__/SceneLight.test.ts +0 -47
  144. package/src/loadingmanager/LoadingManager.ts +0 -50
  145. package/src/loadingmanager/__test__/LoadingManager.test.ts +0 -27
  146. package/src/math/__test__/DIVEMath.test.ts +0 -12
  147. package/src/math/ceil/__test__/ceilExp.test.ts +0 -12
  148. package/src/math/ceil/ceilExp.ts +0 -6
  149. package/src/math/degToRad/__test__/degToRad.test.ts +0 -172
  150. package/src/math/degToRad/degToRad.ts +0 -5
  151. package/src/math/floor/__test__/floorExp.test.ts +0 -14
  152. package/src/math/floor/floorExp.ts +0 -6
  153. package/src/math/helper/__test__/shift.test.ts +0 -12
  154. package/src/math/helper/shift.ts +0 -4
  155. package/src/math/index.ts +0 -28
  156. package/src/math/radToDeg/__test__/radToDeg.test.ts +0 -155
  157. package/src/math/radToDeg/radToDeg.ts +0 -5
  158. package/src/math/round/__test__/roundExp.test.ts +0 -14
  159. package/src/math/round/roundExp.ts +0 -10
  160. package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +0 -20
  161. package/src/math/signedAngleTo/signedAngleTo.ts +0 -20
  162. package/src/math/toFixed/__test__/toFixedExp.test.ts +0 -14
  163. package/src/math/toFixed/toFixedExp.ts +0 -9
  164. package/src/math/truncate/__test__/truncateExp.test.ts +0 -14
  165. package/src/math/truncate/truncateExp.ts +0 -9
  166. package/src/mediacreator/MediaCreator.ts +0 -75
  167. package/src/mediacreator/__test__/MediaCreator.test.ts +0 -155
  168. package/src/model/Model.ts +0 -185
  169. package/src/model/__test__/Model.test.ts +0 -222
  170. package/src/module/Module.ts +0 -45
  171. package/src/module/__test__/Module.test.ts +0 -54
  172. package/src/node/Node.ts +0 -98
  173. package/src/node/__test__/Node.test.ts +0 -120
  174. package/src/primitive/Primitive.ts +0 -299
  175. package/src/primitive/__test__/Primitive.test.ts +0 -281
  176. package/src/primitive/floor/Floor.ts +0 -45
  177. package/src/primitive/floor/__test__/Floor.test.ts +0 -24
  178. package/src/renderer/Renderer.ts +0 -215
  179. package/src/renderer/__test__/Renderer.test.ts +0 -228
  180. package/src/scene/Scene.ts +0 -106
  181. package/src/scene/__test__/Scene.test.ts +0 -124
  182. package/src/scene/root/Root.ts +0 -426
  183. package/src/scene/root/__test__/Root.test.ts +0 -903
  184. package/src/scene/xrroot/XRRoot.ts +0 -56
  185. package/src/scene/xrroot/xrlightroot/XRLightRoot.ts +0 -80
  186. package/src/toolbox/BaseTool.ts +0 -319
  187. package/src/toolbox/Toolbox.ts +0 -129
  188. package/src/toolbox/__test__/BaseTool.test.ts +0 -627
  189. package/src/toolbox/__test__/Toolbox.test.ts +0 -143
  190. package/src/toolbox/select/SelectTool.ts +0 -92
  191. package/src/toolbox/select/__test__/SelectTool.test.ts +0 -237
  192. package/src/toolbox/transform/TransformTool.ts +0 -166
  193. package/src/toolbox/transform/__test__/TransformTool.test.ts +0 -147
  194. package/src/types/SceneData.ts +0 -26
  195. package/src/types/SceneObjects.ts +0 -14
  196. package/src/types/SceneType.ts +0 -14
  197. package/src/types/index.ts +0 -5
@@ -1,274 +0,0 @@
1
- import DIVE, { DIVESettings } from '../dive.ts';
2
-
3
- jest.mock('../com/Communication.ts', () => {
4
- return {
5
- DIVECommunication: jest.fn(function () {
6
- this.PerformAction = jest.fn().mockReturnValue({
7
- position: { x: 0, y: 0, z: 0 },
8
- target: { x: 0, y: 0, z: 0 },
9
- });
10
- this.Subscribe = jest.fn(
11
- (action: string, callback: (data: { id: string }) => void) => {
12
- callback({ id: 'incorrect id' });
13
- callback({ id: 'test_uuid' });
14
- },
15
- );
16
- this.DestroyInstance = jest.fn();
17
-
18
- return this;
19
- }),
20
- };
21
- });
22
-
23
- jest.mock('../renderer/Renderer.ts', () => {
24
- return {
25
- DIVERenderer: jest.fn(function () {
26
- this.domElement = {
27
- clientWidth: 800,
28
- clientHeight: 600,
29
- style: {
30
- position: 'absolute',
31
- },
32
- };
33
- this.domElement.parentElement = this.domElement;
34
- this.AddPreRenderCallback = (callback: () => void) => {
35
- callback();
36
- };
37
- this.RemovePreRenderCallback = jest.fn();
38
- this.AddPostRenderCallback = (callback: () => void) => {
39
- callback();
40
- };
41
- this.getViewport = jest.fn();
42
- this.setViewport = jest.fn();
43
- this.autoClear = false;
44
- this.render = jest.fn();
45
- this.StartRenderer = jest.fn();
46
- this.OnResize = jest.fn();
47
- this.Dispose = jest.fn();
48
- return this;
49
- }),
50
- };
51
- });
52
-
53
- jest.mock('../scene/Scene.ts', () => {
54
- return {
55
- DIVEScene: jest.fn(function () {
56
- this.add = jest.fn();
57
- this.isObject3D = true;
58
- this.parent = null;
59
- this.dispatchEvent = jest.fn();
60
- this.position = {
61
- set: jest.fn(),
62
- };
63
- this.SetIntensity = jest.fn();
64
- this.SetEnabled = jest.fn();
65
- this.SetColor = jest.fn();
66
- this.userData = {
67
- id: undefined,
68
- };
69
- this.removeFromParent = jest.fn();
70
- return this;
71
- }),
72
- };
73
- });
74
-
75
- jest.mock('../camera/PerspectiveCamera.ts', () => {
76
- return jest.fn(function () {
77
- this.isObject3D = true;
78
- this.parent = null;
79
- this.dispatchEvent = jest.fn();
80
- this.position = {
81
- set: jest.fn(),
82
- };
83
- this.SetIntensity = jest.fn();
84
- this.SetEnabled = jest.fn();
85
- this.SetColor = jest.fn();
86
- this.userData = {
87
- id: undefined,
88
- };
89
- this.removeFromParent = jest.fn();
90
- this.OnResize = jest.fn();
91
- return this;
92
- });
93
- });
94
-
95
- jest.mock('../controls/OrbitControls.ts', () => {
96
- return jest.fn(function () {
97
- this.isObject3D = true;
98
- this.parent = null;
99
- this.dispatchEvent = jest.fn();
100
- this.position = {
101
- set: jest.fn(),
102
- };
103
- this.SetIntensity = jest.fn();
104
- this.SetEnabled = jest.fn();
105
- this.SetColor = jest.fn();
106
- this.userData = {
107
- id: undefined,
108
- };
109
- this.removeFromParent = jest.fn();
110
- this.Dispose = jest.fn();
111
- return this;
112
- });
113
- });
114
-
115
- jest.mock('../toolbox/Toolbox.ts', () => {
116
- return jest.fn(function () {
117
- this.isObject3D = true;
118
- this.parent = null;
119
- this.dispatchEvent = jest.fn();
120
- this.position = {
121
- set: jest.fn(),
122
- };
123
- this.SetIntensity = jest.fn();
124
- this.SetEnabled = jest.fn();
125
- this.SetColor = jest.fn();
126
- this.userData = {
127
- id: undefined,
128
- };
129
- this.Dispose = jest.fn();
130
- this.removeFromParent = jest.fn();
131
- return this;
132
- });
133
- });
134
-
135
- jest.mock('../axiscamera/AxisCamera.ts', () => {
136
- return jest.fn(function () {
137
- this.isObject3D = true;
138
- this.parent = null;
139
- this.dispatchEvent = jest.fn();
140
- this.position = {
141
- set: jest.fn(),
142
- };
143
- this.SetIntensity = jest.fn();
144
- this.SetEnabled = jest.fn();
145
- this.SetColor = jest.fn();
146
- this.userData = {
147
- id: undefined,
148
- };
149
- this.removeFromParent = jest.fn();
150
- this.SetFromCameraMatrix = jest.fn();
151
- this.Dispose = jest.fn();
152
- return this;
153
- });
154
- });
155
-
156
- console.log = jest.fn();
157
-
158
- describe('dive/DIVE', () => {
159
- it('should QuickView', () => {
160
- const dive = DIVE.QuickView('test_uri');
161
- expect(dive).toBeDefined();
162
- });
163
-
164
- it('should instantiate', () => {
165
- const dive = new DIVE();
166
- expect(dive).toBeDefined();
167
- expect((window as any).DIVE.PrintScene).toBeDefined();
168
- expect(() => (window as any).DIVE.PrintScene()).not.toThrow();
169
- });
170
-
171
- it('should instantiate in development DIVE_NODE_ENV', () => {
172
- process.env.DIVE_NODE_ENV = 'development';
173
- const dive = new DIVE();
174
- expect(dive).toBeDefined();
175
- expect((window as any).DIVE.PrintScene).toBeDefined();
176
- expect(() => (window as any).DIVE.PrintScene()).not.toThrow();
177
- });
178
-
179
- it('should dispose', () => {
180
- let dive = new DIVE();
181
- expect(() => dive.Dispose()).not.toThrow();
182
-
183
- const settings = {
184
- displayAxes: true,
185
- };
186
- dive = new DIVE(settings);
187
- expect(() => dive.Dispose()).not.toThrow();
188
- });
189
-
190
- it('should instantiate with settings', () => {
191
- const settings = {
192
- autoResize: false,
193
- displayAxes: true,
194
- renderer: {
195
- antialias: false,
196
- alpha: false,
197
- stencil: false,
198
- shadowMapEnabled: false,
199
- shadowMapType: 0,
200
- toneMapping: 0,
201
- },
202
- perspectiveCamera: {
203
- fov: 0,
204
- near: 0,
205
- far: 0,
206
- },
207
- orbitControls: {
208
- enableDamping: false,
209
- dampingFactor: 0,
210
- },
211
- } as DIVESettings;
212
- const dive = new DIVE(settings);
213
- expect(dive).toBeDefined();
214
- });
215
-
216
- it('should have Canvas', () => {
217
- const dive = new DIVE();
218
- expect(dive.Canvas).toBeDefined();
219
- });
220
-
221
- it('should have Communication', () => {
222
- const dive = new DIVE();
223
- expect(dive.Communication).toBeDefined();
224
- });
225
-
226
- it('should have Info', () => {
227
- const dive = new DIVE();
228
- expect(dive.Info).toBeDefined();
229
- });
230
-
231
- it('should resize', () => {
232
- const dive = new DIVE();
233
- expect(() => dive.OnResize(800, 600)).not.toThrow();
234
- });
235
-
236
- it('should update settings', () => {
237
- const dive = new DIVE();
238
- dive.Settings = {
239
- autoResize: false,
240
- displayAxes: true,
241
- renderer: {
242
- antialias: false,
243
- alpha: false,
244
- stencil: false,
245
- shadowMapEnabled: false,
246
- shadowMapType: 0,
247
- toneMapping: 0,
248
- },
249
- perspectiveCamera: {
250
- fov: 0,
251
- near: 0,
252
- far: 0,
253
- },
254
- orbitControls: {
255
- enableDamping: false,
256
- dampingFactor: 0,
257
- },
258
- };
259
-
260
- dive.Settings = {
261
- autoResize: true,
262
- };
263
-
264
- Object.assign(dive.Canvas, { parentElement: null });
265
-
266
- dive.Settings = {
267
- autoResize: false,
268
- };
269
-
270
- dive.Settings = {
271
- autoResize: true,
272
- };
273
- });
274
- });
@@ -1,34 +0,0 @@
1
- import { Tween, update as updateTween } from '@tweenjs/tween.js';
2
- import { DIVERenderer } from '../renderer/Renderer';
3
-
4
- /**
5
- * Updates all animations.
6
- * DIVE uses Tween.js to handle animations.
7
- *
8
- * @module
9
- */
10
-
11
- export class DIVEAnimationSystem {
12
- private _renderer: DIVERenderer;
13
- private _rendererCallbackId: string;
14
-
15
- constructor(renderer: DIVERenderer) {
16
- this._renderer = renderer;
17
-
18
- this._rendererCallbackId = this._renderer.AddPreRenderCallback(() => {
19
- this.Update();
20
- });
21
- }
22
-
23
- public Dispose(): void {
24
- this._renderer.RemovePreRenderCallback(this._rendererCallbackId);
25
- }
26
-
27
- public Update(): void {
28
- updateTween();
29
- }
30
-
31
- public Animate<T extends object>(object: T): Tween<T> {
32
- return new Tween<T>(object);
33
- }
34
- }
@@ -1,40 +0,0 @@
1
- import { DIVERenderer } from '../../renderer/Renderer';
2
- import { DIVEAnimationSystem } from '../AnimationSystem';
3
-
4
- const mockRenderer = {
5
- render: jest.fn(),
6
- OnResize: jest.fn(),
7
- getViewport: jest.fn(),
8
- setViewport: jest.fn(),
9
- AddPreRenderCallback: jest.fn((callback) => {
10
- callback();
11
- }),
12
- AddPostRenderCallback: jest.fn((callback) => {
13
- callback();
14
- }),
15
- RemovePreRenderCallback: jest.fn(),
16
- RemovePostRenderCallback: jest.fn(),
17
- } as unknown as DIVERenderer;
18
-
19
- describe('dive/animation/DIVEAnimationSystem', () => {
20
- it('should instantiate', () => {
21
- const anim = new DIVEAnimationSystem(mockRenderer);
22
- expect(anim).toBeDefined();
23
- });
24
-
25
- it('should Animate', () => {
26
- const anim = new DIVEAnimationSystem(mockRenderer);
27
- const tween = anim.Animate({});
28
- expect(tween).toBeDefined();
29
- });
30
-
31
- it('should update', () => {
32
- const anim = new DIVEAnimationSystem(mockRenderer);
33
- expect(() => anim.Update()).not.toThrow();
34
- });
35
-
36
- it('should dispose', () => {
37
- const anim = new DIVEAnimationSystem(mockRenderer);
38
- expect(() => anim.Dispose()).not.toThrow();
39
- });
40
- });
package/src/ar/AR.ts DELETED
@@ -1,98 +0,0 @@
1
- import { DIVEInfo, WebXRUnsupportedReason } from '../info/Info';
2
- import { DIVEARQuickLook } from './arquicklook/ARQuickLook';
3
- import { DIVEWebXR } from './webxr/WebXR';
4
- import { type DIVEScene } from '../scene/Scene';
5
- import { type DIVERenderer } from '../renderer/Renderer';
6
- import DIVEOrbitControls from '../controls/OrbitControls';
7
- import { DIVESceneViewer } from './sceneviewer/SceneViewer';
8
-
9
- export type DIVEAROptions = {
10
- arPlacement: 'horizontal' | 'vertical';
11
- arScale: 'auto' | 'fixed';
12
- /**
13
- * experimental, currently deactivated
14
- */
15
- useWebXR: false;
16
- };
17
-
18
- export class DIVEAR {
19
- private _renderer: DIVERenderer;
20
- private _scene: DIVEScene;
21
- private _controller: DIVEOrbitControls;
22
-
23
- constructor(
24
- renderer: DIVERenderer,
25
- scene: DIVEScene,
26
- controller: DIVEOrbitControls,
27
- ) {
28
- this._renderer = renderer;
29
- this._scene = scene;
30
- this._controller = controller;
31
- }
32
-
33
- public async Launch(options?: DIVEAROptions): Promise<void> {
34
- const system = DIVEInfo.GetSystem();
35
-
36
- if (system === 'iOS') {
37
- return this.tryARQuickLook();
38
- }
39
-
40
- if (system === 'Android') {
41
- if (options?.useWebXR) {
42
- console.warn('DIVE: WebXR is experimental on Android.');
43
- return this.tryWebXR();
44
- }
45
-
46
- return this.trySceneViewer();
47
- }
48
-
49
- console.log(
50
- 'DIVE: AR not supported. Not a mobile system. (System is ' +
51
- system +
52
- ')',
53
- );
54
- }
55
-
56
- private async tryARQuickLook(options?: DIVEAROptions): Promise<void> {
57
- const support = DIVEInfo.GetSupportsARQuickLook();
58
- if (!support) {
59
- console.log('ARQuickLook not supported');
60
- return Promise.reject();
61
- }
62
-
63
- console.log('DIVE: Launching AR with ARQuickLook ...');
64
-
65
- // Launch ARQuickLook
66
- await DIVEARQuickLook.Launch(this._scene, options);
67
- return Promise.resolve();
68
- }
69
-
70
- private async tryWebXR(): Promise<void> {
71
- const support = await DIVEInfo.GetSupportsWebXR();
72
- if (!support) {
73
- console.log(
74
- 'WebXR not supported. Reason: ' +
75
- WebXRUnsupportedReason[
76
- DIVEInfo.GetWebXRUnsupportedReason()!
77
- ],
78
- );
79
- return Promise.reject();
80
- }
81
-
82
- console.log('DIVE: Launching AR with WebXR ...');
83
- // Launch WebXR
84
- await DIVEWebXR.Launch(this._renderer, this._scene, this._controller);
85
- return Promise.resolve();
86
- }
87
-
88
- private async trySceneViewer(options?: DIVEAROptions): Promise<void> {
89
- // actually we don't have to try here, because SceneViewer is supported on all devices by now.
90
- // if there are no AR services (ARCore) installed on the device, SceneViewer will only show the model in 3D.
91
- // we also have no options to detect if SceneViewer is supported.
92
-
93
- console.log('DIVE: Launching AR with SceneViewer ...');
94
-
95
- DIVESceneViewer.Launch(this._scene, options);
96
- return Promise.resolve();
97
- }
98
- }
@@ -1,187 +0,0 @@
1
- import { DIVEAR, type DIVEAROptions } from '../AR';
2
- import { DIVEInfo } from '../../info/Info';
3
- import { DIVERenderer } from '../../renderer/Renderer';
4
- import { DIVEScene } from '../../scene/Scene';
5
- import DIVEOrbitControls from '../../controls/OrbitControls';
6
- import { DIVEARQuickLook } from '../arquicklook/ARQuickLook';
7
- import { DIVESceneViewer } from '../sceneviewer/SceneViewer';
8
- import { DIVEWebXR } from '../webxr/WebXR';
9
-
10
- jest.mock('../arquicklook/ARQuickLook', () => ({
11
- DIVEARQuickLook: {
12
- Launch: jest.fn(),
13
- },
14
- }));
15
-
16
- jest.mock('../webxr/WebXR', () => ({
17
- DIVEWebXR: {
18
- Launch: jest.fn(),
19
- },
20
- }));
21
-
22
- jest.mock('../sceneviewer/SceneViewer', () => ({
23
- DIVESceneViewer: {
24
- Launch: jest.fn(),
25
- },
26
- }));
27
-
28
- describe('DIVEAR', () => {
29
- let renderer: DIVERenderer;
30
- let scene: DIVEScene;
31
- let controller: DIVEOrbitControls;
32
- let diveAR: DIVEAR;
33
-
34
- beforeEach(() => {
35
- renderer = {} as DIVERenderer;
36
- scene = {} as DIVEScene;
37
- controller = {} as DIVEOrbitControls;
38
- diveAR = new DIVEAR(renderer, scene, controller);
39
- });
40
-
41
- describe('Launch', () => {
42
- describe('AR Quick Look', () => {
43
- it('should launch ARQuickLook on iOS', async () => {
44
- jest.spyOn(DIVEInfo, 'GetSystem').mockReturnValue('iOS');
45
- jest.spyOn(DIVEInfo, 'GetSupportsARQuickLook').mockReturnValue(
46
- true,
47
- );
48
- const arQuickLookLaunchSpy = jest.spyOn(
49
- DIVEARQuickLook,
50
- 'Launch',
51
- );
52
-
53
- const consoleLogSpy = jest
54
- .spyOn(console, 'log')
55
- .mockImplementation();
56
-
57
- await diveAR.Launch();
58
-
59
- expect(arQuickLookLaunchSpy).toHaveBeenCalledWith(
60
- scene,
61
- undefined,
62
- );
63
- arQuickLookLaunchSpy.mockRestore();
64
-
65
- expect(consoleLogSpy).toHaveBeenCalled();
66
- consoleLogSpy.mockRestore();
67
- });
68
-
69
- it('should not launch ARQuickLook on iOS if not supported', async () => {
70
- jest.spyOn(DIVEInfo, 'GetSystem').mockReturnValue('iOS');
71
- jest.spyOn(DIVEInfo, 'GetSupportsARQuickLook').mockReturnValue(
72
- false,
73
- );
74
- const arQuickLookLaunchSpy = jest.spyOn(
75
- DIVEARQuickLook,
76
- 'Launch',
77
- );
78
-
79
- const consoleLogSpy = jest
80
- .spyOn(console, 'log')
81
- .mockImplementation();
82
-
83
- await diveAR.Launch().catch(() => {});
84
-
85
- expect(arQuickLookLaunchSpy).not.toHaveBeenCalled();
86
- arQuickLookLaunchSpy.mockRestore();
87
-
88
- expect(consoleLogSpy).toHaveBeenCalled();
89
- consoleLogSpy.mockRestore();
90
- });
91
- });
92
-
93
- describe('Scene Viewer', () => {
94
- it('should launch SceneViewer on Android', async () => {
95
- jest.spyOn(DIVEInfo, 'GetSystem').mockReturnValue('Android');
96
-
97
- const consoleLogSpy = jest
98
- .spyOn(console, 'log')
99
- .mockImplementation();
100
-
101
- await diveAR.Launch();
102
-
103
- expect(DIVESceneViewer.Launch).toHaveBeenCalledWith(
104
- scene,
105
- undefined,
106
- );
107
-
108
- expect(consoleLogSpy).toHaveBeenCalled();
109
- consoleLogSpy.mockRestore();
110
- });
111
- });
112
-
113
- describe('WebXR', () => {
114
- it('should launch WebXR on Android with useWebXR option', async () => {
115
- jest.spyOn(DIVEInfo, 'GetSystem').mockReturnValue('Android');
116
- jest.spyOn(DIVEInfo, 'GetSupportsWebXR').mockResolvedValue(
117
- true,
118
- );
119
-
120
- const consoleLogSpy = jest
121
- .spyOn(console, 'log')
122
- .mockImplementation();
123
- const consoleWarnSpy = jest
124
- .spyOn(console, 'warn')
125
- .mockImplementation();
126
-
127
- await diveAR.Launch({
128
- useWebXR: true,
129
- } as unknown as DIVEAROptions);
130
-
131
- expect(DIVEWebXR.Launch).toHaveBeenCalledWith(
132
- renderer,
133
- scene,
134
- controller,
135
- );
136
- expect(consoleWarnSpy).toHaveBeenCalled();
137
- consoleWarnSpy.mockRestore();
138
-
139
- expect(consoleLogSpy).toHaveBeenCalled();
140
- consoleLogSpy.mockRestore();
141
- });
142
-
143
- it('should not launch WebXR on Android with useWebXR option', async () => {
144
- jest.spyOn(DIVEInfo, 'GetSystem').mockReturnValue('Android');
145
- jest.spyOn(DIVEInfo, 'GetSupportsWebXR').mockResolvedValue(
146
- false,
147
- );
148
-
149
- const consoleLogSpy = jest
150
- .spyOn(console, 'log')
151
- .mockImplementation();
152
- const consoleWarnSpy = jest
153
- .spyOn(console, 'warn')
154
- .mockImplementation();
155
-
156
- await diveAR
157
- .Launch({
158
- useWebXR: true,
159
- } as unknown as DIVEAROptions)
160
- .catch(() => {});
161
-
162
- expect(DIVEWebXR.Launch).toHaveBeenCalledWith(
163
- renderer,
164
- scene,
165
- controller,
166
- );
167
- expect(consoleWarnSpy).toHaveBeenCalled();
168
- consoleWarnSpy.mockRestore();
169
-
170
- expect(consoleLogSpy).toHaveBeenCalled();
171
- consoleLogSpy.mockRestore();
172
- });
173
- });
174
-
175
- it('should log AR not supported on non-mobile systems', async () => {
176
- const consoleLogSpy = jest
177
- .spyOn(console, 'log')
178
- .mockImplementation();
179
-
180
- jest.spyOn(DIVEInfo, 'GetSystem').mockReturnValue('Windows');
181
-
182
- await diveAR.Launch();
183
-
184
- expect(consoleLogSpy).toHaveBeenCalled();
185
- });
186
- });
187
- });