isosurface-generator
A JS generator function that returns a mesh describing an isosuface given a density and level. Since it's a generator function, you can perform this expensive calculation in a way that allows you to keep your UI responsive.
Install
npm install isosurface-generator
Example
const isosurfaceGenerator = ;const ndarray = ; const size = 8; const density = ; for let i = 0; i < 1000; i++ density; let mesh; for let data of mesh = positions: datapositions cells: datacells ; console; // await display update
API
require('isosurface-generator')(density, level)
Parameters
density
is an ndarray (or an object that implements ndarray's .get
method and .shape
attribute)
level
is the density value for which we're generating an isosurface
Return value
A generator function that will provide a mesh describing the isosurface mesh and the fraction complete:
const generator = ; generatornext; // Returns {// value: {// positions: [[1,2,3], [4,5,6], ...],// cells: [[1,2,3], [4,5,6], ...],// fraction: 0.009// },// done: false// }