-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Feature
Mixed terrain example with worldTerrain
and Ellipsoid
.
This issue was originated from Cesium Community.
What is it for:
Enables terrain to be loaded from multiple sources according to configured areas(with specific zoom level and tile coordinates) as the image shown above. It also enables setting fallback terrain, an error boundary for terrain provider.
Concept
I have implemented the feature on @juun-roh/cesium-utils, with name HybridTerrainProvider
. It works as below:
- The
HybridTerrainProvider
extends existingTerrainProvider
class. - Configure areas to override terrain source with zoom levels, tile coordinates, and
TerrainProvider
having different terrain sources. - Override
requestTileGeometry
method with configured area inclusion checks. - Delegate the method to configured terrain provider's
requestTileGeometry
, with configured areas. - If returns false, proceed with default/fallback provider's.
The overall concept of this feature is to redirect the requestTileGeometry
with different providers.
Implementation
You can see my full implementation here.
Briefly, how I redirected the method is by this:
requestTileGeometry(
x: number,
y: number,
level: number,
request?: Request,
): Promise<Awaited<TerrainData>> | undefined {
if (!this._ready) return undefined;
// Check regions for a match
for (const region of this._regions) {
if (this._regionContains(region, x, y, level)) {
return region.provider.requestTileGeometry(x, y, level, request);
}
}
// Fall back to default provider
if (this._defaultProvider.getTileDataAvailable(x, y, level)) {
return this._defaultProvider.requestTileGeometry(x, y, level, request);
}
// Final fallback
return this._fallbackProvider.requestTileGeometry(x, y, level, request);
}
Request for Guidance
My implementation does not follow Cesium's API design, since it has a separate development environment, so I'm expecting it to take some time to open a direct pull request about this feature.
Meanwhile, I'd appreciate feedback on this feature:
- API design preferences
- Any architectural considerations I've missed