mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 03:32:19 +00:00
Quantized-mesh terrain can supply its tiles through fetchTile, like imagery
A `quantizedMesh` terrain spec takes an optional `fetchTile`, called with the tile (rows from the north), its URL as Cesium resolved it and an abort signal. Cesium still reads `layer.json` at the url and schedules, cancels and decodes the tiles; only the bytes of each tile come from `fetchTile`. A `missing` tile draws its parent's terrain there and a deferred one is asked for again shortly.
This commit is contained in:
1 parent
d9d79ebc4d
commit
eebde0bdca
9 files changed
+390
-6
No files matched your search
@@ -23,6 +23,7 @@ import { createCesiumImagery } from './imagery.js';
|
||||
import { attributionText } from './vectorBase.js';
|
||||
import { loadVectorStyle } from '../vectorBase/index.js';
|
||||
import { createTerrainRetryPolicy } from '../../maps/terrainRetry.js';
|
||||
import { tileFetchResource, trackTileRequests } from './terrainTiles.js';
|
||||
|
||||
// The base marks live outside the adapter, so code that is not Cesium's can
|
||||
// mark a base; they are re-exported here for the code that still is.
|
||||
@@ -68,15 +69,26 @@ async function terrainProvider(spec, { worldDataToken }) {
|
||||
);
|
||||
},
|
||||
});
|
||||
const resource = new Cesium.Resource({
|
||||
const options = {
|
||||
url: spec.url,
|
||||
retryCallback: policy.retryCallback,
|
||||
retryAttempts: policy.retryAttempts,
|
||||
});
|
||||
return Cesium.CesiumTerrainProvider.fromUrl(resource, {
|
||||
};
|
||||
if (spec.fetchTile !== undefined && typeof spec.fetchTile !== 'function')
|
||||
throw new TypeError('Quantized-mesh terrain fetchTile is a function');
|
||||
// With `fetchTile`, Cesium still reads `layer.json` at the url; each
|
||||
// tile's bytes come from `fetchTile`.
|
||||
const tiles = new WeakMap();
|
||||
const resource = spec.fetchTile
|
||||
? tileFetchResource(options, spec.fetchTile, (request) =>
|
||||
request ? tiles.get(request) : undefined,
|
||||
)
|
||||
: new Cesium.Resource(options);
|
||||
const provider = await Cesium.CesiumTerrainProvider.fromUrl(resource, {
|
||||
requestVertexNormals: spec.requestVertexNormals ?? false,
|
||||
requestWaterMask: false,
|
||||
});
|
||||
return spec.fetchTile ? trackTileRequests(provider, tiles) : provider;
|
||||
}
|
||||
throw new TypeError(`Unknown terrain kind: ${spec.kind}`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user