@needle-tools/engine 4.4.0-alpha.2 → 4.4.0-alpha.3
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 +1 -1
- package/dist/needle-engine.bundle.js +826 -770
- package/dist/needle-engine.bundle.light.js +564 -508
- package/dist/needle-engine.bundle.light.min.js +37 -33
- package/dist/needle-engine.bundle.light.umd.cjs +66 -62
- package/dist/needle-engine.bundle.min.js +60 -56
- package/dist/needle-engine.bundle.umd.cjs +67 -63
- package/lib/engine/webcomponents/needle menu/needle-menu.js +4 -0
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +1 -1
- package/lib/engine-components/Camera.js +13 -0
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CameraUtils.js +2 -1
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js.map +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +2 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +68 -4
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/package.json +1 -1
- package/plugins/common/license.js +14 -5
- package/src/engine/webcomponents/needle menu/needle-menu.ts +4 -0
- package/src/engine-components/Camera.ts +16 -1
- package/src/engine-components/CameraUtils.ts +3 -2
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +2 -2
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +77 -4
|
@@ -15,6 +15,7 @@ globalThis["NEEDLE_USE_POSTPROCESSING"] = globalThis["NEEDLE_USE_POSTPROCESSING"
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
const debug = getParam("debugpost");
|
|
18
|
+
const dontMergePasses = getParam("debugpostpasses");
|
|
18
19
|
|
|
19
20
|
const activeKey = Symbol("needle:postprocessing-handler");
|
|
20
21
|
const autoclearSetting = Symbol("needle:previous-autoclear-state");
|
|
@@ -168,6 +169,7 @@ export class PostProcessingHandler {
|
|
|
168
169
|
private applyEffects(context: Context) {
|
|
169
170
|
|
|
170
171
|
const effectsOrPasses = this._effects;
|
|
172
|
+
|
|
171
173
|
if (effectsOrPasses.length <= 0) return;
|
|
172
174
|
|
|
173
175
|
const camera = context.mainCameraComponent as Camera;
|
|
@@ -209,7 +211,7 @@ export class PostProcessingHandler {
|
|
|
209
211
|
composer.addPass(screenpass);
|
|
210
212
|
|
|
211
213
|
const automaticEffectsOrdering = true;
|
|
212
|
-
if (automaticEffectsOrdering) {
|
|
214
|
+
if (automaticEffectsOrdering && !dontMergePasses) {
|
|
213
215
|
try {
|
|
214
216
|
this.orderEffects();
|
|
215
217
|
|
|
@@ -243,9 +245,16 @@ export class PostProcessingHandler {
|
|
|
243
245
|
}
|
|
244
246
|
}
|
|
245
247
|
else {
|
|
248
|
+
// we still want to sort passes, but we do not want to merge them for debugging
|
|
249
|
+
if (automaticEffectsOrdering)
|
|
250
|
+
this.orderEffects();
|
|
251
|
+
|
|
246
252
|
for (const ef of effectsOrPasses) {
|
|
247
|
-
if (ef instanceof MODULES.POSTPROCESSING.MODULE.Effect)
|
|
248
|
-
|
|
253
|
+
if (ef instanceof MODULES.POSTPROCESSING.MODULE.Effect) {
|
|
254
|
+
const pass = new MODULES.POSTPROCESSING.MODULE.EffectPass(cam, ef as Effect);
|
|
255
|
+
pass.name = ef.name;
|
|
256
|
+
composer.addPass(pass);
|
|
257
|
+
}
|
|
249
258
|
else if (ef instanceof MODULES.POSTPROCESSING.MODULE.Pass)
|
|
250
259
|
composer.addPass(ef as Pass);
|
|
251
260
|
else
|
|
@@ -255,10 +264,74 @@ export class PostProcessingHandler {
|
|
|
255
264
|
}
|
|
256
265
|
}
|
|
257
266
|
|
|
258
|
-
if (debug)
|
|
267
|
+
if (debug) {
|
|
268
|
+
|
|
259
269
|
console.log("[PostProcessing] Passes →", composer.passes);
|
|
270
|
+
|
|
271
|
+
// DepthEffect for debugging purposes, disabled by default, can be selected in the debug pass select
|
|
272
|
+
const depthEffect = new MODULES.POSTPROCESSING.MODULE.DepthEffect({
|
|
273
|
+
blendFunction: MODULES.POSTPROCESSING.MODULE.BlendFunction.NORMAL,
|
|
274
|
+
inverted: true,
|
|
275
|
+
});
|
|
276
|
+
depthEffect.name = "Depth Effect";
|
|
277
|
+
const depthPass = new MODULES.POSTPROCESSING.MODULE.EffectPass(cam, depthEffect);
|
|
278
|
+
depthPass.name = "Depth Effect Pass";
|
|
279
|
+
depthPass.enabled = false;
|
|
280
|
+
composer.passes.push(depthPass);
|
|
281
|
+
|
|
282
|
+
if (this._passIndices !== null) {
|
|
283
|
+
const newPasses = [composer.passes[0]];
|
|
284
|
+
if (this._passIndices.length > 0 && this._passIndices[0] !== 0) {
|
|
285
|
+
newPasses.push(...this._passIndices.map(index => composer.passes[index]).filter(pass => pass));
|
|
286
|
+
}
|
|
287
|
+
if (newPasses.length > 0) {
|
|
288
|
+
console.log("[PostProcessing] Passes (selected) →", newPasses);
|
|
289
|
+
}
|
|
290
|
+
composer.passes.length = 0;
|
|
291
|
+
for (const pass of newPasses) {
|
|
292
|
+
pass.enabled = true;
|
|
293
|
+
composer.addPass(pass);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const menu = this.context.menu;
|
|
298
|
+
if (menu && this._passIndices === null) {
|
|
299
|
+
if (this._menuEntry)
|
|
300
|
+
this._menuEntry.remove();
|
|
301
|
+
|
|
302
|
+
const select = document.createElement("select");
|
|
303
|
+
select.multiple = true;
|
|
304
|
+
const defaultOpt = document.createElement("option");
|
|
305
|
+
defaultOpt.innerText = "Final Output";
|
|
306
|
+
defaultOpt.value = "-1";
|
|
307
|
+
select.appendChild(defaultOpt);
|
|
308
|
+
for (const eff of composer.passes) {
|
|
309
|
+
const opt = document.createElement("option");
|
|
310
|
+
opt.innerText = eff.name;
|
|
311
|
+
opt.value = `${composer.passes.indexOf(eff)}`;
|
|
312
|
+
opt.title = eff.name;
|
|
313
|
+
select.appendChild(opt);
|
|
314
|
+
}
|
|
315
|
+
menu.appendChild(select);
|
|
316
|
+
this._menuEntry = select;
|
|
317
|
+
select.addEventListener("change", () => {
|
|
318
|
+
const indices = Array.from(select.selectedOptions).map(option => parseInt(option.value));
|
|
319
|
+
if (indices.length === 1 && indices[0] === -1) {
|
|
320
|
+
this._passIndices = null;
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
this._passIndices = indices;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
this.applyEffects(context);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
260
330
|
}
|
|
261
331
|
|
|
332
|
+
private _menuEntry: HTMLSelectElement | null = null;
|
|
333
|
+
private _passIndices: number[] | null = null;
|
|
334
|
+
|
|
262
335
|
private orderEffects() {
|
|
263
336
|
if (debug) console.log("Before ordering effects", [...this._effects]);
|
|
264
337
|
|