@shopware-ag/dive 1.16.16-beta.0 → 1.16.16
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/dive.cjs +203 -1652
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +8 -50
- package/build/dive.d.ts +8 -50
- package/build/dive.js +159 -1619
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/axiscamera/AxisCamera.ts +4 -4
- package/src/axiscamera/__test__/AxisCamera.test.ts +0 -4
- package/src/com/Communication.ts +0 -17
- package/src/com/__test__/Communication.test.ts +1 -1
- package/src/com/actions/index.ts +0 -2
- package/src/dive.ts +9 -51
- package/src/helper/findSceneRecursive/findSceneRecursive.ts +2 -2
- package/src/info/Info.ts +1 -37
- package/src/info/__test__/Info.test.ts +5 -45
- package/src/mediacreator/MediaCreator.ts +4 -4
- package/src/mediacreator/__test__/MediaCreator.test.ts +2 -7
- package/src/renderer/Renderer.ts +11 -21
- package/src/renderer/__test__/Renderer.test.ts +1 -19
- package/src/scene/Scene.ts +12 -35
- package/src/scene/__test__/Scene.test.ts +5 -39
- package/src/scene/root/Root.ts +0 -1
- package/src/toolbox/BaseTool.ts +3 -9
- package/src/toolbox/Toolbox.ts +1 -1
- package/src/toolbox/__test__/Toolbox.test.ts +1 -1
- package/src/toolbox/select/SelectTool.ts +1 -1
- package/src/toolbox/select/__test__/SelectTool.test.ts +1 -1
- package/src/toolbox/transform/TransformTool.ts +4 -4
- package/src/toolbox/transform/__test__/TransformTool.test.ts +4 -2
- package/src/ar/AR.ts +0 -164
- package/src/ar/arquicklook/ARQuickLook.ts +0 -42
- package/src/ar/webxr/WebXR.ts +0 -176
- package/src/ar/webxr/controller/WebXRController.ts +0 -334
- package/src/ar/webxr/crosshair/WebXRCrosshair.ts +0 -35
- package/src/ar/webxr/origin/WebXROrigin.ts +0 -191
- package/src/ar/webxr/overlay/Overlay.ts +0 -50
- package/src/ar/webxr/raycaster/WebXRRaycaster.ts +0 -131
- package/src/ar/webxr/raycaster/ar/WebXRRaycasterAR.ts +0 -102
- package/src/ar/webxr/raycaster/three/WebXRRaycasterTHREE.ts +0 -49
- package/src/ar/webxr/touchscreencontrols/WebXRTouchscreenControls.ts +0 -356
- package/src/events/EventExecutor.ts +0 -35
- package/src/scene/xrroot/XRRoot.ts +0 -56
- package/src/scene/xrroot/xrlightroot/XRLightRoot.ts +0 -80
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AxesHelper,
|
|
3
3
|
Color,
|
|
4
|
-
|
|
4
|
+
Material,
|
|
5
5
|
Matrix4,
|
|
6
6
|
OrthographicCamera,
|
|
7
7
|
Vector4,
|
|
@@ -16,9 +16,9 @@ import {
|
|
|
16
16
|
AxesColorGreenLetter,
|
|
17
17
|
AxesColorBlueLetter,
|
|
18
18
|
} from '../constant/AxisHelperColors.ts';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
19
|
+
import { DIVERenderer } from '../renderer/Renderer.ts';
|
|
20
|
+
import { DIVEScene } from '../scene/Scene.ts';
|
|
21
|
+
import DIVEOrbitControls from '../controls/OrbitControls.ts';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Shows the scene axes in the bottom left corner of the screen.
|
package/src/com/Communication.ts
CHANGED
|
@@ -21,7 +21,6 @@ import { type DIVEMediaCreator } from '../mediacreator/MediaCreator.ts';
|
|
|
21
21
|
import { type DIVERenderer } from '../renderer/Renderer.ts';
|
|
22
22
|
import { type DIVESelectable } from '../interface/Selectable.ts';
|
|
23
23
|
import { type DIVEIO } from '../io/IO.ts';
|
|
24
|
-
import { type DIVEAR } from '../ar/AR.ts';
|
|
25
24
|
|
|
26
25
|
type EventListener<Action extends keyof Actions> = (
|
|
27
26
|
payload: Actions[Action]['PAYLOAD'],
|
|
@@ -98,16 +97,6 @@ export class DIVECommunication {
|
|
|
98
97
|
return this._io;
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
private _ar: DIVEAR | null;
|
|
102
|
-
private get ar(): DIVEAR {
|
|
103
|
-
if (!this._ar) {
|
|
104
|
-
const DIVEAR = require('../ar/AR.ts')
|
|
105
|
-
.DIVEAR as typeof import('../ar/AR.ts').DIVEAR;
|
|
106
|
-
this._ar = new DIVEAR(this.renderer, this.scene, this.controller);
|
|
107
|
-
}
|
|
108
|
-
return this._ar;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
100
|
private registered: Map<string, COMEntity> = new Map();
|
|
112
101
|
|
|
113
102
|
// private listeners: { [key: string]: EventListener[] } = {};
|
|
@@ -127,7 +116,6 @@ export class DIVECommunication {
|
|
|
127
116
|
this.toolbox = toolbox;
|
|
128
117
|
this._mediaGenerator = null;
|
|
129
118
|
this._io = null;
|
|
130
|
-
this._ar = null;
|
|
131
119
|
|
|
132
120
|
DIVECommunication.__instances.push(this);
|
|
133
121
|
}
|
|
@@ -304,11 +292,6 @@ export class DIVECommunication {
|
|
|
304
292
|
);
|
|
305
293
|
break;
|
|
306
294
|
}
|
|
307
|
-
case 'LAUNCH_AR': {
|
|
308
|
-
this.ar.Launch();
|
|
309
|
-
returnValue = true;
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
295
|
default: {
|
|
313
296
|
console.warn(
|
|
314
297
|
`DIVECommunication.PerformAction: has been executed with unknown Action type ${action}`,
|
|
@@ -21,7 +21,7 @@ import '../actions/scene/updatescene';
|
|
|
21
21
|
import '../actions/toolbox/select/setgizmomode';
|
|
22
22
|
import '../actions/toolbox/transform/setgizmovisible';
|
|
23
23
|
import '../actions/camera/getcameratransform';
|
|
24
|
-
import {
|
|
24
|
+
import type { DIVEScene } from '../../scene/Scene';
|
|
25
25
|
import type DIVEToolbox from '../../toolbox/Toolbox';
|
|
26
26
|
import type DIVEOrbitControls from '../../controls/OrbitControls';
|
|
27
27
|
import { type DIVERenderer } from '../../renderer/Renderer';
|
package/src/com/actions/index.ts
CHANGED
package/src/dive.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { DIVECommunication } from './com/Communication.ts';
|
|
|
17
17
|
import { DIVEAnimationSystem } from './animation/AnimationSystem.ts';
|
|
18
18
|
import DIVEAxisCamera from './axiscamera/AxisCamera.ts';
|
|
19
19
|
import { getObjectDelta } from './helper/getObjectDelta/getObjectDelta.ts';
|
|
20
|
+
|
|
20
21
|
import { generateUUID } from 'three/src/math/MathUtils';
|
|
21
22
|
import { DIVEInfo } from './info/Info.ts';
|
|
22
23
|
import pkgjson from '../package.json';
|
|
@@ -62,11 +63,8 @@ export const DIVEDefaultSettings: DIVESettings = {
|
|
|
62
63
|
|
|
63
64
|
export default class DIVE {
|
|
64
65
|
// static members
|
|
65
|
-
public static QuickView(
|
|
66
|
-
|
|
67
|
-
settings?: Partial<DIVESettings>,
|
|
68
|
-
): DIVE {
|
|
69
|
-
const dive = new DIVE(settings);
|
|
66
|
+
public static QuickView(uri: string): DIVE {
|
|
67
|
+
const dive = new DIVE();
|
|
70
68
|
|
|
71
69
|
dive.Communication.PerformAction('SET_CAMERA_TRANSFORM', {
|
|
72
70
|
position: { x: 0, y: 2, z: 2 },
|
|
@@ -94,22 +92,9 @@ export default class DIVE {
|
|
|
94
92
|
// add loaded listener
|
|
95
93
|
dive.Communication.Subscribe('MODEL_LOADED', (data) => {
|
|
96
94
|
if (data.id !== modelid) return;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
// );
|
|
95
|
+
dive.Communication.PerformAction('PLACE_ON_FLOOR', {
|
|
96
|
+
id: modelid,
|
|
97
|
+
});
|
|
113
98
|
|
|
114
99
|
const transform = dive.Communication.PerformAction(
|
|
115
100
|
'COMPUTE_ENCOMPASSING_VIEW',
|
|
@@ -292,36 +277,9 @@ export default class DIVE {
|
|
|
292
277
|
},
|
|
293
278
|
};
|
|
294
279
|
|
|
295
|
-
console.log(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
@@%=::::.......::---------------------------------------------------------+@@
|
|
299
|
-
@@+:::...........::-----------------------------------------------------------#@@
|
|
300
|
-
@@=:::.........::::::--------------${' DIVE ' + pkgjson.version.padStart(7, ' ') + ' '}---------------------------------%@
|
|
301
|
-
@%:::.......:::::::-------------------${process.env.DIVE_NODE_ENV === 'development' ? ' DEV MODE ' : '--------------'}------------------------------------#@
|
|
302
|
-
@*:::.....:::::-----------------------------------------------------------------------*@
|
|
303
|
-
@%::::::.::::---------------------------------------------------------------------------@@
|
|
304
|
-
@@-:::::::::-----------------------------------------------------------------------------=@
|
|
305
|
-
@%::::::::--------------------------------------------------------------------------------%@
|
|
306
|
-
@+::::::::--------------------------------=@@@@@%-----------------------------------------%@
|
|
307
|
-
@=:::::::--------------------------------*@@ @@+---------------------------------------#@
|
|
308
|
-
@+:::::::-------------------------------*@ @*--------------------------------------%@
|
|
309
|
-
@#::::::::-----------------------------=@@ @@=-------------------------------------%@
|
|
310
|
-
@@-::::::::----------------------------@@ @@------------------------------------=@
|
|
311
|
-
@%:::::::::--------------------------*@ @*-----------------------------------@@
|
|
312
|
-
@*:::::::::-------------------------@@ @@----------------------------------%@
|
|
313
|
-
@#::::::::::----------------------%@ @%--------------------------------%@
|
|
314
|
-
@#:::::::::::-------------------=@@ @@=------------------------------%@
|
|
315
|
-
@@-::::::::::::----------------%@ @%----------------------------=@@
|
|
316
|
-
@@#::::::::::::::------------*@ @*--------------------------#@@
|
|
317
|
-
@@+::::::::::::::::--------@@ @@------------------------+@@
|
|
318
|
-
@@*:::::::::::::::::----@@ @@---------------------+@@
|
|
319
|
-
@@@-:::::::::::::::--#@ @#-----------------=%@@
|
|
320
|
-
@@%-::::::::::::-%@ @%-------------=%@@
|
|
321
|
-
@@@@+:::::::#@@ @@*-------*@@@@
|
|
322
|
-
@@@@@@@ @@@@@@
|
|
323
|
-
|
|
324
|
-
`);
|
|
280
|
+
console.log(
|
|
281
|
+
`DIVE ${pkgjson.version} initialized ${process.env.DIVE_NODE_ENV === 'development' ? 'in development mode' : ''}`,
|
|
282
|
+
);
|
|
325
283
|
}
|
|
326
284
|
|
|
327
285
|
public Dispose(): void {
|
package/src/info/Info.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
export enum WebXRUnsupportedReason {
|
|
2
|
-
'UNKNWON_ERROR' = 0,
|
|
3
|
-
'NO_HTTPS' = 1,
|
|
4
|
-
'IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE' = 2,
|
|
5
|
-
'AR_SESSION_NOT_ALLOWED' = 3,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
1
|
export class DIVEInfo {
|
|
9
2
|
private static _supportsWebXR: boolean | null = null;
|
|
10
|
-
private static _webXRUnsupportedReason: WebXRUnsupportedReason | null =
|
|
11
|
-
null;
|
|
12
3
|
|
|
13
4
|
/**
|
|
14
5
|
*
|
|
@@ -39,48 +30,21 @@ export class DIVEInfo {
|
|
|
39
30
|
return this._supportsWebXR;
|
|
40
31
|
}
|
|
41
32
|
|
|
42
|
-
// check if XRSystem is available && if https enabled
|
|
43
33
|
if (!navigator.xr) {
|
|
44
34
|
this._supportsWebXR = false;
|
|
45
|
-
|
|
46
|
-
if (window.isSecureContext === false) {
|
|
47
|
-
this._webXRUnsupportedReason = WebXRUnsupportedReason.NO_HTTPS;
|
|
48
|
-
} else {
|
|
49
|
-
this._webXRUnsupportedReason =
|
|
50
|
-
WebXRUnsupportedReason.UNKNWON_ERROR;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
35
|
return this._supportsWebXR;
|
|
54
36
|
}
|
|
55
|
-
|
|
56
37
|
// Check if immersive-vr session mode is supported
|
|
57
38
|
try {
|
|
58
39
|
const supported =
|
|
59
|
-
await navigator.xr
|
|
60
|
-
if (!supported) {
|
|
61
|
-
this._webXRUnsupportedReason =
|
|
62
|
-
WebXRUnsupportedReason.IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE;
|
|
63
|
-
}
|
|
40
|
+
await navigator.xr.isSessionSupported('immersive-ar');
|
|
64
41
|
this._supportsWebXR = supported;
|
|
65
42
|
} catch (error) {
|
|
66
43
|
this._supportsWebXR = false;
|
|
67
|
-
this._webXRUnsupportedReason =
|
|
68
|
-
WebXRUnsupportedReason.AR_SESSION_NOT_ALLOWED;
|
|
69
44
|
}
|
|
70
45
|
return this._supportsWebXR;
|
|
71
46
|
}
|
|
72
47
|
|
|
73
|
-
/**
|
|
74
|
-
* @returns The reason why WebXR is not supported on the user's device. Returns null if WebXR is supported nor not has been checked yet.
|
|
75
|
-
*/
|
|
76
|
-
public static GetWebXRUnsupportedReason(): WebXRUnsupportedReason | null {
|
|
77
|
-
if (this._supportsWebXR === null) {
|
|
78
|
-
console.log('WebXR support has not been checked yet.');
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
return this._webXRUnsupportedReason;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
48
|
/**
|
|
85
49
|
* @returns A boolean indicating whether the user's device supports AR Quick Look.
|
|
86
50
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DIVEInfo
|
|
1
|
+
import { DIVEInfo } from '../Info';
|
|
2
2
|
|
|
3
3
|
const mockNavigator = (navigator: any) => {
|
|
4
4
|
Object.defineProperty(global, 'navigator', {
|
|
@@ -60,6 +60,7 @@ describe('dive/info/DIVEInfo', () => {
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
it('should support webXR', async () => {
|
|
63
|
+
DIVEInfo['_supportsWebXR'] = null;
|
|
63
64
|
mockNavigator({
|
|
64
65
|
xr: {
|
|
65
66
|
isSessionSupported: jest.fn().mockResolvedValue(true),
|
|
@@ -70,50 +71,16 @@ describe('dive/info/DIVEInfo', () => {
|
|
|
70
71
|
});
|
|
71
72
|
|
|
72
73
|
it('should not support webXR (xr undefined)', async () => {
|
|
74
|
+
DIVEInfo['_supportsWebXR'] = null;
|
|
73
75
|
mockNavigator({
|
|
74
76
|
xr: undefined,
|
|
75
77
|
});
|
|
76
78
|
const supports = await DIVEInfo.GetSupportsWebXR();
|
|
77
79
|
expect(supports).toBe(false);
|
|
78
|
-
|
|
79
|
-
const reason = DIVEInfo.GetWebXRUnsupportedReason();
|
|
80
|
-
expect(reason).toBe(WebXRUnsupportedReason.UNKNWON_ERROR);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should not support webXR (xr undefined & isSecureContext false)', async () => {
|
|
84
|
-
window.isSecureContext = false;
|
|
85
|
-
mockNavigator({
|
|
86
|
-
xr: undefined,
|
|
87
|
-
});
|
|
88
|
-
const supports = await DIVEInfo.GetSupportsWebXR();
|
|
89
|
-
expect(supports).toBe(false);
|
|
90
|
-
|
|
91
|
-
const reason = DIVEInfo.GetWebXRUnsupportedReason();
|
|
92
|
-
expect(reason).toBe(WebXRUnsupportedReason.NO_HTTPS);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should get empty reason (not checked)', async () => {
|
|
96
|
-
mockNavigator({
|
|
97
|
-
xr: {
|
|
98
|
-
isSessionSupported: jest.fn().mockResolvedValue(true),
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
console.log = jest.fn();
|
|
102
|
-
const reason = DIVEInfo.GetWebXRUnsupportedReason();
|
|
103
|
-
expect(reason).toBe(null);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('should get empty reason (webXR supported)', async () => {
|
|
107
|
-
mockNavigator({
|
|
108
|
-
xr: {
|
|
109
|
-
isSessionSupported: jest.fn().mockResolvedValue(true),
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
const reason = DIVEInfo.GetWebXRUnsupportedReason();
|
|
113
|
-
expect(reason).toBe(null);
|
|
114
80
|
});
|
|
115
81
|
|
|
116
82
|
it('should not support webXR', async () => {
|
|
83
|
+
DIVEInfo['_supportsWebXR'] = null;
|
|
117
84
|
mockNavigator({
|
|
118
85
|
xr: {
|
|
119
86
|
isSessionSupported: jest.fn().mockResolvedValue(false),
|
|
@@ -121,14 +88,10 @@ describe('dive/info/DIVEInfo', () => {
|
|
|
121
88
|
});
|
|
122
89
|
const supports = await DIVEInfo.GetSupportsWebXR();
|
|
123
90
|
expect(supports).toBe(false);
|
|
124
|
-
|
|
125
|
-
const reason = DIVEInfo.GetWebXRUnsupportedReason();
|
|
126
|
-
expect(reason).toBe(
|
|
127
|
-
WebXRUnsupportedReason.IMMERSIVE_AR_NOT_SUPPORTED_BY_DEVICE,
|
|
128
|
-
);
|
|
129
91
|
});
|
|
130
92
|
|
|
131
93
|
it('should not support webXR on error', async () => {
|
|
94
|
+
DIVEInfo['_supportsWebXR'] = null;
|
|
132
95
|
mockNavigator({
|
|
133
96
|
xr: {
|
|
134
97
|
isSessionSupported: jest.fn().mockRejectedValue('error'),
|
|
@@ -136,9 +99,6 @@ describe('dive/info/DIVEInfo', () => {
|
|
|
136
99
|
});
|
|
137
100
|
const supports = await DIVEInfo.GetSupportsWebXR();
|
|
138
101
|
expect(supports).toBe(false);
|
|
139
|
-
|
|
140
|
-
const reason = DIVEInfo.GetWebXRUnsupportedReason();
|
|
141
|
-
expect(reason).toBe(WebXRUnsupportedReason.AR_SESSION_NOT_ALLOWED);
|
|
142
102
|
});
|
|
143
103
|
|
|
144
104
|
it('should return cached value', async () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import DIVEPerspectiveCamera from '../camera/PerspectiveCamera.ts';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
2
|
+
import { DIVEScene } from '../scene/Scene.ts';
|
|
3
|
+
import { DIVERenderer } from '../renderer/Renderer.ts';
|
|
4
|
+
import DIVEOrbitControls from '../controls/OrbitControls.ts';
|
|
5
|
+
import { Vector3Like } from 'three';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Creates renderings of the current scene
|
|
@@ -17,13 +17,8 @@ const mock_toDataURL = jest.fn();
|
|
|
17
17
|
|
|
18
18
|
jest.mock('../../scene/Scene', () => {
|
|
19
19
|
return {
|
|
20
|
-
DIVEScene: jest.fn(
|
|
21
|
-
|
|
22
|
-
this.children = [];
|
|
23
|
-
this.Root = {
|
|
24
|
-
children: [],
|
|
25
|
-
};
|
|
26
|
-
return this;
|
|
20
|
+
DIVEScene: jest.fn(() => {
|
|
21
|
+
return {};
|
|
27
22
|
}),
|
|
28
23
|
};
|
|
29
24
|
});
|
package/src/renderer/Renderer.ts
CHANGED
|
@@ -29,11 +29,6 @@ export const DIVERendererDefaultSettings: DIVERendererSettings = {
|
|
|
29
29
|
canvas: undefined,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
export type DIVERenderCallback = (
|
|
33
|
-
time: DOMHighResTimeStamp,
|
|
34
|
-
frame: XRFrame,
|
|
35
|
-
) => void;
|
|
36
|
-
|
|
37
32
|
/**
|
|
38
33
|
* A changed version of the WebGLRenderer.
|
|
39
34
|
*
|
|
@@ -49,13 +44,13 @@ export class DIVERenderer extends WebGLRenderer {
|
|
|
49
44
|
private force: boolean = false;
|
|
50
45
|
|
|
51
46
|
// pre- and post-render callbacks
|
|
52
|
-
private preRenderCallbacks: Map<string,
|
|
47
|
+
private preRenderCallbacks: Map<string, () => void> = new Map<
|
|
53
48
|
string,
|
|
54
|
-
|
|
49
|
+
() => void
|
|
55
50
|
>();
|
|
56
|
-
private postRenderCallbacks: Map<string,
|
|
51
|
+
private postRenderCallbacks: Map<string, () => void> = new Map<
|
|
57
52
|
string,
|
|
58
|
-
|
|
53
|
+
() => void
|
|
59
54
|
>();
|
|
60
55
|
|
|
61
56
|
constructor(
|
|
@@ -93,8 +88,8 @@ export class DIVERenderer extends WebGLRenderer {
|
|
|
93
88
|
|
|
94
89
|
// Starts the renderer with the given scene and camera.
|
|
95
90
|
public StartRenderer(scene: Scene, cam: Camera): void {
|
|
96
|
-
this.setAnimationLoop((
|
|
97
|
-
this.internal_render(scene, cam
|
|
91
|
+
this.setAnimationLoop(() => {
|
|
92
|
+
this.internal_render(scene, cam);
|
|
98
93
|
});
|
|
99
94
|
this.running = true;
|
|
100
95
|
}
|
|
@@ -125,7 +120,7 @@ export class DIVERenderer extends WebGLRenderer {
|
|
|
125
120
|
* @param callback Executed before rendering.
|
|
126
121
|
* @returns uuid to remove the callback.
|
|
127
122
|
*/
|
|
128
|
-
public AddPreRenderCallback(callback:
|
|
123
|
+
public AddPreRenderCallback(callback: () => void): string {
|
|
129
124
|
// add callback to renderloop
|
|
130
125
|
const newUUID = MathUtils.generateUUID();
|
|
131
126
|
this.preRenderCallbacks.set(newUUID, callback);
|
|
@@ -153,7 +148,7 @@ export class DIVERenderer extends WebGLRenderer {
|
|
|
153
148
|
* @param callback Executed after rendering.
|
|
154
149
|
* @returns uuid to remove the callback.
|
|
155
150
|
*/
|
|
156
|
-
public AddPostRenderCallback(callback:
|
|
151
|
+
public AddPostRenderCallback(callback: () => void): string {
|
|
157
152
|
// add callback to renderloop
|
|
158
153
|
const newUUID = MathUtils.generateUUID();
|
|
159
154
|
this.postRenderCallbacks.set(newUUID, callback);
|
|
@@ -190,24 +185,19 @@ export class DIVERenderer extends WebGLRenderer {
|
|
|
190
185
|
* @param scene Scene to render.
|
|
191
186
|
* @param cam Camera to render with.
|
|
192
187
|
*/
|
|
193
|
-
private internal_render(
|
|
194
|
-
scene: Scene,
|
|
195
|
-
cam: Camera,
|
|
196
|
-
time: DOMHighResTimeStamp,
|
|
197
|
-
frame: XRFrame,
|
|
198
|
-
): void {
|
|
188
|
+
private internal_render(scene: Scene, cam: Camera): void {
|
|
199
189
|
// execute background render loop callbacks
|
|
200
190
|
if ((this.paused || !this.running) && !this.force) return;
|
|
201
191
|
|
|
202
192
|
// execute render loop callbacks
|
|
203
193
|
this.preRenderCallbacks.forEach((callback) => {
|
|
204
|
-
callback(
|
|
194
|
+
callback();
|
|
205
195
|
});
|
|
206
196
|
|
|
207
197
|
this.render(scene, cam);
|
|
208
198
|
|
|
209
199
|
this.postRenderCallbacks.forEach((callback) => {
|
|
210
|
-
callback(
|
|
200
|
+
callback();
|
|
211
201
|
});
|
|
212
202
|
|
|
213
203
|
this.force = false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type DIVEPerspectiveCamera from '../../camera/PerspectiveCamera';
|
|
2
|
-
import {
|
|
2
|
+
import type { DIVEScene } from '../../scene/Scene';
|
|
3
3
|
import { DIVERenderer, DIVERendererDefaultSettings } from '../Renderer';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -123,8 +123,6 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
123
123
|
renderer['internal_render'](
|
|
124
124
|
{} as DIVEScene,
|
|
125
125
|
{} as DIVEPerspectiveCamera,
|
|
126
|
-
0.016,
|
|
127
|
-
{} as XRFrame,
|
|
128
126
|
);
|
|
129
127
|
}).not.toThrow();
|
|
130
128
|
expect(mock_render).toHaveBeenCalledTimes(1);
|
|
@@ -141,8 +139,6 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
141
139
|
renderer['internal_render'](
|
|
142
140
|
{} as DIVEScene,
|
|
143
141
|
{} as DIVEPerspectiveCamera,
|
|
144
|
-
0.016,
|
|
145
|
-
{} as XRFrame,
|
|
146
142
|
);
|
|
147
143
|
expect(mock_render).toHaveBeenCalledTimes(0);
|
|
148
144
|
});
|
|
@@ -152,8 +148,6 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
152
148
|
renderer['internal_render'](
|
|
153
149
|
{} as DIVEScene,
|
|
154
150
|
{} as DIVEPerspectiveCamera,
|
|
155
|
-
0.016,
|
|
156
|
-
{} as XRFrame,
|
|
157
151
|
);
|
|
158
152
|
expect(mock_render).toHaveBeenCalledTimes(1);
|
|
159
153
|
|
|
@@ -161,8 +155,6 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
161
155
|
renderer['internal_render'](
|
|
162
156
|
{} as DIVEScene,
|
|
163
157
|
{} as DIVEPerspectiveCamera,
|
|
164
|
-
0.016,
|
|
165
|
-
{} as XRFrame,
|
|
166
158
|
);
|
|
167
159
|
expect(mock_render).toHaveBeenCalledTimes(1);
|
|
168
160
|
});
|
|
@@ -172,8 +164,6 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
172
164
|
renderer['internal_render'](
|
|
173
165
|
{} as DIVEScene,
|
|
174
166
|
{} as DIVEPerspectiveCamera,
|
|
175
|
-
0.016,
|
|
176
|
-
{} as XRFrame,
|
|
177
167
|
);
|
|
178
168
|
expect(mock_render).toHaveBeenCalledTimes(1);
|
|
179
169
|
|
|
@@ -181,8 +171,6 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
181
171
|
renderer['internal_render'](
|
|
182
172
|
{} as DIVEScene,
|
|
183
173
|
{} as DIVEPerspectiveCamera,
|
|
184
|
-
0.016,
|
|
185
|
-
{} as XRFrame,
|
|
186
174
|
);
|
|
187
175
|
expect(mock_render).toHaveBeenCalledTimes(1);
|
|
188
176
|
});
|
|
@@ -193,8 +181,6 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
193
181
|
renderer['internal_render'](
|
|
194
182
|
{} as DIVEScene,
|
|
195
183
|
{} as DIVEPerspectiveCamera,
|
|
196
|
-
0.016,
|
|
197
|
-
{} as XRFrame,
|
|
198
184
|
);
|
|
199
185
|
expect(mock_render).toHaveBeenCalledTimes(0);
|
|
200
186
|
|
|
@@ -202,8 +188,6 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
202
188
|
renderer['internal_render'](
|
|
203
189
|
{} as DIVEScene,
|
|
204
190
|
{} as DIVEPerspectiveCamera,
|
|
205
|
-
0.016,
|
|
206
|
-
{} as XRFrame,
|
|
207
191
|
);
|
|
208
192
|
expect(mock_render).toHaveBeenCalledTimes(1);
|
|
209
193
|
});
|
|
@@ -249,8 +233,6 @@ describe('dive/renderer/DIVERenderer', () => {
|
|
|
249
233
|
renderer['internal_render'](
|
|
250
234
|
{} as DIVEScene,
|
|
251
235
|
{} as DIVEPerspectiveCamera,
|
|
252
|
-
0.016,
|
|
253
|
-
{} as XRFrame,
|
|
254
236
|
);
|
|
255
237
|
expect(precallback).toHaveBeenCalledTimes(1);
|
|
256
238
|
expect(postcallback).toHaveBeenCalledTimes(1);
|
package/src/scene/Scene.ts
CHANGED
|
@@ -4,8 +4,6 @@ import { DIVERoot } from './root/Root';
|
|
|
4
4
|
import { DIVEGrid } from '../grid/Grid';
|
|
5
5
|
import { DIVEFloor } from '../primitive/floor/Floor';
|
|
6
6
|
import { type DIVESceneObject } from '../types';
|
|
7
|
-
import { DIVEXRRoot } from './xrroot/XRRoot';
|
|
8
|
-
import { type DIVERenderer } from '../renderer/Renderer';
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
* A basic scene class.
|
|
@@ -16,25 +14,20 @@ import { type DIVERenderer } from '../renderer/Renderer';
|
|
|
16
14
|
*/
|
|
17
15
|
|
|
18
16
|
export class DIVEScene extends Scene {
|
|
19
|
-
private
|
|
20
|
-
private
|
|
21
|
-
private
|
|
17
|
+
private root: DIVERoot;
|
|
18
|
+
private floor: DIVEFloor;
|
|
19
|
+
private grid: DIVEGrid;
|
|
22
20
|
|
|
23
21
|
public get Root(): DIVERoot {
|
|
24
|
-
return this.
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private _xrRoot: DIVEXRRoot;
|
|
28
|
-
public get XRRoot(): DIVEXRRoot {
|
|
29
|
-
return this._xrRoot;
|
|
22
|
+
return this.root;
|
|
30
23
|
}
|
|
31
24
|
|
|
32
25
|
public get Floor(): DIVEFloor {
|
|
33
|
-
return this.
|
|
26
|
+
return this.floor;
|
|
34
27
|
}
|
|
35
28
|
|
|
36
29
|
public get Grid(): DIVEGrid {
|
|
37
|
-
return this.
|
|
30
|
+
return this.grid;
|
|
38
31
|
}
|
|
39
32
|
|
|
40
33
|
constructor() {
|
|
@@ -42,30 +35,14 @@ export class DIVEScene extends Scene {
|
|
|
42
35
|
|
|
43
36
|
this.background = new Color(0xffffff);
|
|
44
37
|
|
|
45
|
-
this.
|
|
46
|
-
this.add(this.
|
|
47
|
-
|
|
48
|
-
this._floor = new DIVEFloor();
|
|
49
|
-
this.add(this._floor);
|
|
50
|
-
|
|
51
|
-
this._grid = new DIVEGrid();
|
|
52
|
-
this.add(this._grid);
|
|
38
|
+
this.root = new DIVERoot();
|
|
39
|
+
this.add(this.root);
|
|
53
40
|
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.add(this._xrRoot);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public InitXR(renderer: DIVERenderer): void {
|
|
60
|
-
this._root.visible = false;
|
|
61
|
-
this._xrRoot.visible = true;
|
|
62
|
-
this._xrRoot.InitLightEstimation(renderer);
|
|
63
|
-
}
|
|
41
|
+
this.floor = new DIVEFloor();
|
|
42
|
+
this.add(this.floor);
|
|
64
43
|
|
|
65
|
-
|
|
66
|
-
this.
|
|
67
|
-
this._xrRoot.visible = false;
|
|
68
|
-
this._xrRoot.DisposeLightEstimation();
|
|
44
|
+
this.grid = new DIVEGrid();
|
|
45
|
+
this.add(this.grid);
|
|
69
46
|
}
|
|
70
47
|
|
|
71
48
|
public SetBackground(color: ColorRepresentation): void {
|