wrong tiles at low zooms with terrain enabled
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
An unpitched map with terrain enabled shows a tiles from a mix of zoom levels. It should show tiles from the same zoom level (the way it looks without terrain). The visual effect is more severe when using tilesets with sharper cutoffs (data exists in z2, but not z1).
I think `transform.coveringTiles(...)` is not returning the right tiles and I think this may be related to the [distance calculation it uses](https://github.com/mapbox/mapbox-gl-js/blob/0eecef1d3fd42e9ebc41546e6ff1b292e9213491/src/geo/transform.js#L757). I think it uses a 3D distance from the camera point to the tile when maybe it should be using just the z distance from the camera to the tile.
**mapbox-gl-js version**: main (0eecef1)
**browser**: all
### Steps to Trigger Behavior
1. `yarn run start-debug`
2. open `http://localhost:9966/debug/terrain-debug.html#2.06/54.49/71.37` with a large viewport (innerWidth: 1701, innerHeight: 1361)
3. set `map.showTileBoundaries = true` in the console
### Expected Behavior
Viewport covered by z2 tiles:

### Actual Behavior
Viewport covered by a mix of z1 and z2 tiles:

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run `yarn run start-debug`, open the terrain debug URL from the report with a large viewport, and enable `map.showTileBoundaries`. Start in `src/geo/transform.js` at `transform.coveringTiles(...)` and its linked distance calculation; done means the viewport uses tiles from one zoom level, matching the no-terrain behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100