npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

three-mini-map

v0.0.6

Published

Library to display maps using `three.js`.

Downloads

8

Readme

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.

Live demo

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.

| Key | Description | Default Value | | ------------------------ | --------------------------------------------------------------------- | ------------- | | elevationSource (string) | map elevation provider. | "terrarium" | | elevationSource (obj) | custom elevation provider | - | | zScaleFactor | your elevation data is multiplied to this factor | 1.6 | | tileUnits | the dimension of each tile in Three | 1.0 | | debug | show debug infos in your console. | false | | dryRun | show tiles to load if you want to download them and then work locally | false | | basementHeight | height of the base (in three coords) on which to place the map | 0.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.

| Key | Description | Default Value | | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | | textureSource (str) | map provider used to texture the tile. | "osm" | | textureSource (obj) | custom map provider | - | | tileSegments | nb of segments used per texture tile to build the geometry. must be a power of 2 (16, 32, 64, 128, 256) | 32 | | textureZoom | zoom used to retrieve textures | 15 | | center | array containing position of the map [lng, lat] | [6.4751, 46.1024] | | radius | distance in kilometers used to compute the bbox of your map. | 1 | | material | an 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.) | | | withTexture | wether or not we add map texture (from textureSource) to the material | true |

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";