Skip to content

fix(maplibre): keep picking in sync with the terrain elevation - #10756

Merged
chrisgervang merged 3 commits into
visgl:masterfrom
birkskyum:deck-picking-fix
Sep 30, 2026
Merged

chrisgervang merged 3 commits into
visgl:masterfrom
birkskyum:deck-picking-fix

Conversation

@birkskyum

@birkskyum birkskyum commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Background

Right now picking in interleaved mode uses the view state that MapLibreOverlay updates on MapLibre's move events, while drawing reads the camera from the map every frame. MapLibre raises the center elevation while the terrain tiles load without a move event, so picks over terrain miss until the map moves.

Change List

  • MapLibreOverlay: refresh the view state when the center elevation changes
  • Unit tests for MapLibre 4.5.1, 5.0.0 and 6.0.0, which fail on master

Can be tested here, hover the summits right after the page loads:
Left - deck.gl 9.4.0 / Right - This PR
https://jsbin.com/demexeg/edit?output


Note

Medium Risk
Touches the interleaved render loop and view-state updates on every frame when terrain elevation changes; limited to MapLibre overlay sync but affects picking correctness.

Overview
Fixes interleaved MapLibreOverlay picking drifting from the map while terrain loads: MapLibre can update center elevation on each frame without a move event, but deck’s stored viewState was only refreshed on move.

On MapLibre’s render hook, the overlay now calls syncMapLibreElevation, which compares the map’s center elevation to viewState.position[2] and re-syncs via onMapLibreMove when they differ so picking uses the same camera as drawing.

Adds WebGL regression tests (MapLibre 4.5.1, 5.0.0, 6.0.0) with a synthetic raster-DEM tile, setTerrain, and asserts viewState.position and pickObject hit a 3D scatter point at the summit.

Reviewed by Cursor Bugbot for commit e70cce3. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Syncs map picking with terrain elevation changes.

The PR appears safe to merge; no new actionable issue or outstanding previous finding was identified.

Summary

The PR synchronizes the stored MapLibre view state with terrain elevation during rendering so picking follows the drawn camera, and adds terrain-picking tests for three MapLibre versions.

Reviews (3) · Last reviewed commit: "Merge branch 'master' into deck-picking-..."

Comment thread modules/maplibre/src/deck-utils.ts Resolved
Comment thread test/modules/maplibre/overlay.spec.ts Resolved

@chrisgervang chrisgervang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the bug fix, and the helpful jsbin!

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 82.524% (+0.02%) from 82.505% — birkskyum:deck-picking-fix into visgl:master

@chrisgervang
chrisgervang merged commit ce0808d into visgl:master Sep 30, 2026
8 checks passed
@chrisgervang chrisgervang added this to the v9.4 patch releases milestone Oct 4, 2026
@chrisgervang chrisgervang mentioned this pull request Oct 7, 2026
53 of 66 tasks
chrisgervang pushed a commit that referenced this pull request Oct 22, 2026
@chrisgervang

Copy link
Copy Markdown
Collaborator

Released in deck.gl 9.4.1. Thanks @birkskyum!

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.

[Bug] MapLibreOverlay picking misses objects over terrain in interleaved mode

3 participants