pub struct Mesh {
pub positions: Vec<Vec3>,
pub normals: Vec<Vec3>,
pub indices: Vec<u32>,
}Expand description
Owned triangle or line mesh generated from a built-in Geometry.
Each vector has independently allocated storage. Triangle primitives use
counter-clockwise index triples when viewed from outside; Geometry::Line has
exactly two indices and zero normals.
Fields§
§positions: Vec<Vec3>Vertex positions in local metres.
normals: Vec<Vec3>Per-vertex unit normals; line meshes use zero vectors.
indices: Vec<u32>Zero-based indices into Self::positions.
Implementations§
Source§impl Mesh
impl Mesh
Sourcepub fn validate(&self) -> Result<(), Diagnostic>
pub fn validate(&self) -> Result<(), Diagnostic>
Validates this owned mesh for use with the procedural helpers.
Sourcepub fn translated(&self, offset_m: Vec3) -> Result<Self, Diagnostic>
pub fn translated(&self, offset_m: Vec3) -> Result<Self, Diagnostic>
Returns a copy translated by offset_m metres.
Sourcepub fn rotated_xyz(&self, radians: Vec3) -> Result<Self, Diagnostic>
pub fn rotated_xyz(&self, radians: Vec3) -> Result<Self, Diagnostic>
Returns a copy rotated by XYZ Euler angles in radians.
Sourcepub fn scaled(&self, scale: Vec3) -> Result<Self, Diagnostic>
pub fn scaled(&self, scale: Vec3) -> Result<Self, Diagnostic>
Returns a copy scaled per axis. Negative determinant scales reverse winding once so triangles remain outward-facing relative to their normals.
Sourcepub fn reversed_winding(self) -> Self
pub fn reversed_winding(self) -> Self
Reverses all triangle winding and negates each normal.
Sourcepub fn map_positions<F>(&self, map: F) -> Result<Self, Diagnostic>
pub fn map_positions<F>(&self, map: F) -> Result<Self, Diagnostic>
Maps positions through a pure caller-supplied function and recalculates smooth normals from the resulting triangles.