From 37107353b437c9e99329e607d2e4f46f069ce511 Mon Sep 17 00:00:00 2001 From: Alexander Whitestone Date: Tue, 24 Mar 2026 00:10:11 -0400 Subject: [PATCH] feat: make depth of field always-on as ambient scene effect Enable BokehPass by default with subtle settings (aperture 0.00015, maxblur 0.004) so distant objects are softly blurred at all times. Photo mode (P) boosts aperture and maxblur for stronger DoF and enables orbit controls, then restores ambient settings on exit. Always render through composer instead of falling back to renderer. Fixes #121 --- app.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app.js b/app.js index 4902f2f..0d95d24 100644 --- a/app.js +++ b/app.js @@ -151,16 +151,15 @@ document.addEventListener('keydown', (e) => { // === PHOTO MODE === let photoMode = false; -// Post-processing composer for depth of field +// Post-processing composer for depth of field (always-on, subtle) const composer = new EffectComposer(renderer); composer.addPass(new RenderPass(scene, camera)); const bokehPass = new BokehPass(scene, camera, { focus: 5.0, - aperture: 0.0003, - maxblur: 0.008, + aperture: 0.00015, + maxblur: 0.004, }); -bokehPass.enabled = false; composer.addPass(bokehPass); // Orbit controls for free camera movement in photo mode @@ -185,16 +184,22 @@ document.addEventListener('keydown', (e) => { if (e.key === 'p' || e.key === 'P') { photoMode = !photoMode; document.body.classList.toggle('photo-mode', photoMode); - bokehPass.enabled = photoMode; orbitControls.enabled = photoMode; if (photoIndicator) { photoIndicator.classList.toggle('visible', photoMode); } if (photoMode) { + // Enhanced DoF in photo mode + bokehPass.uniforms['aperture'].value = 0.0003; + bokehPass.uniforms['maxblur'].value = 0.008; // Sync orbit target to current look-at orbitControls.target.set(0, 0, 0); orbitControls.update(); updateFocusDisplay(); + } else { + // Restore subtle ambient DoF + bokehPass.uniforms['aperture'].value = 0.00015; + bokehPass.uniforms['maxblur'].value = 0.004; } } @@ -252,10 +257,8 @@ function animate() { if (photoMode) { orbitControls.update(); - composer.render(); - } else { - renderer.render(scene, camera); } + composer.render(); } animate(); -- 2.43.0