Add coverage LOD tile prefetching#10306
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
chrisgervang
left a comment
There was a problem hiding this comment.
There are a couple of interesting things in the demo that I'm not really sure how to improve:
- As the low-resolution tiles are loading in and the high-resolution tiles are loading on top, I can see almost like a parallax or perspective shift between the low-res and high-res tiles. I'm curious what the root cause of that is.
- I see a lot of z-fighting as we zoom into the final destination in New York between the low-res and high-res tiles. There's a lot of z-fighting in the before as well, so this isn't a regression and more a limitation with our renderer
I wrote a draft of docs for this that I'll push up for you to review.
There was a problem hiding this comment.
before/after comparison demos may be better suited as a test app rather than a website example, since website examples are typically reserved for large new features. Would you be open to moving this to test/apps/?
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4be9e53. Configure here.
| // Some viewport/tile combinations are not projectable. Keep them valid but lowest priority. | ||
| } | ||
| return Number.MAX_SAFE_INTEGER; | ||
| } |
There was a problem hiding this comment.
Unprojectable tiles break priority tier boundaries
Medium Severity
_getTileDistanceSquared returns Number.MAX_SAFE_INTEGER (~9e15) when a tile's bounding box can't be fully projected (fewer than 4 finite screen corners or a caught exception). This value, when added to SELECTED_TILE_PRIORITY (0), produces a priority of ~9e15, far exceeding PREFETCH_TILE_PRIORITY (~4.2e9 max). Since lower priority values load first, an unprojectable selected tile loads after all prefetch and visible tiles, violating the intended tier system. This is particularly likely in pitched globe views—exactly the target use case—where horizon tiles may not project cleanly.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 4be9e53. Configure here.


lod+priority.mov
Summary
This PR improves TileLayer/TerrainLayer transition behavior by giving
Tileset2Dan opt-in coverage LOD strategy and making request priority focus on the viewport center.lodStrategy: 'coverage'to prefetch lower-resolution ancestor tiles while the selected high-resolution tiles load.lodStrategy: 'none'.TileLayerandTerrainLayerso terrain can use the lower-level tile loading behavior.Why
During animated transitions, especially on pitched/globe terrain views, high-resolution target tiles can leave black gaps while requests are saturated. The new strategy keeps coarse coverage available and then prioritizes the tiles nearest the focal point so the visible transition resolves more cleanly.
Validation
npx vitest run --project headless test/modules/geo-layers/tileset-2d/tileset-2d.spec.ts test/modules/geo-layers/tileset-2d/tile-2d-header.spec.tsexamples/website/tile-priority-demoathttp://127.0.0.1:8094/Note
Medium Risk
Touches core
Tileset2Dloading/prioritization and cache eviction logic, which can affect performance and tile loading order across allTileLayer/TerrainLayerusers; behavior is opt-in vialodStrategywith default preserved.Overview
Adds an opt-in
lodStrategytoTileLayer/TerrainLayerthat enables coverage LOD prefetching: when set to'coverage',Tileset2Dnow prefetches lower-zoom ancestor tiles (tracked via newtile.isPrefetch) to provide quick fallback coverage during viewport transitions.Updates the internal request scheduler integration to accept a per-tile priority function and implements viewport-center weighted request prioritization (selected/visible tiles first, then prefetch tiles), plus adjusts request pruning and cache eviction to avoid aborting/evicting prefetch tiles prematurely.
Adds docs for
lodStrategy, new unit tests covering prefetch + priority ordering, and a side-by-side website demo (examples/website/tile-priority-demo) to visually compare legacy vs new behavior.Reviewed by Cursor Bugbot for commit 4be9e53. Bugbot is set up for automated code reviews on this repo. Configure here.