@shopware-ag/dive 1.18.5-beta.2 → 1.18.5-beta.3

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 (34) hide show
  1. package/build/AR-BzVanQ-t.js +722 -0
  2. package/build/AR-BzVanQ-t.js.map +1 -0
  3. package/build/AR-ySzrfSW3.cjs +2 -0
  4. package/build/AR-ySzrfSW3.cjs.map +1 -0
  5. package/build/IO-BTWL9Zfp.cjs +19 -0
  6. package/build/IO-BTWL9Zfp.cjs.map +1 -0
  7. package/build/{IO-BgiJzKrU.js → IO-CYzpSt1J.js} +257 -225
  8. package/build/IO-CYzpSt1J.js.map +1 -0
  9. package/build/{MediaCreator-4zmvmUWH.js → MediaCreator-BFa3Xfwk.js} +2 -2
  10. package/build/{MediaCreator-4zmvmUWH.js.map → MediaCreator-BFa3Xfwk.js.map} +1 -1
  11. package/build/{MediaCreator-BNxZVYyZ.cjs → MediaCreator-BqLcaXbl.cjs} +2 -2
  12. package/build/{MediaCreator-BNxZVYyZ.cjs.map → MediaCreator-BqLcaXbl.cjs.map} +1 -1
  13. package/build/{dive-_-yiZbhn.cjs → dive-BTQZqHRt.cjs} +3 -3
  14. package/build/{dive-_-yiZbhn.cjs.map → dive-BTQZqHRt.cjs.map} +1 -1
  15. package/build/{dive-Mi8g8Khn.js → dive-Dk0rFfvA.js} +35 -35
  16. package/build/{dive-Mi8g8Khn.js.map → dive-Dk0rFfvA.js.map} +1 -1
  17. package/build/dive.cjs +1 -1
  18. package/build/dive.js +1 -1
  19. package/build/src/ar/arquicklook/ARQuickLook.d.ts +2 -3
  20. package/package.json +1 -1
  21. package/src/ar/arquicklook/ARQuickLook.ts +75 -48
  22. package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +45 -80
  23. package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -12
  24. package/build/AR-B-g0updz.js +0 -1450
  25. package/build/AR-B-g0updz.js.map +0 -1
  26. package/build/AR-BWQebw6-.cjs +0 -153
  27. package/build/AR-BWQebw6-.cjs.map +0 -1
  28. package/build/IO-BgiJzKrU.js.map +0 -1
  29. package/build/IO-CuYml7Y5.cjs +0 -2
  30. package/build/IO-CuYml7Y5.cjs.map +0 -1
  31. package/build/TextureUtils-CxpuVgwF.js +0 -38
  32. package/build/TextureUtils-CxpuVgwF.js.map +0 -1
  33. package/build/TextureUtils-DNG-yR77.cjs +0 -19
  34. package/build/TextureUtils-DNG-yR77.cjs.map +0 -1
package/build/dive.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./dive-_-yiZbhn.cjs");exports.DIVE=e.DIVE;exports.DIVECommunication=e.DIVECommunication;exports.DIVEDefaultSettings=e.DIVEDefaultSettings;exports.DIVEMath=e.DIVEMath;exports.default=e.DIVE;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./dive-BTQZqHRt.cjs");exports.DIVE=e.DIVE;exports.DIVECommunication=e.DIVECommunication;exports.DIVEDefaultSettings=e.DIVEDefaultSettings;exports.DIVEMath=e.DIVEMath;exports.default=e.DIVE;
2
2
  //# sourceMappingURL=dive.cjs.map
package/build/dive.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as s, E as D, z as E, F as e, A as o } from "./dive-Mi8g8Khn.js";
1
+ import { A as s, E as D, z as E, F as e, A as o } from "./dive-Dk0rFfvA.js";
2
2
  export {
3
3
  s as DIVE,
4
4
  D as DIVECommunication,
@@ -1,8 +1,7 @@
1
1
  import { DIVEScene } from '../../scene/Scene';
2
2
  import { DIVEAROptions } from '../AR';
3
3
  export declare class DIVEARQuickLook {
4
- private static _usdzExporter;
5
4
  static Launch(scene: DIVEScene, options?: DIVEAROptions): Promise<void>;
6
- private static extractModels;
7
- private static launchARFromNode;
5
+ private static launchARQuickLook;
6
+ private static findARQuickLookSrc;
8
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/dive",
3
- "version": "1.18.5-beta.2",
3
+ "version": "1.18.5-beta.3",
4
4
  "description": "Shopware Spatial Framework",
5
5
  "type": "module",
6
6
  "main": "build/dive.cjs",
@@ -1,66 +1,93 @@
1
- import { Object3D } from 'three';
2
- import { DIVEUSDZExporter } from '../../exporters/usdz/USDZExporter';
3
1
  import { type DIVEScene } from '../../scene/Scene';
4
2
  import { type DIVEAROptions } from '../AR';
5
3
 
6
4
  export class DIVEARQuickLook {
7
- private static _usdzExporter: DIVEUSDZExporter = new DIVEUSDZExporter();
8
-
9
5
  public static Launch(
10
6
  scene: DIVEScene,
11
7
  options?: DIVEAROptions,
12
8
  ): Promise<void> {
13
- // create node to build usdz from
14
- const quickLookScene = new Object3D();
15
-
16
- // extract models from scene
17
- const rootCopy = scene.Root.clone(true);
18
-
19
- quickLookScene.add(...rootCopy.children);
9
+ const url = this.findARQuickLookSrc(scene);
20
10
 
21
11
  // launch ARQuickLook
22
- return this.launchARFromNode(quickLookScene, options);
12
+ return this.launchARQuickLook(url, options);
23
13
  }
24
14
 
25
- private static extractModels(scene: DIVEScene): Object3D[] {
26
- // extract models
27
- return scene.Root.children;
28
- }
29
-
30
- private static launchARFromNode(
31
- node: Object3D,
15
+ private static launchARQuickLook(
16
+ uri: string,
32
17
  options?: DIVEAROptions,
33
18
  ): Promise<void> {
34
- // bundle USDZ
35
- return this._usdzExporter
36
- .parse(node, {
37
- quickLookCompatible: true,
38
- ar: {
39
- anchoring: { type: 'plane' },
40
- planeAnchoring: {
41
- alignment:
42
- options?.arPlacement === 'vertical'
43
- ? 'vertical'
44
- : 'horizontal',
45
- },
46
- },
47
- })
48
- .then((usdz: Uint8Array) => {
49
- // create blob
50
- const blob = new Blob([usdz], { type: 'model/vnd.usdz+zip' });
51
- let url = URL.createObjectURL(blob);
19
+ return new Promise((resolve) => {
20
+ if (options?.arScale === 'fixed') {
21
+ uri = uri.concat('#allowsContentScaling=0');
22
+ }
23
+
24
+ // launch ARQuickLook
25
+ const a = document.createElement('a');
26
+ a.innerHTML = '<picture></picture>'; // This is actually needed so the viewer opens instantly
27
+ a.rel = 'ar';
28
+ a.href = uri;
29
+ a.download = 'scene.usdz';
30
+ resolve();
31
+ a.click();
32
+ });
33
+ }
52
34
 
53
- if (options?.arScale === 'fixed') {
54
- url = url.concat('#allowsContentScaling=0');
55
- }
35
+ private static findARQuickLookSrc(scene: DIVEScene): string {
36
+ let uri: string | null = null;
56
37
 
57
- // launch ARQuickLook
58
- const a = document.createElement('a');
59
- a.innerHTML = '<picture></picture>'; // This is actually needed so the viewer opens instantly
60
- a.rel = 'ar';
61
- a.href = url;
62
- a.download = 'scene.usdz';
63
- a.click();
64
- });
38
+ scene.traverse((object) => {
39
+ if (uri) return;
40
+ if (object.userData.uri) {
41
+ uri = object.userData.uri;
42
+ }
43
+ });
44
+
45
+ if (!uri) {
46
+ throw new Error('No model found in scene');
47
+ }
48
+
49
+ return uri;
65
50
  }
51
+
52
+ // private static extractModels(scene: DIVEScene): Object3D[] {
53
+ // // extract models
54
+ // return scene.Root.children;
55
+ // }
56
+
57
+ // private static launchARFromNode(
58
+ // node: Object3D,
59
+ // options?: DIVEAROptions,
60
+ // ): Promise<void> {
61
+ // // bundle USDZ
62
+ // return this._usdzExporter
63
+ // .parse(node, {
64
+ // quickLookCompatible: true,
65
+ // ar: {
66
+ // anchoring: { type: 'plane' },
67
+ // planeAnchoring: {
68
+ // alignment:
69
+ // options?.arPlacement === 'vertical'
70
+ // ? 'vertical'
71
+ // : 'horizontal',
72
+ // },
73
+ // },
74
+ // })
75
+ // .then((usdz: Uint8Array) => {
76
+ // // create blob
77
+ // const blob = new Blob([usdz], { type: 'model/vnd.usdz+zip' });
78
+ // let url = URL.createObjectURL(blob);
79
+
80
+ // if (options?.arScale === 'fixed') {
81
+ // url = url.concat('#allowsContentScaling=0');
82
+ // }
83
+
84
+ // // launch ARQuickLook
85
+ // const a = document.createElement('a');
86
+ // a.innerHTML = '<picture></picture>'; // This is actually needed so the viewer opens instantly
87
+ // a.rel = 'ar';
88
+ // a.href = url;
89
+ // a.download = 'scene.usdz';
90
+ // a.click();
91
+ // });
92
+ // }
66
93
  }
@@ -1,16 +1,22 @@
1
- import { Object3D } from 'three';
1
+ import { Box3, Color, Euler, Mesh, Object3D, Vector3 } from 'three';
2
2
  import { DIVEScene } from '../../../scene/Scene';
3
3
  import { DIVEAROptions } from '../../AR';
4
4
  import { DIVEARQuickLook } from '../ARQuickLook';
5
5
 
6
- jest.mock('../../../exporters/usdz/USDZExporter', () => {
6
+ jest.mock('../../../scene/Scene', () => {
7
7
  return {
8
- DIVEUSDZExporter: jest.fn().mockImplementation(() => {
9
- return {
10
- parse: jest.fn(() => {
11
- return Promise.resolve(new Uint8Array());
12
- }),
8
+ DIVEScene: jest.fn(function () {
9
+ this.add = jest.fn();
10
+ this.children = [];
11
+ this.Root = {
12
+ children: [],
13
13
  };
14
+ this.traverse = jest.fn((callback) => {
15
+ this.Root.children.forEach((child: Object3D) => {
16
+ callback(child);
17
+ });
18
+ });
19
+ return this;
14
20
  }),
15
21
  };
16
22
  });
@@ -26,10 +32,12 @@ describe('DIVEARQuickLook', () => {
26
32
  mockModels = [
27
33
  new Object3D(),
28
34
  new Object3D(),
35
+ new Object3D(),
29
36
  ];
30
- mockScene = {
31
- Root: new Object3D(),
32
- } as DIVEScene;
37
+ mockModels[1].userData = {
38
+ uri: 'https://example.com',
39
+ };
40
+ mockScene = new DIVEScene();
33
41
  mockOptions = {
34
42
  arPlacement: 'horizontal',
35
43
  arScale: 'auto',
@@ -41,88 +49,45 @@ describe('DIVEARQuickLook', () => {
41
49
  expect(DIVEARQuickLook.Launch).toBeInstanceOf(Function);
42
50
  });
43
51
 
44
- it('should return a promise', () => {
45
- expect(
46
- DIVEARQuickLook.Launch(mockScene, mockOptions),
47
- ).toBeInstanceOf(Promise);
48
- });
49
-
50
- it('should not throw when called without options', () => {
51
- const usdzParseSpy = jest.spyOn(
52
- DIVEARQuickLook['_usdzExporter'],
53
- 'parse',
54
- );
55
-
56
- expect(
57
- async () => await DIVEARQuickLook.Launch(mockScene),
58
- ).not.toThrow();
59
-
60
- expect(usdzParseSpy).toHaveBeenCalled();
61
- });
62
-
63
- it('should not throw when called with empty scene', () => {
64
- const usdzParseSpy = jest.spyOn(
65
- DIVEARQuickLook['_usdzExporter'],
66
- 'parse',
67
- );
68
-
69
- expect(
70
- async () =>
71
- await DIVEARQuickLook.Launch(mockScene, mockOptions),
72
- ).not.toThrow();
52
+ it('should not throw without options', () => {
53
+ mockScene.Root.children = mockModels;
73
54
 
74
- expect(usdzParseSpy).toHaveBeenCalled();
55
+ expect(() => {
56
+ DIVEARQuickLook.Launch(mockScene);
57
+ }).not.toThrow();
75
58
  });
76
59
 
77
- it('should not throw when called with filled scene', () => {
78
- const usdzParseSpy = jest.spyOn(
79
- DIVEARQuickLook['_usdzExporter'],
80
- 'parse',
81
- );
82
-
60
+ it('should not throw with options', () => {
83
61
  mockScene.Root.children = mockModels;
84
62
 
85
- expect(
86
- async () =>
87
- await DIVEARQuickLook.Launch(mockScene, mockOptions),
88
- ).not.toThrow();
89
-
90
- expect(usdzParseSpy).toHaveBeenCalled();
63
+ expect(() => {
64
+ DIVEARQuickLook.Launch(mockScene, mockOptions);
65
+ }).not.toThrow();
91
66
  });
92
67
 
93
- it('should pass options to exporter', async () => {
94
- const usdzParseSpy = jest.spyOn(
95
- DIVEARQuickLook['_usdzExporter'],
96
- 'parse',
97
- );
98
-
99
- mockOptions.arPlacement = 'vertical';
100
- mockOptions.arScale = 'fixed';
68
+ it('should not throw with alternated options', () => {
69
+ mockScene.Root.children = mockModels;
101
70
 
102
- await DIVEARQuickLook.Launch(mockScene, mockOptions);
71
+ mockOptions = {
72
+ arPlacement: 'vertical',
73
+ arScale: 'fixed',
74
+ } as DIVEAROptions;
103
75
 
104
- expect(usdzParseSpy).toHaveBeenCalledWith(expect.any(Object3D), {
105
- quickLookCompatible: true,
106
- ar: {
107
- anchoring: { type: 'plane' },
108
- planeAnchoring: {
109
- alignment: 'vertical',
110
- },
111
- },
112
- });
76
+ expect(() => {
77
+ DIVEARQuickLook.Launch(mockScene, mockOptions);
78
+ }).not.toThrow();
113
79
  });
114
80
 
115
- it('should reject when USDZExporter fails', async () => {
116
- const usdzParseSpy = jest.spyOn(
117
- DIVEARQuickLook['_usdzExporter'],
118
- 'parse',
119
- );
120
-
121
- usdzParseSpy.mockReturnValueOnce(Promise.reject());
81
+ it('should throw if no url is found', () => {
82
+ mockScene.Root.children = [
83
+ new Object3D(),
84
+ new Object3D(),
85
+ new Object3D(),
86
+ ];
122
87
 
123
- await expect(
124
- DIVEARQuickLook.Launch(mockScene, mockOptions),
125
- ).rejects.toBeUndefined();
88
+ expect(() => {
89
+ DIVEARQuickLook.Launch(mockScene, mockOptions);
90
+ }).toThrow();
126
91
  });
127
92
  });
128
93
  });
@@ -21,18 +21,6 @@ jest.mock('../../../scene/Scene', () => {
21
21
  };
22
22
  });
23
23
 
24
- jest.mock('../../../exporters/usdz/USDZExporter', () => {
25
- return {
26
- DIVEUSDZExporter: jest.fn().mockImplementation(() => {
27
- return {
28
- parse: jest.fn(() => {
29
- return Promise.resolve(new Uint8Array());
30
- }),
31
- };
32
- }),
33
- };
34
- });
35
-
36
24
  URL.createObjectURL = jest.fn(() => 'blob:http://localhost:8080/');
37
25
 
38
26
  describe('DIVESceneViewer', () => {