-
-
Notifications
You must be signed in to change notification settings - Fork 665
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
Fix camera jumps with terrain and transformCameraUpdate. #4299
Fix camera jumps with terrain and transformCameraUpdate. #4299
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4299 +/- ##
==========================================
+ Coverage 87.87% 88.12% +0.25%
==========================================
Files 246 246
Lines 33372 33375 +3
Branches 2194 2189 -5
==========================================
+ Hits 29325 29413 +88
+ Misses 3050 2969 -81
+ Partials 997 993 -4 ☔ View full report in Codecov by Sentry. |
The last commit should fix it. Thanks to @UberMouse for the hint at #4377 (comment) |
Thanks for taking the time to fix this issue! |
I think the following unit test can reproduce this issue to some extent - as the recalculate zoom will be done on the original transform and won't take the zoom changes that are done as part of the transfrom camera update: test('recalculate zoom is done on the camera update transform', () => {
const map = createMap({
interactive: true,
clickTolerance: 4,
transformCameraUpdate: ({zoom}) => ({ zoom: zoom + 0.1})
});
map.terrain = {
pointCoordinate: () => null,
getElevationForLngLatZoom: () => 1000
} as any;
const canvas = map.getCanvas();
simulate.dragWithMove(canvas, {x: 100, y: 100}, {x: 100, y: 150});
map._renderTaskQueue.run();
expect(map.getZoom()).toBe(0.20008255564976615);
}); What do you think? |
Seems fine, still I think an integration test that involves transformCameraUpdate wouldn't be bad. But fine for me :) |
I'm good with both tests, just please simplify the style in the integration test... |
Ah, I did that on purpose. Thought about simplifying it, which would be fine for the automatic testing, but if you want to observe the bug, the more complete style is really helpful. But yeah, I can simplify it if you don't think thats important. |
Yeah, the test should be as simple as possible, for debugging you can change the examples in order to reproduce an issue. |
Ah, you did not actually test it? At least, it never fails for me. |
I've test it with and without the fix and it gave different results. |
Maybe I'm missing something. I pushed your unit test, you can check it with the commit "04278f129 | Fix terrain jumps with transformCameraUpdate (#4233)" reversed, which lets the integration test fail for me but not the unit test. |
Ah, it fails when the fix is applied? Did you calculate the zoom by hand? Or is it fine to just fix the expected zoom value with the fix applied? |
Must have written the test when I removed the fix, sorry... |
Fixes camera jumps at end of movement when terrain and transformCameraUpdate is enabled (fixes #4233).
Had to enable WebGL for headless Chrome, as I could not reproduce the bug without it in headless mode.
The problem was caused by directly accessing the map's transform, instead of using _getTransformForUpdate and _applyUpdatedTransform.
Launch Checklist
CHANGELOG.md
under the## main
section.