Skip to content

feat(layers): support custom projections in position-based layers - #10742

Merged
Pessimistress merged 10 commits into
masterfrom
x/alt-proj-layer-plumbing
Oct 7, 2026
Merged

Pessimistress merged 10 commits into
masterfrom
x/alt-proj-layer-plumbing

Conversation

@Pessimistress

@Pessimistress Pessimistress commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

For #10739 (PR 3 of 6)

Connect position-based layers to the custom projection infrastructure.

Changed list

  • Enable position transforms across primitive and mesh layers.
  • Adapt path and polygon tessellation to custom projections.
  • Update bitmap coordinate conversion and mesh matrix handling.
  • Document layer compatibility and known limitations.
  • Add layer tests and EPSG:5070 GeoJsonLayer render tests.
  • Add US state GeoJSON fixtures, including Alaska.

Note

Medium Risk
Touches core attribute projection and tessellation paths across many layers; behavior changes for custom projections and wrapLongitude, though standard MapView paths are largely unchanged when transforms are off.

Overview
Extends experimental CustomProjectionView support to most position-driven layers by wiring usePositionTransforms() into scatterplots, lines/arcs, paths, polygons, icons, text, columns, grid cells, point clouds, bitmaps, and instanced mesh layers.

Geometry pipelines now subdivide and normalize in input CRS, then apply the viewport projection once per vertex. Path and polygon tessellators retessellate on projection, coordinate-system, and modelMatrix changes without mutating source data. wrapLongitude and great-circle shortest-path behavior are disabled when the viewport preprojects; BitmapLayer projects a subdivided mesh and skips geographic image-coordinate uniforms in that mode.

Docs and release notes broaden the supported layer list and document bitmap meshing, great-circle, and longitude-wrap limits. Tests cover transform invalidation, WebGPU paths, EPSG:5070 US-states GeoJSON render goldens (WebGL/WebGPU), and a checked-in states fixture.

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

@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 3/5

[High risk] Extends custom projection support across multiple layer types.

The PR does not appear safe to merge until WebGPU binary polygon positions and extruded-wall bindings are corrected.

Findings

  1. P1 Binary polygon positions misbound ▶

Summary

This PR extends CPU preprojection to position-based and mesh layers, adapts path and polygon tessellation, and adds documentation, unit tests, and EPSG:5070 render fixtures.

  • WebGPU binary polygons can bind XY input where the shader requires XYZ positions.
  • WebGPU extruded polygons use an invalid shifted next-vertex layout.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Layer input positions] --> B[Optional input-space tessellation]
  B --> C[CPU preprojection]
  C --> D[Position attributes]
  D --> E[WebGL or WebGPU shaders]
Loading

Reviews (11) · Last reviewed commit: "address comments"

@coveralls

coveralls commented Sep 24, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 83.234% (+0.1%) from 83.091% — x/alt-proj-layer-plumbing into master

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

API and fundamental functionality review of this revision. The source-space preparation → projection → tessellation flow is a useful foundation. I found four integration issues below to address before approval, particularly for binary geometry and the documented Cartesian bypass. This review is based on source and existing-test inspection; I have not run the tests.

Comment thread modules/mesh-layers/src/utils/matrix.ts Resolved

ibgreen commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks Xiaoji — the broader layer integration makes this stack much more useful. Preparing geometry in source space, projecting the generated vertices, then correcting polygon winding and triangulating is a good foundation. The Albers GeoJSON render cases, including Alaska, are valuable coverage.

A few API/directional observations alongside the four inline correctness comments:

  • Bitmap support already includes interior deformation. With a positive resolution, createMesh generates an interior grid with UVs, and this PR projects those grid vertices. The view documentation currently says only the corners are projected; please describe the resolution-dependent behavior and the remaining interpolation error.
  • Raster coordinate semantics still need an explicit contract. The current mesh assumes the image is mapped by interpolation in the view's source coordinates, and _imageCoordinateSystem is ignored. More subdivision improves that approximation, but cannot correct a raster whose UV mapping is defined in a different CRS. As we connect loaders.gl raster/CRS metadata, the image's source CRS and pixel-to-coordinate mapping should remain distinct from the display projection.
  • Reusable refinement fits naturally in math.gl. Projection-aware edge subdivision, polygon triangulation, and interior mesh refinement are separate operations. Our proposed polyline subdivision utility and triangle-mesh subdivision utility, including barycentric provenance for interpolating UVs and other attributes, could support a future projected-error tolerance alongside the current source-unit resolution. deck.gl should continue to decide when refinement is needed and integrate the output with layer attributes, picking, and lifecycle.
  • Preserve the distinction between a projected anchor and a deformed mesh. Instanced models currently keep local meter-sized geometry around converted anchors. That is useful support, but it is a different contract from projecting every mesh vertex through the nonlinear transform; documentation should make that distinction clear.

These broader ideas can be follow-ups. For this PR, I would address the inline issues around WebGPU binary polygons, longitude wrapping, Cartesian mesh transforms, and coordinate-system changes before approval. This is a source review; I have not run the tests.

@Pessimistress
Pessimistress force-pushed the x/alt-proj-layer-plumbing branch from 38ec0c2 to 0581426 Compare October 6, 2026 16:18

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

Stale Bugbot comment from a previous run.

Comment thread modules/mesh-layers/src/utils/matrix.ts Resolved
@Pessimistress
Pessimistress force-pushed the x/alt-proj-layer-plumbing branch from 0581426 to c466aca Compare October 6, 2026 16:26
Base automatically changed from x/alt-proj-custom-projection to master October 6, 2026 18:02
@Pessimistress
Pessimistress force-pushed the x/alt-proj-layer-plumbing branch from c466aca to be34ebc Compare October 6, 2026 18:45
@greptile-apps

greptile-apps Bot commented Oct 6, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P1 Invalid WebGPU neighbor layout modules/layers/src/solid-polygon-layer/solid-polygon-layer.ts:224 ▶

    For extruded polygons on WebGPU, vertexOffset: 1 places nextVertexPositions one full stride into the same buffer layout as vertexPositions. The next-position attribute, including its low part, extends beyond that layout's stride. The side and wireframe models therefore receive an invalid vertex layout and cannot render.

@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 using default effort and found 2 potential issues.

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 be34ebc. Configure here.

@Pessimistress
Pessimistress merged commit a1cca05 into master Oct 7, 2026
8 checks passed
@Pessimistress
Pessimistress deleted the x/alt-proj-layer-plumbing branch October 7, 2026 22:45
@chrisgervang chrisgervang mentioned this pull request Oct 22, 2026
53 of 66 tasks
charlieforward9 added a commit that referenced this pull request Oct 25, 2026
Master now picks the BitmapLayer mesh by subdivision step and image
coordinates by viewport CRS (#10742, #10874), so this branch keeps that
logic and adds only the shouldUpdateState override: a viewport change
alone (GlobeView crossing zoom 12) does not flag props, so the mesh and
coordinate conversion were never rebuilt for tiles reused across it.

GlobeView's resolution now defaults to 0 (no subdivision), so
TerrainLayer detects a globe by the viewport CRS's geocentric frame, as
SolidPolygonLayer does, instead of by resolution. The BitmapLayer test
builds its GlobeViewport with resolution 10, as GlobeView({resolution})
would, and passes image coordinates as 'cartesian' now that
COORDINATE_SYSTEM is no longer exported.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants