Repository navigation
fix(extensions): ClipExtension geometry mode in GlobeView - #10659
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
[Medium impact] The PR appears safe to merge; the latest change addresses the remaining documentation finding. SummaryThis PR fixes geometry clipping on
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 |
7ebc767 to
4f07d3d
Compare
6f345ea to
b7b043f
Compare
12dfcb6 to
e725942
Compare
8b159e5 to
e346826
Compare
e346826 to
d0e81fa
Compare
|
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. |
d0e81fa to
64fe687
Compare
ibgreen
left a comment
There was a problem hiding this comment.
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
…lipByInstance 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
…tation in Remarks Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
64fe687 to
e61aed0
Compare
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
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
…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.
|
Released in deck.gl 9.4.2, as #11013 on 9.4. |

Follow up of #10657
Background
ClipExtensionin geometry mode comparesgeometry.position.xywithclipBoundsprojected bylayer.projectPosition(). UnderGlobeViewboth are sphere XYZ, so a clippedPolygonLayerrenders as a single diagonal stripe instead of the clipped rectangle. Instance mode compares raw lng/lat and is already correct.clip-geometry-globe: 7 x 4 grid of squares clipped to 5 x 4 with trimmed edges, San Francisco at zoom 11.5clip-geometry-antimeridian-map-vs-globe:MapViewleft,GlobeViewright, bounds crossing 180°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 onGlobeView. The instance-mode cases pass on master and are coverage only.Change List
ClipExtensiongeometry mode (GLSL): vertex shader passesproject_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, anddraw()setsclip.boundswithprojectBoundsToFlatCommon; instance mode unchangedclipmodule: addclip_getCoordinates()andclip_isGeometryInBounds()with the same flatten and per-fragment wrap, used byScatterplotLayer,PathLayerandSolidPolygonLayerinstead of rawgeometry.position.xy, so WebGPU compares the same space as the bounds[170, -20, -170, 20]) clip the intended region instead of needing two layersclip-extension.spec.ts(Clip had none).clip-geometrydraws a 7 x 4 grid of squares whose bounds cut through the second and sixth columns and the first and last rows;clip-instancedraws dots at the square centres. Each renders underMapView,GlobeViewandOrthographicView(6 goldens) and the spec states the expected picture per caseclip-geometry-antipode.png:MapViewfrom 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 edgeclip-geometry-antimeridian-map-vs-globe.png:MapView(left) andGlobeView(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 halfclip.boundsequals the Mercator projection ofclipBoundson both viewports in geometry mode and stays raw lng/lat in instance modedocs/whats-new.mdGlobeView compatibility bullet;clip-extension.mdclipBoundsnotes antimeridian bounds, geometry mode onlyRan the render spec headless on WebGL, the unit spec,
tscand lint. WebGPU was not run here; the WGSL change mirrors the GLSL one.Generated by Claude Code