1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 12:22:03 +08:00
trois/src/effects/BokehPass.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-09-17 05:27:29 +08:00
import { BokehPass } from 'three/examples/jsm/postprocessing/BokehPass.js';
import EffectPass from './EffectPass.js';
export default {
extends: EffectPass,
props: {
focus: {
type: Number,
default: 1,
},
aperture: {
type: Number,
default: 0.025,
},
maxblur: {
type: Number,
default: 0.01,
},
},
2020-09-21 15:15:15 +08:00
watch: {
focus() { this.pass.uniforms.focus.value = this.focus; },
aperture() { this.pass.uniforms.aperture.value = this.aperture; },
maxblur() { this.pass.uniforms.maxblur.value = this.maxblur; },
},
2020-09-17 05:27:29 +08:00
mounted() {
if (!this.three.scene) {
console.error('Missing Scene');
}
if (!this.three.camera) {
console.error('Missing Camera');
}
2020-09-17 05:54:14 +08:00
const params = {
focus: this.focus,
aperture: this.aperture,
maxblur: this.maxblur,
width: this.three.size.width,
height: this.three.size.height,
};
2020-09-17 05:27:29 +08:00
const pass = new BokehPass(this.three.scene, this.three.camera, params);
this.passes.push(pass);
this.pass = pass;
},
2020-09-20 02:29:53 +08:00
__hmrId: 'BokehPass',
2020-09-17 05:27:29 +08:00
};