@@ -118,6 +118,7 @@
|
|
118
118
|
this.cullingMask = (1 << val | 0) >>> 0;
|
119
119
|
}
|
120
120
|
|
121
|
+
/** Modify the background blurriness */
|
121
122
|
@serializable()
|
122
123
|
public set backgroundBlurriness(val: number | undefined) {
|
123
124
|
if (val === this._backgroundBlurriness) return;
|
@@ -130,7 +131,7 @@
|
|
130
131
|
public get backgroundBlurriness(): number | undefined {
|
131
132
|
return this._backgroundBlurriness;
|
132
133
|
}
|
133
|
-
private _backgroundBlurriness?: number;
|
134
|
+
private _backgroundBlurriness?: number = 0;
|
134
135
|
|
135
136
|
@serializable()
|
136
137
|
public set backgroundIntensity(val: number | undefined) {
|
@@ -144,7 +145,7 @@
|
|
144
145
|
public get backgroundIntensity(): number | undefined {
|
145
146
|
return this._backgroundIntensity;
|
146
147
|
}
|
147
|
-
private _backgroundIntensity?: number;
|
148
|
+
private _backgroundIntensity?: number = 1;
|
148
149
|
|
149
150
|
@serializable()
|
150
151
|
public set environmentIntensity(val: number | undefined) {
|
@@ -347,10 +348,13 @@
|
|
347
348
|
}
|
348
349
|
this.enableSkybox();
|
349
350
|
|
351
|
+
// set background blurriness and intensity
|
350
352
|
if (this._backgroundBlurriness !== undefined)
|
351
353
|
this.context.scene.backgroundBlurriness = this._backgroundBlurriness;
|
354
|
+
else if (debug) console.warn(`Camera \"${this.name}\" has no background blurriness`)
|
352
355
|
if (this._backgroundIntensity !== undefined)
|
353
356
|
this.context.scene.backgroundIntensity = this._backgroundIntensity;
|
357
|
+
else if (debug) console.warn(`Camera \"${this.name}\" has no background intensity`)
|
354
358
|
|
355
359
|
break;
|
356
360
|
case ClearFlags.SolidColor:
|
@@ -175,8 +175,9 @@
|
|
175
175
|
return onGetComponent(obj, componentType);
|
176
176
|
}
|
177
177
|
|
178
|
-
export function getComponents<T>(obj: Object3D, componentType: Constructor<T>, arr?: T[] | null): T[] {
|
178
|
+
export function getComponents<T>(obj: Object3D, componentType: Constructor<T>, arr?: T[] | null, clearArray: boolean = true): T[] {
|
179
179
|
if (!arr) arr = [];
|
180
|
+
if (clearArray) arr.length = 0;
|
180
181
|
onGetComponent(obj, componentType, arr);
|
181
182
|
return arr;
|
182
183
|
}
|
@@ -192,11 +193,13 @@
|
|
192
193
|
return null;
|
193
194
|
}
|
194
195
|
|
195
|
-
export function getComponentsInChildren<T>(obj: Object3D, componentType: Constructor<T>, arr?: T[]) {
|
196
|
+
export function getComponentsInChildren<T>(obj: Object3D, componentType: Constructor<T>, arr?: T[], clearArray: boolean = true) {
|
196
197
|
if (!arr) arr = [];
|
197
|
-
|
198
|
+
if (clearArray) arr.length = 0;
|
199
|
+
|
200
|
+
getComponents(obj, componentType, arr, false);
|
198
201
|
for (let i = 0; i < obj?.children?.length; i++) {
|
199
|
-
getComponentsInChildren(obj.children[i], componentType, arr);
|
202
|
+
getComponentsInChildren(obj.children[i], componentType, arr, false);
|
200
203
|
}
|
201
204
|
return arr;
|
202
205
|
}
|
@@ -219,12 +222,14 @@
|
|
219
222
|
return null;
|
220
223
|
}
|
221
224
|
|
222
|
-
export function getComponentsInParent<T>(obj: Object3D, componentType: Constructor<T>, arr?: T[] | null): T[] {
|
225
|
+
export function getComponentsInParent<T>(obj: Object3D, componentType: Constructor<T>, arr?: T[] | null, clearArray: boolean = true): T[] {
|
223
226
|
if (!arr) arr = [];
|
227
|
+
if (clearArray) arr.length = 0;
|
228
|
+
|
224
229
|
if (!obj) return arr;
|
225
|
-
getComponents(obj, componentType, arr);
|
230
|
+
getComponents(obj, componentType, arr, false);
|
226
231
|
if (obj.parent)
|
227
|
-
return getComponentsInParent(obj.parent, componentType, arr);
|
232
|
+
return getComponentsInParent(obj.parent, componentType, arr, false);
|
228
233
|
return arr;
|
229
234
|
}
|
230
235
|
|
@@ -255,6 +260,9 @@
|
|
255
260
|
|
256
261
|
export function findObjectsOfType<T>(type: Constructor<T>, array: T[], contextOrScene): T[] {
|
257
262
|
if (!type) return array;
|
263
|
+
if (!array) array = [];
|
264
|
+
array.length = 0;
|
265
|
+
|
258
266
|
if (!contextOrScene) {
|
259
267
|
contextOrScene = Context.Current;
|
260
268
|
if (!contextOrScene) {
|
@@ -267,7 +275,7 @@
|
|
267
275
|
for (const i in scene.children) {
|
268
276
|
const child = scene.children[i];
|
269
277
|
if (child.constructor == type) return child;
|
270
|
-
getComponentsInChildren(child, type, array);
|
278
|
+
getComponentsInChildren(child, type, array, false);
|
271
279
|
}
|
272
280
|
return array;
|
273
281
|
}
|
@@ -928,15 +928,16 @@
|
|
928
928
|
}
|
929
929
|
|
930
930
|
private updatePointerPosition(evt: NEPointerEvent) {
|
931
|
-
|
932
|
-
|
933
|
-
while (
|
934
|
-
while (
|
931
|
+
const index = evt.pointerId;
|
932
|
+
|
933
|
+
while (index >= this._pointerPositions.length) this._pointerPositions.push(new Vector2());
|
934
|
+
while (index >= this._pointerPositionsLastFrame.length) this._pointerPositionsLastFrame.push(new Vector2());
|
935
|
+
while (index >= this._pointerPositionsDelta.length) this._pointerPositionsDelta.push(new Vector2());
|
935
936
|
|
936
|
-
const lf = this._pointerPositionsLastFrame[
|
937
|
-
lf.copy(this._pointerPositions[
|
937
|
+
const lf = this._pointerPositionsLastFrame[index];
|
938
|
+
lf.copy(this._pointerPositions[index]);
|
938
939
|
// accumulate delta (it's reset in end of frame), if we just write it here it's not correct when the browser console is open
|
939
|
-
const delta = this._pointerPositionsDelta[
|
940
|
+
const delta = this._pointerPositionsDelta[index];
|
940
941
|
let dx = evt.clientX - lf.x;
|
941
942
|
let dy = evt.clientY - lf.y;
|
942
943
|
// if pointer is locked, clientX and Y are not changed, but Movement is.
|
@@ -950,14 +951,14 @@
|
|
950
951
|
delta.x += dx;
|
951
952
|
delta.y += dy;
|
952
953
|
|
953
|
-
this._pointerPositions[
|
954
|
-
this._pointerPositions[
|
954
|
+
this._pointerPositions[index].x = evt.clientX;
|
955
|
+
this._pointerPositions[index].y = evt.clientY;
|
955
956
|
|
956
957
|
// we want to have the position 01 on the canvas for raycasting
|
957
958
|
const px = evt.clientX;
|
958
959
|
const py = evt.clientY;
|
959
|
-
while (
|
960
|
-
const rc = this._pointerPositionsRC[
|
960
|
+
while (index >= this._pointerPositionsRC.length) this._pointerPositionsRC.push(new Vector2());
|
961
|
+
const rc = this._pointerPositionsRC[index];
|
961
962
|
rc.set(px, py);
|
962
963
|
this.convertScreenspaceToRaycastSpace(rc);
|
963
964
|
// console.log(this.context.alias, rc);
|
@@ -80,6 +80,7 @@
|
|
80
80
|
sourceId = sourceId.uri;
|
81
81
|
const settings = this._sceneLightSettings?.get(sourceId);
|
82
82
|
if (!settings) {
|
83
|
+
if(debug) console.warn("No light settings found for", sourceId);
|
83
84
|
return false;
|
84
85
|
}
|
85
86
|
if (debug) console.log("Enable scene light settings", sourceId, settings);
|
@@ -181,8 +181,9 @@
|
|
181
181
|
return ('xr' in navigator) ? navigator.xr : undefined;
|
182
182
|
}
|
183
183
|
static isXRSupported() { return Promise.all([this.isVRSupported(), this.isARSupported()]).then(res => res.some(e => e)).catch(() => false); }
|
184
|
-
static isVRSupported() { return this.
|
185
|
-
static isARSupported() { return this.
|
184
|
+
static isVRSupported() { return this.isSessionSupported("immersive-vr"); }
|
185
|
+
static isARSupported() { return this.isSessionSupported("immersive-ar"); }
|
186
|
+
static isSessionSupported(mode: XRSessionMode) { return this.xrSystem?.isSessionSupported(mode).catch(err => { if (debug) console.error(err); return false }) ?? Promise.resolve(false); }
|
186
187
|
|
187
188
|
private static _currentSessionRequest?: Promise<XRSession>;
|
188
189
|
private static _activeSession: NeedleXRSession | null;
|
@@ -297,11 +297,11 @@
|
|
297
297
|
}
|
298
298
|
|
299
299
|
private updateSessionSupported(button: HTMLButtonElement, mode: XRSessionMode) {
|
300
|
-
if (!navigator
|
300
|
+
if (!("xr" in navigator)) {
|
301
301
|
button.style.display = "none";
|
302
302
|
return;
|
303
303
|
}
|
304
|
-
|
304
|
+
NeedleXRSession.isSessionSupported(mode).then(supported => {
|
305
305
|
button.style.display = !supported ? "none" : "";
|
306
306
|
if (isDevEnvironment() && !supported) console.warn(mode + " is not supported on this device - make sure your server runs using HTTPS and you have a device connected that supports " + mode);
|
307
307
|
});
|