- Notifications
You must be signed in to change notification settings - Fork42
A JavaScript library to make 3D maps with three.js.
License
blaze33/map33.js
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Live demo (you can double click to add missing tiles)
npm install map33
alternatively:
yarn add map33
Map33.js takes two slippy map tilesets, one to fetch elevation data tiles, the other to texture the meshes built from said elevation data (any XYZ tileserver will do).
Live demo (you can double click to add missing tiles)
import{Map,Source,MapPicker}from'map33'// import Map as Map33 if you use the default Map object.constposition=[45.916216,6.860973]constsource=newSource('maptiler','<your_maptiler_token>')constmap=newMap(scene,camera,source,position,{nTiles:3,zoom:11})constmapPicker=newMapPicker(camera,map,renderer.domElement)mapPicker.go(-45,128)
Defines a tileset source used to fetch textures applied to the 3D terrain mesh.
constsource=newSource(api,token)
Argument | Description | Default Value |
---|---|---|
api | One of['osm', 'mapbox', 'eox', 'maptiler'] | - |
token | Your api key when usingmapbox ormaptiler | - |
The main class of map33.js. Creates a 3D map using a grid of tiles.
constmap=newMap(scene,camera,source,position,options)
Argument | Description | Default Value |
---|---|---|
scene | A three.jsScene instance | - |
camera | A three.jsCamera instance | - |
source | A map33.js Source instance | - |
position | An array containing the latitude and longitude values used to center the map | - |
options | An object to pass some options | {} |
Theoptions
schema is defined as follow:
Option | Description | Default Value |
---|---|---|
nTiles | Map.init() will display a grid ofnTiles x nTiles | 3 |
zoom | Default zoom level | 11 |
tileSize | Tile size at the default zoom level | 600 |
tileSegments | Number of segments given to thePlaneBufferGeometry constructor. Maximum value is256 | 100 |
zScale | The raw elevation data is multiplied by zScale when building a Tile mesh | 0.045 |
Long story short, I took what I liked most aboutdroneWorld (cf.https://discourse.threejs.org/t/3d-world-engine-droneworld-prototype/1501), ie. making 3D terrain and started from scratch to build a library that, hopefully, will be much cleaner in order to build upon and reuse.
https://github.com/w3reality/three-geo
https://blog.mapbox.com/bringing-3d-terrain-to-the-browser-with-three-js-410068138357
The map library code is MIT licensed.
InfiniteGridHelper.js used by the example is made byFyrestar (Github repo)
This project was bootstrapped withCreate React App.
In the project directory, you can run:
Runs the app in the development mode.
Openhttp://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Launches the test runner in the interactive watch mode.
See the section aboutrunning tests for more information.
Builds the app for production to thebuild
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section aboutdeployment for more information.
Note: this is a one-way operation. Once youeject
, you can’t go back!
If you aren’t satisfied with the build tool and configuration choices, you caneject
at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands excepteject
will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever useeject
. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
You can learn more in theCreate React App documentation.
To learn React, check out theReact documentation.
This section has moved here:https://facebook.github.io/create-react-app/docs/code-splitting
This section has moved here:https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
This section has moved here:https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
This section has moved here:https://facebook.github.io/create-react-app/docs/advanced-configuration
This section has moved here:https://facebook.github.io/create-react-app/docs/deployment
This section has moved here:https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify