Provide a means to determine occlusion of LatLng positions when using setTerrain()
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
## Motivation
I have an app which projects pixel based animations using a D3 canvas onto a mapboxgl map. All of the animated objects are at sea level and represent dynamic current velocities or tide stations. In V2, after enabling 3D terrains via `setTerrain()`, my D3 canvas objects don't correctly disappear when occluded by intervening terrain.
In the image below, the foreground arrows are correctly displayed, but all of the background yellow boxes (at sea level on another body of water in the distance) should not be visible since they should be hidden behind the intervening mountains. When the world was "flat" this wasn't an issue, but now with `setTerrain()` enabled, there is visual confusion.

## Design Alternatives
While I could rewrite everything to project my pixel based D3 animations into geojson and add them to a mapbox layer, this is, er, work and I have no idea if performance would be impacted. And this seems like a general issue that others will also likely confront.
I would assume `map.project()` would be the best place to return this information. The current return value is:
```
Returns a Point representing pixel coordinates, relative to the map's container,
that correspond to the specified geographical location.
When the map is pitched and lnglat is completely behind the camera,
there are no pixel coordinates corresponding to that location.
In that case, the x and y components of the returned Point are set to Number.MAX_VALUE.
```
## Design
Add an optional parameter to `map.project()` indicating that Number.MAX_VALUE should be returned also in the case of occlusion.
` map.project(coordinate, onlyIfVisible = false);`
This would introduce no backward compatibility issues.
A more general solution would be to add an additional API which explicitly handles elevation such as:
` map.project3D(coordinate3D, onlyIfVisible = false);`
### Mock-Up
### Concepts
### Implementation
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
Review the existing map.project() and setTerrain() entry points, focusing on how terrain affects visibility for projected LatLng positions. The work is done when the API and its behavior for terrain occlusion are defined and validated without breaking existing projection behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- d3, typescript
- Domain
- computer-graphics, frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100