diff --git a/src/App/components/Nova.tsx b/src/App/components/Nova.tsx index 4000db7..4647ba5 100644 --- a/src/App/components/Nova.tsx +++ b/src/App/components/Nova.tsx @@ -65,7 +65,8 @@ export const AvatarNova: FC = () => { ))} void; - disableZoom?: boolean; + controlsMinDistance?: number; + controlsMaxDistance?: number; } /** @@ -207,7 +208,8 @@ const Avatar: FC = ({ fov = 50, onAnimationEnd, materialConfig, - disableZoom + controlsMinDistance, + controlsMaxDistance }) => { const setSpawnState = useSetAtom(spawnState); @@ -230,7 +232,6 @@ const Avatar: FC = ({ scale={scale} onLoaded={onLoaded} bloom={effects?.bloom} - disableZoom={disableZoom} onAnimationEnd={onAnimationEnd} materialConfig={materialConfig} /> @@ -306,8 +307,7 @@ const Avatar: FC = ({ materialConfig, onAnimationEnd, idleRotation, - headMovement, - disableZoom + headMovement ]); useEffect(() => triggerCallback(onLoading), [modelSrc, animationSrc, onLoading]); @@ -328,8 +328,8 @@ const Avatar: FC = ({ cameraTarget={cameraTarget} cameraInitialDistance={cameraInitialDistance} cameraZoomTarget={cameraZoomTarget} - controlsMinDistance={halfBody ? CAMERA.CONTROLS.HALF_BODY.MIN_DISTANCE : CAMERA.CONTROLS.FULL_BODY.MIN_DISTANCE} - controlsMaxDistance={halfBody ? CAMERA.CONTROLS.HALF_BODY.MAX_DISTANCE : CAMERA.CONTROLS.FULL_BODY.MAX_DISTANCE} + controlsMinDistance={controlsMinDistance} + controlsMaxDistance={controlsMaxDistance} updateCameraTargetOnZoom={!halfBody} /> {AvatarModel} diff --git a/src/components/Models/Model/Model.component.tsx b/src/components/Models/Model/Model.component.tsx index 9c464aa..3e194ca 100644 --- a/src/components/Models/Model/Model.component.tsx +++ b/src/components/Models/Model/Model.component.tsx @@ -10,7 +10,6 @@ interface ModelProps extends BaseModelProps { scene: Group; modelRef?: Ref; scale?: number; - disableZoom?: boolean; onSpawnAnimationFinish?: () => void; } @@ -18,7 +17,6 @@ const ROTATION_STEP = 0.005; export const Model: FC = ({ scene, - disableZoom, scale = 1, modelRef, onLoaded, @@ -79,13 +77,6 @@ export const Model: FC = ({ useEffect(() => triggerCallback(onLoaded), [scene, onLoaded]); useEffect(() => { - const disableZoomHandler = (e: WheelEvent) => { - if (disableZoom) { - e.preventDefault(); - e.stopPropagation(); - } - }; - gl.domElement.addEventListener('mousedown', setTouchingOn); gl.domElement.addEventListener('touchstart', setTouchingOn, { passive: true }); window.addEventListener('mouseup', setTouchingOff); @@ -95,10 +86,6 @@ export const Model: FC = ({ window.addEventListener('mousemove', onTouchMove); gl.domElement.addEventListener('touchmove', onTouchMove, { passive: true }); - if (disableZoom) { - gl.domElement.addEventListener('wheel', disableZoomHandler, { passive: false }); - } - return () => { gl.domElement.removeEventListener('mousedown', setTouchingOn); gl.domElement.removeEventListener('touchstart', setTouchingOn); @@ -108,12 +95,8 @@ export const Model: FC = ({ window.removeEventListener('mousemove', onTouchMove); gl.domElement.removeEventListener('touchmove', onTouchMove); - - if (disableZoom) { - gl.domElement.removeEventListener('wheel', disableZoomHandler); - } }; - }, [disableZoom, gl.domElement, onTouchMove]); + }); const spawnComponent = useMemo( () => , diff --git a/src/components/Models/MultipleAnimationModel/MultipleAnimationModel.component.tsx b/src/components/Models/MultipleAnimationModel/MultipleAnimationModel.component.tsx index 1f088f7..1a9f241 100644 --- a/src/components/Models/MultipleAnimationModel/MultipleAnimationModel.component.tsx +++ b/src/components/Models/MultipleAnimationModel/MultipleAnimationModel.component.tsx @@ -14,13 +14,11 @@ export interface MultipleAnimationModelProps extends BaseModelProps { activeAnimation: string; scale?: number; emotion?: Emotion; - disableZoom?: boolean; onAnimationEnd?: (action: AnimationAction) => void; } export const MultipleAnimationModel: FC = ({ modelSrc, - disableZoom, animations, activeAnimation, scale = 1, @@ -108,14 +106,5 @@ export const MultipleAnimationModel: FC = ({ useIdleExpression('blink', scene); useFallbackScene(scene, setModelFallback); - return ( - - ); + return ; };