Skip to content

Commit

Permalink
Fix Camera::position_at_uv_coordinates for Orthographic camera
Browse files Browse the repository at this point in the history
  • Loading branch information
asny committed Dec 13, 2024
1 parent 23dec6f commit 20bfe42
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,9 @@ impl Camera {
match self.projection_type() {
ProjectionType::Orthographic { .. } | ProjectionType::Planar { .. } => {
let coords = coords.into();
let screen_pos = Point3::new(2. * coords.u - 1., 2. * coords.v - 1.0, -1.0);
self.screen2ray().transform_point(screen_pos).to_vec()
let screen_pos = vec4(2. * coords.u - 1., 2. * coords.v - 1.0, 0.0, 1.);
let p = (self.screen2ray() * screen_pos).truncate();
p + (self.position - p).project_on(self.view_direction()) // Project onto the image plane
}
ProjectionType::Perspective { .. } => self.position,
}
Expand Down

0 comments on commit 20bfe42

Please sign in to comment.