implicit-mesh
create simplicial complex meshes from an implicit function
example
var build =var mesh =console
or using a shader:
var build =var mesh =console
either way, you can use meshview:
$ electron-spawn shader.js | meshview
$ node js.js | meshview
api
var js =var shader =
var mesh = js(opts, fn)
Build a 3d mesh
with resolution opts.size
from an implicit function
fn(x,y,z)
.
If opts
is a number of array, it is interpreted as the opts.size
.
opts.size
can be a number or an array of numbers, one for each coordinate.
The f(x,y,z)
coordinates are in the domain [-1,1]
and the resulting mesh
coordinates are in the range [-1,1]
in each dimension.
simplicial complex meshes have:
mesh.positions
- an array of position arraysmesh.cells
- an array of arrays of position indicies comprising a face
To get the surface normals you can use the [angle-normals][2] package:
var angleNormals =var normals =
var mesh = shader(opts, src)
Build a mesh from a glsl function defined in the string src
and:
opts.size
- resolution to sample the implicitopts.precision
- default: 'medium'
You should define a function float surface(vec3 pos)
.
install
npm install implicit-mesh
license
BSD