use crate::matrix::Matrix; use crate::vector::Vec3; #[derive(Debug)] pub struct Camera { position: Vec3, target: Vec3, } impl Camera { pub fn set_position(&mut self, position: Vec3) { self.position = position; } #[must_use] pub fn position(&self) -> &Vec3 { &self.position } pub fn set_target(&mut self, target: Vec3) { self.target = target; } #[must_use] pub fn target(&self) -> &Vec3 { &self.target } pub(crate) fn new() -> Self { let position = Vec3 { x: 0.0, y: 0.0, z: 3.0, }; Self { position, target: Vec3::default(), } } pub(crate) fn as_matrix(&self) -> Matrix { let mut matrix = Matrix::new(); matrix.look_at(&self.position, &self.target, &Vec3::UP); matrix } }