Skip to content

Commit 909179d

Browse files
author
Tino Koch
committed
updated debug mode handling and improve type safety
1 parent f8c46ae commit 909179d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/core/pmndrs/SMAAPmndrs.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script lang="ts" setup>
1+
<script lang="ts">
22
import type { BlendFunction, EdgeDetectionMode, PredicationMode, SMAAPreset } from 'postprocessing'
33
import { EffectPass, SMAAEffect, TextureEffect } from 'postprocessing'
44
import { makePropWatchers } from '../../util/prop'
@@ -7,6 +7,12 @@ import { inject, watch } from 'vue'
77
import { useTresContext } from '@tresjs/core'
88
import { effectComposerInjectionKey } from './EffectComposerPmndrs.vue'
99
10+
export const DEBUG_MODE = {
11+
OFF: 0,
12+
EDGES: 1,
13+
WEIGHTS: 2,
14+
} as const
15+
1016
export interface SMAAPmndrsProps {
1117
/**
1218
* The blend function.
@@ -36,9 +42,11 @@ export interface SMAAPmndrsProps {
3642
* - 1: EDGES
3743
* - 2: WEIGHTS
3844
*/
39-
debug?: number
45+
debug?: typeof DEBUG_MODE[keyof typeof DEBUG_MODE]
4046
}
47+
</script>
4148

49+
<script lang="ts" setup>
4250
const props = defineProps<SMAAPmndrsProps>()
4351
4452
const { pass, effect } = useEffectPmndrs(() => new SMAAEffect(props), props)
@@ -127,9 +135,9 @@ const manageDebugPass = (pass: EffectPass | null, active: boolean) => {
127135
const updateDebugMode = (mode: number) => {
128136
if (!pass.value) { return }
129137
130-
const mainActive = mode === 0
131-
const edgesActive = mode === 1
132-
const weightsActive = mode === 2
138+
const mainActive = mode === DEBUG_MODE.OFF
139+
const edgesActive = mode === DEBUG_MODE.EDGES
140+
const weightsActive = mode === DEBUG_MODE.WEIGHTS
133141
134142
pass.value.enabled = mainActive
135143
pass.value.renderToScreen = mainActive

0 commit comments

Comments
 (0)