Skip to content

Commit

Permalink
Remove unused animation code
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Sep 25, 2023
1 parent 6123ac9 commit cf7ba96
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/viser/client/src/CameraControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function SynchronizedCameraControls() {

const sendCameraThrottled = makeThrottledMessageSender(
viewer.websocketRef,
20,
20
);

// Helper for resetting camera poses.
Expand All @@ -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();
};
Expand Down Expand Up @@ -93,9 +93,6 @@ export function SynchronizedCameraControls() {
});
}, [camera, sendCameraThrottled]);

//Camera Animation code
const animationId = useRef<number | null>(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);
Expand Down Expand Up @@ -164,38 +161,36 @@ 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
);
});

// TODO: we currently don't remove any event listeners. This is a bit messy
// 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]);

Expand Down

0 comments on commit cf7ba96

Please sign in to comment.