🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

three-mini-map

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

three-mini-map

Library to display maps using `three.js`.

latest
Source
npmnpm
Version
0.0.6
Version published
Weekly downloads
1
-87.5%
Maintainers
1
Weekly downloads
 
Created
Source

Three-Mini-Map

Library to display maps using three.js.

  • Generate 3d geometry from elevation tiles.
  • Smooth connexion between tiles.
  • Choose a map provider who deliver (EPSG:3857) WMTS tiles and add textures to tiles.
Three Mini Map

Live demo

Combins Combins debug MĂ´le MĂ´le debug

Installation

if you want to use this library in your three project.

npm install three-mini-map

Examples are located in the examples folder. Each example has defined his own package.json but npm install is not needed. Just execute this command in the root directory. (examples share the same workspace )

If you want to test a Basic Hello World, check the examples/default

git clone https://github.com/lhapaipai/three-mini-map.git
npm install
cd examples/default
npm run dev

Usage

import MiniMapManager from "mini-map-manager";

const miniMapManager = new MiniMapManager();

miniMapManager
  .getMap({
    textureSource: "osm",
    textureZoom: 15,
    center: [6.4751, 46.1024],
    radius: 4,
  })
  .then((map) => {
    let scene = new THREE.Scene();
    scene.add(map);
  });

API

MiniMapManager class

const miniMapManager = new MiniMapManager(options);

Define custom configuration in the options object.

KeyDescriptionDefault Value
elevationSource (string)map elevation provider."terrarium"
elevationSource (obj)custom elevation provider-
zScaleFactoryour elevation data is multiplied to this factor1.6
tileUnitsthe dimension of each tile in Three1.0
debugshow debug infos in your console.false
dryRunshow tiles to load if you want to download them and then work locallyfalse
basementHeightheight of the base (in three coords) on which to place the map0.05

if you want to provide your own elevation provider you can specify configuration in the elevationSource key.

new MiniMapManager({
  elevationSource: {
    url: (z, x, y) =>
      `https://s3.amazonaws.com/elevation-tiles-prod/terrarium/${z}/${x}/${y}.png`,
    size: 256,
    maxZoom: 15,
  },
});

miniMapManager instance methods

miniMapManager.getMap(mapOptions).then((map) => {
  // map is a THREE.Group instance
});

Define custom configuration in the mapOptions object.

KeyDescriptionDefault Value
textureSource (str)map provider used to texture the tile."osm"
textureSource (obj)custom map provider-
tileSegmentsnb of segments used per texture tile to build the geometry. must be a power of 2 (16, 32, 64, 128, 256)32
textureZoomzoom used to retrieve textures15
centerarray containing position of the map [lng, lat][6.4751, 46.1024]
radiusdistance in kilometers used to compute the bbox of your map.1
materialan object with the name and options to apply to each tile. set map to false if you don't want texture (or if you want to preview relief data before download big texture data.)
withTexturewether or not we add map texture (from textureSource) to the materialtrue

if you want to provide your own map provider you can specify configuration in the textureSource key.

miniMapManager.getMap({
  textureSource: {
    url: (z, x, y, token) =>
      `https://api.mapbox.com/styles/v1/mapbox/satellite-v9/tiles/${z}/${x}/${y}?access_token=${token}`,
    size: 256,
    token: "YOUR_TOKEN",
  },
  material: {
    name: "MeshLambertMaterial",
    options: {
      wireframe: false,
    },
  },
});

Issues

I load two times the Three Library...

because all Three.js update are minor version change from major version 0. If you do not install the same version of three as three-mini-map in your project your app will load twice three.js

  • Check the version of Three.js installed by three-mini-map and install the same in your project. or
  • Import MiniMapManager from the sources
import MiniMapManager from "three-mini-map/src/MiniMapManager";

FAQs

Package last updated on 01 Jul 2021

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