# @mapbox/martini

> A JavaScript library for real-time terrain mesh generation

Latest version **0.2.0** (published 2020-01-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install @mapbox/martini
pnpm add @mapbox/martini
yarn add @mapbox/martini
bun add @mapbox/martini
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2020-01-31 |
| First published | 2019-08-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Vladimir Agafonkin |
| Maintainers | mapbox-admin, mapbox-machine-user, mapbox-npm, mapbox-npm-01, mapbox-npm-02, mapbox-npm-03, mapbox-npm-04, mapbox-npm-05, mapbox-npm-06, mapbox-npm-07, mapbox-npm-08, mapbox-npm-09, mapbox-npm-advanced-actions, mapbox-npm-ci |
| Keywords | terrain, rtin, mesh, 3d, webgl |

## Links

- npm: https://www.npmjs.com/package/@mapbox/martini
- npm.io page: https://npm.io/package/@mapbox/martini

## Recent versions

- 0.2.0 (latest) — 2020-01-31
- 0.1.0 — 2019-08-19

## README

# MARTINI

[![Build Status](https://travis-ci.com/mapbox/martini.svg?branch=master)](https://travis-ci.com/mapbox/martini) [![Simply Awesome](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects)

MARTINI stands for **Mapbox's Awesome Right-Triangulated Irregular Networks, Improved**.

It's an experimental JavaScript library for **real-time terrain mesh generation** from height data. Given a (2<sup>k</sup>+1) × (2<sup>k</sup>+1) terrain grid, it generates a hierarchy of triangular meshes of varying level of detail in milliseconds. _A work in progress._

See the algorithm in action and read more about how it works in [this interactive Observable notebook](https://observablehq.com/@mourner/martin-real-time-rtin-terrain-mesh).

Based on the paper ["Right-Triangulated Irregular Networks" by Will Evans et. al. (1997)](https://www.cs.ubc.ca/~will/papers/rtin.pdf).

![MARTINI terrain demo](martini.gif)

## Example

```js
// set up mesh generator for a certain 2^k+1 grid size
const martini = new Martini(257);

// generate RTIN hierarchy from terrain data (an array of size^2 length)
const tile = martini.createTile(terrain);

// get a mesh (vertices and triangles indices) for a 10m error
const mesh = tile.getMesh(10);
```

## Install

```bash
npm install @mapbox/martini
```

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