# volume-brush

> volumetric brush implementation, heavily inspired by toxiclibs

Latest version **1.0.0** (published 2019-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install volume-brush
pnpm add volume-brush
yarn add volume-brush
bun add volume-brush
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-06-24 |
| First published | 2019-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 14 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Szymon Kaliski |
| Maintainers | szymon_k |

## Links

- npm: https://www.npmjs.com/package/volume-brush
- npm.io page: https://npm.io/package/volume-brush

## Dependencies (3)

- [math-ds](https://npm.io/package/math-ds.md) ^1.1.3
- [isosurface](https://npm.io/package/isosurface.md) ^1.0.0
- [sparse-octree](https://npm.io/package/sparse-octree.md) ^5.2.1

## Recent versions

- 1.0.0 (latest) — 2019-06-24

## README

# volume-brush

Volumetric brush implementation, heavily inspired by (and adapted from) [toxiclibs](http://toxiclibs.org/docs/volumeutils/toxi/volume/VolumetricBrush.html).

<p align="center"><img src="assets/screen.png" alt="screenshot" style="max-width:100%;"></p>

## Installation

`npm i volume-brush`

## Usage

```js
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

1. `git clone` this repo
2. `cd examples`
3. `npm install && npm start`
4. `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 dimensions
- `size` - scaled size that can be used with `brush`, defaults to `dims` if not provided

#### `volume.brush(position, radius, [density], [brushMode])`

- `position` - 3d vector describing center of the brush, uses `size` coords provided to `createVolume`
- `radius` - radius of the brush-sphere
- `density` - optional - density of the volume, values less than `0.0` will "carve out" volume, defaults to `1.0`
- `brushMode` - one of three brush modes, (defaults to `"additive"`):
  - `"additive"`
  - `"peak"`
  - `"replace"`

#### `volume.calculateMesh()`

Calculates simplicial complex from current volume. Returns `{ cells, positions }`.

---
_Source: https://npm.io/package/volume-brush · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
