Signed distance field computations for meshes
Via npm:
npm install signed-distance
Here is how you can use it:
var mesh = require("bunny");
var dist = require("signed-distance")(
require("spatial-grid")(mesh.cells, mesh.positions, 0.1),
require("normals").faceNormals(mesh.cells, mesh.positions),
[1.0, 0.0, 0.0]);
require("signed-distance")(grid, faceNormals, point)
Computes the signed distance to the mesh from point
grid
: A spatial gridfaceNormals
: The normals of the meshpoint
: The point to queryReturns: The signed distance to the boundary of the mesh, or else NaN
(c) 2013 Mikola Lysenko. BSD