diff --git a/src/viser/client/src/CameraControls.tsx b/src/viser/client/src/CameraControls.tsx index 503ed7840..23f95d657 100644 --- a/src/viser/client/src/CameraControls.tsx +++ b/src/viser/client/src/CameraControls.tsx @@ -13,7 +13,7 @@ export function SynchronizedCameraControls() { const sendCameraThrottled = makeThrottledMessageSender( viewer.websocketRef, - 20, + 20 ); // Helper for resetting camera poses. @@ -30,12 +30,12 @@ export function SynchronizedCameraControls() { initialCameraRef.current!.lookAt.x, initialCameraRef.current!.lookAt.y, initialCameraRef.current!.lookAt.z, - true, + true ); viewer.cameraRef.current!.up.set( initialCameraRef.current!.camera.up.x, initialCameraRef.current!.camera.up.y, - initialCameraRef.current!.camera.up.z, + initialCameraRef.current!.camera.up.z ); viewer.cameraControlRef.current!.updateCameraUp(); }; @@ -93,9 +93,6 @@ export function SynchronizedCameraControls() { }); }, [camera, sendCameraThrottled]); - //Camera Animation code - const animationId = useRef(null); - // Send camera for new connections. // We add a small delay to give the server time to add a callback. const connected = viewer.useGui((state) => state.websocketConnected); @@ -164,28 +161,28 @@ export function SynchronizedCameraControls() { cameraControls.rotate( -0.05 * THREE.MathUtils.DEG2RAD * event?.deltaTime, 0, - true, + true ); }); rightKey.addEventListener("holding", (event) => { cameraControls.rotate( 0.05 * THREE.MathUtils.DEG2RAD * event?.deltaTime, 0, - true, + true ); }); upKey.addEventListener("holding", (event) => { cameraControls.rotate( 0, -0.05 * THREE.MathUtils.DEG2RAD * event?.deltaTime, - true, + true ); }); downKey.addEventListener("holding", (event) => { cameraControls.rotate( 0, 0.05 * THREE.MathUtils.DEG2RAD * event?.deltaTime, - true, + true ); }); @@ -193,9 +190,7 @@ export function SynchronizedCameraControls() { // because KeyboardKeyHold attaches listeners directly to the // document/window; it's unclear if we can remove these. return () => { - if (animationId.current !== null) { - cancelAnimationFrame(animationId.current); - } + return; }; }, [CameraControls]);