Skip to content

feat: Initial Globe view support - #563

Merged
kylebarron merged 15 commits into
mainfrom
kyle/globe-view-may2026
May 22, 2026
Merged

kylebarron merged 15 commits into
mainfrom
kyle/globe-view-may2026

Conversation

@kylebarron

@kylebarron kylebarron commented May 21, 2026 •

Copy link
Copy Markdown
Member
Screen.Recording.2026-05-22.at.12.02.20.PM.mov

Written by Claude on behalf of @kylebarron

What I am changing

Adds prototype globe-view support to deck.gl-raster. RasterTileLayer-based
layers (COG/Zarr) can now render on a 3D globe — deck.gl _GlobeView, or
MapLibre projection: 'globe' with deck.gl interleaved — not just the flat Web
Mercator map. Includes a new cog-globe example.

Deliberately scoped as a prototype: it renders real data end-to-end and
exercises the full pipeline, with the harder accuracy work called out and
deferred (see Limitations). Design + deferred work:
dev-docs/specs/2026-05-21-globe-view-design.md.

How I did it

  • Globe tile selection. Implemented the globe computeBoundingVolume
    (was assert(false)): sample reference points (REF_POINTS_11), reproject to
    WGS84, and project onto the sphere via viewport.projectPosition for the
    frustum-culling oriented bounding box; keep a Web-Mercator-world AABB for the
    dataset pre-filter and the LOD latitude. The bounding-volume cache is rebuilt
    when the viewport projection mode switches (globe↔mercator).
  • lng/lat-direct rendering. Globe renders in coordinateSystem: 'lnglat'
    (mesh vertices in WGS84 via projectTo4326) — no manual common-space mapping.
    Collapsed SimpleMeshLayer's composeModelMatrix branch in the
    MeshTextureLayer vertex shader to a single direct-projection path (the old
    branch projected lng/lat degrees as if they were meters).
  • Z-fighting with the basemap. The raster mesh is coplanar with MapLibre's
    globe sphere in the shared interleaved depth buffer. A depth bias doesn't help
    with maplibre's globe depth encoding; instead depthCompare: 'always' +
    back-face culling (cullMode: 'back' for this grid's winding). See
    visgl/deck.gl#9592.
  • LOD fix. The meters-per-pixel latitude must come from the mercator-world
    bounds, not the 3D OBB center (globe-common → worldToLngLat returns ~-89°
    near the Mercator singularity → meters/px far too small → the traversal loads
    the finest tiles across the whole globe when zoomed out).
  • Anti-faceting scaffold (throwaway). Globe builds a uniform per-tile grid
    instead of the adaptive Delatin mesh, whose reprojection-error metric is blind
    to sphere curvature (an EPSG:4326 source yields 2 triangles that chord through
    the sphere).
  • Merged main, reconciling with fix: traverse tiles across world copies (#517) #518 (world copies); world-copy passes are
    gated on viewport.subViewports, so they don't run on a globe.
  • Documented the globe path in dev-docs/coordinate-systems.md.

How you can test it

pnpm install
pnpm --filter @developmentseed/deck.gl-raster build
pnpm --filter @developmentseed/deck.gl-geotiff build
pnpm --filter deck.gl-cog-globe-example dev

Confirm: the basemap renders as a 3D globe, the COG drapes onto the sphere and
lines up with the basemap (source selector to try several COGs), no z-fighting,
back-of-globe tiles are occluded, and LOD tracks zoom (coarse when zoomed out,
finer when zoomed in).

Unit tests: pnpm --filter @developmentseed/deck.gl-raster test — globe
bounding volume, cache rebuild on projection switch, and a globe LOD regression
test.

Limitations (deferred — tracked as follow-up issues)

Related Issues

kylebarron and others added 2 commits May 21, 2026 12:39
Scopes a working globe-view prototype (globe tile-selection bounding
volume, lng/lat-direct render path via a shader unification, cog-globe
and zarr-globe examples over MapLibre globe, throwaway anti-faceting
scaffold) while deliberately carving out spherical-reprojection
correctness as a follow-up design.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Replaces the assert(false) globe stub in computeBoundingVolume with an
oriented bounding box built from WGS84 reference points projected onto
the globe sphere via viewport.projectPosition. Makes the bounding-volume
cache key projection-aware so globe and mercator volumes don't collide.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- Drop the projection-namespaced cache key; instead RasterTileset2D
  clears the BoundingVolumeCache when the viewport projection mode
  switches (globe<->mercator). Simpler z/x/y key; adds a clear() method.
- Always use REF_POINTS_11 for the globe bounding volume. Our descriptor
  z is an internal overview index, not web-mercator zoom, so upstream's
  zoom-keyed point count doesn't transfer; a tile never spans more than
  the whole world, so 11 points always suffice and the cache makes the
  per-tile cost one-time.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
kylebarron and others added 3 commits May 21, 2026 14:09
Follow the repo convention of aliasing deck.gl's underscore-prefixed
exports (cf. _Tileset2D as Tileset2D).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Collapse SimpleMeshLayer's composeModelMatrix branch to one
direct-projection path. MeshTextureLayer always draws one identity mesh
at the origin, so projecting the mesh vertex directly is correct for
both cartesian (Web Mercator) and lnglat (GlobeView). Fixes the globe
path, which previously hit the meters-offset branch and ran
project_size on lng/lat degrees. Behavior-preserving for mercator.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Collapse SimpleMeshLayer's composeModelMatrix branch to one
direct-projection path. MeshTextureLayer always draws one identity mesh
at the origin, so projecting the mesh vertex directly is correct for
both cartesian (Web Mercator) and lnglat (GlobeView). Fixes the globe
path, which previously hit the meters-offset branch and ran
project_size on lng/lat degrees. Behavior-preserving for mercator.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@kylebarron
kylebarron force-pushed the kyle/globe-view-may2026 branch from 037f178 to 0f3691b Compare May 21, 2026 18:54
kylebarron and others added 7 commits May 21, 2026 14:57
In globe mode, build a uniform per-tile grid instead of the adaptive
Delatin mesh, whose reprojection-error metric is blind to sphere
curvature and facets EPSG:4326 sources at low zoom. Stopgap only; to be
removed when sphere-aware reprojection lands. Globe is detected via
viewport.resolution (null-safe so direct _generateMesh calls in tests
fall back to the reprojector path).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Standalone example rendering an EPSG:4326 COG on MapLibre's globe
projection (projection="globe") with deck.gl interleaved. Exercises the
globe tile-selection, lng/lat render path, and uniform-grid scaffold
end-to-end. fitBounds frames the data wherever the COG sits.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
In globe mode the raster mesh is coplanar with MapLibre's basemap sphere
and z-fights in the shared interleaved depth buffer. A depth bias does
not help with maplibre's globe depth encoding; instead skip depth
comparison (depthCompare: "always") and occlude the far hemisphere with
back-face culling (cullMode: "back" for this grid's winding). Approach
per visgl/deck.gl#9592.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Mirror cog-basic's source list + selector (and debug controls) so every
COG source can be tested on the globe. fitBounds reframes on each switch.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The LOD meters-per-pixel read the latitude from the 3D oriented bounding
box center, which on a globe is in globe common space (y far outside the
Web Mercator world range), so worldToLngLat returned ~-89deg and
cos(lat) made meters-per-pixel 10-270x too small. devicePixelsPerSource
was then always >>1, so the traversal always recursed to the finest
level -- loading the finest tiles across the whole globe when zoomed out.

Drive the latitude from commonSpaceBounds instead, which is in Web
Mercator world space in both the mercator and globe paths. Adds a
regression test asserting LOD tracks zoom on a globe.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds a "Globe view (prototype)" section: lnglat-direct rendering, the
two-coordinate-space tile selection, the LOD latitude gotcha (+ limb
foreshortening caveat), the depthCompare/cullMode z-fighting recipe, and
the throwaway anti-faceting grid. Links the globe-view spec.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@kylebarron kylebarron changed the title Kyle/globe view may2026 feat: Globe view May 22, 2026
@github-actions github-actions Bot added the feat label May 22, 2026
Reconciles the globe-view work with #518 ("traverse tiles across world
copies"), which refactored raster-tile-traversal.ts. The globe additions
(globe bounding volume, REF_POINTS_11, lnglat LOD via
getMetersPerPixelAtCommonSpaceBounds) layer onto main's worldOffset
structure; update() now also destructures commonSpaceBounds for the LOD
latitude. World-copy passes are gated on viewport.subViewports (>1), so
they never run on a globe.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Comment thread examples/cog-globe/README.md Resolved
Per review: the depthCompare/cullMode recipe for z-fighting against the
basemap depends on the compositing context (MapLibre interleaved globe
handedness vs a standalone _GlobeView), so it's an app decision, not a
library one. RasterLayer no longer injects it; deck.gl forwards the
`parameters` prop from COGLayer down to the mesh via getSubLayerProps,
and the cog-globe example sets it. Also simplify the cog-globe README.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@kylebarron
kylebarron marked this pull request as ready for review May 22, 2026 16:01
@kylebarron
kylebarron merged commit e538d97 into main May 22, 2026
5 checks passed
@kylebarron
kylebarron deleted the kyle/globe-view-may2026 branch May 22, 2026 16:04
@kylebarron kylebarron self-assigned this May 26, 2026
@charlieforward9

Copy link
Copy Markdown
Contributor

nice

thatbudakguy added a commit to OpenGeoMetadata/ogm-viewer that referenced this pull request Sep 21, 2026
The COG preview has asked for a flat map since it was first drawn with
deck.gl, because its tile traversal had no globe bounding volume to cull
against. The comment saying so was optimistic - it claimed the COG still drew
and only the console suffered. On the overlay we moved to in 31e2204 it drew
nothing at all: the assert threw on every frame, no tile was ever selected, and
the preview died on <ogm-map>'s load deadline with "The Cloud Optimized GeoTIFF
preview timed out" filling the pane.

developmentseed/deck.gl-raster#563 implemented that bounding volume, along with
the cache-key fix a globe/mercator switch needs and the mesh shader change that
puts lng/lat vertices on the sphere. It is published only as 0.8.0-beta.2;
`latest` is still the 0.7.0 we were on, and upstream has landed nothing but
dependency chores since June. So the three packages are pinned to that exact
prerelease rather than carried on a range - a caret would take a beta.3 nobody
has looked at.

With that in, this preview has no projection of its own to ask for and takes
MapPreviewer's globe default like everything else. The parameters it already
passed deck.gl - depthCompare 'always', cullMode 'back' - turn out to be
exactly what an interleaved overlay on MapLibre's globe needs, so they only
needed explaining.

One thing the bump doesn't bring. @deck.gl/maplibre chooses between a MapView
and a GlobeView by asking the map which projection it is in, and it asks in two
places: when its own props are set, and on 'styledata'. setProjection() raises
'projectiontransition' and no 'styledata' at all, so a reader pressing the
globe button off left the overlay drawing through the GlobeView it was built
with while MapLibre had gone back to flat - the COG 12px out at zoom 4, 80px at
zoom 3, and staying there, because no pan, zoom or later frame is a style
change either. Handing the overlay its layers again on 'projectiontransition'
is the nudge; deck.gl matches the layer by id, so decoded tiles are kept.

Verified in Chromium, since none of this is visible to the suite - a scalar
LERC DEM through our own pipeline and a CONUS Albers COG through upstream's,
both drawn on the globe with nothing in the console. Registration measured
rather than eyeballed, by comparing map.project() with the deck viewport's own:
0px at every zoom from 1.5 to 16, 0.15px on the frame where the two hand over
around MapLibre's globe-to-mercator transition, and 0px both ways across the
globe button. Mercator is unchanged - both COGs render pixel-identically to
0.7.0.

Co-Authored-By: Claude Opus 5 <[email protected]>
@chrisgervang

Copy link
Copy Markdown

Hey @kylebarron, would these projection helpers be useful to you? visgl/deck.gl#10657

If so, I could push them out in a 9.4 patch.

Also, would be great to know if shipping any of the extension fix PRs mentioned would unblock your follow ups, like ClipExtension, which is mentioned on #561 and has a proposed fixed in visgl/deck.gl#10659

@kylebarron

Copy link
Copy Markdown
Member Author

I'm not sure yet; I think we're going to change how we measure projection error in #708

kylebarron added a commit that referenced this pull request Nov 6, 2026
> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

The globe-view prototype (#563) added a COG globe example, but nothing
showed the Zarr path on a globe. This adds `examples/zarr-globe`, which
animates ECMWF's AIFS Single 2 m temperature forecast on MapLibre's
globe projection with deck.gl interleaved. It's the
`dynamical-zarr-ecmwf` example on a globe, but reads a different
forecast so that the whole visible half of the globe loads quickly. The
shared globe render path already handles `ZarrLayer`, so no library
changes are needed.

## Why AIFS Single, not the IFS ensemble

`dynamical-zarr-ecmwf` reads the IFS ensemble (ENS). Each of its inner
chunks holds 32x32 pixels for all 85 lead times and all 51 ensemble
members, and the example draws one member. On a globe, the first view is
558 such tiles: about 1.3 GB in 558 requests, of which 2% is drawn, and
it took 3.5 minutes to load.

The AIFS Single store, from the same dynamical.org bucket, has no
ensemble dimension, and each inner chunk holds 241x240 pixels (60°x60°)
for all 61 lead times. The whole globe is 18 chunks, of 24-39 MB in
total depending on the run. In Chrome, with the browser cache off, the
example's first view loaded in about 7 seconds, from 22 requests and 24
MB.

## Changes

- New `examples/zarr-globe` (package `deck.gl-zarr-globe-example`), with
the data pipeline and controls of `dynamical-zarr-ecmwf`: it opens the
store with `ZarrSource.open(store, { path })`, checks the data type with
`is`, and passes the source to `ZarrLayer`. For the globe it follows
`cog-globe`: `projection="globe"`, `parameters: { depthCompare: "always"
}` on the layer so the raster does not z-fight the basemap sphere, and a
black background around the globe.
- Differences from `dynamical-zarr-ecmwf`, for AIFS: no ensemble member
in the selection; 61 lead times at a fixed 6-hour step, so each frame
shows for the same time (200 ms by default); a forecast run every 6
hours, with the run's hour next to the date picker; no `maxCacheSize`,
so tiles stay cached as the globe turns; and a default colour range of
-20 to 40 °C, which fits the temperatures in the default view better
than -40 to 50 °C, while the filter keeps -40 to 50 °C.
- Declares the grid `"spatial:registration": "node"`: the store's
coordinates put each value on its grid point, from 90° to -90° and -180°
to 179.75°. #862 makes the same change in `dynamical-zarr-ecmwf`. The
edge cells reach 0.125° past the poles, which #858 clamps on the globe.
- Uses the hosted Dark Matter style with `beforeId:
"boundary_country_outline"`, as `cog-globe` does, instead of copying the
flat example's custom water-less style.
- Docs examples page: a "Globe View" card in the Zarr section, with a
card image. The card shows +6 h of the 06 UTC run, midday over Africa.
It was taken after #858, which fixed dots that showed where the far-side
South Pole lands.
- `pnpm-lock.yaml`: adds the new importer only. The docs workflow and
the pnpm workspace already pick up `examples/*`.

## Tests

- Example-only change, no new tests. The workspace typecheck and the
example build pass, and Biome is clean.
- Checked in Chrome: the forecast drapes on the globe with country
borders and labels on top, with no z-fighting. Zooming in fetches
nothing new, the animation advances one 6 h step every 200 ms, and the
console shows no errors.

## Notes

- Near the globe's limb the raster can stop short, leaving slivers of
basemap. The cause isn't known yet. It would be in the shared globe
path, so it is not addressed here.

Closes #568

🤖 Written by [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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