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

Transform specific projectPoint #5267

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ibesora
Copy link
Collaborator

@ibesora ibesora commented Dec 24, 2024

This PR is my first take on fixing #5255
It moves circle-layer specific projection code to each transform to make it transform-aware.
Globe projection is implemented using the view projection matrix, which works as a simple approximation

Before (Notice how the cursor changes to a hand when the underlying feature is detected)

Screen.Recording.2024-12-24.at.18.13.16.mov

After

Screen.Recording.2024-12-24.at.18.11.10__.mov

@kubapelc I'd love if you could take this PR and follow along with a more exact implementation if you have time

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality.
  • Document any changes to public APIs.
  • Post benchmark scores.
  • Add an entry to CHANGELOG.md under the ## main section.

Copy link

codecov bot commented Dec 24, 2024

Codecov Report

Attention: Patch coverage is 37.50000% with 10 lines in your changes missing coverage. Please review.

Project coverage is 91.83%. Comparing base (f967780) to head (bd7cfd2).
Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
src/style/style_layer/circle_style_layer.ts 0.00% 5 Missing ⚠️
src/geo/projection/mercator_transform.ts 50.00% 2 Missing ⚠️
...c/geo/projection/vertical_perspective_transform.ts 50.00% 2 Missing ⚠️
src/geo/projection/globe_transform.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5267      +/-   ##
==========================================
- Coverage   91.84%   91.83%   -0.01%     
==========================================
  Files         281      281              
  Lines       38856    38864       +8     
  Branches     6793     6795       +2     
==========================================
+ Hits        35686    35690       +4     
- Misses       3043     3046       +3     
- Partials      127      128       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HarelM
Copy link
Collaborator

HarelM commented Dec 24, 2024

While this may solve this case, I'm not sure it will solve the cases for other layers.
When I looked into the code, what I found problematic was the following method:

function getPixelPosMatrix(transform, tileID) {
const t = mat4.create();
mat4.translate(t, t, [1, 1, 0]);
mat4.scale(t, t, [transform.width * 0.5, transform.height * 0.5, 1]);
if (transform.calculatePosMatrix) { // Globe: TODO: remove this hack once queryRendererFeatures supports globe properly
return mat4.multiply(t, t, transform.calculatePosMatrix(tileID.toUnwrapped()));
} else {
return t;
}
}

It is part of the code path that causes this bug as far as I understand.
The method is not typed so it passes well for transform that has the calculatePosMatrix method, which is basically the mercator transform.
I was hoping that solving this method and adding the relevant posMatrix would solve this.
I'll see if I can create a failing test never the less as it will be helpful regardless of the solution.

@HarelM
Copy link
Collaborator

HarelM commented Dec 25, 2024

I've tried to test this code with:
'circle-translate': [100, 100] and it doesn't look like this fully solve this.
I'm guessing there's still a need to fine tune the relevant matrices etc, which is very confusing to me to be honest...

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

Successfully merging this pull request may close these issues.

2 participants