Skip to content

Commit

Permalink
fix camera::rotate_around, normalize vector (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
435vic authored Oct 13, 2023
1 parent 4012acf commit 0d91ef8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ impl Camera {
///
pub fn rotate_around(&mut self, point: &Vec3, x: f32, y: f32) {
let dir = (point - self.position()).normalize();
let right = dir.cross(*self.up());
let right = dir.cross(self.up().normalize());
let up = right.cross(dir);
let new_dir = (point - self.position() + right * x - up * y).normalize();
let rotation = rotation_matrix_from_dir_to_dir(dir, new_dir);
Expand All @@ -633,7 +633,7 @@ impl Camera {
///
pub fn rotate_around_with_fixed_up(&mut self, point: &Vec3, x: f32, y: f32) {
let dir = (point - self.position()).normalize();
let right = dir.cross(*self.up());
let right = dir.cross(self.up().normalize());
let mut up = right.cross(dir);
let new_dir = (point - self.position() + right * x - up * y).normalize();
up = *self.up();
Expand Down

0 comments on commit 0d91ef8

Please # to comment.