@needle-tools/engine 4.4.0-beta.4 → 4.4.0-beta.6
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/CHANGELOG.md +4 -3
- package/dist/needle-engine.bundle.js +4340 -4317
- package/dist/needle-engine.bundle.light.js +4298 -4275
- package/dist/needle-engine.bundle.light.min.js +103 -103
- package/dist/needle-engine.bundle.light.umd.cjs +100 -100
- package/dist/needle-engine.bundle.min.js +103 -103
- package/dist/needle-engine.bundle.umd.cjs +103 -103
- package/lib/engine/engine_components.js +3 -1
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_context.d.ts +10 -1
- package/lib/engine/engine_context.js +33 -12
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_element.js +1 -1
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.js +1 -1
- package/lib/engine/engine_utils_screenshot.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +6 -6
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
- package/lib/engine/xr/NeedleXRController.js +2 -3
- package/lib/engine/xr/NeedleXRController.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.js +12 -12
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine-components/CameraUtils.js +7 -4
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +1 -0
- package/lib/engine-components/ReflectionProbe.js +16 -9
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/package.json +1 -1
- package/plugins/common/license.js +2 -2
- package/plugins/types/userconfig.d.ts +3 -0
- package/plugins/vite/build-pipeline.js +1 -1
- package/src/engine/codegen/register_types.ts +2 -2
- package/src/engine/engine_components.ts +2 -1
- package/src/engine/engine_context.ts +36 -12
- package/src/engine/engine_element.ts +1 -1
- package/src/engine/engine_utils_screenshot.ts +1 -1
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +6 -6
- package/src/engine/xr/NeedleXRController.ts +2 -3
- package/src/engine/xr/NeedleXRSession.ts +12 -12
- package/src/engine-components/CameraUtils.ts +7 -4
- package/src/engine-components/ReflectionProbe.ts +15 -8
|
@@ -381,12 +381,11 @@ export class NeedleXRController implements IPointerHitEventReceiver {
|
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
onUpdate(frame: XRFrame) {
|
|
384
|
-
performance.mark('NeedleXRController onUpdate start');
|
|
385
384
|
this.onUpdateFrame(frame);
|
|
386
385
|
this.updateInputEvents();
|
|
387
386
|
this.onUpdateMove();
|
|
388
|
-
performance.mark('NeedleXRController onUpdate end');
|
|
389
|
-
performance.measure('NeedleXRController onUpdate', 'NeedleXRController onUpdate start', 'NeedleXRController onUpdate end');
|
|
387
|
+
//performance.mark('NeedleXRController onUpdate end');
|
|
388
|
+
//performance.measure('NeedleXRController onUpdate', 'NeedleXRController onUpdate start', 'NeedleXRController onUpdate end');
|
|
390
389
|
}
|
|
391
390
|
|
|
392
391
|
onRenderDebug() {
|
|
@@ -444,7 +444,7 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
444
444
|
if (!context) context = ContextRegistry.All[0] as Context;
|
|
445
445
|
if (!context) throw new Error("No Needle Engine Context found");
|
|
446
446
|
|
|
447
|
-
performance.mark('NeedleXRSession start');
|
|
447
|
+
//performance.mark('NeedleXRSession start');
|
|
448
448
|
|
|
449
449
|
// setup session init args, make sure we have default values
|
|
450
450
|
if (!init) init = {};
|
|
@@ -534,8 +534,8 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
534
534
|
return null;
|
|
535
535
|
}
|
|
536
536
|
const session = this.setSession(mode, newSession, init, context);
|
|
537
|
-
performance.mark('NeedleXRSession end');
|
|
538
|
-
performance.measure('NeedleXRSession Startup', 'NeedleXRSession start', 'NeedleXRSession end');
|
|
537
|
+
//performance.mark('NeedleXRSession end');
|
|
538
|
+
//performance.measure('NeedleXRSession Startup', 'NeedleXRSession start', 'NeedleXRSession end');
|
|
539
539
|
return session;
|
|
540
540
|
}
|
|
541
541
|
|
|
@@ -884,7 +884,7 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
884
884
|
/** the initialization arguments */
|
|
885
885
|
init: XRSessionInit,
|
|
886
886
|
}) {
|
|
887
|
-
performance.mark(measure_SessionStartedMarker);
|
|
887
|
+
//performance.mark(measure_SessionStartedMarker);
|
|
888
888
|
|
|
889
889
|
saveSessionInfo(mode, extra.init);
|
|
890
890
|
this.session = session;
|
|
@@ -1128,8 +1128,8 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1128
1128
|
|
|
1129
1129
|
enableSpatialConsole(false);
|
|
1130
1130
|
|
|
1131
|
-
performance.mark(measure_SessionEndedMarker);
|
|
1132
|
-
performance.measure('NeedleXRSession', measure_SessionStartedMarker, measure_SessionEndedMarker);
|
|
1131
|
+
//performance.mark(measure_SessionEndedMarker);
|
|
1132
|
+
//performance.measure('NeedleXRSession', measure_SessionStartedMarker, measure_SessionEndedMarker);
|
|
1133
1133
|
};
|
|
1134
1134
|
|
|
1135
1135
|
private _didStart: boolean = false;
|
|
@@ -1139,7 +1139,7 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1139
1139
|
const frame = context.xrFrame;
|
|
1140
1140
|
if (!frame) return;
|
|
1141
1141
|
|
|
1142
|
-
performance.mark('NeedleXRSession onBefore start');
|
|
1142
|
+
//performance.mark('NeedleXRSession onBefore start');
|
|
1143
1143
|
|
|
1144
1144
|
// ensure that XR is always set to a running session
|
|
1145
1145
|
this.context.xr = this;
|
|
@@ -1291,7 +1291,7 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1291
1291
|
console.error("XRControllers are not added but inputSources are present");
|
|
1292
1292
|
}
|
|
1293
1293
|
|
|
1294
|
-
performance.mark('NeedleXRSession update scripts start');
|
|
1294
|
+
//performance.mark('NeedleXRSession update scripts start');
|
|
1295
1295
|
// invoke update on all scripts
|
|
1296
1296
|
for (const script of this._xr_update_scripts) {
|
|
1297
1297
|
if (script.destroyed === true) {
|
|
@@ -1304,8 +1304,8 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1304
1304
|
}
|
|
1305
1305
|
if (script.onUpdateXR) script.onUpdateXR(args);
|
|
1306
1306
|
}
|
|
1307
|
-
performance.mark('NeedleXRSession update scripts end');
|
|
1308
|
-
performance.measure('NeedleXRSession update scripts', 'NeedleXRSession update scripts start', 'NeedleXRSession update scripts end');
|
|
1307
|
+
//performance.mark('NeedleXRSession update scripts end');
|
|
1308
|
+
//performance.measure('NeedleXRSession update scripts', 'NeedleXRSession update scripts start', 'NeedleXRSession update scripts end');
|
|
1309
1309
|
|
|
1310
1310
|
// handle inactive scripts
|
|
1311
1311
|
this.handleInactiveScripts();
|
|
@@ -1326,8 +1326,8 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1326
1326
|
this.sync?.onUpdate(this);
|
|
1327
1327
|
|
|
1328
1328
|
this.onRenderDebug();
|
|
1329
|
-
performance.mark('NeedleXRSession onBefore end');
|
|
1330
|
-
performance.measure('NE XR frame', 'NeedleXRSession onBefore start', 'NeedleXRSession onBefore end');
|
|
1329
|
+
//performance.mark('NeedleXRSession onBefore end');
|
|
1330
|
+
//performance.measure('NE XR frame', 'NeedleXRSession onBefore start', 'NeedleXRSession onBefore end');
|
|
1331
1331
|
}
|
|
1332
1332
|
|
|
1333
1333
|
private onRenderDebug() {
|
|
@@ -46,11 +46,14 @@ ContextRegistry.registerCallback(ContextEvent.MissingCamera, (evt) => {
|
|
|
46
46
|
else {
|
|
47
47
|
camInstance.clearFlags = ClearFlags.SolidColor;
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
backgroundColor = "#
|
|
49
|
+
// Don't set the background color if the user set a background color in the <needle-engine> element
|
|
50
|
+
if (!evt.context.domElement.getAttribute("background-color")) {
|
|
51
|
+
let backgroundColor = "#efefef";
|
|
52
|
+
if (typeof window !== undefined && (window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
53
|
+
backgroundColor = "#1f1f1f";
|
|
54
|
+
}
|
|
55
|
+
scene.background = new Color(backgroundColor); // dont set it on the camera because this might be controlled from "background-color" attribute which is set on the scene directly. If the camera has a background color, it will override the scene's background color
|
|
52
56
|
}
|
|
53
|
-
scene.background = new Color(backgroundColor); // dont set it on the camera because this might be controlled from "background-color" attribute which is set on the scene directly. If the camera has a background color, it will override the scene's background color
|
|
54
57
|
|
|
55
58
|
// Generate a default environment map if none is set
|
|
56
59
|
if (!scene.environment) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EquirectangularReflectionMapping, Material, MeshBasicMaterial, Object3D, SRGBColorSpace, Texture, Vector3 } from "three";
|
|
1
|
+
import { EquirectangularReflectionMapping, LinearSRGBColorSpace, Material, MeshBasicMaterial, Object3D, SRGBColorSpace, Texture, Vector3 } from "three";
|
|
2
2
|
|
|
3
3
|
import { serializable } from "../engine/engine_serialization.js";
|
|
4
4
|
import { Context } from "../engine/engine_setup.js";
|
|
@@ -6,6 +6,7 @@ import type { IRenderer } from "../engine/engine_types.js";
|
|
|
6
6
|
import { getParam } from "../engine/engine_utils.js";
|
|
7
7
|
import { BoxHelperComponent } from "./BoxHelperComponent.js";
|
|
8
8
|
import { Behaviour } from "./Component.js";
|
|
9
|
+
import { isDevEnvironment, showBalloonWarning } from "../engine/debug/index.js";
|
|
9
10
|
|
|
10
11
|
export const debug = getParam("debugreflectionprobe");
|
|
11
12
|
const disable = getParam("noreflectionprobe");
|
|
@@ -35,13 +36,11 @@ export class ReflectionProbe extends Behaviour {
|
|
|
35
36
|
return probe;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
/*
|
|
39
39
|
// TODO not supported right now, as we'd have to pass the ReflectionProbe scale through as well.
|
|
40
40
|
else if (probe.isInBox(object)) {
|
|
41
41
|
if (debug) console.log("Found reflection probe", object.name, probe.name);
|
|
42
42
|
return probe;
|
|
43
43
|
}
|
|
44
|
-
*/
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
}
|
|
@@ -53,6 +52,8 @@ export class ReflectionProbe extends Behaviour {
|
|
|
53
52
|
|
|
54
53
|
|
|
55
54
|
private _texture!: Texture;
|
|
55
|
+
|
|
56
|
+
// @serializable(Texture)
|
|
56
57
|
set texture(tex: Texture) {
|
|
57
58
|
if (tex && !(tex instanceof Texture)) {
|
|
58
59
|
console.error("ReflectionProbe.texture must be a Texture", tex);
|
|
@@ -61,7 +62,7 @@ export class ReflectionProbe extends Behaviour {
|
|
|
61
62
|
this._texture = tex;
|
|
62
63
|
if (tex) {
|
|
63
64
|
tex.mapping = EquirectangularReflectionMapping;
|
|
64
|
-
tex.colorSpace =
|
|
65
|
+
tex.colorSpace = LinearSRGBColorSpace;
|
|
65
66
|
tex.needsUpdate = true;
|
|
66
67
|
}
|
|
67
68
|
}
|
|
@@ -94,10 +95,16 @@ export class ReflectionProbe extends Behaviour {
|
|
|
94
95
|
if (debug)
|
|
95
96
|
this._boxHelper.showHelper(0x555500, true);
|
|
96
97
|
|
|
97
|
-
if (this.
|
|
98
|
-
this.
|
|
99
|
-
this.
|
|
100
|
-
this.
|
|
98
|
+
if (this._texture) {
|
|
99
|
+
this._texture.mapping = EquirectangularReflectionMapping;
|
|
100
|
+
this._texture.colorSpace = LinearSRGBColorSpace;
|
|
101
|
+
this._texture.needsUpdate = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
start(): void {
|
|
105
|
+
if (!this._texture && isDevEnvironment()) {
|
|
106
|
+
console.warn(`[ReflectionProbe] Missing texture. Please assign a custom cubemap texture. To use reflection probes assign them to your renderer's "anchor" property.`);
|
|
107
|
+
showBalloonWarning("ReflectionProbe configuration hint: See browser console for details")
|
|
101
108
|
}
|
|
102
109
|
}
|
|
103
110
|
|