Skip to main content

compute_vertex_normals

Function compute_vertex_normals 

Source
pub fn compute_vertex_normals(
    positions: &[f32],
    indices: &[u32],
) -> Result<Vec<f32>, MeshError>
Expand description

Computes smooth per-vertex normals.

Each face normal is weighted by the triangle’s area, accumulated on its three vertices, then normalized. Vertices not used by any non-degenerate triangle get a [0, 0, 0] normal. Returns a buffer with the same length as positions.