import { Component , Input , Optional , SimpleChanges , SkipSelf } from '@angular/core' ; import { RendererService } from '../../renderer/renderer.service' ; import { BokehPass } from 'three/examples/jsm/postprocessing/BokehPass' ; import { EffectComposerComponent } from './effect-composer.component' ; import { AbstractComposeEffect } from './abstract-compose-effect' ; @ Component ( { selector : 'atft-dof' , template : '' } ) export class DofComponent extends AbstractComposeEffect < BokehPass > { @ Input ( ) focus = 1.0 ; @ Input ( ) aperture = 0.025 ; @ Input ( ) maxblur = 0.01 ; constructor ( protected rendererService , @ SkipSelf ( ) @ Optional ( ) protected composer ) { super ( rendererService , composer ) ; } applyChanges ( changes ) { let modified = false ; if ( this . pass [ 0 ] ) { if ( [ 'focus' ] . some ( propName => propName in changes ) ) { this . pass [ 0 ] . uniforms [ 'focus' ] . value = this . focus ; modified = true ; } if ( [ 'aperture' ] . some ( propName => propName in changes ) ) { this . pass [ 0 ] . uniforms [ 'aperture' ] . value = this . aperture ; modified = true ; } if ( [ 'maxblur' ] . some ( propName => propName in changes ) ) { this . pass [ 0 ] . uniforms [ 'maxblur' ] . value = this . maxblur ; modified = true ; } } return modified ; } initPasses ( ) { this . pass . push ( new BokehPass ( this . rendererService . getScene ( ) . getObject ( ) , this . rendererService . getCamera ( ) . camera , { focus : this . focus , aperture : this . aperture , maxblur : this . maxblur , width : window . innerWidth , height : window . innerHeight } ) ) ; } }