@shopware-ag/dive 1.18.5-beta.0 → 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.
- package/build/AR-B-g0updz.js +1450 -0
- package/build/AR-B-g0updz.js.map +1 -0
- package/build/AR-BWQebw6-.cjs +153 -0
- package/build/AR-BWQebw6-.cjs.map +1 -0
- package/build/IO-BgiJzKrU.js +1257 -0
- package/build/IO-BgiJzKrU.js.map +1 -0
- package/build/IO-CuYml7Y5.cjs +2 -0
- package/build/IO-CuYml7Y5.cjs.map +1 -0
- package/build/MediaCreator-4zmvmUWH.js +22 -0
- package/build/MediaCreator-4zmvmUWH.js.map +1 -0
- package/build/MediaCreator-BNxZVYyZ.cjs +2 -0
- package/build/MediaCreator-BNxZVYyZ.cjs.map +1 -0
- package/build/TextureUtils-CxpuVgwF.js +38 -0
- package/build/TextureUtils-CxpuVgwF.js.map +1 -0
- package/build/TextureUtils-DNG-yR77.cjs +19 -0
- package/build/TextureUtils-DNG-yR77.cjs.map +1 -0
- package/build/dive-Mi8g8Khn.js +24852 -0
- package/build/dive-Mi8g8Khn.js.map +1 -0
- package/build/dive-_-yiZbhn.cjs +3857 -0
- package/build/dive-_-yiZbhn.cjs.map +1 -0
- package/build/dive.cjs +1 -3856
- package/build/dive.cjs.map +1 -1
- package/build/dive.js +6 -24721
- package/build/dive.js.map +1 -1
- package/build/src/com/actions/media/generatemedia.d.ts +2 -3
- package/package.json +1 -1
- package/src/ar/arquicklook/ARQuickLook.ts +3 -1
- package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +1 -1
- package/src/camera/PerspectiveCamera.ts +1 -1
- package/src/com/Communication.ts +86 -31
- package/src/com/__test__/Communication.test.ts +18 -9
- package/src/com/actions/media/generatemedia.ts +2 -3
|
@@ -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
|
|
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:
|
|
13
|
+
RETURN: Promise<string>;
|
|
15
14
|
}
|
package/package.json
CHANGED
|
@@ -14,7 +14,9 @@ export class DIVEARQuickLook {
|
|
|
14
14
|
const quickLookScene = new Object3D();
|
|
15
15
|
|
|
16
16
|
// extract models from scene
|
|
17
|
-
|
|
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);
|
package/src/com/Communication.ts
CHANGED
|
@@ -75,37 +75,78 @@ 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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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;
|
|
102
|
-
private get ar(): DIVEAR {
|
|
126
|
+
private get ar(): Promise<DIVEAR> {
|
|
103
127
|
if (!this._ar) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
128
|
+
return new Promise((resolve, reject) => {
|
|
129
|
+
import('../ar/AR.ts')
|
|
130
|
+
.then((module) => {
|
|
131
|
+
const DIVEAR = module.DIVEAR;
|
|
132
|
+
this._ar = new DIVEAR(
|
|
133
|
+
this.renderer,
|
|
134
|
+
this.scene,
|
|
135
|
+
this.controller,
|
|
136
|
+
);
|
|
137
|
+
resolve(this._ar);
|
|
138
|
+
})
|
|
139
|
+
.catch((error) => {
|
|
140
|
+
console.error(
|
|
141
|
+
'DIVE: Error while lazy-loading AR module:',
|
|
142
|
+
error,
|
|
143
|
+
);
|
|
144
|
+
reject(error);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
107
147
|
}
|
|
108
|
-
|
|
148
|
+
|
|
149
|
+
return Promise.resolve(this._ar);
|
|
109
150
|
}
|
|
110
151
|
|
|
111
152
|
private registered: Map<string, COMEntity> = new Map();
|
|
@@ -311,9 +352,17 @@ export class DIVECommunication {
|
|
|
311
352
|
break;
|
|
312
353
|
}
|
|
313
354
|
case 'LAUNCH_AR': {
|
|
314
|
-
returnValue =
|
|
315
|
-
|
|
316
|
-
|
|
355
|
+
returnValue = new Promise<void>((resolve, reject) => {
|
|
356
|
+
this.ar
|
|
357
|
+
.then((arModule) => {
|
|
358
|
+
resolve(
|
|
359
|
+
arModule.Launch(
|
|
360
|
+
payload as Actions['LAUNCH_AR']['PAYLOAD'],
|
|
361
|
+
),
|
|
362
|
+
);
|
|
363
|
+
})
|
|
364
|
+
.catch(reject);
|
|
365
|
+
});
|
|
317
366
|
break;
|
|
318
367
|
}
|
|
319
368
|
default: {
|
|
@@ -735,14 +784,14 @@ export class DIVECommunication {
|
|
|
735
784
|
target = payload.target;
|
|
736
785
|
}
|
|
737
786
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
787
|
+
return this.mediaGenerator.then((module) => {
|
|
788
|
+
return module.GenerateMedia(
|
|
789
|
+
position,
|
|
790
|
+
target,
|
|
791
|
+
payload.width,
|
|
792
|
+
payload.height,
|
|
793
|
+
);
|
|
794
|
+
});
|
|
746
795
|
}
|
|
747
796
|
|
|
748
797
|
private setParent(
|
|
@@ -808,7 +857,13 @@ export class DIVECommunication {
|
|
|
808
857
|
private exportScene(
|
|
809
858
|
payload: Actions['EXPORT_SCENE']['PAYLOAD'],
|
|
810
859
|
): Actions['EXPORT_SCENE']['RETURN'] {
|
|
811
|
-
return
|
|
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
|
+
});
|
|
812
867
|
}
|
|
813
868
|
}
|
|
814
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(
|
|
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(
|
|
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(
|
|
967
|
+
jest.spyOn(ioModule, 'Export').mockResolvedValueOnce(url);
|
|
960
968
|
|
|
961
969
|
const result = await testCom.PerformAction('EXPORT_SCENE', {
|
|
962
970
|
type: 'glb',
|
|
@@ -965,8 +973,9 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
965
973
|
});
|
|
966
974
|
|
|
967
975
|
it('should perform action LAUNCH_AR', async () => {
|
|
976
|
+
const arModule = await testCom['ar'];
|
|
968
977
|
const arLaunchSpy = jest
|
|
969
|
-
.spyOn(
|
|
978
|
+
.spyOn(arModule, 'Launch')
|
|
970
979
|
.mockResolvedValueOnce();
|
|
971
980
|
|
|
972
981
|
const result = await testCom.PerformAction('LAUNCH_AR', undefined);
|
|
@@ -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
|
|
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:
|
|
17
|
+
RETURN: Promise<string>;
|
|
19
18
|
}
|