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:
parent
fb0a98cba4
commit
2070f20a6b
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user