Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating vertex normals for smooth shading with crease angle in Three.js

I have several objects in Three.js's JSON Model Format. It specifies vertex positions, and faces -- sometimes triangles, sometimes quads, sometimes with material indices and sometimes not.

However none of these files have vertex normals specified.

I want an algorithm that can calculate such normals over a set of mesh faces. I'd like to specify an angular limit beyond which a crease is shown (normals are not shared by adjacent faces at a vertex.)

Before coding this myself I wondered, does this exist either in Three.js already or somewhere else that's usable?

like image 743
Drew Noakes Avatar asked Feb 07 '13 23:02

Drew Noakes


1 Answers

The only thing available is

geometry.computeFaceNormals();
geometry.computeVertexNormals();

See the source for the algorithm.

three.js r.55

like image 54
WestLangley Avatar answered Sep 19 '22 01:09

WestLangley