1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00
trois/src/effects/SSAOPass.js
2021-03-21 14:49:41 -04:00

40 lines
906 B
JavaScript

import { SSAOPass } from 'three/examples/jsm/postprocessing/SSAOPass.js';
import EffectPass from './EffectPass.js';
export default {
extends: EffectPass,
props: {
scene: null,
camera: null,
options: {
type: Object,
default: () => ({})
}
},
mounted() {
const pass = new SSAOPass(
this.scene || this.three.scene,
this.camera || this.three.camera,
this.three.size.width,
this.three.size.height
);
this.completePass(pass);
for (let key of Object.keys(this.options)) {
this.pass[key] = this.options[key];
}
// resize will be called in three init
this.three.onAfterResize(this.resize);
},
unmounted() {
this.three.offAfterResize(this.resize);
},
methods: {
resize() {
this.pass.width = this.three.size.width
this.pass.height = this.three.size.height
},
},
__hmrId: 'SSAOPass',
};