From 80c2b5dbe20bd949202b18bb76964f72e8758e84 Mon Sep 17 00:00:00 2001 From: xfy Date: Mon, 13 Jul 2026 18:11:04 +0800 Subject: [PATCH] fix(camera): adjust default pitch and invert zoom scroll direction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Set default pitch to 0.7 rad to keep the camera away from the π/2 gimbal pole, preventing horizontal drag from degenerating into an in-plane roll. - Adjust scroll zoom logic to divide instead of multiply by the zoom factor, so that scrolling up zooms in (reduces distance) rather than out. --- src/camera.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index 132a8ad..f53ddf0 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -17,7 +17,11 @@ impl Default for OrbitCamera { fn default() -> Self { Self { yaw: 0.0, - pitch: 1.3, // ~75 deg — slightly above the disk plane + // Keep away from the π/2 gimbal pole: near the pole the world-Y (yaw) + // axis points almost straight out of the screen, so horizontal drag + // degenerates into an in-plane roll instead of a clean turn around + // the hole. ~0.7 rad (40°) is a 3/4 view with a comfortable yaw axis. + pitch: 0.7, distance: 30.0, fov: 1.0, // radians } @@ -76,8 +80,9 @@ pub fn orbit_controller( } } for ev in wheel.read() { - // Zoom: multiply distance by a factor of the scroll amount. - camera.distance = (camera.distance * (1.0 + ev.y * 0.1)).clamp(2.6, 500.0); + // Scroll up zooms IN: wint's +y (scroll up) must shrink distance, hence + // the negation. The old sign gave natural/inverted scrolling. + camera.distance = (camera.distance / (1.0 + ev.y * 0.1)).clamp(2.6, 500.0); // 2.6 ≈ bcrit; don't let the camera pass through the shadow. } }