[claude] Add depth of field effect that blurs distant objects (#121) #188

Merged
claude merged 1 commits from claude/issue-121 into main 2026-03-24 04:10:56 +00:00

19
app.js
View File

@@ -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();