Skip to content

[9.4-release] fix(extensions): ClipExtension geometry mode in GlobeView (#10659) - #11013

Merged
chrisgervang merged 1 commit into
9.4-releasefrom
chr/backport-10659-9.4
Nov 3, 2026
Merged

chrisgervang merged 1 commit into
9.4-releasefrom
chr/backport-10659-9.4

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Follow up of #10659, for #10972

Background

Backports #10659 to 9.4-release. Fixes ClipExtension geometry mode in GlobeView.

Change List

  • Original commit, cherry-picked with -x
  • Adapted for 9.4: draw() checks only viewport.isGeospatial. On master it also checks !project.isCustomProjection(viewport), but that helper comes from feat(core): layer coordinateSystem supports arbitrary CRS #10874 (arbitrary CRS), which is not in 9.4, and 9.4 has no custom geospatial projection mode. Without this change, ClipExtension throws project.isCustomProjection is not a function.

Merge this before #11014, which is stacked on it for the adjacent whats-new.md entry.

Verified on the full 9.4.2 stack (all 13 backports): yarn lint and node tests pass. Local headless and render runs were flaky, and nothing failed that does not also fail on 9.4-release or pass when run alone, so CI here is the real check.


Note

Low Risk
Changes are contained within the ClipExtension shader logic and projection helpers, backed by comprehensive unit and render regression tests.

Overview
Updates ClipExtension to support geometry-mode clipping across viewports including GlobeView, and adds support for clip bounds that cross the antimeridian.

Bounds projection now converts rectangular bounds into flat common space via projectBoundsToFlatCommon and pairs with project_common_position_to_flat_continuous in the shaders. For geospatial views, shaders receive the world width uniform to wrap coordinates to the world copy nearest the clip center before bounds testing, preventing edge tearing across the antimeridian. Matching updates are applied across GLSL and WGSL shaders, along with new unit and render tests for globe and antimeridian clipping.

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

* 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 chrisgervang added this to the v9.4 patch releases milestone Nov 3, 2026
@chrisgervang
chrisgervang changed the base branch from 9.4-release to master November 3, 2026 02:40
@chrisgervang
chrisgervang added this pull request to stack #11016 November 3, 2026 02:40
@chrisgervang
chrisgervang removed this pull request from stack #11016 November 3, 2026 02:41
@chrisgervang
chrisgervang changed the base branch from master to 9.4-release November 3, 2026 02:41
@chrisgervang
chrisgervang added this pull request to stack #11017 November 3, 2026 02:41
@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches geometry clipping wherever users attach ClipExtension.

The PR appears safe to merge, with a non-blocking gap in WebGPU image coverage.

Findings

  1. P2 WebGPU clip edges go unchecked ▶

Summary

Updates ClipExtension geometry clipping to use flat coordinates on GlobeView.

  • Geometry clipping follows the same bounds across globe and flat views.

No runtime or visual tests were run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[clipBounds] --> B[Convert bounds to flat coordinates]
  C[Geometry position] --> D[Convert vertices to flat coordinates]
  D --> E[Interpolate across each triangle]
  E --> F[Wrap around bounds centre]
  B --> G[Test bounds]
  F --> G
  G --> H[Discard pixels outside bounds]
Loading

Reviews (1) · Last reviewed commit: "fix(extensions): ClipExtension geometry ..." · Reviewed by Greptile

Comment on lines +184 to +187
describe.each([
'webgl'
// 'webgpu'
] as const)('%s', deviceType => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 WebGPU clip edges go unchecked

This suite disables WebGPU, although the PR changes the WGSL clipping code in three layers. The existing WebGPU module tests check layer setup, not the rendered clip edges. Enable WebGPU for the supported map and orthographic cases, including the antimeridian case, so incorrect coordinates or wrapping cannot pass unnoticed.

Knowledge Base Used: Testing and validation

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not changing this in the backport. WebGPU extension support is partial today. ClipExtension.getShaders() returns {} on WebGPU, and the only clipping is the built-in WGSL path in Scatterplot, Path and SolidPolygon. The disabled WebGPU entry matches the other extension render suites. WebGPU render coverage for clip edges, including the antimeridian case, should come with the WebGPU extension port (#10989), not with this 9.4 backport.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That’s a fair correction. ClipExtension.getShaders() returns {} on WebGPU, and WebGPU clipping is currently a partial, layer-specific WGSL path. Since this is a 9.4 backport and the suite follows the existing extension render-test convention, WebGPU render coverage—including antimeridian cases—belongs with the WebGPU extension port (#10989), not this change. I’m withdrawing the finding.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 82.937% — chr/backport-10659-9.4 into 9.4-release. No base build found for 9.4-release.

@chrisgervang
chrisgervang merged commit e05cda9 into 9.4-release Nov 3, 2026
8 checks passed
@chrisgervang
chrisgervang deleted the chr/backport-10659-9.4 branch November 3, 2026 04:16
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.

2 participants