@needle-tools/engine 4.6.0-next.1bf6c80 → 4.6.0-next.3088402
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/dist/{needle-engine.bundle-CAOdqmHM.js → needle-engine.bundle-B1JFnMRs.js} +2874 -2868
- package/dist/{needle-engine.bundle-DIa3s45l.min.js → needle-engine.bundle-CLbeONlI.min.js} +112 -112
- package/dist/{needle-engine.bundle-DVMOm-oS.umd.cjs → needle-engine.bundle-CpQAQ_2N.umd.cjs} +112 -112
- package/dist/needle-engine.js +2 -2
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +2 -1
- package/lib/engine-components/ReflectionProbe.js +4 -1
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.js +9 -5
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js +10 -6
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js.map +1 -1
- package/package.json +1 -1
- package/plugins/vite/dependency-watcher.js +8 -2
- package/src/engine-components/ReflectionProbe.ts +5 -1
- package/src/engine-components/Renderer.ts +10 -7
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +9 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/engine",
|
|
3
|
-
"version": "4.6.0-next.
|
|
3
|
+
"version": "4.6.0-next.3088402",
|
|
4
4
|
"description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.",
|
|
5
5
|
"main": "dist/needle-engine.min.js",
|
|
6
6
|
"exports": {
|
|
@@ -162,8 +162,14 @@ function testIfInstallIsRequired(projectDir, packageJson) {
|
|
|
162
162
|
}
|
|
163
163
|
if (expectedVersion?.length > 0) {
|
|
164
164
|
const isRange = expectedVersion.includes("x") || expectedVersion.includes("^") || expectedVersion.includes(">") || expectedVersion.includes("<") || expectedVersion.includes("~");
|
|
165
|
-
const
|
|
166
|
-
|
|
165
|
+
const isTagName = expectedVersion === "stable" ||
|
|
166
|
+
expectedVersion === "latest" ||
|
|
167
|
+
expectedVersion === "next" ||
|
|
168
|
+
expectedVersion === "beta" ||
|
|
169
|
+
expectedVersion === "alpha" ||
|
|
170
|
+
expectedVersion === "canary" ||
|
|
171
|
+
expectedVersion === "experimental";
|
|
172
|
+
if (!isRange && !isTagName) {
|
|
167
173
|
const packageJsonPath = path.join(depPath, "package.json");
|
|
168
174
|
/** @type {String} */
|
|
169
175
|
const installedVersion = JSON.parse(readFileSync(packageJsonPath, "utf8")).version;
|
|
@@ -22,6 +22,10 @@ export class ReflectionProbe extends Behaviour {
|
|
|
22
22
|
|
|
23
23
|
private static _probes: Map<Context, ReflectionProbe[]> = new Map();
|
|
24
24
|
|
|
25
|
+
static isUsingReflectionProbe(material: Material) {
|
|
26
|
+
return !!(material[$reflectionProbeKey] || material[$originalMaterial]?.[$reflectionProbeKey]);
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
public static get(object: Object3D | null | undefined, context: Context, isAnchor: boolean, anchor?: Object3D): ReflectionProbe | null {
|
|
26
30
|
if (!object || object.isObject3D !== true) return null;
|
|
27
31
|
if (disable) return null;
|
|
@@ -29,7 +33,7 @@ export class ReflectionProbe extends Behaviour {
|
|
|
29
33
|
if (probes) {
|
|
30
34
|
for (const probe of probes) {
|
|
31
35
|
if (!probe.__didAwake) probe.__internalAwake();
|
|
32
|
-
if (probe.
|
|
36
|
+
if (probe.activeAndEnabled) {
|
|
33
37
|
if (anchor) {
|
|
34
38
|
// test if anchor is reflection probe object
|
|
35
39
|
if (probe.gameObject === anchor) {
|
|
@@ -708,7 +708,15 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
708
708
|
if (this.reflectionProbeUsage !== ReflectionProbeUsage.Off && this._reflectionProbe) {
|
|
709
709
|
this._reflectionProbe.onSet(this);
|
|
710
710
|
}
|
|
711
|
-
|
|
711
|
+
// since three 163 we need to set the envMap to the scene envMap if it is not set
|
|
712
|
+
// otherwise the envmapIntensity has no effect: https://github.com/mrdoob/three.js/pull/27903
|
|
713
|
+
// internal issue: https://linear.app/needle/issue/NE-6363
|
|
714
|
+
for (const mat of this._sharedMaterials) {
|
|
715
|
+
// If the material has a envMap and is NOT using a reflection probe we set the envMap to the scene environment
|
|
716
|
+
if (mat && "envMap" in mat && "envMapIntensity" in mat && !ReflectionProbe.isUsingReflectionProbe(mat)) {
|
|
717
|
+
mat.envMap = this.context.scene.environment;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
712
720
|
}
|
|
713
721
|
|
|
714
722
|
private onBeforeRenderThree = (_renderer, _scene, _camera, _geometry, material, _group) => {
|
|
@@ -716,11 +724,6 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
716
724
|
const factor = this.hasLightmap ? Math.PI : 1;
|
|
717
725
|
const environmentIntensity = this.context.mainCameraComponent?.environmentIntensity ?? 1;
|
|
718
726
|
material.envMapIntensity = Math.max(0, environmentIntensity * this.context.sceneLighting.environmentIntensity / factor);
|
|
719
|
-
|
|
720
|
-
// since three 163 we need to set the envMap to the scene envMap if it is not set
|
|
721
|
-
// otherwise the envmapIntensity has no effect: https://github.com/mrdoob/three.js/pull/27903
|
|
722
|
-
// internal issue: https://linear.app/needle/issue/NE-6363
|
|
723
|
-
if (!material.envMap) material.envMap = this.context.scene.environment;
|
|
724
727
|
}
|
|
725
728
|
|
|
726
729
|
if (this._lightmaps) {
|
|
@@ -856,7 +859,7 @@ export class SkinnedMeshRenderer extends MeshRenderer {
|
|
|
856
859
|
mesh.computeBoundingSphere();
|
|
857
860
|
mesh.geometry = geometry;
|
|
858
861
|
}
|
|
859
|
-
catch(err) {
|
|
862
|
+
catch (err) {
|
|
860
863
|
console.error(`Error updating bounding sphere for ${mesh.name}`, err);
|
|
861
864
|
}
|
|
862
865
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ToneMappingEffect as _TonemappingEffect, ToneMappingMode } from "postprocessing";
|
|
2
|
-
import { ACESFilmicToneMapping, AgXToneMapping, LinearToneMapping, NeutralToneMapping, NoToneMapping, ReinhardToneMapping } from "three";
|
|
2
|
+
import { ACESFilmicToneMapping, AgXToneMapping, LinearToneMapping, NeutralToneMapping, NoToneMapping, ReinhardToneMapping, WebGLRenderer } from "three";
|
|
3
3
|
|
|
4
4
|
import { MODULES } from "../../../engine/engine_modules.js";
|
|
5
5
|
import { serializable } from "../../../engine/engine_serialization.js";
|
|
@@ -36,6 +36,7 @@ function toThreeToneMapping(mode: NEToneMappingMode | undefined) {
|
|
|
36
36
|
case NEToneMappingMode.KhronosNeutral:
|
|
37
37
|
return NeutralToneMapping;
|
|
38
38
|
default:
|
|
39
|
+
if(debug) console.warn("[Postprocessing] Unknown tone mapping mode", mode);
|
|
39
40
|
return NeutralToneMapping;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -84,7 +85,7 @@ export class ToneMappingEffect extends PostProcessingEffect {
|
|
|
84
85
|
setMode(mode: NEToneMappingModeNames) {
|
|
85
86
|
const enumValue = NEToneMappingMode[mode as NEToneMappingModeNames];
|
|
86
87
|
if (enumValue === undefined) {
|
|
87
|
-
console.error("Invalid ToneMapping mode", mode);
|
|
88
|
+
console.error("[PostProcessing] Invalid ToneMapping mode", mode);
|
|
88
89
|
return this;
|
|
89
90
|
}
|
|
90
91
|
this.mode.value = enumValue;
|
|
@@ -110,7 +111,7 @@ export class ToneMappingEffect extends PostProcessingEffect {
|
|
|
110
111
|
if (other === this) break;
|
|
111
112
|
// If another tonemapping effect is found, warn the user
|
|
112
113
|
if (other != this && other instanceof ToneMappingEffect) {
|
|
113
|
-
console.warn("Multiple tonemapping effects found in the same postprocessing stack: Please check your scene setup.", { activeEffect: other, ignoredEffect: this });
|
|
114
|
+
console.warn("[PostProcessing] Multiple tonemapping effects found in the same postprocessing stack: Please check your scene setup.", { activeEffect: other, ignoredEffect: this });
|
|
114
115
|
return undefined;
|
|
115
116
|
}
|
|
116
117
|
}
|
|
@@ -119,8 +120,9 @@ export class ToneMappingEffect extends PostProcessingEffect {
|
|
|
119
120
|
|
|
120
121
|
// ensure the effect tonemapping value is initialized
|
|
121
122
|
if (this.mode.isInitialized == false) {
|
|
122
|
-
const
|
|
123
|
-
this.mode
|
|
123
|
+
const mode = threeToNeToneMapping(this.context.renderer.toneMapping);
|
|
124
|
+
if(debug) console.log("[PostProcessing] Initializing ToneMapping mode to renderer.toneMapping", this.context.renderer.toneMapping + " → " + mode);
|
|
125
|
+
this.mode.initialize(mode);
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
const threeMode = toThreeToneMapping(this.mode.value);
|
|
@@ -130,9 +132,9 @@ export class ToneMappingEffect extends PostProcessingEffect {
|
|
|
130
132
|
this.mode.onValueChanged = (newValue) => {
|
|
131
133
|
const threeMode = toThreeToneMapping(newValue);
|
|
132
134
|
tonemapping.mode = threeToneMappingToEffectMode(threeMode);
|
|
133
|
-
if (debug) console.log("ToneMapping mode changed to", NEToneMappingMode[newValue], threeMode, tonemapping.mode);
|
|
135
|
+
if (debug) console.log("[PostProcessing] ToneMapping mode changed to", NEToneMappingMode[newValue], threeMode, tonemapping.mode);
|
|
134
136
|
};
|
|
135
|
-
if (debug) console.log("Use ToneMapping", NEToneMappingMode[this.mode.value], threeMode, tonemapping.mode, "renderer.tonemapping: " + this.context.renderer.toneMapping);
|
|
137
|
+
if (debug) console.log("[PostProcessing] Use ToneMapping", NEToneMappingMode[this.mode.value], threeMode, tonemapping.mode, "renderer.tonemapping: " + this.context.renderer.toneMapping);
|
|
136
138
|
|
|
137
139
|
|
|
138
140
|
this.exposure.onValueChanged = (newValue) => {
|