@shopware-ag/dive 1.18.5-beta.1 → 1.18.5-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 (32) hide show
  1. package/build/{AR-B6LRgTEL.js → AR-B-g0updz.js} +293 -325
  2. package/build/AR-B-g0updz.js.map +1 -0
  3. package/build/AR-BWQebw6-.cjs +153 -0
  4. package/build/AR-BWQebw6-.cjs.map +1 -0
  5. package/build/IO-BgiJzKrU.js +1257 -0
  6. package/build/IO-BgiJzKrU.js.map +1 -0
  7. package/build/IO-CuYml7Y5.cjs +2 -0
  8. package/build/IO-CuYml7Y5.cjs.map +1 -0
  9. package/build/MediaCreator-4zmvmUWH.js +22 -0
  10. package/build/MediaCreator-4zmvmUWH.js.map +1 -0
  11. package/build/MediaCreator-BNxZVYyZ.cjs +2 -0
  12. package/build/MediaCreator-BNxZVYyZ.cjs.map +1 -0
  13. package/build/TextureUtils-CxpuVgwF.js +38 -0
  14. package/build/TextureUtils-CxpuVgwF.js.map +1 -0
  15. package/build/TextureUtils-DNG-yR77.cjs +19 -0
  16. package/build/TextureUtils-DNG-yR77.cjs.map +1 -0
  17. package/build/{dive-BmDCwQRo.js → dive-Mi8g8Khn.js} +2755 -2714
  18. package/build/{dive-BmDCwQRo.js.map → dive-Mi8g8Khn.js.map} +1 -1
  19. package/build/{dive-C-5_QywE.cjs → dive-_-yiZbhn.cjs} +184 -184
  20. package/build/{dive-C-5_QywE.cjs.map → dive-_-yiZbhn.cjs.map} +1 -1
  21. package/build/dive.cjs +1 -1
  22. package/build/dive.js +3 -3
  23. package/build/src/com/actions/media/generatemedia.d.ts +2 -3
  24. package/package.json +1 -1
  25. package/src/ar/arquicklook/ARQuickLook.ts +3 -1
  26. package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +1 -1
  27. package/src/com/Communication.ts +53 -23
  28. package/src/com/__test__/Communication.test.ts +16 -8
  29. package/src/com/actions/media/generatemedia.ts +2 -3
  30. package/build/AR-B6LRgTEL.js.map +0 -1
  31. package/build/AR-YJZL1lm5.cjs +0 -170
  32. package/build/AR-YJZL1lm5.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-C-5_QywE.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-_-yiZbhn.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,9 +1,9 @@
1
- import { k as s, l as D, j as e, m, k as o } from "./dive-BmDCwQRo.js";
1
+ import { A as s, E as D, z as E, F as e, A as o } from "./dive-Mi8g8Khn.js";
2
2
  export {
3
3
  s as DIVE,
4
4
  D as DIVECommunication,
5
- e as DIVEDefaultSettings,
6
- m as DIVEMath,
5
+ E as DIVEDefaultSettings,
6
+ e as DIVEMath,
7
7
  o as default
8
8
  };
9
9
  //# sourceMappingURL=dive.js.map
@@ -1,6 +1,6 @@
1
1
  import { Vector3Like } from 'three';
2
2
  export default interface GENERATE_MEDIA {
3
- DESCRIPTION: 'Generates a screenshot, stores it in a Blob and writes the URL into the payload.';
3
+ DESCRIPTION: 'Generates a screenshot, stores it in a Blob and returns a Promise of a valid URI.';
4
4
  PAYLOAD: ({
5
5
  position: Vector3Like;
6
6
  target: Vector3Like;
@@ -9,7 +9,6 @@ export default interface GENERATE_MEDIA {
9
9
  }) & {
10
10
  width: number;
11
11
  height: number;
12
- dataUri: string;
13
12
  };
14
- RETURN: boolean;
13
+ RETURN: Promise<string>;
15
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/dive",
3
- "version": "1.18.5-beta.1",
3
+ "version": "1.18.5-beta.2",
4
4
  "description": "Shopware Spatial Framework",
5
5
  "type": "module",
6
6
  "main": "build/dive.cjs",
@@ -14,7 +14,9 @@ export class DIVEARQuickLook {
14
14
  const quickLookScene = new Object3D();
15
15
 
16
16
  // extract models from scene
17
- quickLookScene.add(...this.extractModels(scene));
17
+ const rootCopy = scene.Root.clone(true);
18
+
19
+ quickLookScene.add(...rootCopy.children);
18
20
 
19
21
  // launch ARQuickLook
20
22
  return this.launchARFromNode(quickLookScene, options);
@@ -1,4 +1,4 @@
1
- import { Box3, Color, Euler, Mesh, Object3D, Vector3 } from 'three';
1
+ import { Object3D } from 'three';
2
2
  import { DIVEScene } from '../../../scene/Scene';
3
3
  import { DIVEAROptions } from '../../AR';
4
4
  import { DIVEARQuickLook } from '../ARQuickLook';
@@ -75,27 +75,51 @@ export class DIVECommunication {
75
75
  private toolbox: DIVEToolbox;
76
76
 
77
77
  private _mediaGenerator: DIVEMediaCreator | null;
78
- private get mediaGenerator(): DIVEMediaCreator {
78
+ private get mediaGenerator(): Promise<DIVEMediaCreator> {
79
79
  if (!this._mediaGenerator) {
80
- const DIVEMediaCreator = require('../mediacreator/MediaCreator.ts')
81
- .DIVEMediaCreator as typeof import('../mediacreator/MediaCreator.ts').DIVEMediaCreator;
82
- this._mediaGenerator = new DIVEMediaCreator(
83
- this.renderer,
84
- this.scene,
85
- this.controller,
86
- );
80
+ return new Promise((resolve, reject) => {
81
+ import('../mediacreator/MediaCreator.ts')
82
+ .then((module) => {
83
+ const DIVEMediaCreator = module.DIVEMediaCreator;
84
+ this._mediaGenerator = new DIVEMediaCreator(
85
+ this.renderer,
86
+ this.scene,
87
+ this.controller,
88
+ );
89
+ resolve(this._mediaGenerator);
90
+ })
91
+ .catch((error) => {
92
+ console.error(
93
+ 'DIVE: Error while lazy-loading IO module:',
94
+ error,
95
+ );
96
+ reject(error);
97
+ });
98
+ });
87
99
  }
88
- return this._mediaGenerator;
100
+ return Promise.resolve(this._mediaGenerator);
89
101
  }
90
102
 
91
103
  private _io: DIVEIO | null;
92
- private get io(): DIVEIO {
104
+ private get io(): Promise<DIVEIO> {
93
105
  if (!this._io) {
94
- const DIVEIO = require('../io/IO.ts')
95
- .DIVEIO as typeof import('../io/IO.ts').DIVEIO;
96
- this._io = new DIVEIO(this.scene);
106
+ return new Promise((resolve, reject) => {
107
+ import('../io/IO.ts')
108
+ .then((module) => {
109
+ const DIVEIO = module.DIVEIO;
110
+ this._io = new DIVEIO(this.scene);
111
+ resolve(this._io);
112
+ })
113
+ .catch((error) => {
114
+ console.error(
115
+ 'DIVE: Error while lazy-loading IO module:',
116
+ error,
117
+ );
118
+ reject(error);
119
+ });
120
+ });
97
121
  }
98
- return this._io;
122
+ return Promise.resolve(this._io);
99
123
  }
100
124
 
101
125
  private _ar: DIVEAR | null;
@@ -760,14 +784,14 @@ export class DIVECommunication {
760
784
  target = payload.target;
761
785
  }
762
786
 
763
- payload.dataUri = this.mediaGenerator.GenerateMedia(
764
- position,
765
- target,
766
- payload.width,
767
- payload.height,
768
- );
769
-
770
- return true;
787
+ return this.mediaGenerator.then((module) => {
788
+ return module.GenerateMedia(
789
+ position,
790
+ target,
791
+ payload.width,
792
+ payload.height,
793
+ );
794
+ });
771
795
  }
772
796
 
773
797
  private setParent(
@@ -833,7 +857,13 @@ export class DIVECommunication {
833
857
  private exportScene(
834
858
  payload: Actions['EXPORT_SCENE']['PAYLOAD'],
835
859
  ): Actions['EXPORT_SCENE']['RETURN'] {
836
- return this.io.Export(payload.type);
860
+ return new Promise<string | null>((resolve, reject) => {
861
+ this.io
862
+ .then((ioModule) => {
863
+ resolve(ioModule.Export(payload.type));
864
+ })
865
+ .catch(reject);
866
+ });
837
867
  }
838
868
  }
839
869
 
@@ -842,7 +842,14 @@ describe('dive/communication/DIVECommunication', () => {
842
842
  expect(success1).toBe(true);
843
843
  });
844
844
 
845
- it('should perform action GENERATE_MEDIA', () => {
845
+ it('should perform action GENERATE_MEDIA', async () => {
846
+ const blobUri = 'blob:http://localhost:3000/1234';
847
+ const mediaGeneratorModule = await testCom['mediaGenerator'];
848
+
849
+ jest.spyOn(mediaGeneratorModule, 'GenerateMedia').mockReturnValue(
850
+ blobUri,
851
+ );
852
+
846
853
  const mock1 = {
847
854
  entityType: 'pov',
848
855
  id: 'test1',
@@ -851,22 +858,22 @@ describe('dive/communication/DIVECommunication', () => {
851
858
  } as COMPov;
852
859
  testCom.PerformAction('ADD_OBJECT', mock1);
853
860
 
854
- const success0 = testCom.PerformAction('GENERATE_MEDIA', {
861
+ const success0 = await testCom.PerformAction('GENERATE_MEDIA', {
855
862
  id: 'test1',
856
863
  width: 800,
857
864
  height: 600,
858
- dataUri: '',
859
865
  });
860
- expect(success0).toBe(true);
866
+ expect(success0).toBe(blobUri);
861
867
 
862
- const success1 = testCom.PerformAction('GENERATE_MEDIA', {
868
+ const success1 = await testCom.PerformAction('GENERATE_MEDIA', {
863
869
  position: { x: 0, y: 0, z: 0 },
864
870
  target: { x: 0, y: 0, z: 0 },
865
871
  width: 800,
866
872
  height: 600,
867
- dataUri: '',
868
873
  });
869
- expect(success1).toBe(true);
874
+ expect(success1).toBe(blobUri);
875
+
876
+ jest.restoreAllMocks();
870
877
  });
871
878
 
872
879
  it('should perform action SET_PARENT', () => {
@@ -955,8 +962,9 @@ describe('dive/communication/DIVECommunication', () => {
955
962
 
956
963
  it('should perform action EXPORT_SCENE', async () => {
957
964
  const url = 'https://example.com';
965
+ const ioModule = await testCom['io'];
958
966
 
959
- jest.spyOn(testCom['io'], 'Export').mockResolvedValueOnce(url);
967
+ jest.spyOn(ioModule, 'Export').mockResolvedValueOnce(url);
960
968
 
961
969
  const result = await testCom.PerformAction('EXPORT_SCENE', {
962
970
  type: 'glb',
@@ -1,7 +1,7 @@
1
1
  import { Vector3Like } from 'three';
2
2
 
3
3
  export default interface GENERATE_MEDIA {
4
- DESCRIPTION: 'Generates a screenshot, stores it in a Blob and writes the URL into the payload.';
4
+ DESCRIPTION: 'Generates a screenshot, stores it in a Blob and returns a Promise of a valid URI.';
5
5
  PAYLOAD: (
6
6
  | {
7
7
  position: Vector3Like;
@@ -13,7 +13,6 @@ export default interface GENERATE_MEDIA {
13
13
  ) & {
14
14
  width: number; // image width in pixels
15
15
  height: number; // image height in pixels
16
- dataUri: string;
17
16
  };
18
- RETURN: boolean;
17
+ RETURN: Promise<string>;
19
18
  }