Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return distance to feature from queryRenderedFeatures #9729

Open
danvk opened this issue May 27, 2020 · 0 comments
Open

Return distance to feature from queryRenderedFeatures #9729

danvk opened this issue May 27, 2020 · 0 comments

Comments

@danvk
Copy link

danvk commented May 27, 2020

Motivation

I'm mixing Mapbox GL fill-extrusion layers with some custom layers that use Three.js (see this StackOverflow question/answer). When a user clicks on the map, I can use Mapbox's queryRenderedFeatures to figure out which fill-extrusion features were under the cursor. And I can use a Three.js raycaster (see the Stack Overflow question) to figure out which Three.js features were under the cursor.

I want to sort these features by depth, so that I can determine which is on top, whether it's a fill-extrusion layer or a Three.js layer. The Three.js raycaster returns a distance which I can use to sort the meshes. And queryRenderedFeatures sorts the 3D features it returns by distance. But it doesn't return that distance. So it's not clear to me how to merge the two lists of features.

I believe Mapbox GL sorts 3D features by distance from the camera here:

features3D.sort((a, b) => {
return b.intersectionZ - a.intersectionZ;
});

So my strawman proposal would be to expose intersectionZ (or some physically meaningful transformation of it) in the result of queryRenderedFeatures.

Design Alternatives

A method to measure the distance from the camera to a feature would also solve this problem. Or if there's already a way to do that, I'd love to hear about it.

Design

Mock-Up

Concepts

Implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants