This commit is contained in:
Hanno Braun 2024-11-18 20:31:25 +01:00
parent 803c456d05
commit 202641052b
2 changed files with 10 additions and 19 deletions

View File

@ -1,16 +1,5 @@
use crate::screen::NormalizedScreenPosition;
/// An input event
pub enum InputEvent {
/// Move the model up, down, left or right
Translation {
/// The normalized position of the cursor before input
previous: NormalizedScreenPosition,
/// The normalized position of the cursor after input
current: NormalizedScreenPosition,
},
/// Rotate the model around the focus point
Rotation {
/// The angle around the screen x axis to rotate (in radians)

View File

@ -73,10 +73,6 @@ impl Viewer {
};
match event {
InputEvent::Translation { previous, current } => {
self.camera
.apply_translation(previous, current, focus_point);
}
InputEvent::Rotation { angle_x, angle_y } => {
self.camera.apply_rotation(angle_x, angle_y, focus_point);
}
@ -110,10 +106,16 @@ impl Viewer {
Some(InputEvent::Rotation { angle_x, angle_y })
}
MouseButton::Right => Some(InputEvent::Translation {
previous: cursor_old,
current: cursor_new,
}),
MouseButton::Right => {
if let Some(focus_point) = self.focus_point {
self.camera.apply_translation(
cursor_old,
cursor_new,
focus_point,
);
}
None
}
},
_ => None,
};