diff --git a/src/effects/SSAOPass.js b/src/effects/SSAOPass.js new file mode 100644 index 0000000..09de056 --- /dev/null +++ b/src/effects/SSAOPass.js @@ -0,0 +1,40 @@ +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.passes.push(pass); + this.pass = 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: 'FXAAPass', +}; diff --git a/src/effects/index.js b/src/effects/index.js index 76ae78c..5681b80 100644 --- a/src/effects/index.js +++ b/src/effects/index.js @@ -6,6 +6,7 @@ export { default as FilmPass } from './FilmPass.js'; export { default as FXAAPass } from './FXAAPass.js'; export { default as HalftonePass } from './HalftonePass.js'; export { default as SMAAPass } from './SMAAPass.js'; +export { default as SSAOPass } from './SSAOPass.js'; export { default as TiltShiftPass } from './TiltShiftPass.js'; export { default as UnrealBloomPass } from './UnrealBloomPass.js'; export { default as ZoomBlurPass } from './ZoomBlurPass.js'; diff --git a/src/plugin.js b/src/plugin.js index 04e1bfa..bdee5f3 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -69,6 +69,7 @@ export const TroisJSVuePlugin = { 'RenderPass', 'SAOPass', 'SMAAPass', + 'SSAOPass', 'TiltShiftPass', 'UnrealBloomPass', 'ZoomBlurPass',