Skip to content

fix(extensions): ClipExtension geometry mode in GlobeView - #10659

Merged
chrisgervang merged 9 commits into
masterfrom
claude/fix-clip-extension-globe-GveWO
Oct 30, 2026
Merged

chrisgervang merged 9 commits into
masterfrom
claude/fix-clip-extension-globe-GveWO

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Follow up of #10657

Background

ClipExtension in geometry mode compares geometry.position.xy with clipBounds projected by layer.projectPosition(). Under GlobeView both are sphere XYZ, so a clipped PolygonLayer renders as a single diagonal stripe instead of the clipped rectangle. Instance mode compares raw lng/lat and is already correct.

Before After
clip-geometry-globe: 7 x 4 grid of squares clipped to 5 x 4 with trimmed edges, San Francisco at zoom 11.5 before after
clip-geometry-antimeridian-map-vs-globe: MapView left, GlobeView right, bounds crossing 180° before after

Before images are the same cases rendered on master. In the antimeridian row, master keeps the wrong slice on MapView (inverted crossing bounds) and draws nothing on GlobeView. The instance-mode cases pass on master and are coverage only.

Change List

  • ClipExtension geometry mode (GLSL): vertex shader passes project_common_position_to_flat_continuous(geometry.position, cameraFlatX), the fragment shader wraps it about the bounds centre (clip.worldWidth, 0 for non-geospatial views) before the test, and draw() sets clip.bounds with projectBoundsToFlatCommon; instance mode unchanged
  • WGSL clip module: add clip_getCoordinates() and clip_isGeometryInBounds() with the same flatten and per-fragment wrap, used by ScatterplotLayer, PathLayer and SolidPolygonLayer instead of raw geometry.position.xy, so WebGPU compares the same space as the bounds
  • Wrapping per fragment keeps each triangle continuous (a per-vertex wrap tore polygons 180° from the bounds), and bounds whose left edge is more than 180° east of their right edge (e.g. [170, -20, -170, 20]) clip the intended region instead of needing two layers
  • Render tests: new clip-extension.spec.ts (Clip had none). clip-geometry draws a 7 x 4 grid of squares whose bounds cut through the second and sixth columns and the first and last rows; clip-instance draws dots at the square centres. Each renders under MapView, GlobeView and OrthographicView (6 goldens) and the spec states the expected picture per case
  • New golden clip-geometry-antipode.png: MapView from 0° to 180° with one square inside bounds at the prime meridian and one straddling the antimeridian. Look for one red square at the centre and nothing at the right edge
  • New golden clip-geometry-antimeridian-map-vs-globe.png: MapView (left) and GlobeView (right) centred on 180°, a rectangle from 150°E to 150°W clipped by bounds that also cross 180°. Look for one red rectangle 20° wide and 40° tall in the middle of each half
  • Unit test: clip.bounds equals the Mercator projection of clipBounds on both viewports in geometry mode and stays raw lng/lat in instance mode
  • Documentation: docs/whats-new.md GlobeView compatibility bullet; clip-extension.md clipBounds notes antimeridian bounds, geometry mode only

Ran the render spec headless on WebGL, the unit spec, tsc and lint. WebGPU was not run here; the WGSL change mirrors the GLSL one.


Generated by Claude Code

@coveralls

coveralls commented Sep 7, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 84.347% (-0.008%) from 84.355% — claude/fix-clip-extension-globe-GveWO into master

@chrisgervang
chrisgervang marked this pull request as ready for review September 20, 2026 21:17

@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

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7ebc767. Configure here.

@greptile-apps

greptile-apps Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the latest change addresses the remaining documentation finding.

Summary

This PR fixes geometry clipping on GlobeView and adds support for bounds that cross the antimeridian.

  • Geometry clipping uses matching map coordinates on globes and flat views.
  • Geometry bounds can clip one region across the antimeridian.

No new actionable issues were found in the changes since the previous review.

Reviews (15) · Last reviewed commit: "docs(extensions): state the 180° conditi..." · Reviewed by Greptile

@chrisgervang
chrisgervang force-pushed the claude/fix-clip-extension-globe-GveWO branch from 7ebc767 to 4f07d3d Compare September 20, 2026 21:42
Base automatically changed from claude/globe-flat-common-helpers-GveWO to master September 25, 2026 17:34
@chrisgervang
chrisgervang force-pushed the claude/fix-clip-extension-globe-GveWO branch from 8b159e5 to e346826 Compare September 25, 2026 17:37
@chrisgervang
chrisgervang force-pushed the claude/fix-clip-extension-globe-GveWO branch from e346826 to d0e81fa Compare October 3, 2026 22:10
@chrisgervang

Copy link
Copy Markdown
Collaborator Author

This PR is isolated to the extension and fixes issues with both MapView and GlobeView. In fact, the extension hardily worked in GlobeView prior to this change.

@chrisgervang
chrisgervang force-pushed the claude/fix-clip-extension-globe-GveWO branch from d0e81fa to 64fe687 Compare October 3, 2026 22:31
@chrisgervang chrisgervang added this to the v9.4 patch releases milestone Oct 4, 2026

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

Reviewed; the GlobeView geometry-mode support is ready to approve.

In geometry (fragment) mode the extension compared `geometry.position.xy`
with `clipBounds` projected through `layer.projectPosition()`. Both are in
the active projection's common space, which under GlobeView is sphere XYZ:
comparing the x/y of a sphere position against a box has no geographic
meaning and rendered a single diagonal stripe instead of the clipped
rectangle.

Use the flat common-space helpers from the framework branch instead:
the vertex shader converts `geometry.position` with
`project_common_position_to_flat()` (identity for flat projections,
sphere -> absolute Web Mercator under GLOBE) and `draw()` produces the
bounds with `projectBoundsToFlatCommon()`, its CPU twin, so both sides
agree in every projection mode. The instance (vertex) mode compares raw
lng/lat and is untouched, as is the WebGPU path.

Tests: new render spec test/render/test-cases/clip-extension.spec.ts
renders `clip-geometry` (PolygonLayer, clipByInstance: false) and
`clip-instance` (ScatterplotLayer) under MapView, GlobeView and
OrthographicView via expandViewMatrix (6 goldens; all show the same
clipped rectangle). Unit spec asserts the `clip.bounds` uniform equals the
Mercator projection of clipBounds on both WebMercatorViewport and
GlobeViewport in geometry mode and stays raw lng/lat in instance mode.

Docs: clip-extension.md gains a Remarks section (GlobeView support,
Mercator evaluation, antimeridian, clipByInstance semantics).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
…antimeridian

The WGSL layers passed raw geometry.position.xy to clip_filterColor, which
is sphere XY under GlobeView while the bounds are now Mercator. Add
clip_getCoordinates() in the WGSL clip module and use it in
ScatterplotLayer, PathLayer and SolidPolygonLayer.

Both GLSL and WGSL now wrap the flat position around the bounds centre, so
geometry stays continuous across the antimeridian and bounds whose left
edge is east of their right edge clip the intended region instead of
needing two layers. Adds a side-by-side MapView/GlobeView render case.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
Replace the San Francisco zip-code data with a 7 x 4 grid of squares and
dots whose bounds cut through known columns and rows, and state the
expected picture for every case in the spec.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
@chrisgervang
chrisgervang force-pushed the claude/fix-clip-extension-globe-GveWO branch from 64fe687 to e61aed0 Compare October 23, 2026 00:34
claude and others added 3 commits October 23, 2026 00:45
Wrapping each vertex about the bounds centre tears triangles that straddle
the point 180° from the bounds, so a polygon there leaked a stripe into the
bounds. Keep the varying continuous within each triangle (globe seam opposite
the camera) and wrap in the fragment stage, in GLSL and WGSL.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
@chrisgervang
chrisgervang merged commit e1d346d into master Oct 30, 2026
9 checks passed
@chrisgervang
chrisgervang deleted the claude/fix-clip-extension-globe-GveWO branch October 30, 2026 02:26
chrisgervang added a commit that referenced this pull request Nov 3, 2026
…11013)

* fix(extensions): ClipExtension geometry mode in GlobeView

In geometry (fragment) mode the extension compared `geometry.position.xy`
with `clipBounds` projected through `layer.projectPosition()`. Both are in
the active projection's common space, which under GlobeView is sphere XYZ:
comparing the x/y of a sphere position against a box has no geographic
meaning and rendered a single diagonal stripe instead of the clipped
rectangle.

Use the flat common-space helpers from the framework branch instead:
the vertex shader converts `geometry.position` with
`project_common_position_to_flat()` (identity for flat projections,
sphere -> absolute Web Mercator under GLOBE) and `draw()` produces the
bounds with `projectBoundsToFlatCommon()`, its CPU twin, so both sides
agree in every projection mode. The instance (vertex) mode compares raw
lng/lat and is untouched, as is the WebGPU path.

Tests: new render spec test/render/test-cases/clip-extension.spec.ts
renders `clip-geometry` (PolygonLayer, clipByInstance: false) and
`clip-instance` (ScatterplotLayer) under MapView, GlobeView and
OrthographicView via expandViewMatrix (6 goldens; all show the same
clipped rectangle). Unit spec asserts the `clip.bounds` uniform equals the
Mercator projection of clipBounds on both WebMercatorViewport and
GlobeViewport in geometry mode and stays raw lng/lat in instance mode.

Docs: clip-extension.md gains a Remarks section (GlobeView support,
Mercator evaluation, antimeridian, clipByInstance semantics).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

* fix(extensions, layers): clip in flat space on WebGPU and across the antimeridian

The WGSL layers passed raw geometry.position.xy to clip_filterColor, which
is sphere XY under GlobeView while the bounds are now Mercator. Add
clip_getCoordinates() in the WGSL clip module and use it in
ScatterplotLayer, PathLayer and SolidPolygonLayer.

Both GLSL and WGSL now wrap the flat position around the bounds centre, so
geometry stays continuous across the antimeridian and bounds whose left
edge is east of their right edge clip the intended region instead of
needing two layers. Adds a side-by-side MapView/GlobeView render case.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

* docs(extensions): ClipExtension remarks for antimeridian bounds and clipByInstance

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

* test(render): ClipExtension grid cases with obvious expected results

Replace the San Francisco zip-code data with a 7 x 4 grid of squares and
dots whose bounds cut through known columns and rows, and state the
expected picture for every case in the spec.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

* docs(extensions): ClipExtension GlobeView support in what's new, limitation in Remarks

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

* fix(extensions): wrap clip coordinates per fragment, not per vertex

Wrapping each vertex about the bounds centre tears triangles that straddle
the point 180° from the bounds, so a polygon there leaked a stripe into the
bounds. Keep the varying continuous within each triangle (globe seam opposite
the camera) and wrap in the fragment stage, in GLSL and WGSL.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

* docs(extensions): tighten ClipExtension antimeridian note and render test comments

* docs(extensions): state the 180° condition for antimeridian clip bounds

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

---------

Co-authored-by: Claude <[email protected]>

(cherry picked from commit e1d346d)
[9.4-release] Check only viewport.isGeospatial: project.isCustomProjection comes from #10874, which is not in 9.4, and 9.4 has no custom geospatial projection mode.
@chrisgervang

Copy link
Copy Markdown
Collaborator Author

Released in deck.gl 9.4.2, as #11013 on 9.4.

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.

4 participants