radarmp/mp_elements/src/renderer/camera.rs
2024-11-15 17:10:18 +08:00

31 lines
602 B
Rust

use glam::*;
pub struct Camera {
pub position: Vec3,
pub center: Vec3,
pub up: Vec3,
}
impl Default for Camera {
fn default() -> Self {
Self {
position: Vec3::new(0.0, 0.0, 0.0),
center: Vec3::new(0.0, 0.0, 0.0),
up: Vec3::new(0.0, 0.0, 0.0),
}
}
}
impl Camera {
pub fn new(position: Vec3, center: Vec3, up: Vec3) -> Self {
Self {
position,
center,
up,
}
}
pub fn calc_matrix(&self) -> Mat4 {
Mat4::look_at_rh(self.position, self.center, self.up)
}
}