From 8f8eed39879961b0387a910a9f133e560acff21f Mon Sep 17 00:00:00 2001 From: Elar Huik Date: Wed, 20 Sep 2023 09:55:07 +0300 Subject: [PATCH] fix: enable toggling ambient occlusion in showcase --- src/components/Avatar/Avatar.stories.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/Avatar/Avatar.stories.tsx b/src/components/Avatar/Avatar.stories.tsx index 55b73e42..52e4e725 100644 --- a/src/components/Avatar/Avatar.stories.tsx +++ b/src/components/Avatar/Avatar.stories.tsx @@ -68,7 +68,7 @@ const maxValue = 9.0; const stepSize = 0.3; const animationUpdateStepMs = 60; -export const Showcase: StoryFn = (args) => { +export const Showcase: StoryFn = (args: AvatarProps & { ambientOcclusion?: boolean }) => { const [currentValue, setCurrentValue] = useState(args.bloom?.materialIntensity); const [increasing, setIncreasing] = useState(true); const pulsatingBloom = { @@ -79,6 +79,10 @@ export const Showcase: StoryFn = (args) => { useEffect(() => { const animationInterval = setInterval(() => { + if (args?.ambientOcclusion) { + return; + } + if (increasing) { setCurrentValue((prevValue) => { const newValue = prevValue! + stepSize; @@ -101,10 +105,10 @@ export const Showcase: StoryFn = (args) => { }, animationUpdateStepMs); return () => clearInterval(animationInterval); - }, [currentValue, increasing, initialValue, maxValue]); + }, [currentValue, increasing, initialValue, maxValue, args?.ambientOcclusion]); return ( - + ); @@ -142,7 +146,9 @@ Showcase.args = { eyeLookOutLeft: 0.6, eyeLookInRight: 0.6, mouthDimpleLeft: 0.3 - } + }, + // @ts-ignore + ambientOcclusion: false }; Showcase.argTypes = { ...ignoreArgTypesOnExamples,