MARTINI stands for Mapbox's Awesome Right-Triangulated Irregular Networks, Improved.
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).
// 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