diff --git a/src/camera.rs b/src/camera.rs index cb59647..7b9ab4c 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -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, }