use crate::data_types::dimens::Dimens3; use crate::ecs::Component; use crate::matrix::Matrix; use crate::reflection::Reflection; use crate::vector::Vec3; #[derive(Debug, Clone, Component, Reflection)] #[non_exhaustive] pub struct Transform { pub position: Vec3, pub scale: Dimens3, } impl Transform { pub fn position(mut self, position: Vec3) -> Self { self.position = position; self } pub fn scale(mut self, scale: Dimens3) -> Self { self.scale = scale; self } pub fn to_matrix(&self) -> Matrix { let mut matrix = Matrix::new_identity(); matrix.translate(&self.position); matrix.scale(&self.scale); matrix } } impl Default for Transform { fn default() -> Self { Self { position: Vec3 { x: 0.0, y: 0.0, z: 0.0 }, scale: Dimens3 { width: 1.0, height: 1.0, depth: 1.0 }, } } }