From 41c09b8431072931280fcf92e4e700de0cc78e5c Mon Sep 17 00:00:00 2001 From: dan-rpm Date: Tue, 17 Dec 2024 12:51:53 +0200 Subject: [PATCH] feat: disable zoom via props --- src/components/Avatar/Avatar.component.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/Avatar/Avatar.component.tsx b/src/components/Avatar/Avatar.component.tsx index 341d0fe..43d6024 100644 --- a/src/components/Avatar/Avatar.component.tsx +++ b/src/components/Avatar/Avatar.component.tsx @@ -313,6 +313,20 @@ const Avatar: FC = ({ useEffect(() => triggerCallback(onLoading), [modelSrc, animationSrc, onLoading]); const enablePostProcessing = Boolean(effects?.ambientOcclusion || effects?.bloom || effects?.vignette); + const cameraControlsMinDistance = useMemo(() => { + if (controlsMinDistance) { + return controlsMinDistance; + } + + return halfBody ? CAMERA.CONTROLS.HALF_BODY.MIN_DISTANCE : CAMERA.CONTROLS.FULL_BODY.MIN_DISTANCE; + }, [controlsMinDistance, halfBody]); + const cameraControlsMsxDistance = useMemo(() => { + if (controlsMaxDistance) { + return controlsMaxDistance; + } + + return halfBody ? CAMERA.CONTROLS.HALF_BODY.MAX_DISTANCE : CAMERA.CONTROLS.FULL_BODY.MAX_DISTANCE; + }, [controlsMaxDistance, halfBody]); return ( = ({ cameraTarget={cameraTarget} cameraInitialDistance={cameraInitialDistance} cameraZoomTarget={cameraZoomTarget} - controlsMinDistance={controlsMinDistance} - controlsMaxDistance={controlsMaxDistance} + controlsMinDistance={cameraControlsMinDistance} + controlsMaxDistance={cameraControlsMsxDistance} updateCameraTargetOnZoom={!halfBody} /> {AvatarModel}