@shopware-ag/dive 1.16.26-beta.2 → 1.17.0
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/README.md +8 -0
- package/build/dive.cjs +133 -111
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +16 -1
- package/build/dive.d.ts +16 -1
- package/build/dive.js +134 -110
- package/build/dive.js.map +1 -1
- package/package.json +3 -2
- package/src/__test__/DIVE.test.ts +2 -2
- package/src/ar/AR.ts +51 -125
- package/src/ar/__test__/AR.test.ts +187 -0
- package/src/ar/arquicklook/ARQuickLook.ts +29 -7
- package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +268 -0
- package/src/ar/sceneviewer/SceneViewer.ts +74 -0
- package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +245 -0
- package/src/ar/webxr/controller/WebXRController.ts +17 -11
- package/src/ar/webxr/origin/WebXROrigin.ts +1 -0
- package/src/com/Communication.ts +4 -3
- package/src/com/__test__/Communication.test.ts +47 -2
- package/src/com/actions/index.ts +2 -2
- package/src/com/actions/scene/launchar.ts +7 -0
- package/src/dive.ts +0 -16
- package/src/exporters/usdz/USDZExporter.ts +21 -0
- package/src/group/__test__/Group.test.ts +2 -0
- package/src/scene/__test__/Scene.test.ts +10 -0
- package/src/toolbox/transform/__test__/TransformTool.test.ts +4 -1
|
@@ -62,6 +62,16 @@ jest.mock('../../io/IO', () => {
|
|
|
62
62
|
};
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
jest.mock('../../ar/AR', () => {
|
|
66
|
+
return {
|
|
67
|
+
DIVEAR: jest.fn(function () {
|
|
68
|
+
this.Launch = jest.fn();
|
|
69
|
+
|
|
70
|
+
return this;
|
|
71
|
+
}),
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
|
|
65
75
|
jest.mock('../../toolbox/select/SelectTool', () => {
|
|
66
76
|
return {
|
|
67
77
|
isSelectTool: jest.fn().mockReturnValue(true),
|
|
@@ -328,14 +338,40 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
328
338
|
|
|
329
339
|
it('should perform action DELETE_OBJECT with existing object', () => {
|
|
330
340
|
const payload = {
|
|
341
|
+
entityType: 'group',
|
|
342
|
+
id: 'group00',
|
|
343
|
+
} as COMGroup;
|
|
344
|
+
|
|
345
|
+
testCom.PerformAction('ADD_OBJECT', payload);
|
|
346
|
+
|
|
347
|
+
// additionally add a child to the group
|
|
348
|
+
testCom.PerformAction('ADD_OBJECT', {
|
|
331
349
|
entityType: 'light',
|
|
332
350
|
id: 'ambient00',
|
|
333
351
|
type: 'ambient',
|
|
334
352
|
intensity: 0.5,
|
|
335
353
|
color: 'white',
|
|
336
|
-
|
|
354
|
+
parentId: 'group00',
|
|
355
|
+
} as COMLight);
|
|
337
356
|
|
|
338
|
-
|
|
357
|
+
// and one child that has NO parent
|
|
358
|
+
testCom.PerformAction('ADD_OBJECT', {
|
|
359
|
+
entityType: 'light',
|
|
360
|
+
id: 'ambient01',
|
|
361
|
+
type: 'ambient',
|
|
362
|
+
intensity: 0.5,
|
|
363
|
+
color: 'white',
|
|
364
|
+
} as COMLight);
|
|
365
|
+
|
|
366
|
+
// and one child that has A DIFFERENT parent
|
|
367
|
+
testCom.PerformAction('ADD_OBJECT', {
|
|
368
|
+
entityType: 'light',
|
|
369
|
+
id: 'ambient02',
|
|
370
|
+
type: 'ambient',
|
|
371
|
+
intensity: 0.5,
|
|
372
|
+
color: 'white',
|
|
373
|
+
parentId: 'group01',
|
|
374
|
+
} as COMLight);
|
|
339
375
|
|
|
340
376
|
const successDelete = testCom.PerformAction('DELETE_OBJECT', payload);
|
|
341
377
|
expect(mockScene.DeleteSceneObject).toHaveBeenCalledTimes(1);
|
|
@@ -934,6 +970,15 @@ describe('dive/communication/DIVECommunication', () => {
|
|
|
934
970
|
expect(result).toBe(url);
|
|
935
971
|
});
|
|
936
972
|
|
|
973
|
+
it('should perform action LAUNCH_AR', async () => {
|
|
974
|
+
const arLaunchSpy = jest
|
|
975
|
+
.spyOn(testCom['ar'], 'Launch')
|
|
976
|
+
.mockResolvedValueOnce();
|
|
977
|
+
|
|
978
|
+
const result = await testCom.PerformAction('LAUNCH_AR', undefined);
|
|
979
|
+
expect(arLaunchSpy).toHaveBeenCalledTimes(1);
|
|
980
|
+
});
|
|
981
|
+
|
|
937
982
|
it('should warn of action is of invalid type ', () => {
|
|
938
983
|
jest.spyOn(console, 'warn').mockImplementationOnce(() => {});
|
|
939
984
|
testCom.PerformAction('INVALID_ACTION' as keyof Actions, {});
|
package/src/com/actions/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ import COMPUTE_ENCOMPASSING_VIEW from './camera/computeencompassingview.ts';
|
|
|
24
24
|
import USE_TOOL from './toolbox/usetool.ts';
|
|
25
25
|
import SET_PARENT from './object/setparent.ts';
|
|
26
26
|
import EXPORT_SCENE from './scene/exportscene.ts';
|
|
27
|
+
import LAUNCH_AR from './scene/launchar.ts';
|
|
27
28
|
|
|
28
29
|
export interface Actions {
|
|
29
30
|
GET_ALL_SCENE_DATA: GET_ALL_SCENE_DATA;
|
|
@@ -52,6 +53,5 @@ export interface Actions {
|
|
|
52
53
|
GENERATE_MEDIA: GENERATE_MEDIA;
|
|
53
54
|
SET_PARENT: SET_PARENT;
|
|
54
55
|
EXPORT_SCENE: EXPORT_SCENE;
|
|
55
|
-
|
|
56
|
-
LAUNCH_AR: any;
|
|
56
|
+
LAUNCH_AR: LAUNCH_AR;
|
|
57
57
|
}
|
package/src/dive.ts
CHANGED
|
@@ -95,22 +95,6 @@ export default class DIVE {
|
|
|
95
95
|
dive.Communication.Subscribe('MODEL_LOADED', (data) => {
|
|
96
96
|
if (data.id !== modelid) return;
|
|
97
97
|
|
|
98
|
-
// console.log(
|
|
99
|
-
// dive.Communication.PerformAction('GET_OBJECTS', {
|
|
100
|
-
// ids: [modelid],
|
|
101
|
-
// })[0].position,
|
|
102
|
-
// );
|
|
103
|
-
|
|
104
|
-
// dive.Communication.PerformAction('PLACE_ON_FLOOR', {
|
|
105
|
-
// id: modelid,
|
|
106
|
-
// });
|
|
107
|
-
|
|
108
|
-
// console.log(
|
|
109
|
-
// dive.Communication.PerformAction('GET_OBJECTS', {
|
|
110
|
-
// ids: [modelid],
|
|
111
|
-
// }),
|
|
112
|
-
// );
|
|
113
|
-
|
|
114
98
|
const transform = dive.Communication.PerformAction(
|
|
115
99
|
'COMPUTE_ENCOMPASSING_VIEW',
|
|
116
100
|
{},
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
import {
|
|
3
|
+
USDZExporter,
|
|
4
|
+
USDZExporterOptions,
|
|
5
|
+
} from 'three/examples/jsm/exporters/USDZExporter';
|
|
6
|
+
|
|
7
|
+
export type DIVEUSDZExporterOptions = USDZExporterOptions & {
|
|
8
|
+
ar?: {
|
|
9
|
+
anchoring: { type: 'plane' | 'image' | 'face' | 'none' }; // source: https://developer.apple.com/documentation/realitykit/preliminary-anchoring-type
|
|
10
|
+
planeAnchoring: { alignment: 'horizontal' | 'vertical' | 'any' }; // source: https://developer.apple.com/documentation/realitykit/preliminary-planeanchoring-alignment
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export class DIVEUSDZExporter extends USDZExporter {
|
|
15
|
+
public parse(
|
|
16
|
+
scene: Object3D,
|
|
17
|
+
options?: DIVEUSDZExporterOptions,
|
|
18
|
+
): Promise<Uint8Array> {
|
|
19
|
+
return super.parse(scene, options);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -39,6 +39,7 @@ describe('dive/group/DIVEGroup', () => {
|
|
|
39
39
|
|
|
40
40
|
expect(() => group.attach(mockObject)).not.toThrow();
|
|
41
41
|
expect(group.children).toContain(mockObject);
|
|
42
|
+
expect(group.members).toContain(mockObject);
|
|
42
43
|
|
|
43
44
|
jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
|
|
44
45
|
expect(() => group.attach(mockObject)).not.toThrow();
|
|
@@ -49,6 +50,7 @@ describe('dive/group/DIVEGroup', () => {
|
|
|
49
50
|
|
|
50
51
|
expect(() => group.remove(mockObject)).not.toThrow();
|
|
51
52
|
expect(group.children).not.toContain(mockObject);
|
|
53
|
+
expect(group.members).not.toContain(mockObject);
|
|
52
54
|
|
|
53
55
|
jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined);
|
|
54
56
|
expect(() => group.remove(mockObject)).not.toThrow();
|
|
@@ -71,6 +71,16 @@ describe('dive/scene/DIVEScene', () => {
|
|
|
71
71
|
expect(scene.XRRoot).toBeDefined();
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
+
it('should have Floor', () => {
|
|
75
|
+
const scene = new DIVEScene();
|
|
76
|
+
expect(scene.Floor).toBeDefined();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should have Grid', () => {
|
|
80
|
+
const scene = new DIVEScene();
|
|
81
|
+
expect(scene.Grid).toBeDefined();
|
|
82
|
+
});
|
|
83
|
+
|
|
74
84
|
it('should InitXR', () => {
|
|
75
85
|
const scene = new DIVEScene();
|
|
76
86
|
expect(() => scene.InitXR(mockRenderer)).not.toThrow();
|
|
@@ -187,9 +187,12 @@ describe('dive/toolbox/select/DIVETransformTool', () => {
|
|
|
187
187
|
|
|
188
188
|
it('should set gizmo active', () => {
|
|
189
189
|
const transformTool = new DIVETransformTool(mockScene, mockController);
|
|
190
|
+
|
|
190
191
|
expect(() => transformTool.SetGizmoVisibility(true)).not.toThrow();
|
|
191
192
|
|
|
192
|
-
|
|
193
|
+
// mock that gizmo is in scene
|
|
194
|
+
jest.spyOn(mockScene.children, 'includes').mockReturnValueOnce(true);
|
|
195
|
+
|
|
193
196
|
expect(() => transformTool.SetGizmoVisibility(false)).not.toThrow();
|
|
194
197
|
});
|
|
195
198
|
});
|