use nalgebra::{Isometry3, Matrix4, Perspective3, Point3, Real, Scalar, Vector3}; pub struct Camera where T: Real + Scalar, { projection: Perspective3, view: Isometry3, } impl Camera where T: Real + Scalar, { pub fn new(aspect: T, fov: T, near: T, far: T) -> Self { Camera { projection: Perspective3::new(aspect, fov, near, far), view: Isometry3::look_at_rh( &Point3::origin(), &Point3::new(T::zero(), T::zero(), -T::one()), &Vector3::y(), ), } } pub fn look_at(&mut self, from: &Point3, to: &Point3) { self.view = Isometry3::look_at_rh(from, to, &Vector3::y()); } pub fn transform(&self) -> Matrix4 { self.projection.into_inner() * self.view.to_homogeneous() } }