WIP Fix images raster layer being clipped on terrain #4269
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.
This PR should solve issues of raster image layers being clipped when 3d terrain is used. Mentioned in #1559 and #4088
Currently I have only created a failing test that can be started via
npm run test-render -- image/raster-terrain
(check rendered result ./test/integration/render/tests/image/raster-terrain/actual) and another example that can be accessed viayarn start
and openinghttp://localhost:9966/test/examples/add-image-with-terrain.html
in browser.As mentioned in #1559 the issue seem to come from
getTerrainData
.maplibre-gl-js/src/render/draw_raster.ts
Line 64 in 1cbb496
The line
const sourceTile = this.sourceCache.getSourceTile(tileID, true);
does not return a sourceTile forOverscaledTileID
that includes wrapping. So if wrap is 0 the terrain data is loaded, if it is -1 or 1, it won`t load.maplibre-gl-js/src/render/terrain.ts
Line 176 in 1cbb496
getSourceTile
tries to find the next largest terrain tile with proper terrain data. But it fails for the wrap -1 and 1 tiles.maplibre-gl-js/src/source/terrain_source_cache.ts
Line 175 in 1cbb496
Image of render test:
Launch Checklist
CHANGELOG.md
under the## main
section.