1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-23 20:02:32 +08:00

add ready event on effect and pass

This commit is contained in:
Kevin Levron 2021-05-02 22:05:24 +02:00
parent fb0a98cba4
commit 2070f20a6b
2 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,7 @@ export default defineComponent({
props: {
type: { type: String as PropType<EffectTypes>, required: true },
options: { type: Object, default: () => ({}) },
onReady: Function,
},
setup(props) {
const effectPass = inject(EffectPassInjectionKey)
@ -27,6 +28,7 @@ export default defineComponent({
console.error('Invalid effect type')
return
}
props.onReady?.(effect)
effectPass.addEffect(effect, effectIndex)
}
@ -78,7 +80,9 @@ function createEffect(
function createSmaaEffect(options: Record<string, any>, assets: any): PP.Pass {
const { smaaSearch, smaaArea } = assets
// TODO : options
return new PP.SMAAEffect(smaaSearch, smaaArea)
const params = [options.preset ?? PP.SMAAPreset.HIGH, options.edgeDetectionMode ?? PP.EdgeDetectionMode.COLOR]
console.log(params)
return new PP.SMAAEffect(smaaSearch, smaaArea, ...params)
}
function createGodraysEffect(effectPass: EffectPassInterface, options: Record<string, any>): PP.Pass {

View File

@ -13,6 +13,7 @@ export default defineComponent({
options: { type: Object, default: () => ({}) },
// needsSwap: { type: Boolean, default: false },
renderToScreen: { type: Boolean, default: false },
onReady: Function,
},
setup(props) {
const composer = inject(ComposerInjectionKey)
@ -31,6 +32,7 @@ export default defineComponent({
return
}
pass.renderToScreen = props.renderToScreen
props.onReady?.(pass)
composer.composer.addPass(pass, passIndex)
}