From 0def6af6e851f5f0edda65ebb34a3e480766e840 Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Wed, 28 May 2025 11:03:57 +0100 Subject: [PATCH] fix scroll --- src/camera.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index 16d2f58..af355e6 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -82,6 +82,7 @@ pub fn spawn_panning_camera(mut commands: Commands) { pub fn scroll_events(mut evr_scroll: EventReader, mut query: Query<&mut Projection>) { const ZOOM_SENSITIVITY: f32 = 0.035; + const PIXEL_SENSITIVITY: f32 = 0.001; const MIN_SCALE: f32 = 0.2; const MAX_SCALE: f32 = 2.0; @@ -90,17 +91,20 @@ pub fn scroll_events(mut evr_scroll: EventReader, mut query: Query<& let current_scale = match &*projection_component { Projection::Orthographic(ortho_proj) => ortho_proj.scale, Projection::Perspective(_) => 1.0, - Projection::Custom(_custom_projection) => todo!(), + Projection::Custom(_custom_projection) => { + continue; + } }; let new_scale = match ev.unit { MouseScrollUnit::Line => current_scale + ev.y * ZOOM_SENSITIVITY, - MouseScrollUnit::Pixel => todo!(), + MouseScrollUnit::Pixel => current_scale + ev.y * PIXEL_SENSITIVITY, }; + *projection_component = Projection::Orthographic(OrthographicProjection { scale: new_scale.max(MIN_SCALE).min(MAX_SCALE), ..OrthographicProjection::default_2d() }); } } -} +} \ No newline at end of file