1.0.0 • Published 6 years ago
volume-brush v1.0.0
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 clonethis repocd examplesnpm install && npm startopen 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 todimsif not provided
volume.brush(position, radius, [density], [brushMode])
position- 3d vector describing center of the brush, usessizecoords provided tocreateVolumeradius- radius of the brush-spheredensity- optional - density of the volume, values less than0.0will "carve out" volume, defaults to1.0brushMode- one of three brush modes, (defaults to"additive"):"additive""peak""replace"
volume.calculateMesh()
Calculates simplicial complex from current volume. Returns { cells, positions }.
1.0.0
6 years ago