Skip to content
Given an array of triangles' vertices, return a `Float32Array` of their normal vectors.
JavaScript C
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
shaders
.gitignore
README.md
demo.js
index.html
index.js
package.json

README.md

mesh-normals experimental

Given a list of vertices and faces, generate the normals for a triangle mesh.

Geared more towards "soft" low-poly normals, as you can't use indexed draw calls with the resulting normals. If you're just planning on straight smooth vertex normals, use the normals module. If you want low-poly and only have a "triangle soup" mesh, face-normals will still work for you.

view demo

Installation

mesh-normals

Usage

normals(cells, positions, flatness, [output])

cells is an indexed list of faces. Each face should be three elements long, one element per point.

positions is a list of vertex positions.

flatness is a value between 0 and 1, where 0 will return results only from the vertex normals and 1 will return results only from the face normals. 0.5 will be the middle ground between them.

Optionally, you can pass in an array-like output object to set the values directly. If not, a Float32Array will be created for you - either way, the new/updated array will be returned.

Something went wrong with that request. Please try again.