summaryrefslogtreecommitdiff
path: root/engine/src/transform.rs
blob: 5e5e296a3a571bdaf2599dce2010dfc0ad72d027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use ecs::Component;

use crate::vector::Vec3;

/// A position in 3D space.
#[derive(Debug, Default, Clone, Copy, Component)]
pub struct Position
{
    pub position: Vec3<f32>,
}

impl From<Vec3<f32>> for Position
{
    fn from(position: Vec3<f32>) -> Self
    {
        Self { position }
    }
}

/// Scaling of a 3D object.
#[derive(Debug, Clone, Copy, Component)]
pub struct Scale
{
    pub scale: Vec3<f32>,
}

impl From<Vec3<f32>> for Scale
{
    fn from(scale: Vec3<f32>) -> Self
    {
        Self { scale }
    }
}

impl Default for Scale
{
    fn default() -> Self
    {
        Self {
            scale: Vec3 { x: 1.0, y: 1.0, z: 1.0 },
        }
    }
}