in packages/utils/tile-manager/src/CommonTileManager.ts [252:329]
private _updateTiles() {
if (!this._timeline || !this._projection || !this._polaris) return
this._currZoomLevel = this._polaris.cameraProxy.zoom
const tokenList = this.config.getViewTiles(
this._polaris,
this.config.minZoom,
this.config.maxZoom
)
this._currVisibleKeys.length = 0
tokenList.forEach((token) => {
const cacheKey = this.tileTokenToKey(token)
this._currVisibleKeys.push(cacheKey)
// check visibility if mesh already exists
if (this._tileMap.has(cacheKey)) {
return
}
// skip if already in query queue
if (this._promiseMap.has(cacheKey)) {
return
}
// query new tile
const tilePromise = this.config.getTileRenderables(token, this)
if (!tilePromise || !tilePromise.promise) {
if (this.config.printErrors) {
console.error('Polaris::TileManager - getTileRenderables() result is invalid. ')
}
return
}
// cache
const cachedPromise: CachedTilePromise = {
...tilePromise,
key: cacheKey,
outOfViewFrames: 0,
}
this._promiseMap.set(cacheKey, cachedPromise)
// handle renderables
const promise = cachedPromise.promise
promise
.then((tile) => {
this._addTile(cacheKey, tile)
})
.catch((err) => {
if (this._tileMap.has(cacheKey)) {
return
}
if (!this._promiseMap.has(cacheKey)) {
// promise was either aborted by us or never requested (which is abnormal)
// @NOTE: We do not identify the 'AbortError string from this error obj,
// as in many apps the errors are intercepted in the way of rejection.
// So, we should never assume the error.name/.message to be some specific string.
// We should only identify it from the user's abort() function return value.
// When abort() returns { success: true }, the promiseCache will be removed from map
return
}
if (this.config.printErrors) {
console.error('Polaris::TileManager - getTileRenderables error', err)
}
if (this.config.RetryErroredRequests) {
// delete errored requests, retry next time
this._promiseMap.delete(cacheKey)
} else {
// add empty tile renderables if server response is errorlike
this._addTile(cacheKey, undefined)
}
})
})
}