# voxel

> tools to work with voxel generation and chunking in javascript

Latest version **0.5.0** (published 2015-02-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install voxel
pnpm add voxel
yarn add voxel
bun add voxel
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2015-02-13 |
| First published | 2012-12-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 192 |
| Author | Max Ogden |
| Maintainers | maxogden, deathcap |

## Links

- npm: https://www.npmjs.com/package/voxel
- Repository: http://github.com/maxogden/voxel
- Homepage: https://github.com/maxogden/voxel
- Issues: https://github.com/maxogden/voxel/issues
- npm.io page: https://npm.io/package/voxel

## Dependencies (2)

- [ndarray](https://npm.io/package/ndarray.md) ~1.0.5
- [inherits](https://npm.io/package/inherits.md) 1.0.0

## Recent versions

- 0.5.0 (latest) — 2015-02-13
- 0.4.0 — 2014-03-25
- 0.3.1 — 2013-03-02
- 0.2.0 — 2013-02-28
- 0.1.5 — 2013-02-10
- 0.1.4 — 2013-02-03
- 0.1.3 — 2013-01-30
- 0.1.2 — 2013-01-29
- 0.1.1 — 2013-01-22
- 0.1.0 — 2013-01-17
- 0.0.9 — 2013-01-08
- 0.0.8 — 2013-01-08
- 0.0.7 — 2013-01-08
- 0.0.6 — 2013-01-08
- 0.0.5 — 2013-01-07
- … 4 more at https://npm.io/package/voxel/versions

## README

# voxel

voxel geometry generation and meshing algorithms in javascript. written by @mikolalysenko and put on npm by me.

- original repo: https://github.com/mikolalysenko/mikolalysenko.github.com/tree/master/MinecraftMeshes2
- blog post: http://0fps.wordpress.com/2012/07/07/meshing-minecraft-part-2/
- webgl demo: http://mikolalysenko.github.com/MinecraftMeshes2/

# installation

in node:
```
npm install voxel
```
in a browser:

use `voxel-browser.js`

# usage

## require('voxel').generate(low, high, iterator)

where `low` and `high` are `[x, y, z]` start and end positions to iterate over and `iterator` is the function that visits each voxel

returns an object like this: `{ "voxels": "a 1D Int32Array filled with voxel data", "dims": [x, y, z] }`

example that creates randomly colored voxels:

```javascript
require('voxel').generate([0,0,0], [16,16,16], function(x,y,z) {
  return Math.round(Math.random() * 0xffffff)
})
```

a sphere:

```javascript
require('voxel').generate([0,0,0], [32,32,32], function(x,y,z) {
  return x*x+y*y+z*z <= 16*16 ? 0x113344 : 0
})
```

using the included generator functions:

```javascript
var voxel = require('voxel')
voxel.generate([0,0,0], [32,32,32], voxel.generator['Hilly Terrain'])
// or
voxel.geometry['Hilly Terrain'] // pre-generated at some specific example size
```

## require('voxel').meshers

`meshers` is an object with `stupid`, `culled`, `monotone` and `greedy` mesher functions. you probably want to just use `greedy`. all mesher functions accept voxel data in the format the gets returned by the `generate` function.

## require('voxel').generator

an object that contains a bunch of voxel generation functions to play with, from http://mikolalysenko.github.com/MinecraftMeshes2/

## require('voxel').generateExamples()

returns an object that contains a bunch of pre-generated voxel geometries to play with, from http://mikolalysenko.github.com/MinecraftMeshes2/

# license

MIT

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