Repository navigation
[9.4-release] fix(extensions): ClipExtension geometry mode in GlobeView (#10659) - #11013
Conversation
* 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.
[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
SummaryUpdates
No runtime or visual tests were run during this review.
|
| describe.each([ | ||
| 'webgl' | ||
| // 'webgpu' | ||
| ] as const)('%s', deviceType => { |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Follow up of #10659, for #10972
Background
Backports #10659 to
9.4-release. Fixes ClipExtension geometry mode in GlobeView.Change List
-xdraw()checks onlyviewport.isGeospatial. Onmasterit 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 throwsproject.isCustomProjection is not a function.Merge this before #11014, which is stacked on it for the adjacent
whats-new.mdentry.Verified on the full 9.4.2 stack (all 13 backports):
yarn lintand node tests pass. Local headless and render runs were flaky, and nothing failed that does not also fail on9.4-releaseor 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
ClipExtensionto support geometry-mode clipping across viewports includingGlobeView, and adds support for clip bounds that cross the antimeridian.Bounds projection now converts rectangular bounds into flat common space via
projectBoundsToFlatCommonand pairs withproject_common_position_to_flat_continuousin 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.