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
use super::{Face, Transform3D, Vec3D};
mod mesh3d_presets;

/// The struct for a `Mesh3D` object, containing a position, rotation, collection of vertices and collection of [`Face`]s with indices to the vertex collection.
#[derive(Debug, Clone)]
pub struct Mesh3D {
    /// The mesh's transform (position, rotation, scale) in 3D space
    pub transform: Transform3D,
    /// A vector of the [`Mesh3D`]'s
    pub vertices: Vec<Vec3D>,
    /// A vector of [`Face`]s of indexes into [`Mesh3D::vertices`]
    pub faces: Vec<Face>,
}

impl Mesh3D {
    /// Create a `Mesh3D` with a default `Transform3D`
    #[must_use]
    pub const fn new(transform: Transform3D, vertices: Vec<Vec3D>, faces: Vec<Face>) -> Self {
        Self {
            transform,
            vertices,
            faces,
        }
    }

    /// Create a `Mesh3D` with a default `Transform3D`
    #[must_use]
    pub const fn new_at_origin(vertices: Vec<Vec3D>, faces: Vec<Face>) -> Self {
        Self {
            transform: Transform3D::DEFAULT,
            vertices,
            faces,
        }
    }
}