Skip to content

Commit

Permalink
Fix camera rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Oct 24, 2023
1 parent 7d12c46 commit bd52e06
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/scene/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,13 +767,14 @@ fn main() {
winit::event::WindowEvent::CursorMoved { position, .. } => {
last_mouse_pos = [position.x as i32, position.y as i32];
if let Some(ref mut drag) = drag_start {
// This is rotation around the world UP, which is assumed to be Y
let qx = glam::Quat::from_rotation_y(
(drag.screen_pos.x - last_mouse_pos[0]) as f32 * rotate_speed,
);
let qy = glam::Quat::from_rotation_x(
(drag.screen_pos.y - last_mouse_pos[1]) as f32 * rotate_speed,
);
example.camera.rot = (drag.rotation * qx * qy).into();
example.camera.rot = (qx * drag.rotation * qy).into();
example.debug.mouse_pos = None;
}
}
Expand Down

0 comments on commit bd52e06

Please sign in to comment.