From 159145fc7547c8e9bbbf758467fab257f616cbd5 Mon Sep 17 00:00:00 2001 From: DaCameraGirl Date: Tue, 4 Aug 2026 04:24:22 +0000 Subject: [PATCH] fix(viewport): stop camera snapping back on slider changes Every slider tweak (feather, crop, colors, morph, etc.) was nuking the user's OrbitControls zoom/pan position. Root cause: ThreeCanvas avatar rebuild effect called fitCameraToAvatar() unconditionally after buildAvatar(). Since faceCanvas regenerates on every feather/crop change, the avatar rebuild effect fired constantly, snapping the camera back to the default framed distance each time. Fix: Remove fitCameraToAvatar() from the avatar rebuild effect. Camera framing is already handled separately by the cameraPreset/cameraFov effect, which is the correct place - it only runs when the user actually changes the camera view, not on every material/texture/geometry tweak. The user's manual zoom/scroll position is now preserved across all config slider changes. --- src/components/ThreeCanvas.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/components/ThreeCanvas.tsx b/src/components/ThreeCanvas.tsx index 08fab4a..15c75bf 100644 --- a/src/components/ThreeCanvas.tsx +++ b/src/components/ThreeCanvas.tsx @@ -1035,6 +1035,10 @@ export default function ThreeCanvas({ }, [onSceneReady]); // 5. Re-build Avatar ONLY when layout, geometry, or appearance configurations change + // NOTE: Do NOT call fitCameraToAvatar here - that resets the user's + // OrbitControls zoom/pan position every time a slider changes (feather, + // crop, colors, etc). Camera framing is handled separately by the + // cameraPreset/cameraFov effect above. useEffect(() => { if (!sceneRef.current) return; @@ -1049,15 +1053,6 @@ export default function ThreeCanvas({ sceneRef.current.add(avatarGroup); avatarGroupRef.current = avatarGroup; - if (cameraRef.current) { - fitCameraToAvatar( - cameraRef.current, - controlsRef.current, - avatarGroup, - config.cameraPreset - ); - } - if (onSceneReadyRef.current) { onSceneReadyRef.current(avatarGroup); }