Skip to content

Commit

Permalink
chore: removed prop defaults for scanline effect, improved blendMode …
Browse files Browse the repository at this point in the history
…watcher
  • Loading branch information
Tinoooo committed Jan 6, 2025
1 parent 3bf8273 commit 02a0eef
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/core/pmndrs/ScanlinePmndrs.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts" setup>
import { watch } from 'vue'
import type { BlendFunction } from 'postprocessing'
import { ScanlineEffect } from 'postprocessing'
import { makePropWatchers } from '../../util/prop'
Expand Down Expand Up @@ -26,14 +27,7 @@ export interface ScanlinePmndrsProps {
opacity?: number
}
const props = withDefaults(
defineProps<ScanlinePmndrsProps>(),
{
density: 1.25,
opacity: 1.0,
scrollSpeed: 0.0,
},
)
const props = defineProps<ScanlinePmndrsProps>()
const { pass, effect } = useEffectPmndrs(() => new ScanlineEffect(props), props)
Expand All @@ -42,11 +36,27 @@ defineExpose({ pass, effect })
makePropWatchers(
[
[() => props.blendFunction, 'blendMode.blendFunction'],
[() => props.opacity, 'blendMode.opacity.value'],
[() => props.density, 'density'],
[() => props.scrollSpeed, 'scrollSpeed'],
],
effect,
() => new ScanlineEffect(),
)
watch(
[() => props.opacity],
() => {
if (props.opacity !== undefined) {
effect.value?.blendMode.setOpacity(props.opacity)
}
else {
const plainEffect = new ScanlineEffect()
effect.value?.blendMode.setOpacity(plainEffect.blendMode.getOpacity())
plainEffect.dispose()
}
},
{
immediate: true,
},
)
</script>

0 comments on commit 02a0eef

Please sign in to comment.