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
use crate::{Material, Shape};
use rapier3d::math::{Isometry, Real};
use serde::Serialize;

#[derive(Debug, Copy, Clone, Serialize)]
#[serde(tag = "t", content = "c")]
pub enum Component {
    Shape(Option<Shape>),
    Material(Material),
    Isometry(Isometry<Real>),
}

impl From<Shape> for Component {
    fn from(shape: Shape) -> Self {
        Self::Shape(Some(shape))
    }
}

impl From<Material> for Component {
    fn from(material: Material) -> Self {
        Self::Material(material)
    }
}

impl From<Isometry<Real>> for Component {
    fn from(isometry: Isometry<Real>) -> Self {
        Self::Isometry(isometry)
    }
}