Eviction grace window (frames): when over budget, tiles touched within this many frames are kept if possible, so briefly looking away from a tile and back doesn't evict + reload it (which pops). Only when that isn't enough to get under budget are recently-used tiles evicted too. ~4 s at 60 fps, so a tile you turn away from and back to stays loaded (no pop) within that window.
Soft-overage multiplier (see EVICT_HARD_DEFAULT). Lower it on memory-
constrained devices so the cache's real high-water mark stays near the budget
(e.g. ~1.25 on mobile) instead of tolerating up to 2× and risking an OOM.
Max concurrent in-flight loads to any single host. The global cap alone lets
one slow host (e.g. a terrain server) hold every slot and starve another (the
imagery host, or a second tileset), so a frame can stall on one provider while
others sit idle. Capping per host keeps every provider making progress. The
host is the origin of the load's cache key (an absolute URL); synthetic keys
with no scheme — upsample fills, which do no fetch of their own — share one
bucket. Defaults to maxConcurrent (no per-host limit beyond the global
cap, so a single-host dataset is never throttled); lower it for multi-host
setups (terrain + imagery + tiles). Kept LAST so existing positional callers
(maxConcurrent, retainFrames, evictHard) are unaffected.
Updates the byte + triangle budget live (e.g. from a quality slider). A lower budget evicts down toward it on the next dispatch; a higher one simply lets more tiles stay resident.
Returns a cached value and marks it used this frame, or undefined.
True if a load for this key is already in flight.
Registers intent to load key this frame at the given priority (smaller =
more urgent). Returns the value immediately if already cached (and marks it
used); otherwise records the request — the actual load is started, by
priority, in the next dispatch. Re-requesting an in-flight key keeps
it from being canceled as stale. Cheap to call every frame for every tile.
End-of-frame scheduler. Aborts in-flight loads not re-requested this frame (the camera moved on), starts the highest-priority pending loads until the concurrency cap is reached, then evicts to budget. Call once per frame after the traversal has issued all its requests.
Evicts least-recently-used entries toward budget. Stale tiles (untouched for longer than the retain window) go first. Recently-used tiles are spared unless memory is far over budget (a hard ceiling), because evicting the just-used working set is what causes LOD pop: moving the camera forward refines deeply and slams the cache, and without this guard that surge evicts the fine tiles just shown, which then re-stream from the coarsest LOD ("pop to lowest, then up"). Tolerating soft overage up to HARD× the target keeps those tiles.
Destroys everything (e.g. when switching datasets) and aborts in-flight loads so their orphaned results are dropped on arrival.
Max concurrent in-flight loads. The traversal naively requests every tile it might need each frame; without a cap a wide implicit quadtree (terrain) fires thousands of simultaneous fetches and the browser throws ERR_INSUFFICIENT_RESOURCES. Excess requests stay queued and are started, by priority, on later frames as slots free up.