pub struct Mesh3d { /* private fields */ }Expand description
Immutable validated topology for retained stereometry rendering.
Vertices use caller-defined model-space world units. Triangle indices are a flat triangle list. Winding is preserved but deliberately not interpreted: the current surface pass disables face culling, and a global “counter-clockwise” rule is meaningless without a declared outward side. Optional display edges identify the mathematical edges that a later visible/hidden-line pass should draw; they are not inferred from triangle adjacency because triangulation diagonals are not necessarily meaningful construction edges. A mesh may contain surfaces, display edges, or both.
Implementations§
Source§impl Mesh3d
impl Mesh3d
Sourcepub fn new(
vertices: Vec<Vec3>,
triangle_indices: Vec<u32>,
) -> Result<Self, Mesh3dError>
pub fn new( vertices: Vec<Vec3>, triangle_indices: Vec<u32>, ) -> Result<Self, Mesh3dError>
Builds a surface mesh without explicit display edges.
Sourcepub fn with_display_edges(
vertices: Vec<Vec3>,
triangle_indices: Vec<u32>,
display_edges: Vec<MeshEdge3d>,
) -> Result<Self, Mesh3dError>
pub fn with_display_edges( vertices: Vec<Vec3>, triangle_indices: Vec<u32>, display_edges: Vec<MeshEdge3d>, ) -> Result<Self, Mesh3dError>
Builds a mesh with explicit mathematical display edges.
Construction rejects an empty vertex set, geometry with neither triangles nor display edges, incomplete triangle lists, out-of-range indices, repeated/collinear triangle vertices, duplicate display edges, display edges with coincident endpoints, and display edges outside the vertex array.
Sourcepub fn textured(
vertices: Vec<Vec3>,
texture_coordinates: Vec<TextureCoordinate2d>,
triangle_indices: Vec<u32>,
display_edges: Vec<MeshEdge3d>,
) -> Result<Self, Mesh3dError>
pub fn textured( vertices: Vec<Vec3>, texture_coordinates: Vec<TextureCoordinate2d>, triangle_indices: Vec<u32>, display_edges: Vec<MeshEdge3d>, ) -> Result<Self, Mesh3dError>
Builds surfaces with one validated texture coordinate per model vertex.
Duplicate model positions with different UVs are valid for atlas seams. Winding and explicit display edges keep the untextured mesh contract. A texture/material is attached only when uploading or binding to a renderer; constructing this data requires no GPU dependencies.
Sourcepub fn with_attributes(
vertices: Vec<Vec3>,
triangle_indices: Vec<u32>,
display_edges: Vec<MeshEdge3d>,
attributes: Mesh3dAttributes,
) -> Result<Self, Mesh3dError>
pub fn with_attributes( vertices: Vec<Vec3>, triangle_indices: Vec<u32>, display_edges: Vec<MeshEdge3d>, attributes: Mesh3dAttributes, ) -> Result<Self, Mesh3dError>
Builds topology with optional UVs and normalized straight-linear colors. Supplied attributes must match every vertex, including unused vertices. Missing colors multiply by white. Opaque ignores alpha; Mask and Blend use combined vertex/material/texture alpha. All buffers are moved into immutable shared storage without copies.
Sourcepub fn triangle_indices(&self) -> &[u32]
pub fn triangle_indices(&self) -> &[u32]
Returns the flat host-wound triangle index list.
Sourcepub fn display_edges(&self) -> &[MeshEdge3d]
pub fn display_edges(&self) -> &[MeshEdge3d]
Returns explicit mathematical edges, excluding triangulation diagonals.
Sourcepub fn texture_coordinates(&self) -> &[TextureCoordinate2d]
pub fn texture_coordinates(&self) -> &[TextureCoordinate2d]
Returns per-vertex normalized UVs, or an empty slice for untextured data.
Sourcepub fn vertex_colors(&self) -> &[Color]
pub fn vertex_colors(&self) -> &[Color]
Returns normalized straight-linear vertex RGBA, or empty for white. The opaque surface pass ignores alpha; mathematical edges are unaffected.
Sourcepub fn normals(&self) -> &[Vec3]
pub fn normals(&self) -> &[Vec3]
Returns normalized application-supplied model normals, or an empty slice. Lambert surfaces require normals; Unlit surfaces never evaluate them.
Sourcepub fn triangle_count(&self) -> usize
pub fn triangle_count(&self) -> usize
Returns the number of retained triangles.
Sourcepub const fn bounds_min(&self) -> Vec3
pub const fn bounds_min(&self) -> Vec3
Returns the inclusive model-space lower bound.
Sourcepub const fn bounds_max(&self) -> Vec3
pub const fn bounds_max(&self) -> Vec3
Returns the inclusive model-space upper bound.
Sourcepub fn recovery_memory_bytes(&self) -> usize
pub fn recovery_memory_bytes(&self) -> usize
Returns retained CPU capacity bytes for topology and optional attributes.