Skip to content

feat(core, maplibre): add camera roll support - #10697

Open
birkskyum wants to merge 16 commits into
visgl:masterfrom
birkskyum:feat/map-camera-roll
Open

birkskyum wants to merge 16 commits into
visgl:masterfrom
birkskyum:feat/map-camera-roll

Conversation

@birkskyum

@birkskyum birkskyum commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

@chrisgervang Here's the addition of roll to deck.gl - relevant for e.g. noodles.gl


Screenshot 2026-09-10 at 19 31 27

For #10503

Background

Calling map.setRoll() currently banks MapLibre's basemap while deck.gl layers remain level. This adds camera roll to geospatial view states and synchronizes it through the new @deck.gl/maplibre package, so projected coordinates, rendered layers, and picking follow the same camera.

Change List

  • Add optional roll (degrees, default 0) to MapViewState, GlobeViewState, and their viewports. Positive roll rotates the image counter-clockwise, matching MapLibre.
  • Apply roll in camera space after bearing and pitch. Account for rolled Mercator frustum bounds and far clipping, including repeated worlds.
  • Preserve roll during controller interactions, map globe drag deltas through the rolled screen axes, and support roll in linear/fly-to transitions with shortest-path angle handling.
  • Read MapLibre's public getRoll() in @deck.gl/maplibre, with a zero fallback for v4.5.1. Cover v5/v6, Mercator/globe, and overlaid/interleaved modes.
  • Document the API and add regression tests for projection/unprojection, clipping, controllers, transitions, rendered pixel alignment, and picking with padding. Overlaid tests also resize the map while rolled.

Draft notes

  • The independent startup camera synchronization fix and focused v4/v5/v6 regression tests have been split into fix(maplibre): sync camera changes made during Deck initialization #10702.

  • No new roll gesture is introduced. Roll is controlled through view state, transitions, or MapLibre's camera API.

  • Interleaved resize coverage is held back by an existing framebuffer-size issue: after changing the map container size, the CPU viewport updates but rendering uses stale framebuffer dimensions. Reproduced with zero roll against the unchanged base commit 3aabc11038. Overlaid resize is covered.

  • Terrain-specific integration and the golden-image/website suites have not been validated in this draft.


Note

Medium Risk
Touches core camera matrices, bounds, and MapLibre view-state sync, but behavior is guarded by broad new tests and defaults preserve prior zero-roll rendering.

Overview
Adds optional roll (degrees, default 0) to Mercator and globe view states so deck.gl layers bank with the same camera as MapLibre when setRoll() is used.

Roll is applied in the viewport view matrix after bearing and pitch, with Mercator-specific fixes for far-plane clipping, geographic bounds, and repeated worlds. Map and Globe controllers keep roll through pan/zoom/rotate, normalize angles, and globe panning maps screen drag through the rolled axes. Linear and fly-to transitions interpolate roll (shortest path) and treat missing roll as 0 so existing view states do not spuriously animate.

@deck.gl/maplibre reads map.getRoll() (falls back to 0 on older MapLibre). Docs and regression tests cover projection, picking, controllers, transitions, and v5/v6 Mercator/globe overlay alignment.

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

@greptile-apps

greptile-apps Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the only previous finding is fully fixed and no new actionable issue was identified.

Findings

  1. P2 Missing whats-new entry ▶

Summary

Adds camera-roll support throughout deck.gl’s geospatial camera stack.

  • Adds roll to map and globe view states and viewport matrices.
  • Preserves roll through controller interactions and camera transitions.
  • Synchronizes MapLibre v5+ roll in overlaid and interleaved modes.
  • Accounts for rolled Mercator bounds, clipping, projection, and picking.
  • Adds API, release-note, controller, viewport, transition, and integration coverage.
  • The new docs/whats-new.md entries fully address the previous documentation finding.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  M[MapLibre camera getRoll] --> S[Deck view state roll]
  V[MapView or GlobeView state] --> C[Controller and transitions]
  S --> P[Mercator or Globe viewport]
  C --> P
  P --> X[Rolled view matrix]
  X --> R[Rendering]
  X --> K[Projection and picking]
  X --> B[Bounds and clipping]
Loading

Reviews (6) · Last reviewed commit: "docs: add camera roll release notes"

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 146d53c. Configure here.

this.longitude = longitude;
this.bearing = bearing;
this.pitch = pitch;
this.roll = roll;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Globe bounds ignore camera roll

Medium Severity

GlobeViewport.getBounds still samples screen mid-edges and wraps only left/right as west/east. After roll, those edges are no longer the geographic extrema, so the returned box can omit visible corners and mis-handle the antimeridian. Tile loading, culling, and callers of getBounds on a rolled globe can drop content.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 146d53c. Configure here.

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.

Seems worth looking into

@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.

This is awesome! Most comments are style, doc, or test suggestions

Comment thread docs/api-reference/core/globe-view.md Resolved
Comment thread docs/api-reference/core/globe-view.md Outdated
Comment on lines +86 to +89
Roll is applied around the camera's forward axis after pitch and bearing, including
the Mercator projection used at high zoom. The controller preserves it during
interaction but does not provide a roll gesture.

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.

Suggested change
Roll is applied around the camera's forward axis after pitch and bearing, including
the Mercator projection used at high zoom. The controller preserves it during
interaction but does not provide a roll gesture.

I don't think this is necessary. How does maplibre offer a roll gesture, if at all? Maybe we can offer it too on deck controllers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

MapLibre supports Ctrl + right-click dragging when rollEnabled: true is set (disabled by default). See its rollEnabled option and mouse roll handler. Adding the equivalent deck controller gesture would be a separate interaction change; this PR supplies the camera state and preserves roll through existing interactions.

Comment thread docs/api-reference/core/map-view.md Resolved
Comment thread docs/api-reference/core/map-view.md Resolved
Comment thread modules/maplibre/src/deck-utils.ts Outdated
Comment on lines +163 to +164
// The camera may have moved while Deck was initializing.
onMapLibreMove(deck, map);

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.

This seems like a potentially unrelated bug fix, or an unnecessary call. Can you check? If needed, let's split out into its own PR and understand when this happens in practice

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed this is an independent bug. Calling map.jumpTo(...) immediately after adding an interleaved overlay leaves Deck's initial camera state stale. Split the fix and a dedicated regression test into #10702. The test fails on master for MapLibre 4.5.1, 5.0.0, and 6.0.0, and passes with the fix. The roll test now waits for initialization before changing roll.

@chrisgervang chrisgervang Sep 20, 2026 •

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.

Merged #10702

Comment thread test/modules/maplibre/overlay.spec.ts Resolved
Comment on lines +280 to +282
// Deck.finalize removes its canvas but does not release the WebGL context.
// Avoid exhausting the browser context limit in the shared test page.
overlayCanvas?.getContext('webgl2')?.getExtension('WEBGL_lose_context')?.loseContext();

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.

@Pessimistress @felixpalmer @ibgreen it seems odd that the context isn't released after finalize. Do you have any idea if that is intentional, a bug, or if this is just an over-cautious LLM addition?

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.

Hey @birkskyum, this context finalization behavior sounds concerning, if true.

I'd rather see the issue addressed in the module than merge in a testing hack

@greptile-apps

greptile-apps Bot commented Sep 20, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.

  • P1 Initialization misses camera changes modules/maplibre/src/deck-utils.ts:159 ▶

    If the MapLibre camera changes while an interleaved Deck instance is initializing, move events are not watched yet. This callback starts watching after Deck loads but does not synchronize the latest camera state, so Deck keeps the view-state snapshot captured before initialization until another camera move occurs. Although interleaved rendering constructs a live viewport, operations backed by Deck's view manager, such as picking, can use the stale camera in the meantime.

        deckProps.onLoad = () => {
          onLoad?.();
          if (MAPLIBRE_DECK_STATES.get(map) === state) {
            startWatchingMove(map, state);
            onMapLibreMove(deck, map);
          }
        };
    

@chrisgervang

Copy link
Copy Markdown
Collaborator

Interleaved resize coverage is held back by an existing framebuffer-size issue: after changing the map container size, the CPU viewport updates but rendering uses stale framebuffer dimensions. Reproduced with zero roll against the unchanged base commit 3aabc11. Overlaid resize is covered.

Is there an issue or PR for more information about this?

@birkskyum

birkskyum commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Interleaved resize coverage is held back by an existing framebuffer-size issue: after changing the map container size, the CPU viewport updates but rendering uses stale framebuffer dimensions. Reproduced with zero roll against the unchanged base commit 3aabc11. Overlaid resize is covered.

Is there an issue or PR for more information about this?

@chrisgervang it was the issue here visgl/luma.gl#3177 , which got fixed in visgl/luma.gl#3178

@chrisgervang

Copy link
Copy Markdown
Collaborator

Oh great, let's add interleaved coverage then

Comment thread docs/api-reference/maplibre/overview.md Resolved
@charlieforward9 charlieforward9 mentioned this pull request Sep 28, 2026
14 of 70 tasks
@chrisgervang chrisgervang mentioned this pull request Oct 29, 2026
29 of 30 tasks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants