This commit is contained in:
Hanno Braun 2024-11-18 20:33:46 +01:00
parent 202641052b
commit 96204d4174
2 changed files with 9 additions and 13 deletions

View File

@ -1,14 +1,5 @@
/// An input event
pub enum InputEvent {
/// Rotate the model around the focus point
Rotation {
/// The angle around the screen x axis to rotate (in radians)
angle_x: f64,
/// The angle around the screen y axis to rotate (in radians)
angle_y: f64,
},
/// Move the view forwards and backwards
Zoom(f64),
}

View File

@ -73,9 +73,6 @@ impl Viewer {
};
match event {
InputEvent::Rotation { angle_x, angle_y } => {
self.camera.apply_rotation(angle_x, angle_y, focus_point);
}
InputEvent::Zoom(zoom_delta) => {
self.camera.apply_zoom(zoom_delta, focus_point);
}
@ -104,7 +101,15 @@ impl Viewer {
let angle_y =
diff_x * self.camera_tuning_config.rotation_sensitivity;
Some(InputEvent::Rotation { angle_x, angle_y })
if let Some(focus_point) = self.focus_point {
self.camera.apply_rotation(
angle_x,
angle_y,
focus_point,
);
}
None
}
MouseButton::Right => {
if let Some(focus_point) = self.focus_point {