Skip to content

[geo-layers] Fix TerrainLayer globe Mercator tile warping#10293

Closed
charlieforward9 wants to merge 2 commits into
visgl:cr/feat/terrain-layer-globe-gridfrom
NEW-HEAT:codex/terrain-globe-mercator-remap
Closed

[geo-layers] Fix TerrainLayer globe Mercator tile warping#10293
charlieforward9 wants to merge 2 commits into
visgl:cr/feat/terrain-layer-globe-gridfrom
NEW-HEAT:codex/terrain-globe-mercator-remap

Conversation

@charlieforward9
Copy link
Copy Markdown
Collaborator

@charlieforward9 charlieforward9 commented May 12, 2026

Before

Screen.Recording.2026-02-15.at.6.42.25.PM.mov

Now

No warping

Summary

Fixes TerrainLayer globe rendering for WebMercator terrain tiles by remapping mesh row latitude through inverse WebMercator instead of treating texture rows as linearly spaced latitude.

This addresses the severe continent compression seen near the poles and at far zooms in GlobeView.

Validation

  • npx vitest run --project headless test/modules/geo-layers/terrain-layer.spec.ts

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

@charlieforward9 charlieforward9 force-pushed the codex/terrain-globe-mercator-remap branch from 7a58fd4 to 6bf36a5 Compare May 12, 2026 21:07
@coveralls
Copy link
Copy Markdown

coveralls commented May 12, 2026

Coverage Status

Coverage is 83.788%NEW-HEAT:codex/terrain-globe-mercator-remap into visgl:cr/feat/terrain-layer-globe-grid. No base build found for visgl:cr/feat/terrain-layer-globe-grid.

meshMaxError,
signal
})?.then(mesh =>
viewport.resolution && mesh ? remapMeshToWebMercatorTile(mesh, overlappedBounds) : mesh
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.

Unsure how much this costs - seems heavy.

Easier to handle directly in loadTerrain? Gotta check

};
}

function lngLatToMercatorY(latitude: number): 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.

math.gl?

const isTileSetURL = (url: string): boolean =>
url.includes('{x}') && (url.includes('{y}') || url.includes('{-y}'));

function remapMeshToWebMercatorTile(mesh: Mesh, bounds: Bounds): Mesh {
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.

math.gl?

@charlieforward9 charlieforward9 marked this pull request as ready for review May 13, 2026 04:19
@charlieforward9 charlieforward9 linked an issue May 13, 2026 that may be closed by this pull request
7 tasks
@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.

[Bug] Projection issue with TileLayer on low-zoom GlobeView

3 participants