@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,105 +0,0 @@
1
- /**
2
- * Find the difference between two objects.
3
- */
4
-
5
- export const getObjectDelta = <T extends object>(
6
- a: T,
7
- b: Partial<T>,
8
- ): Partial<T> => {
9
- // if a and b have no entries we have no delta
10
- if (Object.keys(a).length === 0 && Object.keys(b).length === 0) {
11
- return {};
12
- }
13
-
14
- // if a or b is not an object we have a delta
15
- if (typeof a !== 'object' || typeof b !== 'object') {
16
- return b;
17
- }
18
-
19
- let delta = {};
20
-
21
- Object.keys(b).forEach((key) => {
22
- // if key is not in a we have a delta
23
- if (!Object.keys(a).includes(key)) {
24
- delta = { ...delta, [key]: b[key as keyof object] };
25
- return;
26
- }
27
-
28
- // assumption: b[key] is an array
29
- if (Array.isArray(b[key as keyof object])) {
30
- // if a[key] is not an array we have a delta
31
- if (!Array.isArray(a[key as keyof object])) {
32
- delta = { ...delta, [key]: b[key as keyof object] };
33
- return;
34
- }
35
-
36
- // create arrays (for TS types to be correct)
37
- const aArray = a[key as keyof object] as [];
38
- const bArray = b[key as keyof object] as [];
39
-
40
- // if both arrays are empty we have no delta
41
- if (aArray.length === 0 && bArray.length === 0) {
42
- delta = { ...delta };
43
- return;
44
- }
45
-
46
- // if array length is different we have a delta
47
- if (aArray.length !== bArray.length) {
48
- delta = { ...delta, [key]: b[key as keyof object] };
49
- return;
50
- }
51
-
52
- // create array for deltas
53
- const arrayDeltas: [] = [];
54
-
55
- bArray.forEach((entry, index) => {
56
- // getObjectDelta in array
57
- const inArrayDelta = getObjectDelta(
58
- aArray[index],
59
- bArray[index],
60
- );
61
-
62
- // if inArrayDelta has more then 0 entries we have a delta
63
- if (Object.keys(inArrayDelta).length) {
64
- arrayDeltas.push(bArray[index]);
65
- }
66
- });
67
-
68
- // if arrayDeltas has more than 0 entries we have a delta
69
- if (Object.keys(arrayDeltas).length) {
70
- delta = { ...delta, [key]: arrayDeltas };
71
- return;
72
- }
73
-
74
- return;
75
- }
76
-
77
- // assumption: b[key] is an object
78
- if (typeof b[key as keyof object] === 'object') {
79
- // if a[key] is not an object we have a delta
80
- if (typeof a[key as keyof object] !== 'object') {
81
- delta = { ...delta, [key]: b[key as keyof object] };
82
- return;
83
- }
84
-
85
- // recursive: find objectDelta in a and b
86
- const objectDelta = getObjectDelta(
87
- a[key as keyof object],
88
- b[key as keyof object],
89
- );
90
-
91
- // if objectDelta has more than 0 entries we have a delta
92
- if (Object.keys(objectDelta).length) {
93
- delta = { ...delta, [key]: objectDelta };
94
- return;
95
- }
96
- }
97
-
98
- // if a[key] is not equal to b[key] we have a delta
99
- if (a[key as keyof object] !== b[key as keyof object]) {
100
- delta = { ...delta, [key]: b[key as keyof object] };
101
- }
102
- });
103
-
104
- return delta;
105
- };
@@ -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,178 +0,0 @@
1
- import { ESystem, EWebXRUnsupportedReason } from '../types/info';
2
-
3
- export class SystemInfo {
4
- private static _supportsWebXR: boolean = false;
5
- private static _webXRUnsupportedReason: EWebXRUnsupportedReason | null =
6
- null;
7
-
8
- /**
9
- * Gets the current system (iOS, Android, Windows, etc.)
10
- * @returns DIVESystem The current system
11
- */
12
- public static GetSystem(): ESystem {
13
- if (typeof window === 'undefined' || !window.navigator) {
14
- return ESystem.UNKNOWN;
15
- }
16
-
17
- const userAgent = window.navigator.userAgent.toLowerCase();
18
- if (userAgent.includes('iphone') || userAgent.includes('ipad')) {
19
- return ESystem.IOS;
20
- }
21
- if (userAgent.includes('android')) {
22
- return ESystem.ANDROID;
23
- }
24
- if (userAgent.includes('windows')) {
25
- return ESystem.WINDOWS;
26
- }
27
- if (userAgent.includes('macintosh')) {
28
- return ESystem.MACOS;
29
- }
30
- if (userAgent.includes('linux')) {
31
- return ESystem.LINUX;
32
- }
33
- return ESystem.UNKNOWN;
34
- }
35
-
36
- /**
37
- * @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
38
- */
39
- public static async GetSupportsWebXR(): Promise<boolean> {
40
- if (this._supportsWebXR !== false) {
41
- return this._supportsWebXR;
42
- }
43
-
44
- // Check if we're in a secure context (HTTPS)
45
- if (!window.isSecureContext) {
46
- this._supportsWebXR = false;
47
- this._webXRUnsupportedReason = EWebXRUnsupportedReason.NO_HTTPS;
48
- return this._supportsWebXR;
49
- }
50
-
51
- // Check if XRSystem is available
52
- if (!navigator.xr) {
53
- this._supportsWebXR = false;
54
- this._webXRUnsupportedReason = EWebXRUnsupportedReason.NO_WEBXR_API;
55
- return this._supportsWebXR;
56
- }
57
-
58
- try {
59
- // Check specifically for immersive-ar support
60
- const arSupported =
61
- await navigator.xr.isSessionSupported('immersive-ar');
62
- this._supportsWebXR = arSupported;
63
-
64
- if (!this._supportsWebXR) {
65
- this._webXRUnsupportedReason =
66
- EWebXRUnsupportedReason.IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE;
67
- }
68
- } catch (error) {
69
- this._supportsWebXR = false;
70
- this._webXRUnsupportedReason =
71
- EWebXRUnsupportedReason.AR_PERMISSION_DENIED;
72
- }
73
-
74
- return this._supportsWebXR;
75
- }
76
-
77
- /**
78
- * @returns The reason why WebXR is not supported on the user's device. Returns null if WebXR is supported.
79
- */
80
- public static GetWebXRUnsupportedReason(): EWebXRUnsupportedReason | null {
81
- if (this._supportsWebXR) {
82
- console.log('WebXR is supported.');
83
- return null;
84
- }
85
- return this._webXRUnsupportedReason;
86
- }
87
-
88
- /**
89
- * Checks if ARQuickLook is supported on the current device
90
- * This checks for:
91
- * 1. AR support via relList
92
- *
93
- * Requirements:
94
- * - iOS 13.0 or later
95
- * - Safari browser (ARQuickLook is only supported in Safari)
96
- * - Device with AR capabilities (iPhone/iPad with LiDAR scanner or ARKit support)
97
- *
98
- * Note: ARQuickLook is only available in Safari on iOS. Other browsers
99
- * (Chrome, Firefox, etc.) do not support ARQuickLook, even on iOS.
100
- *
101
- * @returns boolean indicating if ARQuickLook is supported
102
- */
103
- public static GetSupportsARQuickLook(): boolean {
104
- const a = document.createElement('a');
105
- return a.relList.supports('ar');
106
- }
107
-
108
- /**
109
- * Checks if SceneViewer is supported on the current device
110
- * This checks for:
111
- * 1. Android device
112
- * 2. Chrome browser (version 89 or later)
113
- *
114
- * Requirements:
115
- * - Android 7.0 (API level 24) or later
116
- * - Chrome for Android 89 or later
117
- *
118
- * Note: According to Google's documentation, if these requirements are met,
119
- * SceneViewer will be available. If ARCore is not installed, SceneViewer will
120
- * fall back to showing the model in 3D.
121
- *
122
- * @returns boolean indicating if SceneViewer is supported
123
- */
124
- public static GetSupportsSceneViewer(): boolean {
125
- // Check if we're in a browser environment
126
- if (typeof window === 'undefined' || !window.navigator) {
127
- return false;
128
- }
129
-
130
- const userAgent = window.navigator.userAgent.toLowerCase();
131
-
132
- // Check if we're on Android
133
- if (!userAgent.includes('android')) {
134
- return false;
135
- }
136
-
137
- // Check if we're using Chrome
138
- if (!userAgent.includes('chrome')) {
139
- return false;
140
- }
141
-
142
- // Check Chrome version (89 or later)
143
- const chromeVersion = userAgent.match(/chrome\/(\d+)/);
144
- if (!chromeVersion || parseInt(chromeVersion[1]) < 89) {
145
- return false;
146
- }
147
-
148
- return true;
149
- }
150
-
151
- /**
152
- * @returns A boolean indicating whether the user's device is a mobile device.
153
- */
154
- public static get isMobile(): boolean {
155
- return (
156
- this.GetSystem() === ESystem.ANDROID ||
157
- this.GetSystem() === ESystem.IOS
158
- );
159
- }
160
-
161
- /**
162
- * @returns A boolean indicating whether the user's device is a desktop device.
163
- */
164
- public static get isDesktop(): boolean {
165
- return !this.isMobile;
166
- }
167
-
168
- /**
169
- * @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
170
- */
171
- public static async GetIsARCapable(): Promise<boolean> {
172
- if (this.GetSupportsARQuickLook()) {
173
- return true;
174
- }
175
-
176
- return await this.GetSupportsWebXR();
177
- }
178
- }
@@ -1,346 +0,0 @@
1
- import { SystemInfo } from '../Info';
2
- import { ESystem, EWebXRUnsupportedReason } from '../../types/info';
3
-
4
- const mockNavigator = (navigator: any) => {
5
- Object.defineProperty(global, 'navigator', {
6
- value: navigator,
7
- writable: true,
8
- });
9
- };
10
-
11
- describe('dive/info/DIVEInfo', () => {
12
- beforeEach(() => {
13
- SystemInfo['_supportsWebXR'] = false;
14
- jest.clearAllMocks();
15
- });
16
-
17
- it('should get system: Windows', () => {
18
- mockNavigator({
19
- userAgent:
20
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.153 Safari/537.36',
21
- });
22
- expect(SystemInfo.GetSystem()).toBe(ESystem.WINDOWS);
23
- });
24
-
25
- it('should get system: MacOS', () => {
26
- mockNavigator({
27
- userAgent:
28
- 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.153 Safari/537.36',
29
- });
30
- expect(SystemInfo.GetSystem()).toBe(ESystem.MACOS);
31
- });
32
-
33
- it('should get system: Linux', () => {
34
- mockNavigator({
35
- userAgent:
36
- 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.153 Safari/537.36',
37
- });
38
- expect(SystemInfo.GetSystem()).toBe(ESystem.LINUX);
39
- });
40
-
41
- it('should get system: Android', () => {
42
- mockNavigator({
43
- userAgent:
44
- 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.153 Mobile Safari/537.36',
45
- });
46
- expect(SystemInfo.GetSystem()).toBe(ESystem.ANDROID);
47
- });
48
-
49
- it('should get system: iOS', () => {
50
- mockNavigator({
51
- userAgent:
52
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
53
- });
54
- expect(SystemInfo.GetSystem()).toBe(ESystem.IOS);
55
- });
56
-
57
- it('should get system: Unknown', () => {
58
- mockNavigator({
59
- userAgent: 'Unknown Browser',
60
- });
61
- expect(SystemInfo.GetSystem()).toBe(ESystem.UNKNOWN);
62
- });
63
-
64
- it('should get system: Unknown when window is undefined', () => {
65
- const originalNavigator = window.navigator;
66
- window.navigator = undefined as any;
67
- expect(SystemInfo.GetSystem()).toBe(ESystem.UNKNOWN);
68
- window.navigator = originalNavigator;
69
- });
70
-
71
- it('should support webXR', async () => {
72
- mockNavigator({
73
- xr: {
74
- isSessionSupported: jest.fn().mockResolvedValue(true),
75
- },
76
- });
77
- const restoreSecureContext = window.isSecureContext;
78
- window.isSecureContext = true;
79
-
80
- const supports = await SystemInfo.GetSupportsWebXR();
81
- expect(supports).toBe(true);
82
-
83
- window.isSecureContext = restoreSecureContext;
84
- });
85
-
86
- it('should not support webXR (xr undefined)', async () => {
87
- mockNavigator({
88
- xr: undefined,
89
- });
90
- const restoreSecureContext = window.isSecureContext;
91
- window.isSecureContext = true;
92
-
93
- const supports = await SystemInfo.GetSupportsWebXR();
94
- expect(supports).toBe(false);
95
-
96
- const reason = SystemInfo.GetWebXRUnsupportedReason();
97
- expect(reason).toBe(EWebXRUnsupportedReason.NO_WEBXR_API);
98
-
99
- window.isSecureContext = restoreSecureContext;
100
- });
101
-
102
- it('should not support webXR (xr undefined & isSecureContext false)', async () => {
103
- window.isSecureContext = false;
104
- mockNavigator({
105
- xr: undefined,
106
- });
107
- const supports = await SystemInfo.GetSupportsWebXR();
108
- expect(supports).toBe(false);
109
-
110
- const reason = SystemInfo.GetWebXRUnsupportedReason();
111
- expect(reason).toBe(EWebXRUnsupportedReason.NO_HTTPS);
112
- });
113
-
114
- it('should get empty reason (not checked)', async () => {
115
- mockNavigator({
116
- xr: {
117
- isSessionSupported: jest.fn().mockResolvedValue(true),
118
- },
119
- });
120
- const restoreSecureContext = window.isSecureContext;
121
- window.isSecureContext = true;
122
-
123
- await SystemInfo.GetSupportsWebXR();
124
- console.log = jest.fn();
125
- const reason = SystemInfo.GetWebXRUnsupportedReason();
126
- expect(reason).toBe(null);
127
-
128
- window.isSecureContext = restoreSecureContext;
129
- });
130
-
131
- it('should get empty reason (webXR supported)', async () => {
132
- mockNavigator({
133
- xr: {
134
- isSessionSupported: jest.fn().mockResolvedValue(true),
135
- },
136
- });
137
- const restoreSecureContext = window.isSecureContext;
138
- window.isSecureContext = true;
139
-
140
- await SystemInfo.GetSupportsWebXR();
141
- const reason = SystemInfo.GetWebXRUnsupportedReason();
142
- expect(reason).toBe(null);
143
-
144
- window.isSecureContext = restoreSecureContext;
145
- });
146
-
147
- it('should not support webXR', async () => {
148
- mockNavigator({
149
- xr: {
150
- isSessionSupported: jest.fn().mockResolvedValue(false),
151
- },
152
- });
153
- const restoreSecureContext = window.isSecureContext;
154
- window.isSecureContext = true;
155
-
156
- const supports = await SystemInfo.GetSupportsWebXR();
157
- expect(supports).toBe(false);
158
-
159
- const reason = SystemInfo.GetWebXRUnsupportedReason();
160
- expect(reason).toBe(
161
- EWebXRUnsupportedReason.IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE,
162
- );
163
-
164
- window.isSecureContext = restoreSecureContext;
165
- });
166
-
167
- it('should not support webXR on error', async () => {
168
- mockNavigator({
169
- xr: {
170
- isSessionSupported: jest.fn().mockRejectedValue('error'),
171
- },
172
- });
173
- const restoreSecureContext = window.isSecureContext;
174
- window.isSecureContext = true;
175
-
176
- const supports = await SystemInfo.GetSupportsWebXR();
177
- expect(supports).toBe(false);
178
-
179
- const reason = SystemInfo.GetWebXRUnsupportedReason();
180
- expect(reason).toBe(EWebXRUnsupportedReason.AR_PERMISSION_DENIED);
181
-
182
- window.isSecureContext = restoreSecureContext;
183
- });
184
-
185
- it('should return cached value', async () => {
186
- SystemInfo['_supportsWebXR'] = true;
187
- mockNavigator({
188
- xr: {
189
- isSessionSupported: jest.fn().mockRejectedValue('error'),
190
- },
191
- });
192
- const supports = await SystemInfo.GetSupportsWebXR();
193
- expect(supports).toBe(true);
194
- });
195
-
196
- it('should return cached value (false)', async () => {
197
- SystemInfo['_supportsWebXR'] = false;
198
- mockNavigator({
199
- xr: {
200
- isSessionSupported: jest.fn().mockRejectedValue('error'),
201
- },
202
- });
203
- const supports = await SystemInfo.GetSupportsWebXR();
204
- expect(supports).toBe(false);
205
- });
206
-
207
- it('should support ARQuickLook when relList supports AR', () => {
208
- jest.spyOn(document, 'createElement').mockReturnValue({
209
- relList: { supports: () => true },
210
- } as unknown as HTMLAnchorElement);
211
- const supports = SystemInfo.GetSupportsARQuickLook();
212
- expect(supports).toBe(true);
213
- });
214
-
215
- it('should not support ARQuickLook when relList does not support AR', () => {
216
- jest.spyOn(document, 'createElement').mockReturnValue({
217
- relList: { supports: () => false },
218
- } as unknown as HTMLAnchorElement);
219
- const supports = SystemInfo.GetSupportsARQuickLook();
220
- expect(supports).toBe(false);
221
- });
222
-
223
- it('should be mobile (iOS)', () => {
224
- jest.spyOn(SystemInfo, 'GetSystem').mockReturnValue(ESystem.IOS);
225
- expect(SystemInfo.isMobile).toBe(true);
226
- expect(SystemInfo.isDesktop).toBe(false);
227
- });
228
-
229
- it('should be mobile (Android)', () => {
230
- jest.spyOn(SystemInfo, 'GetSystem').mockReturnValue(ESystem.ANDROID);
231
- expect(SystemInfo.isMobile).toBe(true);
232
- expect(SystemInfo.isDesktop).toBe(false);
233
- });
234
-
235
- it('should be desktop (Windows)', () => {
236
- jest.spyOn(SystemInfo, 'GetSystem').mockReturnValue(ESystem.WINDOWS);
237
- expect(SystemInfo.isMobile).toBe(false);
238
- expect(SystemInfo.isDesktop).toBe(true);
239
- });
240
-
241
- it('should be desktop (MacOS)', () => {
242
- jest.spyOn(SystemInfo, 'GetSystem').mockReturnValue(ESystem.MACOS);
243
- expect(SystemInfo.isMobile).toBe(false);
244
- expect(SystemInfo.isDesktop).toBe(true);
245
- });
246
-
247
- it('should be desktop (Linux)', () => {
248
- jest.spyOn(SystemInfo, 'GetSystem').mockReturnValue(ESystem.LINUX);
249
- expect(SystemInfo.isMobile).toBe(false);
250
- expect(SystemInfo.isDesktop).toBe(true);
251
- });
252
-
253
- it('should be desktop (Unknown)', () => {
254
- jest.spyOn(SystemInfo, 'GetSystem').mockReturnValue(ESystem.UNKNOWN);
255
- expect(SystemInfo.isMobile).toBe(false);
256
- expect(SystemInfo.isDesktop).toBe(true);
257
- });
258
-
259
- it('should be capable of AR (ARQuickLook)', async () => {
260
- jest.spyOn(SystemInfo, 'GetSupportsARQuickLook').mockReturnValue(true);
261
- jest.spyOn(SystemInfo, 'GetSupportsWebXR').mockResolvedValue(false);
262
- expect(await SystemInfo.GetIsARCapable()).toBe(true);
263
- });
264
-
265
- it('should be capable of AR (WebXR)', async () => {
266
- jest.spyOn(SystemInfo, 'GetSupportsARQuickLook').mockReturnValue(false);
267
- jest.spyOn(SystemInfo, 'GetSupportsWebXR').mockResolvedValue(true);
268
- expect(await SystemInfo.GetIsARCapable()).toBe(true);
269
- });
270
-
271
- it('should not be capable of AR', async () => {
272
- jest.spyOn(SystemInfo, 'GetSupportsARQuickLook').mockReturnValue(false);
273
- jest.spyOn(SystemInfo, 'GetSupportsWebXR').mockResolvedValue(false);
274
- expect(await SystemInfo.GetIsARCapable()).toBe(false);
275
- });
276
-
277
- it('should support SceneViewer (Android, Chrome 89+)', () => {
278
- mockNavigator({
279
- userAgent:
280
- 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Mobile Safari/537.36',
281
- });
282
- const supports = SystemInfo.GetSupportsSceneViewer();
283
- expect(supports).toBe(true);
284
- });
285
-
286
- it('should support SceneViewer (Android, Chrome 126+)', () => {
287
- mockNavigator({
288
- userAgent:
289
- 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.153 Mobile Safari/537.36',
290
- });
291
- const supports = SystemInfo.GetSupportsSceneViewer();
292
- expect(supports).toBe(true);
293
- });
294
-
295
- it('should not support SceneViewer (Android, Chrome <89)', () => {
296
- mockNavigator({
297
- userAgent:
298
- 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4389.72 Mobile Safari/537.36',
299
- });
300
- const supports = SystemInfo.GetSupportsSceneViewer();
301
- expect(supports).toBe(false);
302
- });
303
-
304
- it('should not support SceneViewer (Android, no Chrome)', () => {
305
- mockNavigator({
306
- userAgent:
307
- 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Mobile Safari/537.36',
308
- });
309
- const supports = SystemInfo.GetSupportsSceneViewer();
310
- expect(supports).toBe(false);
311
- });
312
-
313
- it('should not support SceneViewer (iOS)', () => {
314
- mockNavigator({
315
- userAgent:
316
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
317
- });
318
- const supports = SystemInfo.GetSupportsSceneViewer();
319
- expect(supports).toBe(false);
320
- });
321
-
322
- it('should not support SceneViewer (Windows)', () => {
323
- mockNavigator({
324
- userAgent:
325
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.153 Safari/537.36',
326
- });
327
- const supports = SystemInfo.GetSupportsSceneViewer();
328
- expect(supports).toBe(false);
329
- });
330
-
331
- it('should not support SceneViewer (no window)', () => {
332
- const originalWindow = global.window;
333
- global.window = undefined as any;
334
- const supports = SystemInfo.GetSupportsSceneViewer();
335
- expect(supports).toBe(false);
336
- global.window = originalWindow;
337
- });
338
-
339
- it('should not support SceneViewer (no navigator)', () => {
340
- const originalNavigator = global.navigator;
341
- global.navigator = undefined as any;
342
- const supports = SystemInfo.GetSupportsSceneViewer();
343
- expect(supports).toBe(false);
344
- global.navigator = originalNavigator;
345
- });
346
- });
@@ -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
- }