@needle-tools/engine 4.5.8-next.e775d5d → 4.6.0-next.16a31e7
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 +10 -0
- package/dist/{gltf-progressive-Bx_ZJgfQ.min.js → gltf-progressive-Bm9eEfgu.min.js} +1 -1
- package/dist/{gltf-progressive-Ccf3INjK.umd.cjs → gltf-progressive-Dn6o99rH.umd.cjs} +1 -1
- package/dist/{gltf-progressive-D8GP6sjZ.js → gltf-progressive-GjIqwSG3.js} +2 -2
- package/dist/{needle-engine.bundle-BiAJyneD.min.js → needle-engine.bundle-B3R3Wy6r.min.js} +128 -124
- package/dist/{needle-engine.bundle-DJj-8wQv.js → needle-engine.bundle-CD_7OoAZ.js} +5920 -5903
- package/dist/{needle-engine.bundle-CTuPA4BD.umd.cjs → needle-engine.bundle-zz9fVYpB.umd.cjs} +141 -137
- package/dist/needle-engine.js +4 -4
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-CLwnKusi.umd.cjs → postprocessing-CRQa6Qxn.umd.cjs} +177 -97
- package/dist/{postprocessing-DS5I4Iim.js → postprocessing-D6W1EyZ-.js} +1095 -1001
- package/dist/{postprocessing-CdIScgB8.min.js → postprocessing-DF8AlRgW.min.js} +178 -98
- package/dist/{three-CFtLGNtV.min.js → three-Boa-jOq-.min.js} +18 -18
- package/dist/{three-1JG7vpNC.js → three-Bz6X1mrw.js} +0 -1
- package/dist/{three-f-JuZtOs.umd.cjs → three-DMrv-4ar.umd.cjs} +20 -20
- package/dist/{three-examples-BeoqFh8m.umd.cjs → three-examples-C7ryg8vN.umd.cjs} +1 -1
- package/dist/{three-examples-CPlN41GO.min.js → three-examples-DuVhxqft.min.js} +1 -1
- package/dist/{three-examples-CyWe9wwo.js → three-examples-GggCDHv0.js} +1 -1
- package/dist/{three-mesh-ui-B18kdQmk.js → three-mesh-ui-CLNOfsWn.js} +1 -1
- package/dist/{three-mesh-ui-BMeLuYD5.min.js → three-mesh-ui-CY6Izc7C.min.js} +1 -1
- package/dist/{three-mesh-ui-DMdtSVhY.umd.cjs → three-mesh-ui-CwlN0FUC.umd.cjs} +1 -1
- package/dist/{vendor-BbM-oI6p.js → vendor-BSD1RQIh.js} +1 -1
- package/dist/{vendor-CJFfVMoq.umd.cjs → vendor-DHr4aqIZ.umd.cjs} +1 -1
- package/dist/{vendor-CTtGKiDe.min.js → vendor-zxXa3Dmr.min.js} +1 -1
- package/lib/engine/engine_assetdatabase.js +3 -1
- package/lib/engine/engine_assetdatabase.js.map +1 -1
- package/lib/engine/engine_context.d.ts +2 -2
- package/lib/engine/engine_context.js +11 -10
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_utils.js +1 -1
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine-components/AudioSource.d.ts +1 -1
- package/lib/engine-components/AudioSource.js +5 -4
- package/lib/engine-components/AudioSource.js.map +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/Skybox.d.ts +7 -1
- package/lib/engine-components/Skybox.js +30 -9
- package/lib/engine-components/Skybox.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/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +2 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +81 -66
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/package.json +1 -1
- package/plugins/types/userconfig.d.ts +1 -1
- package/plugins/vite/asap.js +26 -20
- package/plugins/vite/dependency-watcher.js +8 -2
- package/plugins/vite/local-files.js +268 -59
- package/src/engine/engine_assetdatabase.ts +3 -1
- package/src/engine/engine_context.ts +14 -11
- package/src/engine/engine_utils.ts +1 -1
- package/src/engine-components/AudioSource.ts +5 -5
- package/src/engine-components/ReflectionProbe.ts +5 -1
- package/src/engine-components/Renderer.ts +10 -7
- package/src/engine-components/Skybox.ts +30 -10
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +9 -7
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +88 -72
|
@@ -124,11 +124,17 @@ function registerLoadedTexture(src: string, texture: Promise<Texture>) {
|
|
|
124
124
|
* evt.detail.apply(url);
|
|
125
125
|
* });
|
|
126
126
|
* ```
|
|
127
|
+
*
|
|
128
|
+
* @example update skybox url
|
|
129
|
+
* ```ts
|
|
130
|
+
* skybox.setSkybox("https://example.com/skybox.hdr");
|
|
131
|
+
* ```
|
|
127
132
|
*/
|
|
128
133
|
export class RemoteSkybox extends Behaviour {
|
|
129
134
|
|
|
130
135
|
/**
|
|
131
|
-
* URL to a remote skybox. This value can also use a magic skybox name. Options are "quicklook", "quicklook-ar", "studio", "blurred-skybox".
|
|
136
|
+
* URL to a remote skybox. This value can also use a magic skybox name. Options are "quicklook", "quicklook-ar", "studio", "blurred-skybox".
|
|
137
|
+
* To update the skybox/environment map use `setSkybox(url)`
|
|
132
138
|
* @example
|
|
133
139
|
* ```ts
|
|
134
140
|
* skybox.url = "https://example.com/skybox.hdr";
|
|
@@ -197,6 +203,9 @@ export class RemoteSkybox extends Behaviour {
|
|
|
197
203
|
if (this.isRemoteTexture(this.url)) {
|
|
198
204
|
this.setSkybox(this.url);
|
|
199
205
|
}
|
|
206
|
+
else if (debug) {
|
|
207
|
+
console.warn(`RemoteSkybox: Not setting skybox: ${this.url} is not a remote texture. If you want to set a local texture, set allowNetworking to false.`);
|
|
208
|
+
}
|
|
200
209
|
}
|
|
201
210
|
}
|
|
202
211
|
|
|
@@ -222,7 +231,7 @@ export class RemoteSkybox extends Behaviour {
|
|
|
222
231
|
if (debug) console.log("Set remote skybox url: " + url);
|
|
223
232
|
|
|
224
233
|
if (this._prevUrl === url && this._prevLoadedEnvironment) {
|
|
225
|
-
this.
|
|
234
|
+
this.apply();
|
|
226
235
|
return true;
|
|
227
236
|
}
|
|
228
237
|
else {
|
|
@@ -231,19 +240,30 @@ export class RemoteSkybox extends Behaviour {
|
|
|
231
240
|
}
|
|
232
241
|
this._prevUrl = url;
|
|
233
242
|
|
|
234
|
-
const
|
|
235
|
-
if (!
|
|
243
|
+
const texture = await this.loadTexture(url, name);
|
|
244
|
+
if (!texture) {
|
|
245
|
+
if (debug) console.warn("RemoteSkybox: Failed to load texture from url", url);
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
236
248
|
// Check if we're still enabled
|
|
237
|
-
if (!this.enabled)
|
|
249
|
+
if (!this.enabled) {
|
|
250
|
+
if (debug) console.warn("RemoteSkybox: Component is not enabled, aborting setSkybox");
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
// Check if the url has changed while loading
|
|
254
|
+
if (this._prevUrl !== url) {
|
|
255
|
+
if (debug) console.warn("RemoteSkybox: URL changed while loading texture, aborting setSkybox");
|
|
256
|
+
return false; // URL changed while loading
|
|
257
|
+
}
|
|
238
258
|
// Update the current url
|
|
239
259
|
this.url = url;
|
|
240
260
|
const nameIndex = url.lastIndexOf("/");
|
|
241
|
-
|
|
261
|
+
texture.name = url.substring(nameIndex >= 0 ? nameIndex + 1 : 0);
|
|
242
262
|
if (this._loader instanceof TextureLoader) {
|
|
243
|
-
|
|
263
|
+
texture.colorSpace = SRGBColorSpace;
|
|
244
264
|
}
|
|
245
|
-
this._prevLoadedEnvironment =
|
|
246
|
-
this.
|
|
265
|
+
this._prevLoadedEnvironment = texture;
|
|
266
|
+
this.apply();
|
|
247
267
|
return true;
|
|
248
268
|
}
|
|
249
269
|
|
|
@@ -284,7 +304,7 @@ export class RemoteSkybox extends Behaviour {
|
|
|
284
304
|
return envMap;
|
|
285
305
|
}
|
|
286
306
|
|
|
287
|
-
private
|
|
307
|
+
private apply() {
|
|
288
308
|
const envMap = this._prevLoadedEnvironment;
|
|
289
309
|
if (!envMap) return;
|
|
290
310
|
|
|
@@ -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) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Effect, EffectComposer, Pass, ToneMappingEffect as _TonemappingEffect } from "postprocessing";
|
|
2
|
-
import { HalfFloatType, NoToneMapping } from "three";
|
|
2
|
+
import { HalfFloatType, NoToneMapping, Camera as Camera3 } from "three";
|
|
3
3
|
|
|
4
4
|
import { showBalloonWarning } from "../../engine/debug/index.js";
|
|
5
5
|
// import { internal_SetSharpeningEffectModule } from "./Effects/Sharpening.js";
|
|
@@ -44,7 +44,7 @@ export class PostProcessingHandler {
|
|
|
44
44
|
this.context = context;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
apply(components: PostProcessingEffect[])
|
|
47
|
+
apply(components: PostProcessingEffect[]): Promise<void> {
|
|
48
48
|
if ("env" in import.meta && import.meta.env.VITE_NEEDLE_USE_POSTPROCESSING === "false") {
|
|
49
49
|
if (debug) console.warn("Postprocessing is disabled via vite env setting");
|
|
50
50
|
else console.debug("Postprocessing is disabled via vite env setting");
|
|
@@ -169,9 +169,7 @@ export class PostProcessingHandler {
|
|
|
169
169
|
private applyEffects(context: Context) {
|
|
170
170
|
|
|
171
171
|
const effectsOrPasses = this._effects;
|
|
172
|
-
|
|
173
172
|
if (effectsOrPasses.length <= 0) return;
|
|
174
|
-
|
|
175
173
|
const camera = context.mainCameraComponent as Camera;
|
|
176
174
|
const renderer = context.renderer;
|
|
177
175
|
const scene = context.scene;
|
|
@@ -199,6 +197,7 @@ export class PostProcessingHandler {
|
|
|
199
197
|
composer.setMainCamera(cam);
|
|
200
198
|
composer.setRenderer(renderer);
|
|
201
199
|
composer.setMainScene(scene);
|
|
200
|
+
composer.autoRenderToScreen = true; // Must be enabled because it might be disabled during addPass by the composer itself (depending on the effect's settings or order)
|
|
202
201
|
|
|
203
202
|
for (const prev of composer.passes)
|
|
204
203
|
prev.dispose();
|
|
@@ -218,9 +217,11 @@ export class PostProcessingHandler {
|
|
|
218
217
|
const effects: Array<Effect> = [];
|
|
219
218
|
|
|
220
219
|
for (const ef of effectsOrPasses) {
|
|
221
|
-
if (ef instanceof MODULES.POSTPROCESSING.MODULE.Effect)
|
|
220
|
+
if (ef instanceof MODULES.POSTPROCESSING.MODULE.Effect) {
|
|
222
221
|
effects.push(ef as Effect);
|
|
222
|
+
}
|
|
223
223
|
else if (ef instanceof MODULES.POSTPROCESSING.MODULE.Pass) {
|
|
224
|
+
ef.renderToScreen = false;
|
|
224
225
|
composer.addPass(ef as Pass);
|
|
225
226
|
}
|
|
226
227
|
else {
|
|
@@ -233,9 +234,10 @@ export class PostProcessingHandler {
|
|
|
233
234
|
// create and apply uber pass
|
|
234
235
|
if (effects.length > 0) {
|
|
235
236
|
const pass = new MODULES.POSTPROCESSING.MODULE.EffectPass(cam, ...effects);
|
|
236
|
-
pass.name = effects.map(e => e.name).join(" ");
|
|
237
|
+
pass.name = effects.map(e => e.name).join(", ");
|
|
237
238
|
pass.mainScene = scene;
|
|
238
239
|
pass.enabled = true;
|
|
240
|
+
pass.renderToScreen = false;
|
|
239
241
|
composer.addPass(pass);
|
|
240
242
|
}
|
|
241
243
|
}
|
|
@@ -255,8 +257,10 @@ export class PostProcessingHandler {
|
|
|
255
257
|
pass.name = ef.name;
|
|
256
258
|
composer.addPass(pass);
|
|
257
259
|
}
|
|
258
|
-
else if (ef instanceof MODULES.POSTPROCESSING.MODULE.Pass)
|
|
260
|
+
else if (ef instanceof MODULES.POSTPROCESSING.MODULE.Pass) {
|
|
261
|
+
ef.renderToScreen = false;
|
|
259
262
|
composer.addPass(ef as Pass);
|
|
263
|
+
}
|
|
260
264
|
else
|
|
261
265
|
// seems some effects are not correctly typed, but three can deal with them,
|
|
262
266
|
// so we just pass them through
|
|
@@ -264,10 +268,83 @@ export class PostProcessingHandler {
|
|
|
264
268
|
}
|
|
265
269
|
}
|
|
266
270
|
|
|
267
|
-
if (debug) {
|
|
268
271
|
|
|
269
|
-
|
|
272
|
+
// The last pass is the one that renders to the screen, so we need to set the gamma correction for it (and enable it for all others)
|
|
273
|
+
for (let i = 0; i < composer.passes.length; i++) {
|
|
274
|
+
const pass = composer.passes[i] as any;
|
|
275
|
+
const isLast = i === composer.passes.length - 1;
|
|
276
|
+
if (pass?.configuration !== undefined) {
|
|
277
|
+
pass.configuration.gammaCorrection = isLast;
|
|
278
|
+
}
|
|
279
|
+
else if ("autosetGamma" in pass) {
|
|
280
|
+
// Some effects have a autosetGamma property that we can use to set the gamma correction
|
|
281
|
+
pass.autosetGamma = isLast;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// DEBUG LAND BELOW
|
|
286
|
+
if (debug) console.log("[PostProcessing] Passes →", [...composer.passes], "\n---------------------------------\n• " + composer.passes.map(i => i.name).join("\n• ") + "\n");
|
|
287
|
+
if (debug) this._onCreateEffectsDebug(this._composer!, cam);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private orderEffects() {
|
|
291
|
+
if (debug === "verbose") console.debug("Before ordering effects", [...this._effects]);
|
|
292
|
+
|
|
293
|
+
// Order of effects for correct results.
|
|
294
|
+
// Aligned with https://github.com/pmndrs/postprocessing/wiki/Effect-Merging#effect-execution-order
|
|
295
|
+
// We can not put this into global scope because then the module might not yet be initialized
|
|
296
|
+
effectsOrder ??= [
|
|
297
|
+
MODULES.POSTPROCESSING.MODULE.NormalPass,
|
|
298
|
+
MODULES.POSTPROCESSING.MODULE.DepthDownsamplingPass,
|
|
299
|
+
MODULES.POSTPROCESSING.MODULE.SMAAEffect,
|
|
300
|
+
MODULES.POSTPROCESSING.MODULE.SSAOEffect,
|
|
301
|
+
MODULES.POSTPROCESSING_AO.MODULE.N8AOPostPass,
|
|
302
|
+
MODULES.POSTPROCESSING.MODULE.TiltShiftEffect,
|
|
303
|
+
MODULES.POSTPROCESSING.MODULE.DepthOfFieldEffect,
|
|
304
|
+
MODULES.POSTPROCESSING.MODULE.ChromaticAberrationEffect,
|
|
305
|
+
MODULES.POSTPROCESSING.MODULE.BloomEffect,
|
|
306
|
+
MODULES.POSTPROCESSING.MODULE.SelectiveBloomEffect,
|
|
307
|
+
MODULES.POSTPROCESSING.MODULE.VignetteEffect,
|
|
308
|
+
MODULES.POSTPROCESSING.MODULE.PixelationEffect,
|
|
309
|
+
MODULES.POSTPROCESSING.MODULE.ToneMappingEffect,
|
|
310
|
+
MODULES.POSTPROCESSING.MODULE.HueSaturationEffect,
|
|
311
|
+
MODULES.POSTPROCESSING.MODULE.BrightnessContrastEffect,
|
|
312
|
+
// __SHARPENING_MODULE._SharpeningEffect,
|
|
313
|
+
];
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
// TODO: enforce correct order of effects (e.g. DOF before Bloom)
|
|
317
|
+
const effects = this._effects;
|
|
318
|
+
effects.sort((a, b) => {
|
|
319
|
+
// we use find index here because sometimes constructor names are prefixed with `_`
|
|
320
|
+
// TODO: find a more robust solution that isnt name based (not sure if that exists tho... maybe we must give effect TYPES some priority/index)
|
|
321
|
+
const aidx = effectsOrder!.findIndex(e => a.constructor.name.endsWith(e.name));
|
|
322
|
+
const bidx = effectsOrder!.findIndex(e => b.constructor.name.endsWith(e.name));
|
|
323
|
+
// Unknown effects should be rendered first
|
|
324
|
+
if (aidx < 0) {
|
|
325
|
+
if (debug) console.warn("Unknown effect found: ", a.constructor.name);
|
|
326
|
+
return -1;
|
|
327
|
+
}
|
|
328
|
+
else if (bidx < 0) {
|
|
329
|
+
if (debug) console.warn("Unknown effect found: ", b.constructor.name);
|
|
330
|
+
return 1;
|
|
331
|
+
}
|
|
332
|
+
// if (aidx < 0) return 1;
|
|
333
|
+
// if (bidx < 0) return -1;
|
|
334
|
+
return aidx - bidx;
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
if (debug === "verbose") console.debug("After ordering effects", [...this._effects]);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
270
342
|
|
|
343
|
+
private _menuEntry: HTMLSelectElement | null = null;
|
|
344
|
+
private _passIndices: number[] | null = null;
|
|
345
|
+
|
|
346
|
+
private _onCreateEffectsDebug(composer: EffectComposer, cam: Camera3) {
|
|
347
|
+
if (debug === "passes") {
|
|
271
348
|
// DepthEffect for debugging purposes, disabled by default, can be selected in the debug pass select
|
|
272
349
|
const depthEffect = new MODULES.POSTPROCESSING.MODULE.DepthEffect({
|
|
273
350
|
blendFunction: MODULES.POSTPROCESSING.MODULE.BlendFunction.NORMAL,
|
|
@@ -303,7 +380,7 @@ export class PostProcessingHandler {
|
|
|
303
380
|
if (menu && this._passIndices === null) {
|
|
304
381
|
if (this._menuEntry)
|
|
305
382
|
this._menuEntry.remove();
|
|
306
|
-
|
|
383
|
+
|
|
307
384
|
const select = document.createElement("select");
|
|
308
385
|
select.multiple = true;
|
|
309
386
|
const defaultOpt = document.createElement("option");
|
|
@@ -327,73 +404,12 @@ export class PostProcessingHandler {
|
|
|
327
404
|
else {
|
|
328
405
|
this._passIndices = indices;
|
|
329
406
|
}
|
|
330
|
-
|
|
331
|
-
this.applyEffects(context);
|
|
407
|
+
this.applyEffects(this.context);
|
|
332
408
|
});
|
|
333
409
|
}
|
|
334
410
|
}
|
|
335
411
|
}
|
|
336
412
|
|
|
337
|
-
private _menuEntry: HTMLSelectElement | null = null;
|
|
338
|
-
private _passIndices: number[] | null = null;
|
|
339
|
-
|
|
340
|
-
private orderEffects() {
|
|
341
|
-
if (debug) console.log("Before ordering effects", [...this._effects]);
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
// Order of effects for correct results.
|
|
346
|
-
// Aligned with https://github.com/pmndrs/postprocessing/wiki/Effect-Merging#effect-execution-order
|
|
347
|
-
// We can not put this into global scope because then the module might not yet be initialized
|
|
348
|
-
effectsOrder ??= [
|
|
349
|
-
MODULES.POSTPROCESSING.MODULE.NormalPass,
|
|
350
|
-
MODULES.POSTPROCESSING.MODULE.DepthDownsamplingPass,
|
|
351
|
-
MODULES.POSTPROCESSING.MODULE.SMAAEffect,
|
|
352
|
-
MODULES.POSTPROCESSING.MODULE.SSAOEffect,
|
|
353
|
-
MODULES.POSTPROCESSING_AO.MODULE.N8AOPostPass,
|
|
354
|
-
MODULES.POSTPROCESSING.MODULE.TiltShiftEffect,
|
|
355
|
-
MODULES.POSTPROCESSING.MODULE.DepthOfFieldEffect,
|
|
356
|
-
MODULES.POSTPROCESSING.MODULE.ChromaticAberrationEffect,
|
|
357
|
-
MODULES.POSTPROCESSING.MODULE.BloomEffect,
|
|
358
|
-
MODULES.POSTPROCESSING.MODULE.SelectiveBloomEffect,
|
|
359
|
-
MODULES.POSTPROCESSING.MODULE.VignetteEffect,
|
|
360
|
-
MODULES.POSTPROCESSING.MODULE.PixelationEffect,
|
|
361
|
-
MODULES.POSTPROCESSING.MODULE.ToneMappingEffect,
|
|
362
|
-
MODULES.POSTPROCESSING.MODULE.HueSaturationEffect,
|
|
363
|
-
MODULES.POSTPROCESSING.MODULE.BrightnessContrastEffect,
|
|
364
|
-
// __SHARPENING_MODULE._SharpeningEffect,
|
|
365
|
-
];
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
// TODO: enforce correct order of effects (e.g. DOF before Bloom)
|
|
369
|
-
const effects = this._effects;
|
|
370
|
-
effects.sort((a, b) => {
|
|
371
|
-
// we use find index here because sometimes constructor names are prefixed with `_`
|
|
372
|
-
// TODO: find a more robust solution that isnt name based (not sure if that exists tho... maybe we must give effect TYPES some priority/index)
|
|
373
|
-
const aidx = effectsOrder!.findIndex(e => a.constructor.name.endsWith(e.name));
|
|
374
|
-
const bidx = effectsOrder!.findIndex(e => b.constructor.name.endsWith(e.name));
|
|
375
|
-
// Unknown effects should be rendered first
|
|
376
|
-
if (aidx < 0) {
|
|
377
|
-
if (debug) console.warn("Unknown effect found: ", a.constructor.name);
|
|
378
|
-
return -1;
|
|
379
|
-
}
|
|
380
|
-
else if (bidx < 0) {
|
|
381
|
-
if (debug) console.warn("Unknown effect found: ", b.constructor.name);
|
|
382
|
-
return 1;
|
|
383
|
-
}
|
|
384
|
-
if (aidx < 0) return 1;
|
|
385
|
-
if (bidx < 0) return -1;
|
|
386
|
-
return aidx - bidx;
|
|
387
|
-
});
|
|
388
|
-
if (debug) console.log("After ordering effects", [...this._effects]);
|
|
389
|
-
for (let i = 0; i < effects.length; i++) {
|
|
390
|
-
const effect = effects[i] as any;
|
|
391
|
-
if (effect?.configuration?.gammaCorrection !== undefined) {
|
|
392
|
-
const isLast = i === effects.length - 1;
|
|
393
|
-
effect.configuration.gammaCorrection = isLast;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
413
|
}
|
|
398
414
|
|
|
399
415
|
let effectsOrder: Array<Constructor<Effect | Pass>> | null = null;
|