Skip to content

[geo-layers] Prioritize tile requests near viewport center#10294

Closed
charlieforward9 wants to merge 9 commits into
visgl:cr/feat/terrain-layer-globe-gridfrom
NEW-HEAT:codex/tile-center-priority
Closed

[geo-layers] Prioritize tile requests near viewport center#10294
charlieforward9 wants to merge 9 commits into
visgl:cr/feat/terrain-layer-globe-gridfrom
NEW-HEAT:codex/tile-center-priority

Conversation

@charlieforward9
Copy link
Copy Markdown
Collaborator

@charlieforward9 charlieforward9 commented May 12, 2026

i want to explore a more responsive LoD refinementStrategy and globe cache approach for improving GlobeView initialization and flyToTransition UX - Google Earth feel. Latest experiment in this direction

Summary

Adds a Tileset2D request priority callback so visible tile requests can be ordered by distance from the viewport center.

This keeps center tiles ahead of edge tiles during throttled loading without changing TileLayer's public API.

Validation

  • npx vitest run --project headless test/modules/geo-layers/tileset-2d/tile-2d-header.spec.ts

Stacked on #10250 / cr/feat/terrain-layer-globe-grid.

@charlieforward9 charlieforward9 force-pushed the codex/tile-center-priority branch from a66bfa0 to ecd4c24 Compare May 12, 2026 21:10
@coveralls
Copy link
Copy Markdown

coveralls commented May 12, 2026

Coverage Status

Coverage is 83.428%NEW-HEAT:codex/tile-center-priority into visgl:cr/feat/terrain-layer-globe-grid. No base build found for visgl:cr/feat/terrain-layer-globe-grid.

Copy link
Copy Markdown
Collaborator

@felixpalmer felixpalmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to see a video of this in action, shouldn't be too hard if you use a small tile size and potentially throttle your network.

Otherwise, like the idea - integrates nicely

return this._getTileDistanceToViewportCenter(tile);
}
if (tile.isVisible) {
return 1e6 + this._getTileDistanceToViewportCenter(tile);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this backwards? the further we are from center, the higher this value and thus the higher the priority?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 426b06e. This is intentionally ordered this way: loaders.gl RequestScheduler sorts queued requests ascending and loads lower priority values first, so smaller squared distance means higher effective priority. I added a code comment at the call site to make that explicit.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why the -1? Doesn't this mean tiles which are not selected and not visible get loaded first?

return -1;
}

private _getTileDistanceToViewportCenter(tile: Tile2DHeader): number {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private _getTileDistanceToViewportCenter(tile: Tile2DHeader): number {
private _getTileDistanceSquared(tile: Tile2DHeader): number {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 426b06e. Renamed the helper to _getTileDistanceSquared so the method name matches the value returned.

@charlieforward9
Copy link
Copy Markdown
Collaborator Author

Review follow-up pushed in 426b06e.

What changed:

  • Added an explicit comment that RequestScheduler loads lower numeric priority values first, which is why smaller viewport-center distance is returned directly.
  • Renamed _getTileDistanceToViewportCenter to _getTileDistanceSquared.

Verification:

  • yarn test node test/modules/geo-layers/tileset-2d/tile-2d-header.spec.ts test/modules/geo-layers/tileset-2d/tileset-2d.spec.ts
  • Built a local TileLayer/GlobeView satellite demo against the PR branch, with maxRequests: 4, request-order overlay, and z20 zoom verification. The demo shows lower-priority-number requests loading first near the viewport center.

@charlieforward9 charlieforward9 self-assigned this May 15, 2026
@felixpalmer felixpalmer deleted the branch visgl:cr/feat/terrain-layer-globe-grid May 15, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants