fix scroll
This commit is contained in:
+6
-2
@@ -82,6 +82,7 @@ pub fn spawn_panning_camera(mut commands: Commands) {
|
||||
|
||||
pub fn scroll_events(mut evr_scroll: EventReader<MouseWheel>, 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,13 +91,16 @@ pub fn scroll_events(mut evr_scroll: EventReader<MouseWheel>, 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()
|
||||
|
||||
Reference in New Issue
Block a user