mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-04 01:48:28 +00:00
Simplify
This commit is contained in:
parent
6fa8109bf6
commit
5538be6a30
@ -5,7 +5,7 @@ use crate::{
|
||||
NormalizedScreenPosition,
|
||||
};
|
||||
|
||||
use super::{rotation::Rotation, zoom::Zoom, InputEvent};
|
||||
use super::{rotation::Rotation, zoom, InputEvent};
|
||||
|
||||
/// Input handling abstraction
|
||||
///
|
||||
@ -28,7 +28,7 @@ impl InputHandler {
|
||||
Rotation::apply(angle_x, angle_y, focus_point, camera);
|
||||
}
|
||||
InputEvent::Zoom(zoom_delta) => {
|
||||
Zoom::apply(zoom_delta, focus_point, camera);
|
||||
zoom::apply(zoom_delta, focus_point, camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,9 @@ use fj_math::{Transform, Vector};
|
||||
|
||||
use crate::camera::{Camera, FocusPoint};
|
||||
|
||||
pub struct Zoom;
|
||||
|
||||
impl Zoom {
|
||||
pub fn apply(
|
||||
zoom_delta: f64,
|
||||
focus_point: FocusPoint,
|
||||
camera: &mut Camera,
|
||||
) {
|
||||
let distance = (focus_point.0 - camera.position()).magnitude();
|
||||
let displacement = zoom_delta * distance.into_f64();
|
||||
camera.translation = camera.translation
|
||||
* Transform::translation(Vector::from([0.0, 0.0, displacement]));
|
||||
}
|
||||
pub fn apply(zoom_delta: f64, focus_point: FocusPoint, camera: &mut Camera) {
|
||||
let distance = (focus_point.0 - camera.position()).magnitude();
|
||||
let displacement = zoom_delta * distance.into_f64();
|
||||
camera.translation = camera.translation
|
||||
* Transform::translation(Vector::from([0.0, 0.0, displacement]));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user