@needle-tools/engine 4.6.2 → 4.6.4
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 +5 -0
- package/dist/{needle-engine.bundle-DmYMLdWP.umd.cjs → needle-engine.bundle-B0b8OtrF.umd.cjs} +86 -83
- package/dist/{needle-engine.bundle-D0XWaCQs.min.js → needle-engine.bundle-BDUZt2gN.min.js} +97 -94
- package/dist/{needle-engine.bundle-DGcStTA7.js → needle-engine.bundle-xlXwBS9f.js} +1409 -1390
- 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/engine_context.js +3 -2
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js +8 -1
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/BloomEffect.js +0 -3
- package/lib/engine-components/postprocessing/Effects/BloomEffect.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +43 -11
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/lib/engine-components/postprocessing/Volume.js +1 -1
- package/lib/engine-components/postprocessing/Volume.js.map +1 -1
- package/lib/engine-components/postprocessing/utils.d.ts +1 -0
- package/lib/engine-components/postprocessing/utils.js.map +1 -1
- package/package.json +1 -1
- package/plugins/vite/alias.js +48 -38
- package/src/engine/engine_context.ts +3 -2
- package/src/engine-components/postprocessing/Effects/Antialiasing.ts +8 -1
- package/src/engine-components/postprocessing/Effects/BloomEffect.ts +0 -2
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +1 -1
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +49 -12
- package/src/engine-components/postprocessing/Volume.ts +1 -1
- package/src/engine-components/postprocessing/utils.ts +1 -0
|
@@ -6,6 +6,7 @@ import { showBalloonWarning } from "../../engine/debug/index.js";
|
|
|
6
6
|
import { MODULES } from "../../engine/engine_modules.js";
|
|
7
7
|
import { Context } from "../../engine/engine_setup.js";
|
|
8
8
|
import { Graphics } from "../../engine/engine_three_utils.js";
|
|
9
|
+
import { Constructor } from "../../engine/engine_types.js";
|
|
9
10
|
import { getParam } from "../../engine/engine_utils.js";
|
|
10
11
|
import { Camera } from "../Camera.js";
|
|
11
12
|
import { threeToneMappingToEffectMode } from "./Effects/Tonemapping.utils.js";
|
|
@@ -161,21 +162,36 @@ export class PostProcessingHandler {
|
|
|
161
162
|
const res = component.apply(ctx);
|
|
162
163
|
if (!res) continue;
|
|
163
164
|
|
|
165
|
+
const name = component.typeName || component.constructor.name;
|
|
164
166
|
|
|
165
167
|
if (Array.isArray(res)) {
|
|
166
168
|
for (const effect of res) {
|
|
169
|
+
if (!validateEffect(name, effect)) continue;
|
|
167
170
|
this._effects.push({
|
|
168
171
|
effect,
|
|
172
|
+
typeName: component.typeName,
|
|
169
173
|
priority: component.order
|
|
170
174
|
});
|
|
171
175
|
}
|
|
172
176
|
}
|
|
173
177
|
else {
|
|
178
|
+
if (!validateEffect(name, res)) continue;
|
|
174
179
|
this._effects.push({
|
|
175
180
|
effect: res,
|
|
181
|
+
typeName: component.typeName,
|
|
176
182
|
priority: component.order
|
|
177
183
|
});
|
|
178
184
|
}
|
|
185
|
+
|
|
186
|
+
function validateEffect(source: string, effect: Effect | Pass): boolean {
|
|
187
|
+
if (!effect) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
if (!(effect instanceof MODULES.POSTPROCESSING.MODULE.Effect || effect instanceof MODULES.POSTPROCESSING.MODULE.Pass)) {
|
|
191
|
+
console.warn(`PostprocessingEffect ${source} created neither Effect nor Pass - this might be caused by a bundler error or false import. Below you find some possible solutions:\n- If you create custom effect try creating it like this: 'new NEEDLE_ENGINE_MODULES.POSTPROCESSING.MODULE.Effect(...)' instead of 'new Effect(...)'`);
|
|
192
|
+
}
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
179
195
|
}
|
|
180
196
|
}
|
|
181
197
|
else {
|
|
@@ -244,7 +260,11 @@ export class PostProcessingHandler {
|
|
|
244
260
|
const tonemapping = new MODULES.POSTPROCESSING.MODULE.ToneMappingEffect();
|
|
245
261
|
tonemapping.name = `ToneMapping (${renderer.toneMapping})`;
|
|
246
262
|
tonemapping.mode = threeToneMappingToEffectMode(renderer.toneMapping);
|
|
247
|
-
this._effects.push({
|
|
263
|
+
this._effects.push({
|
|
264
|
+
typeName: "ToneMapping",
|
|
265
|
+
effect: tonemapping,
|
|
266
|
+
priority: PostProcessingEffectOrder.ToneMapping
|
|
267
|
+
});
|
|
248
268
|
}
|
|
249
269
|
}
|
|
250
270
|
|
|
@@ -363,7 +383,8 @@ export class PostProcessingHandler {
|
|
|
363
383
|
const effectsToMerge: Array<Effect> = [];
|
|
364
384
|
let hasConvolutionEffectInArray = false;
|
|
365
385
|
|
|
366
|
-
for (
|
|
386
|
+
for (let i = 0; i < this._effects.length; i++) {
|
|
387
|
+
const entry = this._effects[i];
|
|
367
388
|
const ef = entry.effect;
|
|
368
389
|
|
|
369
390
|
if (ef instanceof MODULES.POSTPROCESSING.MODULE.SMAAEffect) {
|
|
@@ -373,8 +394,7 @@ export class PostProcessingHandler {
|
|
|
373
394
|
this._anyPassHasNormal = true;
|
|
374
395
|
}
|
|
375
396
|
|
|
376
|
-
|
|
377
|
-
// There can be only one tonemapping effect in the scene, so we can skip all others
|
|
397
|
+
// There can be only one tonemapping effect in the scene, so we skip all others
|
|
378
398
|
if (ef instanceof MODULES.POSTPROCESSING.MODULE.ToneMappingEffect && activeTonemappingEffect !== ef) {
|
|
379
399
|
// If we already have a tonemapping effect, we can skip this one
|
|
380
400
|
continue;
|
|
@@ -383,18 +403,20 @@ export class PostProcessingHandler {
|
|
|
383
403
|
// We can also not merge multiple effects of the same type in one pass
|
|
384
404
|
// So we first need to create a new pass with whatever effects we have so far
|
|
385
405
|
// TODO: this seems to work fine for some effects (like ColorAdjustments) and only caused issues with multiple Tonemapping effects so far which is handled above
|
|
386
|
-
// const constructor = ef.constructor
|
|
387
|
-
// if(effectsToMerge.find(e => e.constructor === constructor)) {
|
|
388
|
-
//
|
|
406
|
+
// const constructor = ef.constructor;
|
|
407
|
+
// if (effectsToMerge.find(e => e.constructor === constructor)) {
|
|
408
|
+
// this.createPassForMergeableEffects(effectsToMerge, composer, cam, scene);
|
|
389
409
|
// }
|
|
390
410
|
|
|
411
|
+
|
|
412
|
+
|
|
391
413
|
if (ef instanceof MODULES.POSTPROCESSING.MODULE.Effect) {
|
|
392
414
|
const attributes = ef.getAttributes();
|
|
393
415
|
const convolution = MODULES.POSTPROCESSING.MODULE.EffectAttribute.CONVOLUTION;
|
|
394
416
|
if (attributes & convolution) {
|
|
395
417
|
if (debug) console.log("[PostProcessing] Convolution effect: " + ef.name);
|
|
396
418
|
if (hasConvolutionEffectInArray) {
|
|
397
|
-
if (debug) console.log("[PostProcessing] Merging effects
|
|
419
|
+
if (debug) console.log("[PostProcessing] → Merging effects [" + effectsToMerge.map(e => e.name).join(", ") + "]");
|
|
398
420
|
this.createPassForMergeableEffects(effectsToMerge, composer, cam, scene);
|
|
399
421
|
}
|
|
400
422
|
hasConvolutionEffectInArray = true;
|
|
@@ -415,28 +437,43 @@ export class PostProcessingHandler {
|
|
|
415
437
|
this.createPassForMergeableEffects(effectsToMerge, composer, cam, scene);
|
|
416
438
|
composer.addPass(ef);
|
|
417
439
|
}
|
|
440
|
+
|
|
418
441
|
}
|
|
419
442
|
|
|
420
443
|
this.createPassForMergeableEffects(effectsToMerge, composer, cam, scene);
|
|
421
444
|
}
|
|
422
445
|
catch (e) {
|
|
423
446
|
console.error("Error while applying postprocessing effects", e);
|
|
447
|
+
composer.passes.forEach(p => p.dispose());
|
|
424
448
|
composer.removeAllPasses();
|
|
425
449
|
}
|
|
426
450
|
|
|
427
451
|
// 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)
|
|
428
|
-
|
|
452
|
+
let foundEnabled = false;
|
|
453
|
+
for (let i = composer.passes.length - 1; i >= 0; i--) {
|
|
429
454
|
const pass = composer.passes[i];
|
|
430
|
-
|
|
455
|
+
let gammaCorrect = false;
|
|
456
|
+
let renderToScreen = false;
|
|
457
|
+
if (pass.enabled) {
|
|
458
|
+
if (!foundEnabled) {
|
|
459
|
+
gammaCorrect = true;
|
|
460
|
+
renderToScreen = true;
|
|
461
|
+
}
|
|
462
|
+
foundEnabled = true;
|
|
463
|
+
}
|
|
464
|
+
pass.renderToScreen = renderToScreen;
|
|
465
|
+
|
|
431
466
|
if ((pass as any)?.configuration !== undefined) {
|
|
432
|
-
(pass as any).configuration.gammaCorrection =
|
|
467
|
+
(pass as any).configuration.gammaCorrection = gammaCorrect;
|
|
433
468
|
}
|
|
434
469
|
else if ("autosetGamma" in pass) {
|
|
435
470
|
// Some effects have a autosetGamma property that we can use to set the gamma correction
|
|
436
|
-
pass.autosetGamma =
|
|
471
|
+
pass.autosetGamma = gammaCorrect;
|
|
437
472
|
}
|
|
438
473
|
|
|
474
|
+
|
|
439
475
|
this._anyPassHasDepth ||= pass.needsDepthTexture;
|
|
476
|
+
|
|
440
477
|
}
|
|
441
478
|
|
|
442
479
|
// DEBUG LAND BELOW
|
|
@@ -194,7 +194,7 @@ export class Volume extends Behaviour implements IEditorModificationReceiver, IP
|
|
|
194
194
|
if (this._postprocessing.multisampling !== 0) {
|
|
195
195
|
this._postprocessing.multisampling = 0;
|
|
196
196
|
if (debug || isDevEnvironment()) {
|
|
197
|
-
console.
|
|
197
|
+
console.log(`[PostProcessing] multisampling is disabled because it's set to 'auto' on your PostprocessingManager/Volume component that also has an SMAA effect.\n\nIf you need multisampling consider changing 'auto' to a fixed value (e.g. 4).`);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
}
|