1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

defineComponent for effects (#10)

This commit is contained in:
Kevin Levron 2021-04-04 21:02:21 +02:00
parent a1d786297c
commit 98c74aa1c4
12 changed files with 41 additions and 42 deletions

View File

@ -1,7 +1,8 @@
import { defineComponent } from 'vue';
import { BokehPass } from 'three/examples/jsm/postprocessing/BokehPass.js'; import { BokehPass } from 'three/examples/jsm/postprocessing/BokehPass.js';
import EffectPass from './EffectPass.js'; import EffectPass from './EffectPass.js';
export default { export default defineComponent({
extends: EffectPass, extends: EffectPass,
props: { props: {
focus: { focus: {
@ -40,4 +41,4 @@ export default {
this.completePass(pass); this.completePass(pass);
}, },
__hmrId: 'BokehPass', __hmrId: 'BokehPass',
}; });

View File

@ -1,6 +1,7 @@
import { defineComponent } from 'vue';
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js'; import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js';
export default { export default defineComponent({
setup() { setup() {
return { return {
passes: [], passes: [],
@ -37,4 +38,4 @@ export default {
return this.$slots.default(); return this.$slots.default();
}, },
__hmrId: 'EffectComposer', __hmrId: 'EffectComposer',
}; });

View File

@ -1,4 +1,6 @@
export default { import { defineComponent } from 'vue';
export default defineComponent({
inject: ['three', 'passes'], inject: ['three', 'passes'],
emits: ['ready'], emits: ['ready'],
beforeMount() { beforeMount() {
@ -20,4 +22,4 @@ export default {
return []; return [];
}, },
__hmrId: 'EffectPass', __hmrId: 'EffectPass',
}; });

View File

@ -1,8 +1,9 @@
import { defineComponent } from 'vue';
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'; import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js';
import { FXAAShader } from 'three/examples/jsm/shaders/FXAAShader.js'; import { FXAAShader } from 'three/examples/jsm/shaders/FXAAShader.js';
import EffectPass from './EffectPass.js'; import EffectPass from './EffectPass.js';
export default { export default defineComponent({
extends: EffectPass, extends: EffectPass,
mounted() { mounted() {
const pass = new ShaderPass(FXAAShader); const pass = new ShaderPass(FXAAShader);
@ -22,4 +23,4 @@ export default {
}, },
}, },
__hmrId: 'FXAAPass', __hmrId: 'FXAAPass',
}; });

View File

@ -1,25 +1,14 @@
import { defineComponent } from 'vue';
import { FilmPass } from 'three/examples/jsm/postprocessing/FilmPass.js'; import { FilmPass } from 'three/examples/jsm/postprocessing/FilmPass.js';
import EffectPass from './EffectPass.js'; import EffectPass from './EffectPass.js';
export default { export default defineComponent({
extends: EffectPass, extends: EffectPass,
props: { props: {
noiseIntensity: { noiseIntensity: { type: Number, default: 0.5 },
type: Number, scanlinesIntensity: { type: Number, default: 0.05 },
default: 0.5, scanlinesCount: { type: Number, default: 4096 },
}, grayscale: { type: Number, default: 0 },
scanlinesIntensity: {
type: Number,
default: 0.05,
},
scanlinesCount: {
type: Number,
default: 4096,
},
grayscale: {
type: Number,
default: 0,
},
}, },
watch: { watch: {
noiseIntensity() { this.pass.uniforms.nIntensity.value = this.noiseIntensity; }, noiseIntensity() { this.pass.uniforms.nIntensity.value = this.noiseIntensity; },
@ -32,4 +21,4 @@ export default {
this.completePass(pass); this.completePass(pass);
}, },
__hmrId: 'FilmPass', __hmrId: 'FilmPass',
}; });

View File

@ -1,8 +1,8 @@
import { defineComponent, watch } from 'vue';
import { HalftonePass } from 'three/examples/jsm/postprocessing/HalftonePass.js'; import { HalftonePass } from 'three/examples/jsm/postprocessing/HalftonePass.js';
import { watch } from 'vue';
import EffectPass from './EffectPass.js'; import EffectPass from './EffectPass.js';
export default { export default defineComponent({
extends: EffectPass, extends: EffectPass,
props: { props: {
shape: { type: Number, default: 1 }, shape: { type: Number, default: 1 },
@ -25,4 +25,4 @@ export default {
this.completePass(pass); this.completePass(pass);
}, },
__hmrId: 'HalftonePass', __hmrId: 'HalftonePass',
}; });

View File

@ -1,7 +1,8 @@
import { defineComponent } from 'vue';
import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js'; import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js';
import EffectPass from './EffectPass.js'; import EffectPass from './EffectPass.js';
export default { export default defineComponent({
extends: EffectPass, extends: EffectPass,
mounted() { mounted() {
if (!this.three.scene) { if (!this.three.scene) {
@ -14,4 +15,4 @@ export default {
this.completePass(pass); this.completePass(pass);
}, },
__hmrId: 'RenderPass', __hmrId: 'RenderPass',
}; });

View File

@ -1,7 +1,8 @@
import { defineComponent } from 'vue';
import { SMAAPass } from 'three/examples/jsm/postprocessing/SMAAPass.js'; import { SMAAPass } from 'three/examples/jsm/postprocessing/SMAAPass.js';
import EffectPass from './EffectPass.js'; import EffectPass from './EffectPass.js';
export default { export default defineComponent({
extends: EffectPass, extends: EffectPass,
mounted() { mounted() {
// three size is not set yet, but this pass will be resized by effect composer // three size is not set yet, but this pass will be resized by effect composer
@ -9,4 +10,4 @@ export default {
this.completePass(pass); this.completePass(pass);
}, },
__hmrId: 'SMAAPass', __hmrId: 'SMAAPass',
}; });

View File

@ -1,7 +1,8 @@
import { defineComponent } from 'vue';
import { SSAOPass } from 'three/examples/jsm/postprocessing/SSAOPass.js'; import { SSAOPass } from 'three/examples/jsm/postprocessing/SSAOPass.js';
import EffectPass from './EffectPass.js'; import EffectPass from './EffectPass.js';
export default { export default defineComponent({
extends: EffectPass, extends: EffectPass,
props: { props: {
scene: null, scene: null,
@ -26,4 +27,4 @@ export default {
this.completePass(pass); this.completePass(pass);
}, },
__hmrId: 'SSAOPass', __hmrId: 'SSAOPass',
}; });

View File

@ -1,11 +1,11 @@
import { defineComponent, watch } from 'vue';
import { Vector2 } from 'three'; import { Vector2 } from 'three';
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'; import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js';
import { watch } from 'vue';
import EffectPass from './EffectPass.js'; import EffectPass from './EffectPass.js';
import TiltShift from '../shaders/TiltShift.js'; import TiltShift from '../shaders/TiltShift.js';
import { bindProp } from '../tools'; import { bindProp } from '../tools';
export default { export default defineComponent({
extends: EffectPass, extends: EffectPass,
props: { props: {
blurRadius: { type: Number, default: 10 }, blurRadius: { type: Number, default: 10 },
@ -54,4 +54,4 @@ export default {
}, },
}, },
__hmrId: 'TiltShiftPass', __hmrId: 'TiltShiftPass',
}; });

View File

@ -1,8 +1,9 @@
import { defineComponent } from 'vue';
import { Vector2 } from 'three'; import { Vector2 } from 'three';
import { UnrealBloomPass } from 'three/examples/jsm/postprocessing/UnrealBloomPass.js'; import { UnrealBloomPass } from 'three/examples/jsm/postprocessing/UnrealBloomPass.js';
import EffectPass from './EffectPass.js'; import EffectPass from './EffectPass.js';
export default { export default defineComponent({
extends: EffectPass, extends: EffectPass,
props: { props: {
strength: { type: Number, default: 1.5 }, strength: { type: Number, default: 1.5 },
@ -20,4 +21,4 @@ export default {
this.completePass(pass); this.completePass(pass);
}, },
__hmrId: 'UnrealBloomPass', __hmrId: 'UnrealBloomPass',
}; });

View File

@ -1,9 +1,10 @@
import { defineComponent } from 'vue';
import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'; import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js';
import EffectPass from './EffectPass.js'; import EffectPass from './EffectPass.js';
import ZoomBlur from '../shaders/ZoomBlur.js'; import ZoomBlur from '../shaders/ZoomBlur.js';
import { bindProp } from '../tools'; import { bindProp } from '../tools';
export default { export default defineComponent({
extends: EffectPass, extends: EffectPass,
props: { props: {
center: { type: Object, default: { x: 0.5, y: 0.5 } }, center: { type: Object, default: { x: 0.5, y: 0.5 } },
@ -19,4 +20,4 @@ export default {
this.completePass(pass); this.completePass(pass);
}, },
__hmrId: 'ZoomBlurPass', __hmrId: 'ZoomBlurPass',
}; });