mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Cesium vectorBase: transparent where the style paints no background; cancelled tiles not painted
The provider said it had no alpha channel, so a style with no or a translucent background drew black there. And its requestImage ignored the Cesium request, so tiles of a removed layer were still painted once their source tiles arrived; a cancelled request now aborts the paint.
This commit is contained in:
1 parent
09d1133d90
commit
750dab0123
3 files changed
+42
-5
No files matched your search
@@ -28,13 +28,36 @@ export function vectorBaseProvider(style) {
|
||||
rectangle: tilingScheme.rectangle,
|
||||
credit: undefined,
|
||||
errorEvent: new Cesium.Event(),
|
||||
hasAlphaChannel: false,
|
||||
// Where the style paints no opaque background the base below (or the
|
||||
// globe's own colour) shows through, never black.
|
||||
hasAlphaChannel: true,
|
||||
tileDiscardPolicy: undefined,
|
||||
proxy: undefined,
|
||||
getTileCredits: () => undefined,
|
||||
pickFeatures: () => undefined,
|
||||
requestImage: (x, y, level) =>
|
||||
paintVectorTile(style, level, x, y, { size: VECTOR_TILE_PX }),
|
||||
// A tile whose request was cancelled (its layer removed) is not
|
||||
// painted once its source tiles arrive.
|
||||
requestImage: (x, y, level, request) =>
|
||||
paintVectorTile(style, level, x, y, {
|
||||
size: VECTOR_TILE_PX,
|
||||
signal: cancelledBy(request),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* An `AbortSignal`-like view of a Cesium request: aborted once the request
|
||||
* is cancelled. Undefined without a request.
|
||||
*/
|
||||
export function cancelledBy(request) {
|
||||
if (!request) return undefined;
|
||||
return {
|
||||
get aborted() {
|
||||
return request.cancelled === true;
|
||||
},
|
||||
get reason() {
|
||||
return new DOMException('The tile request was cancelled', 'AbortError');
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user