A JavaScript library for real-time RTIN terrain mesh generation
JavaScript
659
24 commits
updated Jun 24, 2026
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 (2k+1) × (2k+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.
Based on the paper "Right-Triangulated Irregular Networks" by Will Evans et. al. (1997).

import Martini from '@mapbox/martini';
// 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);
npm install @mapbox/martini
609 followers · starred Aug 2019
266 followers · starred Aug 2019
18 followers · starred Apr 2021
255 followers · starred Jan 2021
A JavaScript library for real-time RTIN terrain mesh generation
JavaScript
659
24 commits
updated Jun 24, 2026
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 (2k+1) × (2k+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.
Based on the paper "Right-Triangulated Irregular Networks" by Will Evans et. al. (1997).

import Martini from '@mapbox/martini';
// 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);
npm install @mapbox/martini
609 followers · starred Aug 2019
266 followers · starred Aug 2019
18 followers · starred Apr 2021
255 followers · starred Jan 2021