31 lines
602 B
Rust
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)
|
|
}
|
|
}
|