use number_traits::Float;
use mat4;


pub struct InnerTransform3D<T: 'static + Sync + Send + Copy + Float> {
    pub position: [T; 3],
    pub scale: [T; 3],
    pub rotation: [T; 4],
}


impl<T: 'static + Sync + Send + Copy + Float> Default for InnerTransform3D<T> {

    #[inline(always)]
    fn default() -> Self {
        InnerTransform3D {
            position: [T::zero(); 3],
            scale: [T::one(); 3],
            rotation: [T::zero(), T::zero(), T::zero(), T::one()],
        }
    }
}


impl<T: 'static + Sync + Send + Copy + Float> InnerTransform3D<T> {

    #[inline(always)]
    pub fn new() -> Self {
        Self::default()
    }

    #[inline]
    pub fn matrix(&self) -> [T; 16] {
        let mut matrix = mat4::new_identity();
        mat4::compose(&mut matrix, &self.position, &self.scale, &self.rotation);
        matrix
    }
}
