davenquinn / cesium-martini

On-the-fly meshing of raster elevation tiles for the CesiumJS virtual globe
MIT License
81 stars 17 forks source link

Decouple tile fetching from mesh generation #5

Closed stuarta0 closed 3 years ago

stuarta0 commented 3 years ago

I have a need to consume and merge multiple terrain datasources. The logic for fetching tiles and generating terrain are contained in the same class, making this task difficult.

This PR decouples the tile fetching from the terrain generation, such that the source of the terrain tiles can be implemented independently from the terrain. This also allows the Mapbox-specific parameters (e.g. access token, high resolution) to be isolated to the MapboxTerrainResource class. A base class DefaultHeightmapResource is provided with the relevant fetching logic extracted from MartiniTerrainProvider.

The simple example shows the minimal changes required to compose these classes.

Apart from a clean separation of concerns, this change allows me to write a new CompositeHeightmapResource class that will take an array of HeightmapResource instances. Available terrain tiles from these resources will be combined into a single image, which will then be consumed by the terrain provider as usual.

stuarta0 commented 3 years ago

Merged with master. I actually have these changes in my repo already (core-js + babel-loader), with Cesium 1.84 and the webpack fix described here: https://github.com/CesiumGS/cesium/issues/9790#issuecomment-943773870

This fixes the library so it works in my Electron bundled app. I can add another PR with these changes if you like?

davenquinn commented 3 years ago

Awesome. I'd appreciate that other PR, these bugs have been kind of annoying! We'll want to bump probably a minor version, it sounds like, once the dust settles on these changes.