guf.js is a small collection of functions that calculate geometric properties of a mesh. The key feature it currently provides is normal calculation (face & vertex normals).
var guf = require('guf');
var positions = [[x,y,z], [x,y,z], [x,y,z], [x,y,z], ... ];
var cells = [[i0,i1,i2], [i0,i1,i2], [i0,i1,i2], ... ];
// Vertex Normals (Left Image)
var vertexNormals = guf.vertexNormals( positions, cells ) );
// Face Normals (Right Image)
var facePositions = [];
var faceNormals = [];
for( var i = 0; i < cells.length; i++ ) {
var a = positions[ cells[ i ][ 0 ] ];
var b = positions[ cells[ i ][ 1 ] ];
var c = positions[ cells[ i ][ 2 ] ];
var n = guf.calculateNormal( a, b, c );
facePositions.push( a, b, c );
faceNormals.push( n, n, n );
}
This library is part of a larger project / series of libraries that aspires to bring computational and parametric design to the web. This library helps render meshes so you can see if your mesh's normals are oriented properly. This is useful in applications that enable higher level computational design, 3d printing, g-code generation, cnc milling tool path creation, laser cutting paths, robotic motion planning, and more.
node.js (4.4.0+) & npm
You can add this library to your project by running:
npm install --save https://github.com/YCAMInterlab/guf.js.git
or via npm:
npm install --save guf
See https://github.com/rezaali/webgl-sketches/tree/master/hull
Copyright 2015-2016 Reza Ali co-developed by YCAMInterLab during the Guest Research Project v.3
Apache-2.0