Skip to content

Commit bbd996c

Browse files
review: add computed for array-vector lens
1 parent 4a6ee26 commit bbd996c

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/core/pmndrs/FishEyePmndrs.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Vector2 } from 'three'
44
import { FishEyeEffect } from './custom/fish-eye/index'
55
import { makePropWatchers } from '../../util/prop'
66
import { useEffectPmndrs } from './composables/useEffectPmndrs'
7+
import { computed } from 'vue'
78
89
export interface FishEyePmndrsProps {
910
/**
@@ -33,12 +34,20 @@ export interface FishEyePmndrsProps {
3334
3435
const props = defineProps<FishEyePmndrsProps>()
3536
37+
const computedLensS = computed(() =>
38+
Array.isArray(props.lensS) ? new Vector2(...props.lensS) : props.lensS,
39+
)
40+
const computedLensF = computed(() =>
41+
Array.isArray(props.lensF) ? new Vector2(...props.lensF) : props.lensF,
42+
)
43+
3644
const { pass, effect } = useEffectPmndrs(
37-
() => new FishEyeEffect({
38-
...props,
39-
lensS: Array.isArray(props.lensS) ? new Vector2(...props.lensS) : props.lensS,
40-
lensF: Array.isArray(props.lensF) ? new Vector2(...props.lensF) : props.lensF,
41-
}),
45+
() =>
46+
new FishEyeEffect({
47+
...props,
48+
lensS: computedLensS.value,
49+
lensF: computedLensF.value,
50+
}),
4251
props,
4352
)
4453
@@ -47,8 +56,8 @@ defineExpose({ pass, effect })
4756
makePropWatchers(
4857
[
4958
[() => props.blendFunction, 'blendMode.blendFunction'],
50-
[() => props.lensS, 'lensS'],
51-
[() => props.lensF, 'lensF'],
59+
[() => computedLensS.value, 'lensS'],
60+
[() => computedLensF.value, 'lensF'],
5261
[() => props.scale, 'scale'],
5362
],
5463
effect,

0 commit comments

Comments
 (0)