Hi everyone!
A few years ago I started a small library for myself: 3D terrain for three.js from map tiles. It sat there for a while, and this year I finally rebuilt it properly. Maybe it will be useful to someone, so here it is.
Live example: three-map-terrain · live example — pick any place on the map, switch layers on and off, export a model.
What it does:
- terrain from elevation tiles, with any imagery on top, stitched without cracks while it loads
- OpenStreetMap buildings, roads, bridges, water and trees, lying exactly on the terrain (no floating or sunken roads)
- picking: the location, building or road under the pointer
- export to GLB, STL (3D printing, with a solid base), OBJ or USDZ
- your own data, layers and materials at every step
- plain three.js materials: works with WebGLRenderer and WebGPURenderer, no runtime dependencies
No API keys needed: by default it uses free sources (AWS Terrain Tiles, EOX Sentinel-2, OpenFreeMap).
import { Buildings, Map, Roads } from 'three-map-terrain'
const map = new Map({
location: { lat: 46.515, lon: 6.632 }, // Lausanne
source: { api: 'eox' },
options: { zoom: 15, exaggeration: 1, baseAltitude: 372 }
})
map.addLayer(new Buildings({ source: { api: 'openfreemap' } }))
map.addLayer(new Roads({ source: { api: 'openfreemap' } }))
scene.add(map.terrain)
await map.init()
It is made for an area in detail (a city, a valley, a mountain range), not for a globe. For larger areas you can stream tiles around the camera or combine zoom levels; the README shows how.
Code and docs: GitHub - whidrubeld/three-map-terrain: Real-world 3D terrain for three.js from any map tiles: elevation, imagery, OpenStreetMap buildings, roads and bridges, water and trees, a frame for your own layers, streaming and levels of detail, and GLB / STL / USDZ export · GitHub (npm install three-map-terrain)
Feedback is very welcome: bugs, ideas, or what you would build with it.