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

30 lines
847 B
TypeScript
Raw Normal View History

2021-04-20 18:41:04 +08:00
import { defineComponent, watch } from 'vue'
import { Vector2 } from 'three'
import { UnrealBloomPass } from 'three/examples/jsm/postprocessing/UnrealBloomPass.js'
import EffectPass from './EffectPass'
const props = {
strength: { type: Number, default: 1.5 },
radius: { type: Number, default: 0 },
threshold: { type: Number, default: 0 },
2021-04-27 01:54:56 +08:00
} as const
2021-04-20 18:41:04 +08:00
export default defineComponent({
extends: EffectPass,
props,
created() {
2021-04-25 03:45:57 +08:00
if (!this.renderer) return
2021-04-22 03:05:02 +08:00
const size = new Vector2(this.renderer.size.width, this.renderer.size.height)
2021-04-20 18:41:04 +08:00
const pass = new UnrealBloomPass(size, this.strength, this.radius, this.threshold)
Object.keys(props).forEach(p => {
// @ts-ignore
watch(() => this[p], (value) => { pass.uniforms[p].value = value })
})
this.initEffectPass(pass)
},
__hmrId: 'UnrealBloomPass',
})