Skip to content

Given an array of triangles' vertices, return a `Float32Array` of their normal vectors.

Notifications You must be signed in to change notification settings

hughsk/mesh-normals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Given an array of triangles' vertices, return a `Float32Array` of their normal vectors.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published