Repository navigation
Apply paddings by shifting the camera centre - #31
Merged
Merged
Conversation
Native padding widens the frustum upward. Under tilt a large top padding reaches past the horizon: the engine loads tiles out to it and stalls, and MapLibre also lowers the pitch (60 -> 55.4 deg) and clamps the padding. The target is now placed at the padded centre by moving the camera centre with CameraPaddingEmulation and the provider's fov; native padding is always zero. Read-back undoes the shift, and padding on the initial camera is applied once the map has a size.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Apply
MapCameraPosition.paddingsby shifting the camera centre (core padding emulation with the provider's fov) instead of the engine's own padding, which is now always reset to zero.The engine's padding widens the frustum toward the top. Under tilt, a large top padding pushed the top edge past the horizon and the engine loaded tiles out to it: on the web playground's editor layout (map ~350 px high, top padding ~500 px) frames went to 130–200 ms with stalls of several seconds. Shifting the centre puts the target at the padded-area centre with the same frustum as without padding.
Reading the camera back undoes the shift and reports the requested paddings. Initial-camera paddings are applied by the first move.
Verification
Tilt 0 and 60, top padding 300 and larger than the map: the target lands at the padded centre (within ~1 px when on screen), read-back ≈ target, frame times the same as without padding.
Commits