# greedy-mesher

> Greedy mesh compiler

Latest version **1.0.3** (published 2016-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install greedy-mesher
pnpm add greedy-mesher
yarn add greedy-mesher
bun add greedy-mesher
```

## 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.3 |
| Published | 2016-02-12 |
| First published | 2013-06-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 54 |
| Author | Mikola Lysenko |
| Maintainers | mikolalysenko |
| Keywords | greedy, mesh, compiler, voxel, geometry, ndarray |

## Links

- npm: https://www.npmjs.com/package/greedy-mesher
- Repository: https://github.com/mikolalysenko/greedy-mesher
- Homepage: https://github.com/mikolalysenko/greedy-mesher#readme
- Issues: https://github.com/mikolalysenko/greedy-mesher/issues
- npm.io page: https://npm.io/package/greedy-mesher

## Dependencies (3)

- [uniq](https://npm.io/package/uniq.md) ^1.0.1
- [iota-array](https://npm.io/package/iota-array.md) ^1.0.0
- [typedarray-pool](https://npm.io/package/typedarray-pool.md) ^1.1.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2016-02-12
- 1.0.2 — 2014-04-29
- 1.0.1 — 2013-07-18
- 1.0.0 — 2013-06-30
- 0.1.0 — 2013-06-27
- 0.0.3 — 2013-06-19
- 0.0.2 — 2013-06-13
- 0.0.1 — 2013-06-13
- 0.0.0 — 2013-06-02

## README

greedy-mesher
=============
A flexible system for generating [greedy meshes](http://0fps.wordpress.com/2012/07/07/meshing-minecraft-part-2/) of [ndarrays](https://github.com/mikolalysenko/ndarray).

## Example

```javascript
var compileMesher = require("greedy-mesher")

var mesher = compileMesher({
  extraArgs: 1,
  order: [1, 0],
  append: function(lo_x, lo_y, hi_x, hi_y, val, result) {
    result.push([[lo_x, lo_y], [hi_x, hi_y]])
  }
})

var test_array = require("ndarray-pack")(
[[0, 2, 0, 0],
 [0, 1, 1, 0],
 [0, 1, 1, 0],
 [0, 0, 0, 0]])

var result = []
mesher(test_array, result)
console.log(result); 
// outputs: [ [ [ 1, 0 ], [ 2, 1 ] ], [ [ 1, 1 ], [ 3, 3 ] ] ]
```

## Install

    npm install greedy-mesher
    
### `require("greedy-mesher")(options)`
This routine generates a greedy mesher for a given order and list of closures

* `order` An array representing the order in which to mesh the input.
* `extraArgs` The number of optional arguments to pass to each closure.
* `skip(a,...)` A closure which tests if the given voxel should be skipped.  (Default: skips 0)
* `merge(a,b,...)` A closure which tests if voxels a and b can be merged in the mesh.  (Default: checks if voxels are equal)
* `append(lo0, lo1, ..., lon, hi0, hi1, ..., hin, val, ...)`
* `useGetter` if set, use `.get()` to access underlying data store
* `debug` If set, print out the generated source code to the console

**Returns** A compiled mesh generator.  Call this method using:

```javascript
var my_mesh = mesher(array, option1, option2, ...)
```

## Credits
(c) 2013 Mikola Lysenko. MIT License

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