@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,21 +1,12 @@
1
- import { FileType, ExportOptions } from '../types';
2
- export declare class ConversionError extends Error {
3
- readonly cause?: unknown | undefined;
4
- constructor(message: string, cause?: unknown | undefined);
5
- }
6
- export declare class FileTypeError extends ConversionError {
7
- constructor(extension: string);
8
- }
9
- export declare class NetworkError extends ConversionError {
10
- constructor(uri: string, cause?: unknown);
11
- }
1
+ import { FileTypeToExporterOptions } from '../exporter/Exporter';
2
+ import { FileType } from '../types/file';
12
3
  export declare class Converter {
13
4
  private readonly _uri;
14
5
  private _loader;
15
6
  private _exporter;
16
7
  constructor(_uri: string);
17
8
  static convert(uri: string): Converter;
18
- to<T extends FileType>(type: T, options?: ExportOptions<T>): Promise<ArrayBuffer>;
19
9
  private _getFileTypeFromUri;
20
10
  private _loadFile;
11
+ to<T extends FileType>(type: T, options?: FileTypeToExporterOptions[T]): Promise<ArrayBuffer>;
21
12
  }
@@ -60,6 +60,7 @@ export default class DIVE {
60
60
  }
61
61
  export { DIVE, DIVECommunication };
62
62
  export * from './math/index.ts';
63
+ export * from './ar/AR';
63
64
  export type * from './com/actions/index.ts';
64
65
  export type * from './com/types';
65
66
  export type * from './types';
@@ -1,10 +1,28 @@
1
1
  import { Object3D } from 'three';
2
- import { FileType, ExportOptions } from '../types';
2
+ import { GLTFExporterOptions as THREEGLTFExporterOptions } from 'three/examples/jsm/exporters/GLTFExporter';
3
+ import { USDZExporterOptions as THREEUSDZExporterOptions } from 'three/examples/jsm/exporters/USDZExporter';
4
+ import { FileType } from '../types/file/FileTypes';
5
+ export type USDZExporterOptions = THREEUSDZExporterOptions & {
6
+ ar?: {
7
+ anchoring: {
8
+ type: 'plane' | 'image' | 'face' | 'none';
9
+ };
10
+ planeAnchoring: {
11
+ alignment: 'horizontal' | 'vertical' | 'any';
12
+ };
13
+ };
14
+ };
15
+ export type GLTFExporterOptions = THREEGLTFExporterOptions;
16
+ export type FileTypeToExporterOptions = {
17
+ glb: GLTFExporterOptions;
18
+ gltf: GLTFExporterOptions;
19
+ usdz: USDZExporterOptions;
20
+ };
3
21
  export declare class Exporter {
4
22
  private _gltfExporter;
5
23
  private _usdzExporter;
6
24
  constructor();
7
- export<T extends FileType>(object: Object3D, type: T, options?: ExportOptions<T>): Promise<ArrayBuffer>;
25
+ export<T extends FileType>(object: Object3D, type: T, options?: FileTypeToExporterOptions[T]): Promise<ArrayBuffer>;
8
26
  private _exportGlb;
9
27
  private _exportGltf;
10
28
  private _exportUsdz;
@@ -4,8 +4,4 @@ export declare class Loader {
4
4
  private _usdzLoader;
5
5
  constructor();
6
6
  load(uri: string): Promise<Object3D>;
7
- private _getFileTypeFromUri;
8
- private _load;
9
- private _loadGltf;
10
- private _loadUsdz;
11
7
  }
@@ -0,0 +1,12 @@
1
+ export declare class ConversionError extends Error {
2
+ readonly cause?: unknown | undefined;
3
+ constructor(message: string, cause?: unknown | undefined);
4
+ }
5
+ export declare class FileTypeError extends Error {
6
+ constructor(message: string);
7
+ }
8
+ export declare class NetworkError extends Error {
9
+ readonly url: string;
10
+ readonly cause?: unknown | undefined;
11
+ constructor(url: string, message: string, cause?: unknown | undefined);
12
+ }
@@ -0,0 +1,17 @@
1
+ declare const FILE_TYPES: {
2
+ readonly glb: {
3
+ readonly key: "glb";
4
+ readonly extension: "glb";
5
+ };
6
+ readonly gltf: {
7
+ readonly key: "gltf";
8
+ readonly extension: "gltf";
9
+ };
10
+ readonly usdz: {
11
+ readonly key: "usdz";
12
+ readonly extension: "usdz";
13
+ };
14
+ };
15
+ export type FileType = keyof typeof FILE_TYPES;
16
+ export declare const SUPPORTED_FILE_TYPES: readonly string[];
17
+ export {};
@@ -0,0 +1 @@
1
+ export * from './FileTypes';
@@ -1,8 +1,5 @@
1
- import { DIVESceneObject } from './SceneObjects';
2
- import { DIVESceneFileType } from './SceneType';
3
- import { DIVESceneData } from './SceneData';
4
- import { FileType, FileTypeKey, FileTypeOptions, FileTypeDefinition, FILE_TYPES, SUPPORTED_FILE_TYPES } from './FileTypes';
5
- import { GLTFExporterOptions, USDZExporterOptions, ExportOptions } from './ExporterOptions';
6
- export { type DIVESceneObject, type DIVESceneFileType, type DIVESceneData };
7
- export { type FileType, type FileTypeKey, type FileTypeOptions, type FileTypeDefinition, FILE_TYPES, SUPPORTED_FILE_TYPES, };
8
- export { type GLTFExporterOptions, type USDZExporterOptions, type ExportOptions, };
1
+ export * from './SceneData';
2
+ export * from './SceneObjects';
3
+ export * from './SceneType';
4
+ export * from './file';
5
+ export * from './info';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/dive",
3
- "version": "1.19.1-beta.0",
3
+ "version": "1.19.1-beta.2",
4
4
  "description": "Shopware Spatial Framework",
5
5
  "type": "module",
6
6
  "main": "build/dive.cjs",
@@ -25,8 +25,7 @@
25
25
  "build",
26
26
  "LICENSE",
27
27
  "package.json",
28
- "README.md",
29
- "src"
28
+ "README.md"
30
29
  ],
31
30
  "keywords": [
32
31
  "dive",
@@ -1,15 +0,0 @@
1
- import { GLTFExporterOptions as THREEGLTFExporterOptions } from 'three/examples/jsm/exporters/GLTFExporter';
2
- import { USDZExporterOptions as THREEUSDZExporterOptions } from 'three/examples/jsm/exporters/USDZExporter';
3
- import { FileType, FileTypeOptions } from './FileTypes';
4
- export type USDZExporterOptions = THREEUSDZExporterOptions & {
5
- ar?: {
6
- anchoring: {
7
- type: 'plane' | 'image' | 'face' | 'none';
8
- };
9
- planeAnchoring: {
10
- alignment: 'horizontal' | 'vertical' | 'any';
11
- };
12
- };
13
- };
14
- export type GLTFExporterOptions = THREEGLTFExporterOptions;
15
- export type ExportOptions<T extends FileType> = FileTypeOptions<T>;
@@ -1,27 +0,0 @@
1
- import { GLTFExporterOptions, USDZExporterOptions } from './ExporterOptions';
2
- export type FileTypeDefinition<T extends string, O> = {
3
- key: T;
4
- extension: string;
5
- options: O;
6
- };
7
- export declare const FILE_TYPES: {
8
- readonly glb: {
9
- readonly key: "glb";
10
- readonly extension: ".glb";
11
- readonly options: GLTFExporterOptions;
12
- };
13
- readonly gltf: {
14
- readonly key: "gltf";
15
- readonly extension: ".gltf";
16
- readonly options: GLTFExporterOptions;
17
- };
18
- readonly usdz: {
19
- readonly key: "usdz";
20
- readonly extension: ".usdz";
21
- readonly options: USDZExporterOptions;
22
- };
23
- };
24
- export type FileType = keyof typeof FILE_TYPES;
25
- export type FileTypeKey = (typeof FILE_TYPES)[FileType]['key'];
26
- export type FileTypeOptions<T extends FileType> = (typeof FILE_TYPES)[T]['options'];
27
- export declare const SUPPORTED_FILE_TYPES: readonly string[];
@@ -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,101 +0,0 @@
1
- import { SystemInfo } from '../info/Info';
2
- import { ESystem } from '../types/info';
3
- import { ARQuickLook } from './arquicklook/ARQuickLook';
4
- import { SceneViewer } from './sceneviewer/SceneViewer';
5
-
6
- /**
7
- * Options for configuring the AR system behavior
8
- */
9
- export type ARSystemOptions = {
10
- /** The placement orientation for AR content - either horizontal or vertical */
11
- arPlacement: 'horizontal' | 'vertical';
12
- /** The scaling behavior for AR content - either automatic or fixed */
13
- arScale: 'auto' | 'fixed';
14
- };
15
-
16
- /**
17
- * Main class for handling AR functionality across different platforms
18
- * Provides methods to launch AR experiences using platform-specific implementations
19
- */
20
- export class ARSystem {
21
- /**
22
- * Launches an AR experience using the appropriate platform-specific implementation
23
- *
24
- * @param uri - The URI of the 3D model to display in AR
25
- * @param options - Optional configuration for the AR experience
26
- * @returns Promise that resolves when AR is launched successfully
27
- * @throws Error if AR is not supported on the current platform
28
- */
29
- public async launch(uri: string, options?: ARSystemOptions): Promise<void> {
30
- const system = SystemInfo.GetSystem();
31
-
32
- if (system === ESystem.IOS) {
33
- return this.tryARQuickLook(uri, options);
34
- }
35
-
36
- if (system === ESystem.ANDROID) {
37
- return this.trySceneViewer(uri, options);
38
- }
39
-
40
- console.log(
41
- 'DIVE: AR not supported. Not a mobile system. (System is ' +
42
- system +
43
- ')',
44
- );
45
- return Promise.reject(
46
- new Error('AR not supported on non-mobile systems'),
47
- );
48
- }
49
-
50
- /**
51
- * Attempts to launch AR using ARQuickLook (iOS-specific implementation)
52
- *
53
- * @param uri - The URI of the 3D model to display in AR
54
- * @param options - Optional configuration for the AR experience
55
- * @returns Promise that resolves when ARQuickLook is launched successfully
56
- * @throws Error if ARQuickLook is not supported on the device
57
- */
58
- private async tryARQuickLook(
59
- uri: string,
60
- options?: ARSystemOptions,
61
- ): Promise<void> {
62
- const support = SystemInfo.GetSupportsARQuickLook();
63
- if (!support) {
64
- console.log('ARQuickLook not supported');
65
- return Promise.reject(new Error('ARQuickLook not supported'));
66
- }
67
-
68
- console.log('DIVE: Launching AR with ARQuickLook ...');
69
-
70
- try {
71
- return new ARQuickLook().launch(uri, options);
72
- } catch (error) {
73
- console.error('Error launching ARQuickLook:', error);
74
- return Promise.reject(error);
75
- }
76
- }
77
-
78
- /**
79
- * Launches AR using SceneViewer (Android-specific implementation)
80
- * Note: SceneViewer is supported on all Android devices. If ARCore is not installed,
81
- * the model will be displayed in 3D view mode instead of AR mode.
82
- *
83
- * @param uri - The URI of the 3D model to display in AR
84
- * @param options - Optional configuration for the AR experience
85
- * @returns Promise that resolves when SceneViewer is launched successfully
86
- * @throws Error if there's an issue launching SceneViewer
87
- */
88
- private async trySceneViewer(
89
- uri: string,
90
- options?: ARSystemOptions,
91
- ): Promise<void> {
92
- console.log('DIVE: Launching AR with SceneViewer ...');
93
-
94
- try {
95
- return new SceneViewer().launch(uri, options);
96
- } catch (error) {
97
- console.error('Error launching SceneViewer:', error);
98
- return Promise.reject(error);
99
- }
100
- }
101
- }