@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,19 +0,0 @@
1
- import { Object3D } from 'three';
2
- import { implementsInterface } from '../implementsInterface.ts';
3
-
4
- describe('dive/helper/implementsInterface', () => {
5
- it('should not find interface', () => {
6
- expect(implementsInterface(undefined, 'isInterface')).toBe(false);
7
-
8
- expect(implementsInterface(null, 'isInterface')).toBe(false);
9
-
10
- const obj = {} as unknown as Object3D;
11
-
12
- expect(implementsInterface(obj, 'isInterface')).toBe(false);
13
- });
14
-
15
- it('should find interface', () => {
16
- const obj = { isInterface: true } as unknown as Object3D;
17
- expect(implementsInterface(obj, 'isInterface')).toBe(true);
18
- });
19
- });
@@ -1,9 +0,0 @@
1
- import { type Object3D } from 'three';
2
-
3
- export function implementsInterface<T>(
4
- object: Object3D | null | undefined,
5
- discriminator: string,
6
- ): object is Object3D & T {
7
- if (!object) return false;
8
- return discriminator in object;
9
- }
package/src/info/Info.ts DELETED
@@ -1,154 +0,0 @@
1
- export enum WebXRUnsupportedReason {
2
- 'UNKNWON_ERROR' = 0,
3
- 'NO_HTTPS' = 1,
4
- 'IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE' = 2,
5
- 'AR_SESSION_NOT_ALLOWED' = 3,
6
- }
7
-
8
- export class DIVEInfo {
9
- private static _supportsWebXR: boolean | null = null;
10
- private static _webXRUnsupportedReason: WebXRUnsupportedReason | null =
11
- null;
12
-
13
- /**
14
- *
15
- * @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
16
- */
17
- public static GetSystem(): string {
18
- const platform = navigator.platform;
19
- if (/Android/.test(navigator.userAgent)) {
20
- return 'Android';
21
- } else if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
22
- return 'iOS';
23
- } else if (platform.startsWith('Win')) {
24
- return 'Windows';
25
- } else if (platform.startsWith('Mac')) {
26
- return 'MacOS';
27
- } else if (platform.startsWith('Linux')) {
28
- return 'Linux';
29
- } else {
30
- return 'Unknown';
31
- }
32
- }
33
-
34
- /**
35
- * @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
36
- */
37
- public static async GetSupportsWebXR(): Promise<boolean> {
38
- if (this._supportsWebXR !== null) {
39
- return this._supportsWebXR;
40
- }
41
-
42
- // check if XRSystem is available && if https enabled
43
- if (!navigator.xr) {
44
- this._supportsWebXR = false;
45
-
46
- if (window.isSecureContext === false) {
47
- this._webXRUnsupportedReason = WebXRUnsupportedReason.NO_HTTPS;
48
- } else {
49
- this._webXRUnsupportedReason =
50
- WebXRUnsupportedReason.UNKNWON_ERROR;
51
- }
52
-
53
- return this._supportsWebXR;
54
- }
55
-
56
- // Check if immersive-vr session mode is supported
57
- try {
58
- const supported =
59
- await navigator.xr!.isSessionSupported('immersive-ar');
60
- if (!supported) {
61
- this._webXRUnsupportedReason =
62
- WebXRUnsupportedReason.IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE;
63
- }
64
- this._supportsWebXR = supported;
65
- } catch (error) {
66
- this._supportsWebXR = false;
67
- this._webXRUnsupportedReason =
68
- WebXRUnsupportedReason.AR_SESSION_NOT_ALLOWED;
69
- }
70
- return this._supportsWebXR;
71
- }
72
-
73
- /**
74
- * @returns The reason why WebXR is not supported on the user's device. Returns null if WebXR is supported nor not has been checked yet.
75
- */
76
- public static GetWebXRUnsupportedReason(): WebXRUnsupportedReason | null {
77
- if (this._supportsWebXR === null) {
78
- console.log('WebXR support has not been checked yet.');
79
- return null;
80
- }
81
- return this._webXRUnsupportedReason;
82
- }
83
-
84
- /**
85
- * @returns A boolean indicating whether the user's device supports AR Quick Look.
86
- */
87
- public static GetSupportsARQuickLook(): boolean {
88
- const a = document.createElement('a');
89
- if (a.relList.supports('ar')) {
90
- return true;
91
- }
92
-
93
- // fallback check
94
- const userAgent = navigator.userAgent;
95
-
96
- // Check if the device is running iOS
97
- const isIOS =
98
- /iPad|iPhone|iPod/.test(userAgent) &&
99
- !(window as unknown as Window & { MSStream?: string }).MSStream;
100
- if (!isIOS) {
101
- return false;
102
- }
103
-
104
- // Extract iOS version
105
- const match = userAgent.match(/OS (\d+)_/);
106
- if (!match || match.length < 2) {
107
- return false;
108
- }
109
- const iOSVersion = parseInt(match[1], 10);
110
-
111
- // Minimum iOS version for QuickLook support
112
- const minQuickLookVersion = 12;
113
-
114
- // Check if the iOS version is supported
115
- if (iOSVersion < minQuickLookVersion) {
116
- return false;
117
- }
118
-
119
- // Check for supported browser
120
- const isSupportedBrowser =
121
- /^((?!chrome|android).)*safari|CriOS|FxiOS/i.test(userAgent);
122
- if (isSupportedBrowser) {
123
- return true;
124
- }
125
-
126
- // Default to false if none of the conditions are met
127
- return false;
128
- }
129
-
130
- /**
131
- * @returns A boolean indicating whether the user's device is a mobile device.
132
- */
133
- public static get isMobile(): boolean {
134
- return this.GetSystem() === 'Android' || this.GetSystem() === 'iOS';
135
- }
136
-
137
- /**
138
- * @returns A boolean indicating whether the user's device is a desktop device.
139
- */
140
- public static get isDesktop(): boolean {
141
- return !this.isMobile;
142
- }
143
-
144
- /**
145
- * @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
146
- */
147
- public static async GetIsARCapable(): Promise<boolean> {
148
- if (this.GetSupportsARQuickLook()) {
149
- return true;
150
- }
151
-
152
- return await this.GetSupportsWebXR();
153
- }
154
- }
@@ -1,338 +0,0 @@
1
- import { DIVEInfo, WebXRUnsupportedReason } from '../Info';
2
-
3
- const mockNavigator = (navigator: any) => {
4
- Object.defineProperty(global, 'navigator', {
5
- value: navigator,
6
- writable: true,
7
- });
8
- };
9
-
10
- describe('dive/info/DIVEInfo', () => {
11
- beforeEach(() => {
12
- DIVEInfo['_supportsWebXR'] = null;
13
- jest.clearAllMocks();
14
- });
15
-
16
- it('should get system: Windows', () => {
17
- mockNavigator({
18
- platform: 'Win64',
19
- });
20
- expect(DIVEInfo.GetSystem()).toBe('Windows');
21
- });
22
-
23
- it('should get system: MacOS', () => {
24
- mockNavigator({
25
- platform: 'MacIntel',
26
- });
27
- expect(DIVEInfo.GetSystem()).toBe('MacOS');
28
- });
29
-
30
- it('should get system: Linux', () => {
31
- mockNavigator({
32
- platform: 'Linux',
33
- });
34
- expect(DIVEInfo.GetSystem()).toBe('Linux');
35
- });
36
-
37
- it('should get system: Android', () => {
38
- mockNavigator({
39
- userAgent:
40
- 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
41
- platform: 'Linux',
42
- });
43
- expect(DIVEInfo.GetSystem()).toBe('Android');
44
- });
45
-
46
- it('should get system: iOS', () => {
47
- mockNavigator({
48
- userAgent:
49
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0_1 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
50
- platform: 'iPhone',
51
- });
52
- expect(DIVEInfo.GetSystem()).toBe('iOS');
53
- });
54
-
55
- it('should get system: Unknown', () => {
56
- mockNavigator({
57
- platform: 'Unknown',
58
- });
59
- expect(DIVEInfo.GetSystem()).toBe('Unknown');
60
- });
61
-
62
- it('should support webXR', async () => {
63
- mockNavigator({
64
- xr: {
65
- isSessionSupported: jest.fn().mockResolvedValue(true),
66
- },
67
- });
68
- const supports = await DIVEInfo.GetSupportsWebXR();
69
- expect(supports).toBe(true);
70
- });
71
-
72
- it('should not support webXR (xr undefined)', async () => {
73
- mockNavigator({
74
- xr: undefined,
75
- });
76
- const supports = await DIVEInfo.GetSupportsWebXR();
77
- expect(supports).toBe(false);
78
-
79
- const reason = DIVEInfo.GetWebXRUnsupportedReason();
80
- expect(reason).toBe(WebXRUnsupportedReason.UNKNWON_ERROR);
81
- });
82
-
83
- it('should not support webXR (xr undefined & isSecureContext false)', async () => {
84
- window.isSecureContext = false;
85
- mockNavigator({
86
- xr: undefined,
87
- });
88
- const supports = await DIVEInfo.GetSupportsWebXR();
89
- expect(supports).toBe(false);
90
-
91
- const reason = DIVEInfo.GetWebXRUnsupportedReason();
92
- expect(reason).toBe(WebXRUnsupportedReason.NO_HTTPS);
93
- });
94
-
95
- it('should get empty reason (not checked)', async () => {
96
- mockNavigator({
97
- xr: {
98
- isSessionSupported: jest.fn().mockResolvedValue(true),
99
- },
100
- });
101
- console.log = jest.fn();
102
- const reason = DIVEInfo.GetWebXRUnsupportedReason();
103
- expect(reason).toBe(null);
104
- });
105
-
106
- it('should get empty reason (webXR supported)', async () => {
107
- mockNavigator({
108
- xr: {
109
- isSessionSupported: jest.fn().mockResolvedValue(true),
110
- },
111
- });
112
- const reason = DIVEInfo.GetWebXRUnsupportedReason();
113
- expect(reason).toBe(null);
114
- });
115
-
116
- it('should not support webXR', async () => {
117
- mockNavigator({
118
- xr: {
119
- isSessionSupported: jest.fn().mockResolvedValue(false),
120
- },
121
- });
122
- const supports = await DIVEInfo.GetSupportsWebXR();
123
- expect(supports).toBe(false);
124
-
125
- const reason = DIVEInfo.GetWebXRUnsupportedReason();
126
- expect(reason).toBe(
127
- WebXRUnsupportedReason.IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE,
128
- );
129
- });
130
-
131
- it('should not support webXR on error', async () => {
132
- mockNavigator({
133
- xr: {
134
- isSessionSupported: jest.fn().mockRejectedValue('error'),
135
- },
136
- });
137
- const supports = await DIVEInfo.GetSupportsWebXR();
138
- expect(supports).toBe(false);
139
-
140
- const reason = DIVEInfo.GetWebXRUnsupportedReason();
141
- expect(reason).toBe(WebXRUnsupportedReason.AR_SESSION_NOT_ALLOWED);
142
- });
143
-
144
- it('should return cached value', async () => {
145
- DIVEInfo['_supportsWebXR'] = true;
146
- mockNavigator({
147
- xr: {
148
- isSessionSupported: jest.fn().mockRejectedValue('error'),
149
- },
150
- });
151
- const supports = await DIVEInfo.GetSupportsWebXR();
152
- expect(supports).toBe(true);
153
- });
154
-
155
- it('should return cached value (false)', async () => {
156
- DIVEInfo['_supportsWebXR'] = false;
157
- mockNavigator({
158
- xr: {
159
- isSessionSupported: jest.fn().mockRejectedValue('error'),
160
- },
161
- });
162
- const supports = await DIVEInfo.GetSupportsWebXR();
163
- expect(supports).toBe(false);
164
- });
165
-
166
- it('should support ARQuickLook with feature detection', () => {
167
- mockNavigator({
168
- userAgent:
169
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Mobile/15E148 Safari/604.',
170
- });
171
- jest.spyOn(document, 'createElement').mockReturnValue({
172
- relList: { supports: () => true },
173
- } as unknown as HTMLAnchorElement);
174
- const supports = DIVEInfo.GetSupportsARQuickLook();
175
- expect(supports).toBe(true);
176
- });
177
-
178
- it('should support ARQuickLook (iPhone, iOS 15, Safari)', () => {
179
- mockNavigator({
180
- userAgent:
181
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Mobile/15E148 Safari/604.',
182
- });
183
- jest.spyOn(document, 'createElement').mockReturnValue({
184
- relList: { supports: () => false },
185
- } as unknown as HTMLAnchorElement);
186
- const supports = DIVEInfo.GetSupportsARQuickLook();
187
- expect(supports).toBe(true);
188
- });
189
-
190
- it('should support ARQuickLook (iPhone, iOS 17, Google)', () => {
191
- mockNavigator({
192
- userAgent:
193
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/277.0.555192628 Mobile/15E148 Safari/604.',
194
- });
195
- jest.spyOn(document, 'createElement').mockReturnValue({
196
- relList: { supports: () => false },
197
- } as unknown as HTMLAnchorElement);
198
- const supports = DIVEInfo.GetSupportsARQuickLook();
199
- expect(supports).toBe(true);
200
- });
201
-
202
- it('should support ARQuickLook (iPhone, iOS 17, Chrome)', () => {
203
- mockNavigator({
204
- userAgent:
205
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/126.0.6478.153 Mobile/15E148 Safari/604.',
206
- });
207
- jest.spyOn(document, 'createElement').mockReturnValue({
208
- relList: { supports: () => false },
209
- } as unknown as HTMLAnchorElement);
210
- const supports = DIVEInfo.GetSupportsARQuickLook();
211
- expect(supports).toBe(true);
212
- });
213
-
214
- it('should support ARQuickLook (iPhone, iOS 17, Chrome)', () => {
215
- mockNavigator({
216
- userAgent:
217
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X) AppleWebKit/605.1.11 (KHTML, like Gecko) Version/11.1 Mobile/11E148 CriOS/604.',
218
- });
219
- jest.spyOn(document, 'createElement').mockReturnValue({
220
- relList: { supports: () => false },
221
- } as unknown as HTMLAnchorElement);
222
- const supports = DIVEInfo.GetSupportsARQuickLook();
223
- expect(supports).toBe(true);
224
- });
225
-
226
- it('should support ARQuickLook (iPhone, iOS 17, Firefox)', () => {
227
- mockNavigator({
228
- userAgent:
229
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X) AppleWebKit/605.1.11 (KHTML, like Gecko) Version/11.1 Mobile/11E148 FxiOS/604.',
230
- });
231
- jest.spyOn(document, 'createElement').mockReturnValue({
232
- relList: { supports: () => false },
233
- } as unknown as HTMLAnchorElement);
234
- const supports = DIVEInfo.GetSupportsARQuickLook();
235
- expect(supports).toBe(true);
236
- });
237
-
238
- it('should not support ARQuickLook (Android)', () => {
239
- mockNavigator({
240
- userAgent:
241
- 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.3',
242
- });
243
- jest.spyOn(document, 'createElement').mockReturnValue({
244
- relList: { supports: () => false },
245
- } as unknown as HTMLAnchorElement);
246
- const supports = DIVEInfo.GetSupportsARQuickLook();
247
- expect(supports).toBe(false);
248
- });
249
-
250
- it('should not support ARQuickLook (iPhone, no iOS version)', () => {
251
- mockNavigator({
252
- userAgent:
253
- 'Mozilla/5.0 (iPhone; CPU iPhone OS like Mac OS X) AppleWebKit/605.1.11 (KHTML, like Gecko) Version/11.1 Mobile/11E148 Safari/604.',
254
- });
255
- jest.spyOn(document, 'createElement').mockReturnValue({
256
- relList: { supports: () => false },
257
- } as unknown as HTMLAnchorElement);
258
- const supports = DIVEInfo.GetSupportsARQuickLook();
259
- expect(supports).toBe(false);
260
- });
261
-
262
- it('should not support ARQuickLook (iPhone, iOS 17, no browser)', () => {
263
- mockNavigator({
264
- userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X)',
265
- });
266
- jest.spyOn(document, 'createElement').mockReturnValue({
267
- relList: { supports: () => false },
268
- } as unknown as HTMLAnchorElement);
269
- const supports = DIVEInfo.GetSupportsARQuickLook();
270
- expect(supports).toBe(false);
271
- });
272
-
273
- it('should not support ARQuickLook (iPhone, iOS <12, Safari)', () => {
274
- mockNavigator({
275
- userAgent:
276
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_1 like Mac OS X) AppleWebKit/605.1.11 (KHTML, like Gecko) Version/11.1 Mobile/11E148 Safari/604.',
277
- });
278
- jest.spyOn(document, 'createElement').mockReturnValue({
279
- relList: { supports: () => false },
280
- } as unknown as HTMLAnchorElement);
281
- const supports = DIVEInfo.GetSupportsARQuickLook();
282
- expect(supports).toBe(false);
283
- });
284
-
285
- it('should be mobile (iOS)', () => {
286
- jest.spyOn(DIVEInfo, 'GetSystem').mockReturnValue('iOS');
287
- expect(DIVEInfo.isMobile).toBe(true);
288
- expect(DIVEInfo.isDesktop).toBe(false);
289
- });
290
-
291
- it('should be mobile (Android)', () => {
292
- jest.spyOn(DIVEInfo, 'GetSystem').mockReturnValue('Android');
293
- expect(DIVEInfo.isMobile).toBe(true);
294
- expect(DIVEInfo.isDesktop).toBe(false);
295
- });
296
-
297
- it('should be desktop (Windows)', () => {
298
- jest.spyOn(DIVEInfo, 'GetSystem').mockReturnValue('Windows');
299
- expect(DIVEInfo.isMobile).toBe(false);
300
- expect(DIVEInfo.isDesktop).toBe(true);
301
- });
302
-
303
- it('should be desktop (MacOS)', () => {
304
- jest.spyOn(DIVEInfo, 'GetSystem').mockReturnValue('MacOS');
305
- expect(DIVEInfo.isMobile).toBe(false);
306
- expect(DIVEInfo.isDesktop).toBe(true);
307
- });
308
-
309
- it('should be desktop (Linux)', () => {
310
- jest.spyOn(DIVEInfo, 'GetSystem').mockReturnValue('Linux');
311
- expect(DIVEInfo.isMobile).toBe(false);
312
- expect(DIVEInfo.isDesktop).toBe(true);
313
- });
314
-
315
- it('should be desktop (Unknown)', () => {
316
- jest.spyOn(DIVEInfo, 'GetSystem').mockReturnValue('Unknown');
317
- expect(DIVEInfo.isMobile).toBe(false);
318
- expect(DIVEInfo.isDesktop).toBe(true);
319
- });
320
-
321
- it('should be capable of AR (ARQuickLook)', async () => {
322
- jest.spyOn(DIVEInfo, 'GetSupportsARQuickLook').mockReturnValue(true);
323
- jest.spyOn(DIVEInfo, 'GetSupportsWebXR').mockResolvedValue(false);
324
- expect(await DIVEInfo.GetIsARCapable()).toBe(true);
325
- });
326
-
327
- it('should be capable of AR (WebXR)', async () => {
328
- jest.spyOn(DIVEInfo, 'GetSupportsARQuickLook').mockReturnValue(false);
329
- jest.spyOn(DIVEInfo, 'GetSupportsWebXR').mockResolvedValue(true);
330
- expect(await DIVEInfo.GetIsARCapable()).toBe(true);
331
- });
332
-
333
- it('should not be capable of AR', async () => {
334
- jest.spyOn(DIVEInfo, 'GetSupportsARQuickLook').mockReturnValue(false);
335
- jest.spyOn(DIVEInfo, 'GetSupportsWebXR').mockResolvedValue(false);
336
- expect(await DIVEInfo.GetIsARCapable()).toBe(false);
337
- });
338
- });
@@ -1,14 +0,0 @@
1
- /**
2
- * Interface for objects that can be hovered in the scene.
3
- *
4
- * @module
5
- */
6
-
7
- import { type DraggableEvent } from '../toolbox/BaseTool';
8
-
9
- export interface DIVEDraggable {
10
- isDraggable: true;
11
- onDragStart?: (e: DraggableEvent) => void;
12
- onDrag?: (e: DraggableEvent) => void;
13
- onDragEnd?: (e: DraggableEvent) => void;
14
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Interface for objects that can be hovered in the scene.
3
- *
4
- * @module
5
- */
6
-
7
- import { type Intersection } from 'three';
8
-
9
- export interface DIVEHoverable {
10
- isHoverable: true;
11
- onPointerEnter?: (i: Intersection) => void;
12
- onPointerOver?: (i: Intersection) => void;
13
- onPointerLeave?: () => void;
14
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Interface for objects that can be moved in the scene.
3
- *
4
- * @module
5
- */
6
-
7
- export interface DIVEMovable {
8
- isMovable: true;
9
- onMoveStart?: () => void;
10
- onMove?: () => void;
11
- onMoveEnd?: () => void;
12
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Interface for objects that can be rotated in the scene.
3
- *
4
- * @module
5
- */
6
-
7
- export interface DIVERotatable {
8
- isRotatable: true;
9
- onRotate?: () => void;
10
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Interface for objects that can be scaled in the scene.
3
- *
4
- * @module
5
- */
6
-
7
- export interface DIVEScalable {
8
- isScalable: true;
9
- onScale?: () => void;
10
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Interface for objects that can be selected in the scene.
3
- *
4
- * @module
5
- */
6
-
7
- export interface DIVESelectable {
8
- isSelectable: true;
9
- onSelect?: () => void;
10
- onDeselect?: () => void;
11
- }
package/src/io/IO.ts DELETED
@@ -1,62 +0,0 @@
1
- import { DIVEGLTFIO } from './gltf/GLTFIO';
2
-
3
- import { type DIVESceneFileType } from '../types';
4
- import { type DIVEScene } from '../scene/Scene';
5
-
6
- export class DIVEIO {
7
- private _scene: DIVEScene;
8
-
9
- private _gltfIO: DIVEGLTFIO;
10
-
11
- constructor(scene: DIVEScene) {
12
- this._scene = scene;
13
-
14
- this._gltfIO = new DIVEGLTFIO();
15
- }
16
-
17
- public Import<FileType extends keyof DIVESceneFileType>(
18
- type: FileType,
19
- url: string,
20
- ): Promise<DIVESceneFileType[FileType] | null> {
21
- switch (type) {
22
- case 'glb': {
23
- return this._gltfIO.Import(url).catch((error) => {
24
- console.error(error);
25
- return null;
26
- });
27
- }
28
-
29
- default: {
30
- console.error('DIVEIO.Import: Unsupported file type: ' + type);
31
- return Promise.reject();
32
- }
33
- }
34
- }
35
-
36
- public Export<FileType extends keyof DIVESceneFileType>(
37
- type: FileType,
38
- ): Promise<string | null> {
39
- switch (type) {
40
- case 'glb': {
41
- return this._gltfIO
42
- .Export(this._scene, true, true)
43
- .then((data) => {
44
- return this._createBlobURL(data);
45
- })
46
- .catch((error) => {
47
- console.error(error);
48
- return null;
49
- });
50
- }
51
-
52
- default: {
53
- console.error('DIVEIO.Export: Unsupported file type: ' + type);
54
- return Promise.reject();
55
- }
56
- }
57
- }
58
-
59
- private _createBlobURL(data: ArrayBuffer): string {
60
- return URL.createObjectURL(new Blob([data]));
61
- }
62
- }