Fix map tiles vanishing on narrow viewports with top-down view#9228
Draft
markschlosseratbentley wants to merge 11 commits into
Draft
Fix map tiles vanishing on narrow viewports with top-down view#9228markschlosseratbentley wants to merge 11 commits into
markschlosseratbentley wants to merge 11 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, background map tiles disappeared entirely when the viewport was narrow (~≤162px wide) and the camera was in a near-top-down orientation. This was reported on iTwin.js apps using Google Maps on mobile devices, but also reproduces with Bing Maps. It seems to be a core map tile selection bug, not provider-specific.
Problem
The pixel-size calculation for globe (non-planar) map tiles underestimates their screen coverage due to two compounding errors:
getSizeProjectionCornersreturned corners from the tile's ECEF axis-aligned bounding box: a flat rectangle at one Z-plane deep inside the Earth that bears no geometric relationship to the tile's angular extent on the spheregetPixelSizeFromProjectionuses the geometric mean of the projected X and Y ranges. Because longitude lines converge toward the poles, globe tiles project anisotropically (more rectangular than square), meaning the geometric mean systematically underestimates screen coverageThe combined underestimate causes the calculated pixel size to drop below map tiles'
maximumSize(512 px) when the viewport is narrow, halting refinement at depth 3 (the minimum displayable depth in the map tile tree). Because structural ancestors (depths 0–2) carry no imagery and the child-selection mechanism is all-or-nothing, nothing renders and the viewport goes black.Fix
MapTile.getSizeProjectionCorners: for non-planar tiles, use the origins of the tile's 4 corner rays. These are closer to the actual tile size than points from the AABB, making the whole process more accurate.MapTile.computeVisibilityFactoroverride method: if the visibility factor > 0, do a second pass that uses the maximum tile dimension (in either width or height, whichever is highest) instead of itsTileDrawArgs.getPixelSizeFromProjectionTesting
maxmay request ~1 extra refinement level for significantly anisotropic tiles at high latitudes (>55°)