Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apostololeg/terrain-navigator
https://github.com/apostololeg/terrain-navigator
Last synced: 26 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/apostololeg/terrain-navigator
- Owner: apostololeg
- Created: 2022-10-25T21:37:37.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-20T15:41:35.000Z (about 1 year ago)
- Last Synced: 2024-04-24T14:38:15.463Z (7 months ago)
- Language: TypeScript
- Size: 81.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Terrain navigator
- get height data from mapbox API by coordinates
- cache height data in IndexDB
- create terrains far from observer position
- resize imageData for low-poly tiles
- [optimize rendering at very far distances](https://discourse.threejs.org/t/moving-the-camera-model-will-shake-if-the-coordinates-are-large/7214)
- rebuild tiles after change observer position## Quick start
```js
import TerrainNavigator from 'terrain-navigator';const scene: THREE.Scene;
const observer: THREE.Object3D;const terrain = new TerrainNavigator({
mapBoxToken: MAPBOX_TOKEN,
container: scene,
material: new MeshPhongMaterial({
color: 0x424240,
shininess: 0.1,
// wireframe: true,
});,
zoom: 14,
scale: 0.125,
getPosition() {
return observer.target.position;
},
setPosition(pos) {
const { position } = observer.object;Object.entries(pos).forEach(([key, val]) => {
if (Number.isFinite(val)) position[key] = val;
});
},
onTileRebuilded(tile, oldObject) {
if (oldObject) observer.removeTeleportTargets([oldObject]);scene.add(tile.object);
if (tile.isNear) observer.addTeleportTargets([tile.object]);
editor.dyeTile(tile);
},
});// every time you change the observer position:
terrain.update();
```TODO:
- move data processing to Worker