diff --git a/crates/viewer/src/camera.rs b/crates/viewer/src/camera.rs index 6397ebf1..cf1af5e0 100644 --- a/crates/viewer/src/camera.rs +++ b/crates/viewer/src/camera.rs @@ -58,7 +58,9 @@ impl OrbitCamera { } /// Zoom in or out, while looking at the same target. - pub fn zoom(&mut self, zoom_delta: f32) {} + pub fn zoom(&mut self, zoom_delta: f32) { + self.radius = f32::max(self.radius * f32::exp(zoom_delta), f32::EPSILON); + } /// Orbit around the target while keeping the distance. pub fn rotate(&mut self, rotator: Quat) { diff --git a/crates/viewer/src/main.rs b/crates/viewer/src/main.rs index 4993d70c..e00211a1 100644 --- a/crates/viewer/src/main.rs +++ b/crates/viewer/src/main.rs @@ -262,7 +262,8 @@ impl GameApp for ViewerApp { self.camera.pan(TOUCHPAD_PAN_MULTIPLIER * camera_space_delta); }, WindowEvent::TouchpadMagnify { delta, .. } => { - self.camera.zoom(*delta as f32 * TOUCHPAD_ZOOM_MULTIPLIER); + let zoom_delta = *delta as f32 * TOUCHPAD_ZOOM_MULTIPLIER; + self.camera.zoom(-zoom_delta); }, WindowEvent::KeyboardInput { input: KeyboardInput { virtual_keycode: Some(keycode), .. },