Socket
Socket
Sign inDemoInstall

@mapbox/martini

Package Overview
Dependencies
0
Maintainers
14
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/martini


Version published
Maintainers
14
Created

Package description

What is @mapbox/martini?

@mapbox/martini is a JavaScript library for generating adaptive meshes for terrain rendering. It is designed to work with digital elevation models (DEMs) and can create efficient, level-of-detail (LOD) meshes that are suitable for real-time rendering in 3D applications.

What are @mapbox/martini's main functionalities?

Generating a Terrain Mesh

This feature allows you to generate a terrain mesh from a digital elevation model (DEM). The code sample demonstrates how to create a Martini instance, initialize a terrain tile with elevation data, and generate a mesh with a specified error threshold.

const Martini = require('@mapbox/martini');
const DEM = new Float32Array([/* elevation data */]);
const tileSize = 256;
const martini = new Martini(tileSize + 1);
const terrain = martini.createTile(DEM);
const mesh = terrain.getMesh(10); // 10 is the error threshold
console.log(mesh);

Getting Terrain Errors

This feature allows you to retrieve the error values for each vertex in the terrain mesh. The code sample shows how to create a Martini instance, initialize a terrain tile with elevation data, and get the error values.

const Martini = require('@mapbox/martini');
const DEM = new Float32Array([/* elevation data */]);
const tileSize = 256;
const martini = new Martini(tileSize + 1);
const terrain = martini.createTile(DEM);
const errors = terrain.getErrors();
console.log(errors);

Simplifying a Mesh

This feature allows you to simplify an existing terrain mesh by increasing the error threshold. The code sample demonstrates how to generate an initial mesh and then create a simplified version of it by using a higher error threshold.

const Martini = require('@mapbox/martini');
const DEM = new Float32Array([/* elevation data */]);
const tileSize = 256;
const martini = new Martini(tileSize + 1);
const terrain = martini.createTile(DEM);
const mesh = terrain.getMesh(10); // initial mesh
const simplifiedMesh = terrain.getMesh(20); // simplified mesh with higher error threshold
console.log(simplifiedMesh);

Other packages similar to @mapbox/martini

Readme

Source

MARTINI

Build Status Simply Awesome

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).

MARTINI terrain demo

Example

// 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

npm install @mapbox/martini

Keywords

FAQs

Last updated on 31 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc