volume-brush
Volumetric brush implementation, heavily inspired by (and adapted from) toxiclibs.
Installation
npm i volume-brush
Usage
const createVolume = require("volume-brush");
// create volume to work with
const volume = createVolume([128, 128, 128], [100, 100, 100]);
// leave a mark in 3d space of size `10`
volume.brush([50, 50, 50], 10);
// do something with the mesh
const mesh = volume.calculateMesh();
Running Examples
git clone
this repocd examples
npm install && npm start
open http://localhost:3000
Examples can also generate OBJ files by using npm run export
.
API
const volume = createVolume(dims, [size])
Creates the sparse voxel octree, params:
dims
- 3d vector describing the actual voxel octree dimensionssize
- scaled size that can be used withbrush
, defaults todims
if not provided
volume.brush(position, radius, [density], [brushMode])
position
- 3d vector describing center of the brush, usessize
coords provided tocreateVolume
radius
- radius of the brush-spheredensity
- optional - density of the volume, values less than0.0
will "carve out" volume, defaults to1.0
brushMode
- one of three brush modes, (defaults to"additive"
):"additive"
"peak"
"replace"
volume.calculateMesh()
Calculates simplicial complex from current volume. Returns { cells, positions }
.