🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@mapbox/martini

Package Overview
Dependencies
Maintainers
14
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/martini

A JavaScript library for real-time terrain mesh generation

0.2.0
latest
npm
Version published
Weekly downloads
182K
-0.83%
Maintainers
14
Weekly downloads
 
Created

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

Keywords

terrain

FAQs

Package 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