1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +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: { props: {
type: { type: String as PropType<EffectTypes>, required: true }, type: { type: String as PropType<EffectTypes>, required: true },
options: { type: Object, default: () => ({}) }, options: { type: Object, default: () => ({}) },
onReady: Function,
}, },
setup(props) { setup(props) {
const effectPass = inject(EffectPassInjectionKey) const effectPass = inject(EffectPassInjectionKey)
@ -27,6 +28,7 @@ export default defineComponent({
console.error('Invalid effect type') console.error('Invalid effect type')
return return
} }
props.onReady?.(effect)
effectPass.addEffect(effect, effectIndex) effectPass.addEffect(effect, effectIndex)
} }
@ -78,7 +80,9 @@ function createEffect(
function createSmaaEffect(options: Record<string, any>, assets: any): PP.Pass { function createSmaaEffect(options: Record<string, any>, assets: any): PP.Pass {
const { smaaSearch, smaaArea } = assets const { smaaSearch, smaaArea } = assets
// TODO : options // 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 { function createGodraysEffect(effectPass: EffectPassInterface, options: Record<string, any>): PP.Pass {

View File

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