gemini_engine/mesh3d/
mod.rs

1//! This module contains the [`Mesh3D`], which stores 3D objects as vertices and index faces
2
3mod components;
4mod mesh3d_presets;
5
6pub use components::{Face, Transform3D, Vec3D};
7
8/// A 3D mesh made up of vertices, faces made of indices into `vertices`, and a transformation.
9#[derive(Debug, Clone)]
10pub struct Mesh3D {
11    /// The mesh's transform matrix in 3D space
12    pub transform: Transform3D,
13    /// A vector of the [`Mesh3D`]'s vertices
14    pub vertices: Vec<Vec3D>,
15    /// A vector of [`Face`]s of indexes into `vertices`
16    pub faces: Vec<Face>,
17}
18
19impl Mesh3D {
20    /// Create a `Mesh3D` with an identity `Transform3D`
21    #[must_use]
22    pub const fn new(vertices: Vec<Vec3D>, faces: Vec<Face>) -> Self {
23        Self {
24            transform: Transform3D::IDENTITY,
25            vertices,
26            faces,
27        }
28    }
29
30    /// Return the `Mesh3D` with an updated `transform` property. Consumes the original `Mesh3D`
31    #[must_use]
32    pub const fn with_transform(mut self, transform: Transform3D) -> Self {
33        self.transform = transform;
34        self
35    }
36}