use {
crate::shader_data::ModelTransform,
glam::{Mat4, Quat, Vec3},
};
#[derive(Clone, Copy)]
pub struct Transform {
pub pos: Vec3,
pub rot: Quat,
pub scl: Vec3,
}
impl Transform {
pub fn from_position<P>(pos: P) -> Self
where
P: Into<Vec3>,
{
Self {
pos: pos.into(),
..Default::default()
}
}
}
impl Default for Transform {
fn default() -> Self {
Self {
pos: Vec3::ZERO,
rot: Quat::IDENTITY,
scl: Vec3::ONE,
}
}
}
impl From<Transform> for ModelTransform {
fn from(Transform { pos, rot, scl }: Transform) -> Self {
let mat = Mat4::from_scale_rotation_translation(scl, rot, pos);
Self::from(mat)
}
}