Skip to content
🎉 Angular Three v4 is here! Read the announcement

NgtpDepthOfField

The depth of field effect simulates camera focus, blurring objects that are not at the focal distance.

import { NgtpEffectComposer, NgtpDepthOfField } from 'angular-three-postprocessing';
@Component({
template: `
<ngtp-effect-composer>
<ngtp-depth-of-field [options]="{
focusDistance: 0.01,
focalLength: 0.02,
bokehScale: 2
}" />
</ngtp-effect-composer>
`,
imports: [NgtpEffectComposer, NgtpDepthOfField],
})
export class SceneGraph {}
PropertyTypeDefaultDescription
focusDistancenumber0Distance to focus point (normalized 0-1)
focalLengthnumber0.05Focal length of the camera
bokehScalenumber2Scale of the bokeh blur
targetVector3undefinedTarget position to focus on
@Component({
template: `
<ngt-mesh #target [position]="[0, 0, -5]">
<ngt-box-geometry />
<ngt-mesh-standard-material />
</ngt-mesh>
<ngtp-effect-composer>
<ngtp-depth-of-field [options]="{
target: targetPosition,
focalLength: 0.02,
bokehScale: 3
}" />
</ngtp-effect-composer>
`,
})
export class SceneGraph {
targetPosition = new THREE.Vector3(0, 0, -5);
}