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

27 lines
731 B
JavaScript
Raw Normal View History

2020-10-05 04:23:00 +08:00
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js';
import { FXAAShader } from 'three/examples/jsm/shaders/FXAAShader.js';
import EffectPass from './EffectPass.js';
export default {
extends: EffectPass,
mounted() {
const pass = new ShaderPass(FXAAShader);
this.passes.push(pass);
this.pass = pass;
2020-10-05 04:52:39 +08:00
// resize will be called in three init
2020-10-05 04:23:00 +08:00
this.three.onAfterResize(this.resize);
},
unmounted() {
this.three.offAfterResize(this.resize);
},
methods: {
resize() {
const { resolution } = this.pass.material.uniforms;
resolution.value.x = 1 / this.three.size.width;
resolution.value.y = 1 / this.three.size.height;
},
},
__hmrId: 'FXAAPass',
};