@shopware-ag/dive 1.19.1-beta.2 → 1.19.1-beta.4

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 (116) hide show
  1. package/README.md +295 -362
  2. package/build/chunks/PerspectiveCamera-ACx6umAu.mjs +38 -0
  3. package/build/chunks/PerspectiveCamera-ACx6umAu.mjs.map +1 -0
  4. package/build/chunks/PerspectiveCamera-BXPNOM71.cjs +2 -0
  5. package/build/chunks/PerspectiveCamera-BXPNOM71.cjs.map +1 -0
  6. package/build/chunks/fflate.module-DHdJvhNh.cjs +7 -0
  7. package/build/chunks/fflate.module-DHdJvhNh.cjs.map +1 -0
  8. package/build/chunks/fflate.module-DkZg07PZ.mjs +603 -0
  9. package/build/chunks/fflate.module-DkZg07PZ.mjs.map +1 -0
  10. package/build/chunks/file-type-error-D6aWGgyc.mjs +15 -0
  11. package/build/chunks/file-type-error-D6aWGgyc.mjs.map +1 -0
  12. package/build/chunks/file-type-error-DtvBgs64.cjs +2 -0
  13. package/build/chunks/file-type-error-DtvBgs64.cjs.map +1 -0
  14. package/build/chunks/index-C7Wx_9uY.mjs +34 -0
  15. package/build/chunks/index-C7Wx_9uY.mjs.map +1 -0
  16. package/build/chunks/index-MNP0K5dt.cjs +2 -0
  17. package/build/chunks/index-MNP0K5dt.cjs.map +1 -0
  18. package/build/chunks/network-error-C2ZDC8qS.cjs +2 -0
  19. package/build/chunks/network-error-C2ZDC8qS.cjs.map +1 -0
  20. package/build/chunks/network-error-DgecatEk.mjs +27 -0
  21. package/build/chunks/network-error-DgecatEk.mjs.map +1 -0
  22. package/build/index.cjs +57 -0
  23. package/build/index.cjs.map +1 -0
  24. package/build/index.d.ts +6 -0
  25. package/build/index.mjs +6884 -0
  26. package/build/index.mjs.map +1 -0
  27. package/build/src/animation/AnimationSystem.d.ts +1 -1
  28. package/build/src/axiscamera/AxisCamera.d.ts +2 -2
  29. package/build/src/com/Communication.d.ts +5 -8
  30. package/build/src/com/actions/scene/exportscene.d.ts +1 -1
  31. package/build/src/com/actions/scene/launchar.d.ts +1 -1
  32. package/build/src/controls/OrbitControls.d.ts +2 -2
  33. package/build/src/dive.d.ts +12 -29
  34. package/build/src/engine/Engine.d.ts +32 -0
  35. package/build/src/{camera → engine/camera}/PerspectiveCamera.d.ts +1 -1
  36. package/build/src/{scene → engine/scene}/Scene.d.ts +4 -4
  37. package/build/src/{scene → engine/scene}/root/Root.d.ts +2 -3
  38. package/build/src/error/ar-compatibility/ar-compatibility-error.d.ts +12 -0
  39. package/build/src/error/file-type/file-type-error.d.ts +4 -0
  40. package/build/src/error/index.d.ts +4 -0
  41. package/build/src/error/network/network-error.d.ts +5 -0
  42. package/build/src/error/parse/parse-error.d.ts +4 -0
  43. package/build/src/helper/findSceneRecursive/findSceneRecursive.d.ts +1 -1
  44. package/build/src/helper/getFileTypeFromUri/getFileTypeFromUri.d.ts +6 -0
  45. package/build/src/helper/index.d.ts +7 -0
  46. package/build/src/helper/isFileTypeSupported/isFileTypeSupported.d.ts +7 -0
  47. package/build/src/index.d.ts +2 -0
  48. package/build/src/math/index.d.ts +1 -1
  49. package/build/src/modules/_system/Module.d.ts +13 -0
  50. package/build/src/modules/_system/ModuleRegistry.d.ts +29 -0
  51. package/build/src/modules/ar/ARSystem.cjs +2 -0
  52. package/build/src/modules/ar/ARSystem.cjs.map +1 -0
  53. package/build/src/{ar/AR.d.ts → modules/ar/ARSystem.d.ts} +26 -0
  54. package/build/src/modules/ar/ARSystem.mjs +164 -0
  55. package/build/src/modules/ar/ARSystem.mjs.map +1 -0
  56. package/build/src/{ar → modules/ar}/arquicklook/ARQuickLook.d.ts +2 -1
  57. package/build/src/{ar → modules/ar}/sceneviewer/SceneViewer.d.ts +1 -1
  58. package/build/src/{ar → modules/ar}/webxr/WebXR.d.ts +3 -3
  59. package/build/src/{ar → modules/ar}/webxr/controller/WebXRController.d.ts +2 -2
  60. package/build/src/{ar → modules/ar}/webxr/origin/WebXROrigin.d.ts +1 -1
  61. package/build/src/{ar → modules/ar}/webxr/raycaster/WebXRRaycaster.d.ts +3 -3
  62. package/build/src/{ar → modules/ar}/webxr/raycaster/ar/WebXRRaycasterAR.d.ts +1 -1
  63. package/build/src/{ar → modules/ar}/webxr/raycaster/three/WebXRRaycasterTHREE.d.ts +2 -2
  64. package/build/src/{ar → modules/ar}/webxr/touchscreencontrols/WebXRTouchscreenControls.d.ts +1 -1
  65. package/build/src/modules/asset/converter/AssetConverter.cjs +2 -0
  66. package/build/src/modules/asset/converter/AssetConverter.cjs.map +1 -0
  67. package/build/src/modules/asset/converter/AssetConverter.d.ts +29 -0
  68. package/build/src/modules/asset/converter/AssetConverter.mjs +22 -0
  69. package/build/src/modules/asset/converter/AssetConverter.mjs.map +1 -0
  70. package/build/src/modules/asset/exporter/AssetExporter.cjs +165 -0
  71. package/build/src/modules/asset/exporter/AssetExporter.cjs.map +1 -0
  72. package/build/src/{exporter/Exporter.d.ts → modules/asset/exporter/AssetExporter.d.ts} +7 -2
  73. package/build/src/modules/asset/exporter/AssetExporter.mjs +1622 -0
  74. package/build/src/modules/asset/exporter/AssetExporter.mjs.map +1 -0
  75. package/build/src/modules/asset/loader/AssetLoader.cjs +3 -0
  76. package/build/src/modules/asset/loader/AssetLoader.cjs.map +1 -0
  77. package/build/src/modules/asset/loader/AssetLoader.d.ts +33 -0
  78. package/build/src/modules/asset/loader/AssetLoader.mjs +1924 -0
  79. package/build/src/modules/asset/loader/AssetLoader.mjs.map +1 -0
  80. package/build/src/modules/index.d.ts +10 -0
  81. package/build/src/modules/mediacreator/MediaCreator.cjs +2 -0
  82. package/build/src/modules/mediacreator/MediaCreator.cjs.map +1 -0
  83. package/build/src/modules/mediacreator/MediaCreator.d.ts +40 -0
  84. package/build/src/modules/mediacreator/MediaCreator.mjs +28 -0
  85. package/build/src/modules/mediacreator/MediaCreator.mjs.map +1 -0
  86. package/build/src/modules/systeminfo/SystemInfo.cjs +2 -0
  87. package/build/src/modules/systeminfo/SystemInfo.cjs.map +1 -0
  88. package/build/src/{info/Info.d.ts → modules/systeminfo/SystemInfo.d.ts} +40 -7
  89. package/build/src/modules/systeminfo/SystemInfo.mjs +115 -0
  90. package/build/src/modules/systeminfo/SystemInfo.mjs.map +1 -0
  91. package/build/src/toolbox/BaseTool.d.ts +1 -1
  92. package/build/src/toolbox/Toolbox.d.ts +1 -1
  93. package/build/src/toolbox/select/SelectTool.d.ts +1 -1
  94. package/build/src/toolbox/transform/TransformTool.d.ts +1 -1
  95. package/build/src/types/file/FileTypes.d.ts +1 -2
  96. package/build/src/types/index.d.ts +1 -0
  97. package/package.json +17 -21
  98. package/build/dive.cjs +0 -4025
  99. package/build/dive.cjs.map +0 -1
  100. package/build/dive.d.ts +0 -6
  101. package/build/dive.js +0 -4025
  102. package/build/dive.js.map +0 -1
  103. package/build/dive.mjs +0 -28200
  104. package/build/dive.mjs.map +0 -1
  105. package/build/src/converter/Converter.d.ts +0 -12
  106. package/build/src/io/IO.d.ts +0 -10
  107. package/build/src/io/gltf/GLTFIO.d.ts +0 -12
  108. package/build/src/loader/Loader.d.ts +0 -7
  109. package/build/src/mediacreator/MediaCreator.d.ts +0 -17
  110. package/build/src/module/Module.d.ts +0 -8
  111. package/build/src/types/error/index.d.ts +0 -12
  112. /package/build/src/{renderer → engine/renderer}/Renderer.d.ts +0 -0
  113. /package/build/src/{scene → engine/scene}/xrroot/XRRoot.d.ts +0 -0
  114. /package/build/src/{scene → engine/scene}/xrroot/xrlightroot/XRLightRoot.d.ts +0 -0
  115. /package/build/src/{ar → modules/ar}/webxr/crosshair/WebXRCrosshair.d.ts +0 -0
  116. /package/build/src/{ar → modules/ar}/webxr/overlay/Overlay.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import { Tween } from '@tweenjs/tween.js';
2
- import { DIVERenderer } from '../renderer/Renderer';
2
+ import { DIVERenderer } from '../engine/renderer/Renderer';
3
3
  /**
4
4
  * Updates all animations.
5
5
  * DIVE uses Tween.js to handle animations.
@@ -1,6 +1,6 @@
1
1
  import { Matrix4, OrthographicCamera } from 'three';
2
- import { DIVERenderer } from '../renderer/Renderer.ts';
3
- import { DIVEScene } from '../scene/Scene.ts';
2
+ import { DIVERenderer } from '../engine/renderer/Renderer.ts';
3
+ import { DIVEScene } from '../engine/scene/Scene.ts';
4
4
  import { default as DIVEOrbitControls } from '../controls/OrbitControls.ts';
5
5
  /**
6
6
  * Shows the scene axes in the bottom left corner of the screen.
@@ -1,8 +1,8 @@
1
1
  import { Actions } from './actions/index.ts';
2
- import { DIVEScene } from '../scene/Scene.ts';
3
- import { default as DIVEToolbox } from '../toolbox/Toolbox.ts';
4
- import { default as DIVEOrbitControls } from '../controls/OrbitControls.ts';
5
- import { DIVERenderer } from '../renderer/Renderer.ts';
2
+ import { DIVEScene } from '../engine/scene/Scene';
3
+ import { default as DIVEToolbox } from '../toolbox/Toolbox';
4
+ import { default as DIVEOrbitControls } from '../controls/OrbitControls';
5
+ import { DIVERenderer } from '../engine/renderer/Renderer';
6
6
  type EventListener<Action extends keyof Actions> = (payload: Actions[Action]['PAYLOAD']) => void;
7
7
  type Unsubscribe = () => boolean;
8
8
  /**
@@ -17,7 +17,7 @@ type Unsubscribe = () => boolean;
17
17
  *
18
18
  * dive.Communication.Subscribe('GET_ALL_SCENE_DATA', () => {
19
19
  * // do something
20
- * }));
20
+ * });
21
21
  *
22
22
  * dive.Communication.PerformAction('GET_ALL_SCENE_DATA', {});
23
23
  * ```
@@ -33,9 +33,6 @@ export declare class DIVECommunication {
33
33
  private scene;
34
34
  private controller;
35
35
  private toolbox;
36
- private _mediaGenerator;
37
- private _io;
38
- private _ar;
39
36
  private registered;
40
37
  private listeners;
41
38
  constructor(renderer: DIVERenderer, scene: DIVEScene, controls: DIVEOrbitControls, toolbox: DIVEToolbox);
@@ -4,5 +4,5 @@ export default interface EXPORT_SCENE {
4
4
  PAYLOAD: {
5
5
  type: keyof DIVESceneFileType;
6
6
  };
7
- RETURN: Promise<string | null>;
7
+ RETURN: Promise<ArrayBuffer | null>;
8
8
  }
@@ -1,4 +1,4 @@
1
- import { ARSystemOptions } from '../../../ar/AR';
1
+ import { ARSystemOptions } from '../../../modules/ar/ARSystem';
2
2
  export default interface LAUNCH_AR {
3
3
  DESCRIPTION: 'Launches AR mode in native capabilities. (iOS: AR Quick Look, Android: Google Scene Viewer)';
4
4
  PAYLOAD: {
@@ -1,6 +1,6 @@
1
1
  import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
2
- import { default as DIVEPerspectiveCamera } from '../camera/PerspectiveCamera.ts';
3
- import { DIVERenderer } from '../renderer/Renderer.ts';
2
+ import { DIVEPerspectiveCamera } from '../engine/camera/PerspectiveCamera.ts';
3
+ import { DIVERenderer } from '../engine/renderer/Renderer.ts';
4
4
  import { Box3, Vector3Like } from 'three';
5
5
  import { DIVEAnimationSystem } from '../animation/AnimationSystem.ts';
6
6
  export type DIVEOrbitControlsSettings = {
@@ -1,14 +1,7 @@
1
- import { DIVERendererSettings } from './renderer/Renderer.ts';
2
- import { DIVEPerspectiveCameraSettings } from './camera/PerspectiveCamera.ts';
3
1
  import { DIVEOrbitControlsSettings } from './controls/OrbitControls.ts';
4
2
  import { DIVECommunication } from './com/Communication.ts';
5
- import { SystemInfo } from './info/Info.ts';
6
- export type DIVESettings = {
7
- autoResize: boolean;
8
- autoStart: boolean;
9
- displayAxes: boolean;
10
- renderer: Partial<DIVERendererSettings>;
11
- perspectiveCamera: Partial<DIVEPerspectiveCameraSettings>;
3
+ import { Engine, EngineSettings } from './engine/Engine.ts';
4
+ export type DIVESettings = EngineSettings & {
12
5
  orbitControls: Partial<DIVEOrbitControlsSettings>;
13
6
  };
14
7
  export declare const DIVEDefaultSettings: DIVESettings;
@@ -35,32 +28,22 @@ export declare const DIVEDefaultSettings: DIVESettings;
35
28
  * @module
36
29
  */
37
30
  export default class DIVE {
38
- static QuickView(uri: string, settings?: Partial<DIVESettings>): DIVE;
31
+ static QuickView(uri: string, settings?: Partial<DIVESettings>): Promise<DIVE>;
39
32
  private _settings;
40
- private _resizeObserverId;
41
- private _width;
42
- private _height;
43
- private renderer;
44
- private scene;
45
- private perspectiveCamera;
33
+ get engine(): Engine;
34
+ private _engine;
46
35
  private orbitControls;
47
36
  private toolbox;
48
- private communication;
37
+ private _communication;
49
38
  private animationSystem;
50
39
  private axisCamera;
51
- get Communication(): DIVECommunication;
52
- get Canvas(): HTMLCanvasElement;
53
- get Info(): SystemInfo;
54
- set Settings(settings: Partial<DIVESettings>);
40
+ get communication(): DIVECommunication;
41
+ get canvas(): HTMLCanvasElement;
55
42
  constructor(settings?: Partial<DIVESettings>);
56
43
  Dispose(): void;
57
- OnResize(width: number, height: number): void;
58
- private addResizeObserver;
59
- private removeResizeObserver;
60
44
  }
61
45
  export { DIVE, DIVECommunication };
62
- export * from './math/index.ts';
63
- export * from './ar/AR';
64
- export type * from './com/actions/index.ts';
65
- export type * from './com/types';
66
- export type * from './types';
46
+ export { DiveMath } from './math/index.ts';
47
+ export * from './com/actions/index.ts';
48
+ export * from './com/types';
49
+ export * from './types';
@@ -0,0 +1,32 @@
1
+ import { DIVERenderer, DIVERendererSettings } from './renderer/Renderer.ts';
2
+ import { DIVEScene } from './scene/Scene.ts';
3
+ import { DIVEPerspectiveCamera, DIVEPerspectiveCameraSettings } from './camera/PerspectiveCamera.ts';
4
+ export type EngineSettings = {
5
+ autoResize: boolean;
6
+ autoStart: boolean;
7
+ displayAxes: boolean;
8
+ renderer: Partial<DIVERendererSettings>;
9
+ perspectiveCamera: Partial<DIVEPerspectiveCameraSettings>;
10
+ };
11
+ export declare const EngineDefaultSettings: EngineSettings;
12
+ export declare class Engine {
13
+ get renderer(): DIVERenderer;
14
+ get scene(): DIVEScene;
15
+ get perspectiveCamera(): DIVEPerspectiveCamera;
16
+ private _renderer;
17
+ private _scene;
18
+ private _perspectiveCamera;
19
+ private _settings;
20
+ private _resizeObserverId;
21
+ private _width;
22
+ private _height;
23
+ constructor(settings?: Partial<EngineSettings>);
24
+ /**
25
+ * Disposes the engine.
26
+ * @internal
27
+ */
28
+ dispose(): void;
29
+ onResize(width: number, height: number): void;
30
+ private _addResizeObserver;
31
+ private _removeResizeObserver;
32
+ }
@@ -10,7 +10,7 @@ export declare const DIVEPerspectiveCameraDefaultSettings: DIVEPerspectiveCamera
10
10
  *
11
11
  * @module
12
12
  */
13
- export default class DIVEPerspectiveCamera extends PerspectiveCamera {
13
+ export declare class DIVEPerspectiveCamera extends PerspectiveCamera {
14
14
  static readonly EDITOR_VIEW_LAYER_MASK: number;
15
15
  static readonly LIVE_VIEW_LAYER_MASK = 16;
16
16
  onSetCameraLayer: (mask: number) => void;
@@ -1,9 +1,9 @@
1
1
  import { Scene, Box3, ColorRepresentation } from 'three';
2
- import { COMModel, COMEntity } from '../com/types';
2
+ import { COMModel, COMEntity } from '../../com/types';
3
3
  import { DIVERoot } from './root/Root';
4
- import { DIVEGrid } from '../grid/Grid';
5
- import { DIVEFloor } from '../primitive/floor/Floor';
6
- import { DIVESceneObject } from '../types';
4
+ import { DIVEGrid } from '../../grid/Grid';
5
+ import { DIVEFloor } from '../../primitive/floor/Floor';
6
+ import { DIVESceneObject } from '../../types';
7
7
  import { DIVEXRRoot } from './xrroot/XRRoot';
8
8
  import { DIVERenderer } from '../renderer/Renderer';
9
9
  /**
@@ -1,6 +1,6 @@
1
1
  import { Box3, Object3D } from 'three';
2
- import { COMEntity } from '../../com/types';
3
- import { DIVESceneObject } from '../../types';
2
+ import { COMEntity } from '../../../com/types';
3
+ import { DIVESceneObject } from '../../../types';
4
4
  /**
5
5
  * A basic scene node to hold grid, floor and all lower level roots.
6
6
  *
@@ -8,7 +8,6 @@ import { DIVESceneObject } from '../../types';
8
8
  */
9
9
  export declare class DIVERoot extends Object3D {
10
10
  readonly isDIVERoot: true;
11
- private loader;
12
11
  constructor();
13
12
  ComputeSceneBB(): Box3;
14
13
  GetSceneObject<T extends DIVESceneObject>(object: Partial<COMEntity> & {
@@ -0,0 +1,12 @@
1
+ export declare class ARCompatibilityError extends Error {
2
+ readonly browserInfo: {
3
+ userAgent: string;
4
+ platform: string;
5
+ vendor: string;
6
+ browser: string;
7
+ version: string;
8
+ os: string;
9
+ osVersion: string;
10
+ };
11
+ constructor(baseMessage: string, userAgent: string, platform: string, vendor: string);
12
+ }
@@ -0,0 +1,4 @@
1
+ export declare class FileTypeError extends Error {
2
+ readonly requestedFileType: string;
3
+ constructor(message: string, requestedFileType: string);
4
+ }
@@ -0,0 +1,4 @@
1
+ export { ParseError } from './parse/parse-error';
2
+ export { FileTypeError } from './file-type/file-type-error';
3
+ export { NetworkError } from './network/network-error';
4
+ export { ARCompatibilityError } from './ar-compatibility/ar-compatibility-error';
@@ -0,0 +1,5 @@
1
+ export declare class NetworkError extends Error {
2
+ readonly url: string;
3
+ readonly cause?: unknown | undefined;
4
+ constructor(url: string, message: string, cause?: unknown | undefined);
5
+ }
@@ -0,0 +1,4 @@
1
+ export declare class ParseError extends Error {
2
+ readonly cause?: unknown | undefined;
3
+ constructor(message: string, cause?: unknown | undefined);
4
+ }
@@ -1,5 +1,5 @@
1
1
  import { Object3D } from 'three';
2
- import { DIVEScene } from '../../scene/Scene';
2
+ import { DIVEScene } from '../../engine/scene/Scene';
3
3
  /**
4
4
  * Find the scene object of an object.
5
5
  *
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Extracts the file extension from a URI
3
+ * @param uri The URI to extract the extension from
4
+ * @returns The file extension in lowercase, or an empty string if no extension is found
5
+ */
6
+ export declare function getFileTypeFromUri(uri: string): string;
@@ -0,0 +1,7 @@
1
+ export * from './getFileTypeFromUri/getFileTypeFromUri';
2
+ export * from './isFileTypeSupported/isFileTypeSupported';
3
+ export * from './findSceneRecursive/findSceneRecursive';
4
+ export * from './getObjectDelta/getObjectDelta';
5
+ export * from './isInterface/implementsInterface';
6
+ export * from './findInterface/findInterface';
7
+ export * from './applyMixins/applyMixins';
@@ -0,0 +1,7 @@
1
+ import { FileType } from '../../types/file/FileTypes';
2
+ /**
3
+ * Checks if a file extension is supported
4
+ * @param extension The file extension to check
5
+ * @returns True if the extension is supported, false otherwise
6
+ */
7
+ export declare function isFileTypeSupported(extension: string): extension is FileType;
@@ -0,0 +1,2 @@
1
+ export { default } from './dive';
2
+ export * from './dive';
@@ -6,7 +6,7 @@ import { default as toFixedExp } from './toFixed/toFixedExp.ts';
6
6
  import { default as truncateExp } from './truncate/truncateExp.ts';
7
7
  import { default as radToDeg } from './radToDeg/radToDeg.ts';
8
8
  import { default as degToRad } from './degToRad/degToRad.ts';
9
- export declare const DIVEMath: {
9
+ export declare const DiveMath: {
10
10
  ceilExp: typeof ceilExp;
11
11
  floorExp: typeof floorExp;
12
12
  roundExp: typeof roundExp;
@@ -0,0 +1,13 @@
1
+ /** @internal */
2
+ export declare class Module<T extends new (...args: unknown[]) => unknown> {
3
+ private _name;
4
+ private _promise;
5
+ private _instance;
6
+ private _importFn;
7
+ constructor(_name: keyof ModuleClasses);
8
+ /**
9
+ * Get or create a singleton instance of the module
10
+ * @internal
11
+ */
12
+ getInstance(): Promise<InstanceType<T>>;
13
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @internal
3
+ * This module contains the internal module registry implementation.
4
+ * Do not import directly - use the central export from 'src/modules/index.ts' instead.
5
+ */
6
+ declare global {
7
+ interface ModuleClasses {
8
+ }
9
+ }
10
+ /** @internal */
11
+ declare class ModuleRegistryClass {
12
+ private static _instance;
13
+ private _modules;
14
+ private constructor();
15
+ static get instance(): ModuleRegistryClass;
16
+ /**
17
+ * Register a module
18
+ * @internal
19
+ */
20
+ register<Id extends keyof ModuleClasses>(name: Id): void;
21
+ /**
22
+ * Get a singleton instance of the module
23
+ * @internal
24
+ */
25
+ get<Id extends keyof ModuleClasses>(name: Id): Promise<ModuleClasses[Id]>;
26
+ }
27
+ /** @internal */
28
+ export declare const internalModuleRegistry: ModuleRegistryClass;
29
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";var u=Object.defineProperty;var d=(a,e,t)=>e in a?u(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var l=(a,e,t)=>d(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../systeminfo/SystemInfo.cjs"),s=require("../../../chunks/index-MNP0K5dt.cjs"),m=require("../asset/converter/AssetConverter.cjs"),h=require("../asset/loader/AssetLoader.cjs"),y=require("../asset/exporter/AssetExporter.cjs");class S{constructor(){l(this,"converter",new m.AssetConverter(new h.AssetLoader,new y.AssetExporter))}async launch(e,t){const r=await this.convertToUSDZ(e,t);return this.launchARQuickLook(r,t)}async convertToUSDZ(e,t){const r=await this.converter.convert(e).to("usdz",{quickLookCompatible:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:(t==null?void 0:t.arPlacement)==="vertical"?"vertical":"horizontal"}}}),n=new Blob([r],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(n)}launchARQuickLook(e,t){return new Promise(r=>{(t==null?void 0:t.arScale)==="fixed"&&(e=e.concat("#allowsContentScaling=0"));const n=document.createElement("a");n.innerHTML="<picture></picture>",n.rel="ar",n.href=e,n.download="scene.usdz",r(),n.click()})}}class _{launch(e,t){const r=self.location.toString(),n=document.createElement("a"),c=this._createParams(r,e,t),o=this._createIntent(r,e,c);n.setAttribute("href",o),n.click()}_createParams(e,t,r){const n=new URL(t,e),c=new URLSearchParams(n.search);return c.set("mode","ar_preferred"),this._applyScaleOption(c,r),this._applyPlacementOption(c,r),this._applySoundOption(c,e),this._applyLinkOption(c,e),c}_applyScaleOption(e,t){(t==null?void 0:t.arScale)==="fixed"&&e.set("resizable","false")}_applyPlacementOption(e,t){(t==null?void 0:t.arPlacement)==="vertical"&&e.set("enable_vertical_placement","true")}_applySoundOption(e,t){if(e.has("sound")){const r=new URL(e.get("sound"),t);e.set("sound",r.toString())}}_applyLinkOption(e,t){if(e.has("link")){const r=new URL(e.get("link"),t);e.set("link",r.toString())}}_createIntent(e,t,r){const n=new URL(e),c=new URL(t,e),o="#model-viewer-no-ar-fallback";return n.hash=o,`intent://arvr.google.com/scene-viewer/1.2?${r.toString()+"&file="+c.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(n.toString())};end;`}}class w{async launch(e,t){const r=i.SystemInfo.getSystem();return r===s.ESystem.IOS?this.tryARQuickLook(e,t):r===s.ESystem.ANDROID?this.trySceneViewer(e,t):Promise.reject(new s.ARCompatibilityError("AR not supported on non-mobile systems",window.navigator.userAgent,window.navigator.platform,window.navigator.vendor))}async tryARQuickLook(e,t){try{i.SystemInfo.getSupportsARQuickLook()}catch(r){return Promise.reject(r)}return new S().launch(e,t)}async trySceneViewer(e,t){try{return new _().launch(e,t)}catch(r){return Promise.reject(r)}}}exports.ARSystem=w;
2
+ //# sourceMappingURL=ARSystem.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ARSystem.cjs","sources":["../../../../src/modules/ar/arquicklook/ARQuickLook.ts","../../../../src/modules/ar/sceneviewer/SceneViewer.ts","../../../../src/modules/ar/ARSystem.ts"],"sourcesContent":["import { type ARSystemOptions } from '../ARSystem';\nimport { AssetConverter } from '../../asset/converter/AssetConverter';\nimport { AssetLoader } from '../../asset/loader/AssetLoader';\nimport { AssetExporter } from '../../asset/exporter/AssetExporter';\n\nexport class ARQuickLook {\n private converter = new AssetConverter(\n new AssetLoader(),\n new AssetExporter(),\n );\n\n public async launch(uri: string, options?: ARSystemOptions): Promise<void> {\n const usdzUrl = await this.convertToUSDZ(uri, options);\n return this.launchARQuickLook(usdzUrl, options);\n }\n\n private async convertToUSDZ(\n uri: string,\n options?: ARSystemOptions,\n ): Promise<string> {\n // Convert the file to USDZ format\n const usdzBuffer = await this.converter.convert(uri).to('usdz', {\n quickLookCompatible: true,\n ar: {\n anchoring: { type: 'plane' },\n planeAnchoring: {\n alignment:\n options?.arPlacement === 'vertical'\n ? 'vertical'\n : 'horizontal',\n },\n },\n });\n\n // Create a blob from the USDZ buffer\n const blob = new Blob([usdzBuffer], { type: 'model/vnd.usdz+zip' });\n return URL.createObjectURL(blob);\n }\n\n private launchARQuickLook(\n uri: string,\n options?: ARSystemOptions,\n ): Promise<void> {\n return new Promise((resolve) => {\n if (options?.arScale === 'fixed') {\n uri = uri.concat('#allowsContentScaling=0');\n }\n\n // launch ARQuickLook\n const a = document.createElement('a');\n a.innerHTML = '<picture></picture>'; // This is actually needed so the viewer opens instantly\n a.rel = 'ar';\n a.href = uri;\n a.download = 'scene.usdz';\n resolve();\n a.click();\n });\n }\n}\n","import { type ARSystemOptions } from '../ARSystem';\n\nexport class SceneViewer {\n public launch(uri: string, options?: ARSystemOptions): void {\n const location = self.location.toString();\n const anchor = document.createElement('a');\n const params = this._createParams(location, uri, options);\n const intent = this._createIntent(location, uri, params);\n\n anchor.setAttribute('href', intent);\n anchor.click();\n }\n\n /**\n * Creates the base URL parameters for SceneViewer\n * @param location Current page location URL\n * @returns URLSearchParams with base configuration\n */\n private _createParams(\n location: string,\n uri: string,\n options?: ARSystemOptions,\n ): URLSearchParams {\n const modelUrl = new URL(uri, location);\n const params = new URLSearchParams(modelUrl.search);\n\n // Set AR mode as preferred\n params.set('mode', 'ar_preferred');\n\n // Apply any custom options\n this._applyScaleOption(params, options);\n this._applyPlacementOption(params, options);\n\n // Apply additional parameters if present\n this._applySoundOption(params, location);\n this._applyLinkOption(params, location);\n\n return params;\n }\n\n /**\n * Applies the scale option to the parameters\n * If scale is set to 'fixed', the model will not be resizable in AR\n * @param params URLSearchParams to modify\n */\n private _applyScaleOption(\n params: URLSearchParams,\n options?: ARSystemOptions,\n ): void {\n if (options?.arScale === 'fixed') {\n params.set('resizable', 'false');\n }\n }\n\n /**\n * Applies the placement option to the parameters\n * If placement is set to 'vertical', vertical placement will be enabled\n * @param params URLSearchParams to modify\n */\n private _applyPlacementOption(\n params: URLSearchParams,\n options?: ARSystemOptions,\n ): void {\n if (options?.arPlacement === 'vertical') {\n params.set('enable_vertical_placement', 'true');\n }\n }\n\n /**\n * Applies the sound option to the parameters if present\n * This will resolve any relative sound URLs to absolute URLs\n * @param params URLSearchParams to modify\n * @param location Current page location URL\n */\n private _applySoundOption(params: URLSearchParams, location: string): void {\n if (params.has('sound')) {\n const soundUrl = new URL(params.get('sound')!, location);\n params.set('sound', soundUrl.toString());\n }\n }\n\n /**\n * Applies the link option to the parameters if present\n * This will resolve any relative link URLs to absolute URLs\n * @param params URLSearchParams to modify\n * @param location Current page location URL\n */\n private _applyLinkOption(params: URLSearchParams, location: string): void {\n if (params.has('link')) {\n const linkUrl = new URL(params.get('link')!, location);\n params.set('link', linkUrl.toString());\n }\n }\n\n /**\n * Creates the Android Intent URL for SceneViewer\n * @param params URLSearchParams containing all configuration\n * @param location Current page location URL\n * @returns The complete Intent URL\n */\n private _createIntent(\n location: string,\n uri: string,\n params: URLSearchParams,\n ): string {\n const locationUrl = new URL(location);\n const modelUrl = new URL(uri, location);\n const noArViewerSigil = '#model-viewer-no-ar-fallback';\n\n locationUrl.hash = noArViewerSigil;\n\n // Construct the intent URL with all parameters\n return `intent://arvr.google.com/scene-viewer/1.2?${\n params.toString() + '&file=' + modelUrl.toString()\n }#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(\n locationUrl.toString(),\n )};end;`;\n }\n}\n","import { SystemInfo } from '../systeminfo/SystemInfo';\nimport { ARCompatibilityError } from '../../error';\nimport { ESystem } from '../../types/info';\nimport { ARQuickLook } from './arquicklook/ARQuickLook';\nimport { SceneViewer } from './sceneviewer/SceneViewer';\n\ndeclare global {\n interface ModuleClasses {\n ARSystem: ARSystem;\n }\n}\n\n/**\n * @module ARSystem\n *\n * The AR module enables Augmented Reality features across different platforms:\n *\n * ```ts\n * import { ARSystem } from '@shopware-ag/dive/modules/ar';\n * const arSystem = new ARSystem();\n *\n * // Launch AR with options\n * await arSystem.launch('path/to/model.glb', {\n * arPlacement: 'horizontal', // or 'vertical'\n * arScale: 'auto' // or 'fixed'\n * });\n * ```\n *\n * Features:\n * - Platform-specific AR implementations (ARQuickLook for iOS, SceneViewer for Android)\n * - Automatic format conversion for AR compatibility\n * - Configurable placement and scaling options\n */\n\n/**\n * Options for configuring the AR system behavior\n */\nexport type ARSystemOptions = {\n /** The placement orientation for AR content - either horizontal or vertical */\n arPlacement: 'horizontal' | 'vertical';\n /** The scaling behavior for AR content - either automatic or fixed */\n arScale: 'auto' | 'fixed';\n};\n\n/**\n * Main class for handling AR functionality across different platforms\n * Provides methods to launch AR experiences using platform-specific implementations\n */\nexport class ARSystem {\n /**\n * Launches an AR experience using the appropriate platform-specific implementation\n *\n * @param uri - The URI of the 3D model to display in AR\n * @param options - Optional configuration for the AR experience\n * @returns Promise that resolves when AR is launched successfully\n * @throws Error if AR is not supported on the current platform\n */\n public async launch(uri: string, options?: ARSystemOptions): Promise<void> {\n const system = SystemInfo.getSystem();\n\n if (system === ESystem.IOS) {\n return this.tryARQuickLook(uri, options);\n }\n\n if (system === ESystem.ANDROID) {\n return this.trySceneViewer(uri, options);\n }\n\n return Promise.reject(\n new ARCompatibilityError(\n 'AR not supported on non-mobile systems',\n window.navigator.userAgent,\n window.navigator.platform,\n window.navigator.vendor,\n ),\n );\n }\n\n /**\n * Attempts to launch AR using ARQuickLook (iOS-specific implementation)\n *\n * @param uri - The URI of the 3D model to display in AR\n * @param options - Optional configuration for the AR experience\n * @returns Promise that resolves when ARQuickLook is launched successfully\n * @throws Error if ARQuickLook is not supported on the device\n */\n private async tryARQuickLook(\n uri: string,\n options?: ARSystemOptions,\n ): Promise<void> {\n try {\n SystemInfo.getSupportsARQuickLook();\n } catch (error) {\n return Promise.reject(error);\n }\n\n return new ARQuickLook().launch(uri, options);\n }\n\n /**\n * Launches AR using SceneViewer (Android-specific implementation)\n * Note: SceneViewer is supported on all Android devices. If ARCore is not installed,\n * the model will be displayed in 3D view mode instead of AR mode.\n *\n * @param uri - The URI of the 3D model to display in AR\n * @param options - Optional configuration for the AR experience\n * @returns Promise that resolves when SceneViewer is launched successfully\n * @throws Error if there's an issue launching SceneViewer\n */\n private async trySceneViewer(\n uri: string,\n options?: ARSystemOptions,\n ): Promise<void> {\n try {\n return new SceneViewer().launch(uri, options);\n } catch (error) {\n return Promise.reject(error);\n }\n }\n}\n"],"names":["ARQuickLook","__publicField","AssetConverter","AssetLoader","AssetExporter","uri","options","usdzUrl","usdzBuffer","blob","resolve","a","SceneViewer","location","anchor","params","intent","modelUrl","soundUrl","linkUrl","locationUrl","noArViewerSigil","ARSystem","system","SystemInfo","ESystem","ARCompatibilityError","error"],"mappings":"qeAKO,MAAMA,CAAY,CAAlB,cACKC,EAAA,iBAAY,IAAIC,EAAA,eACpB,IAAIC,cACJ,IAAIC,EAAc,aACtB,GAEA,MAAa,OAAOC,EAAaC,EAA0C,CACvE,MAAMC,EAAU,MAAM,KAAK,cAAcF,EAAKC,CAAO,EAC9C,OAAA,KAAK,kBAAkBC,EAASD,CAAO,CAAA,CAGlD,MAAc,cACVD,EACAC,EACe,CAET,MAAAE,EAAa,MAAM,KAAK,UAAU,QAAQH,CAAG,EAAE,GAAG,OAAQ,CAC5D,oBAAqB,GACrB,GAAI,CACA,UAAW,CAAE,KAAM,OAAQ,EAC3B,eAAgB,CACZ,WACIC,GAAA,YAAAA,EAAS,eAAgB,WACnB,WACA,YAAA,CACd,CACJ,CACH,EAGKG,EAAO,IAAI,KAAK,CAACD,CAAU,EAAG,CAAE,KAAM,qBAAsB,EAC3D,OAAA,IAAI,gBAAgBC,CAAI,CAAA,CAG3B,kBACJJ,EACAC,EACa,CACN,OAAA,IAAI,QAASI,GAAY,EACxBJ,GAAA,YAAAA,EAAS,WAAY,UACfD,EAAAA,EAAI,OAAO,yBAAyB,GAIxC,MAAAM,EAAI,SAAS,cAAc,GAAG,EACpCA,EAAE,UAAY,sBACdA,EAAE,IAAM,KACRA,EAAE,KAAON,EACTM,EAAE,SAAW,aACLD,EAAA,EACRC,EAAE,MAAM,CAAA,CACX,CAAA,CAET,CCxD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I,IAAIZ,EAAKQ,CAAQ,EAChCQ,EAAkB,+BAExB,OAAAD,EAAY,KAAOC,EAGZ,6CACHN,EAAO,SAAS,EAAI,SAAWE,EAAS,UAC5C,iIAAiI,mBAC7HG,EAAY,SAAS,CACxB,CAAA,OAAA,CAET,CCtEO,MAAME,CAAS,CASlB,MAAa,OAAOjB,EAAaC,EAA0C,CACjE,MAAAiB,EAASC,aAAW,UAAU,EAEhC,OAAAD,IAAWE,UAAQ,IACZ,KAAK,eAAepB,EAAKC,CAAO,EAGvCiB,IAAWE,UAAQ,QACZ,KAAK,eAAepB,EAAKC,CAAO,EAGpC,QAAQ,OACX,IAAIoB,EAAA,qBACA,yCACA,OAAO,UAAU,UACjB,OAAO,UAAU,SACjB,OAAO,UAAU,MAAA,CAEzB,CAAA,CAWJ,MAAc,eACVrB,EACAC,EACa,CACT,GAAA,CACAkB,EAAAA,WAAW,uBAAuB,QAC7BG,EAAO,CACL,OAAA,QAAQ,OAAOA,CAAK,CAAA,CAG/B,OAAO,IAAI3B,EAAc,EAAA,OAAOK,EAAKC,CAAO,CAAA,CAahD,MAAc,eACVD,EACAC,EACa,CACT,GAAA,CACA,OAAO,IAAIM,EAAc,EAAA,OAAOP,EAAKC,CAAO,QACvCqB,EAAO,CACL,OAAA,QAAQ,OAAOA,CAAK,CAAA,CAC/B,CAER"}
@@ -1,3 +1,29 @@
1
+ declare global {
2
+ interface ModuleClasses {
3
+ ARSystem: ARSystem;
4
+ }
5
+ }
6
+ /**
7
+ * @module ARSystem
8
+ *
9
+ * The AR module enables Augmented Reality features across different platforms:
10
+ *
11
+ * ```ts
12
+ * import { ARSystem } from '@shopware-ag/dive/modules/ar';
13
+ * const arSystem = new ARSystem();
14
+ *
15
+ * // Launch AR with options
16
+ * await arSystem.launch('path/to/model.glb', {
17
+ * arPlacement: 'horizontal', // or 'vertical'
18
+ * arScale: 'auto' // or 'fixed'
19
+ * });
20
+ * ```
21
+ *
22
+ * Features:
23
+ * - Platform-specific AR implementations (ARQuickLook for iOS, SceneViewer for Android)
24
+ * - Automatic format conversion for AR compatibility
25
+ * - Configurable placement and scaling options
26
+ */
1
27
  /**
2
28
  * Options for configuring the AR system behavior
3
29
  */
@@ -0,0 +1,164 @@
1
+ var u = Object.defineProperty;
2
+ var m = (c, e, t) => e in c ? u(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
3
+ var i = (c, e, t) => m(c, typeof e != "symbol" ? e + "" : e, t);
4
+ import { SystemInfo as l } from "../systeminfo/SystemInfo.mjs";
5
+ import { E as s, A as d } from "../../../chunks/index-C7Wx_9uY.mjs";
6
+ import { AssetConverter as h } from "../asset/converter/AssetConverter.mjs";
7
+ import { AssetLoader as w } from "../asset/loader/AssetLoader.mjs";
8
+ import { AssetExporter as p } from "../asset/exporter/AssetExporter.mjs";
9
+ class y {
10
+ constructor() {
11
+ i(this, "converter", new h(
12
+ new w(),
13
+ new p()
14
+ ));
15
+ }
16
+ async launch(e, t) {
17
+ const r = await this.convertToUSDZ(e, t);
18
+ return this.launchARQuickLook(r, t);
19
+ }
20
+ async convertToUSDZ(e, t) {
21
+ const r = await this.converter.convert(e).to("usdz", {
22
+ quickLookCompatible: !0,
23
+ ar: {
24
+ anchoring: { type: "plane" },
25
+ planeAnchoring: {
26
+ alignment: (t == null ? void 0 : t.arPlacement) === "vertical" ? "vertical" : "horizontal"
27
+ }
28
+ }
29
+ }), n = new Blob([r], { type: "model/vnd.usdz+zip" });
30
+ return URL.createObjectURL(n);
31
+ }
32
+ launchARQuickLook(e, t) {
33
+ return new Promise((r) => {
34
+ (t == null ? void 0 : t.arScale) === "fixed" && (e = e.concat("#allowsContentScaling=0"));
35
+ const n = document.createElement("a");
36
+ n.innerHTML = "<picture></picture>", n.rel = "ar", n.href = e, n.download = "scene.usdz", r(), n.click();
37
+ });
38
+ }
39
+ }
40
+ class S {
41
+ launch(e, t) {
42
+ const r = self.location.toString(), n = document.createElement("a"), a = this._createParams(r, e, t), o = this._createIntent(r, e, a);
43
+ n.setAttribute("href", o), n.click();
44
+ }
45
+ /**
46
+ * Creates the base URL parameters for SceneViewer
47
+ * @param location Current page location URL
48
+ * @returns URLSearchParams with base configuration
49
+ */
50
+ _createParams(e, t, r) {
51
+ const n = new URL(t, e), a = new URLSearchParams(n.search);
52
+ return a.set("mode", "ar_preferred"), this._applyScaleOption(a, r), this._applyPlacementOption(a, r), this._applySoundOption(a, e), this._applyLinkOption(a, e), a;
53
+ }
54
+ /**
55
+ * Applies the scale option to the parameters
56
+ * If scale is set to 'fixed', the model will not be resizable in AR
57
+ * @param params URLSearchParams to modify
58
+ */
59
+ _applyScaleOption(e, t) {
60
+ (t == null ? void 0 : t.arScale) === "fixed" && e.set("resizable", "false");
61
+ }
62
+ /**
63
+ * Applies the placement option to the parameters
64
+ * If placement is set to 'vertical', vertical placement will be enabled
65
+ * @param params URLSearchParams to modify
66
+ */
67
+ _applyPlacementOption(e, t) {
68
+ (t == null ? void 0 : t.arPlacement) === "vertical" && e.set("enable_vertical_placement", "true");
69
+ }
70
+ /**
71
+ * Applies the sound option to the parameters if present
72
+ * This will resolve any relative sound URLs to absolute URLs
73
+ * @param params URLSearchParams to modify
74
+ * @param location Current page location URL
75
+ */
76
+ _applySoundOption(e, t) {
77
+ if (e.has("sound")) {
78
+ const r = new URL(e.get("sound"), t);
79
+ e.set("sound", r.toString());
80
+ }
81
+ }
82
+ /**
83
+ * Applies the link option to the parameters if present
84
+ * This will resolve any relative link URLs to absolute URLs
85
+ * @param params URLSearchParams to modify
86
+ * @param location Current page location URL
87
+ */
88
+ _applyLinkOption(e, t) {
89
+ if (e.has("link")) {
90
+ const r = new URL(e.get("link"), t);
91
+ e.set("link", r.toString());
92
+ }
93
+ }
94
+ /**
95
+ * Creates the Android Intent URL for SceneViewer
96
+ * @param params URLSearchParams containing all configuration
97
+ * @param location Current page location URL
98
+ * @returns The complete Intent URL
99
+ */
100
+ _createIntent(e, t, r) {
101
+ const n = new URL(e), a = new URL(t, e), o = "#model-viewer-no-ar-fallback";
102
+ return n.hash = o, `intent://arvr.google.com/scene-viewer/1.2?${r.toString() + "&file=" + a.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(
103
+ n.toString()
104
+ )};end;`;
105
+ }
106
+ }
107
+ class A {
108
+ /**
109
+ * Launches an AR experience using the appropriate platform-specific implementation
110
+ *
111
+ * @param uri - The URI of the 3D model to display in AR
112
+ * @param options - Optional configuration for the AR experience
113
+ * @returns Promise that resolves when AR is launched successfully
114
+ * @throws Error if AR is not supported on the current platform
115
+ */
116
+ async launch(e, t) {
117
+ const r = l.getSystem();
118
+ return r === s.IOS ? this.tryARQuickLook(e, t) : r === s.ANDROID ? this.trySceneViewer(e, t) : Promise.reject(
119
+ new d(
120
+ "AR not supported on non-mobile systems",
121
+ window.navigator.userAgent,
122
+ window.navigator.platform,
123
+ window.navigator.vendor
124
+ )
125
+ );
126
+ }
127
+ /**
128
+ * Attempts to launch AR using ARQuickLook (iOS-specific implementation)
129
+ *
130
+ * @param uri - The URI of the 3D model to display in AR
131
+ * @param options - Optional configuration for the AR experience
132
+ * @returns Promise that resolves when ARQuickLook is launched successfully
133
+ * @throws Error if ARQuickLook is not supported on the device
134
+ */
135
+ async tryARQuickLook(e, t) {
136
+ try {
137
+ l.getSupportsARQuickLook();
138
+ } catch (r) {
139
+ return Promise.reject(r);
140
+ }
141
+ return new y().launch(e, t);
142
+ }
143
+ /**
144
+ * Launches AR using SceneViewer (Android-specific implementation)
145
+ * Note: SceneViewer is supported on all Android devices. If ARCore is not installed,
146
+ * the model will be displayed in 3D view mode instead of AR mode.
147
+ *
148
+ * @param uri - The URI of the 3D model to display in AR
149
+ * @param options - Optional configuration for the AR experience
150
+ * @returns Promise that resolves when SceneViewer is launched successfully
151
+ * @throws Error if there's an issue launching SceneViewer
152
+ */
153
+ async trySceneViewer(e, t) {
154
+ try {
155
+ return new S().launch(e, t);
156
+ } catch (r) {
157
+ return Promise.reject(r);
158
+ }
159
+ }
160
+ }
161
+ export {
162
+ A as ARSystem
163
+ };
164
+ //# sourceMappingURL=ARSystem.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ARSystem.mjs","sources":["../../../../src/modules/ar/arquicklook/ARQuickLook.ts","../../../../src/modules/ar/sceneviewer/SceneViewer.ts","../../../../src/modules/ar/ARSystem.ts"],"sourcesContent":["import { type ARSystemOptions } from '../ARSystem';\nimport { AssetConverter } from '../../asset/converter/AssetConverter';\nimport { AssetLoader } from '../../asset/loader/AssetLoader';\nimport { AssetExporter } from '../../asset/exporter/AssetExporter';\n\nexport class ARQuickLook {\n private converter = new AssetConverter(\n new AssetLoader(),\n new AssetExporter(),\n );\n\n public async launch(uri: string, options?: ARSystemOptions): Promise<void> {\n const usdzUrl = await this.convertToUSDZ(uri, options);\n return this.launchARQuickLook(usdzUrl, options);\n }\n\n private async convertToUSDZ(\n uri: string,\n options?: ARSystemOptions,\n ): Promise<string> {\n // Convert the file to USDZ format\n const usdzBuffer = await this.converter.convert(uri).to('usdz', {\n quickLookCompatible: true,\n ar: {\n anchoring: { type: 'plane' },\n planeAnchoring: {\n alignment:\n options?.arPlacement === 'vertical'\n ? 'vertical'\n : 'horizontal',\n },\n },\n });\n\n // Create a blob from the USDZ buffer\n const blob = new Blob([usdzBuffer], { type: 'model/vnd.usdz+zip' });\n return URL.createObjectURL(blob);\n }\n\n private launchARQuickLook(\n uri: string,\n options?: ARSystemOptions,\n ): Promise<void> {\n return new Promise((resolve) => {\n if (options?.arScale === 'fixed') {\n uri = uri.concat('#allowsContentScaling=0');\n }\n\n // launch ARQuickLook\n const a = document.createElement('a');\n a.innerHTML = '<picture></picture>'; // This is actually needed so the viewer opens instantly\n a.rel = 'ar';\n a.href = uri;\n a.download = 'scene.usdz';\n resolve();\n a.click();\n });\n }\n}\n","import { type ARSystemOptions } from '../ARSystem';\n\nexport class SceneViewer {\n public launch(uri: string, options?: ARSystemOptions): void {\n const location = self.location.toString();\n const anchor = document.createElement('a');\n const params = this._createParams(location, uri, options);\n const intent = this._createIntent(location, uri, params);\n\n anchor.setAttribute('href', intent);\n anchor.click();\n }\n\n /**\n * Creates the base URL parameters for SceneViewer\n * @param location Current page location URL\n * @returns URLSearchParams with base configuration\n */\n private _createParams(\n location: string,\n uri: string,\n options?: ARSystemOptions,\n ): URLSearchParams {\n const modelUrl = new URL(uri, location);\n const params = new URLSearchParams(modelUrl.search);\n\n // Set AR mode as preferred\n params.set('mode', 'ar_preferred');\n\n // Apply any custom options\n this._applyScaleOption(params, options);\n this._applyPlacementOption(params, options);\n\n // Apply additional parameters if present\n this._applySoundOption(params, location);\n this._applyLinkOption(params, location);\n\n return params;\n }\n\n /**\n * Applies the scale option to the parameters\n * If scale is set to 'fixed', the model will not be resizable in AR\n * @param params URLSearchParams to modify\n */\n private _applyScaleOption(\n params: URLSearchParams,\n options?: ARSystemOptions,\n ): void {\n if (options?.arScale === 'fixed') {\n params.set('resizable', 'false');\n }\n }\n\n /**\n * Applies the placement option to the parameters\n * If placement is set to 'vertical', vertical placement will be enabled\n * @param params URLSearchParams to modify\n */\n private _applyPlacementOption(\n params: URLSearchParams,\n options?: ARSystemOptions,\n ): void {\n if (options?.arPlacement === 'vertical') {\n params.set('enable_vertical_placement', 'true');\n }\n }\n\n /**\n * Applies the sound option to the parameters if present\n * This will resolve any relative sound URLs to absolute URLs\n * @param params URLSearchParams to modify\n * @param location Current page location URL\n */\n private _applySoundOption(params: URLSearchParams, location: string): void {\n if (params.has('sound')) {\n const soundUrl = new URL(params.get('sound')!, location);\n params.set('sound', soundUrl.toString());\n }\n }\n\n /**\n * Applies the link option to the parameters if present\n * This will resolve any relative link URLs to absolute URLs\n * @param params URLSearchParams to modify\n * @param location Current page location URL\n */\n private _applyLinkOption(params: URLSearchParams, location: string): void {\n if (params.has('link')) {\n const linkUrl = new URL(params.get('link')!, location);\n params.set('link', linkUrl.toString());\n }\n }\n\n /**\n * Creates the Android Intent URL for SceneViewer\n * @param params URLSearchParams containing all configuration\n * @param location Current page location URL\n * @returns The complete Intent URL\n */\n private _createIntent(\n location: string,\n uri: string,\n params: URLSearchParams,\n ): string {\n const locationUrl = new URL(location);\n const modelUrl = new URL(uri, location);\n const noArViewerSigil = '#model-viewer-no-ar-fallback';\n\n locationUrl.hash = noArViewerSigil;\n\n // Construct the intent URL with all parameters\n return `intent://arvr.google.com/scene-viewer/1.2?${\n params.toString() + '&file=' + modelUrl.toString()\n }#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(\n locationUrl.toString(),\n )};end;`;\n }\n}\n","import { SystemInfo } from '../systeminfo/SystemInfo';\nimport { ARCompatibilityError } from '../../error';\nimport { ESystem } from '../../types/info';\nimport { ARQuickLook } from './arquicklook/ARQuickLook';\nimport { SceneViewer } from './sceneviewer/SceneViewer';\n\ndeclare global {\n interface ModuleClasses {\n ARSystem: ARSystem;\n }\n}\n\n/**\n * @module ARSystem\n *\n * The AR module enables Augmented Reality features across different platforms:\n *\n * ```ts\n * import { ARSystem } from '@shopware-ag/dive/modules/ar';\n * const arSystem = new ARSystem();\n *\n * // Launch AR with options\n * await arSystem.launch('path/to/model.glb', {\n * arPlacement: 'horizontal', // or 'vertical'\n * arScale: 'auto' // or 'fixed'\n * });\n * ```\n *\n * Features:\n * - Platform-specific AR implementations (ARQuickLook for iOS, SceneViewer for Android)\n * - Automatic format conversion for AR compatibility\n * - Configurable placement and scaling options\n */\n\n/**\n * Options for configuring the AR system behavior\n */\nexport type ARSystemOptions = {\n /** The placement orientation for AR content - either horizontal or vertical */\n arPlacement: 'horizontal' | 'vertical';\n /** The scaling behavior for AR content - either automatic or fixed */\n arScale: 'auto' | 'fixed';\n};\n\n/**\n * Main class for handling AR functionality across different platforms\n * Provides methods to launch AR experiences using platform-specific implementations\n */\nexport class ARSystem {\n /**\n * Launches an AR experience using the appropriate platform-specific implementation\n *\n * @param uri - The URI of the 3D model to display in AR\n * @param options - Optional configuration for the AR experience\n * @returns Promise that resolves when AR is launched successfully\n * @throws Error if AR is not supported on the current platform\n */\n public async launch(uri: string, options?: ARSystemOptions): Promise<void> {\n const system = SystemInfo.getSystem();\n\n if (system === ESystem.IOS) {\n return this.tryARQuickLook(uri, options);\n }\n\n if (system === ESystem.ANDROID) {\n return this.trySceneViewer(uri, options);\n }\n\n return Promise.reject(\n new ARCompatibilityError(\n 'AR not supported on non-mobile systems',\n window.navigator.userAgent,\n window.navigator.platform,\n window.navigator.vendor,\n ),\n );\n }\n\n /**\n * Attempts to launch AR using ARQuickLook (iOS-specific implementation)\n *\n * @param uri - The URI of the 3D model to display in AR\n * @param options - Optional configuration for the AR experience\n * @returns Promise that resolves when ARQuickLook is launched successfully\n * @throws Error if ARQuickLook is not supported on the device\n */\n private async tryARQuickLook(\n uri: string,\n options?: ARSystemOptions,\n ): Promise<void> {\n try {\n SystemInfo.getSupportsARQuickLook();\n } catch (error) {\n return Promise.reject(error);\n }\n\n return new ARQuickLook().launch(uri, options);\n }\n\n /**\n * Launches AR using SceneViewer (Android-specific implementation)\n * Note: SceneViewer is supported on all Android devices. If ARCore is not installed,\n * the model will be displayed in 3D view mode instead of AR mode.\n *\n * @param uri - The URI of the 3D model to display in AR\n * @param options - Optional configuration for the AR experience\n * @returns Promise that resolves when SceneViewer is launched successfully\n * @throws Error if there's an issue launching SceneViewer\n */\n private async trySceneViewer(\n uri: string,\n options?: ARSystemOptions,\n ): Promise<void> {\n try {\n return new SceneViewer().launch(uri, options);\n } catch (error) {\n return Promise.reject(error);\n }\n }\n}\n"],"names":["ARQuickLook","__publicField","AssetConverter","AssetLoader","AssetExporter","uri","options","usdzUrl","usdzBuffer","blob","resolve","a","SceneViewer","location","anchor","params","intent","modelUrl","soundUrl","linkUrl","locationUrl","noArViewerSigil","ARSystem","system","SystemInfo","ESystem","ARCompatibilityError","error"],"mappings":";;;;;;;;AAKO,MAAMA,EAAY;AAAA,EAAlB;AACK,IAAAC,EAAA,mBAAY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export declare class ARQuickLook {
3
+ private converter;
3
4
  launch(uri: string, options?: ARSystemOptions): Promise<void>;
4
5
  private convertToUSDZ;
5
6
  private launchARQuickLook;
@@ -1,4 +1,4 @@
1
- import { ARSystemOptions } from '../AR';
1
+ import { ARSystemOptions } from '../ARSystem';
2
2
  export declare class SceneViewer {
3
3
  launch(uri: string, options?: ARSystemOptions): void;
4
4
  /**