compute_vertex_normals: Compute per-vertex normals for a mesh

View source: R/mesh_utils.R

compute_vertex_normalsR Documentation

Compute per-vertex normals for a mesh

Description

Computes smooth vertex normals by averaging face normals. Returns the same mesh with a normals component (Nx3 numeric matrix). Useful for imported meshes that lack pre-computed normals.

Usage

compute_vertex_normals(mesh)

Arguments

mesh

A mesh descriptor list with vertices and triangles.

Value

The mesh with a normals component added.

Examples

mesh <- generate_cuboid(c(0, 0, 0), c(1, 1, 1))
mesh <- compute_vertex_normals(mesh)
nrow(mesh$normals)


scimesh documentation built on Aug. 9, 2026, 9:07 a.m.