Repository navigation
feat(core): Viewport classes depend on math.gl projectionEngine - #10872
Conversation
[High impact] The latest changes appear safe to merge with the dependent caller fix in PR #10874. SummaryMoves viewport coordinate conversion and distance scales onto math.gl CRS descriptors. The latest changes let a fresh, equal view retry failed initialization.
|
ibgreen
left a comment
There was a problem hiding this comment.
Approving the descriptor integration as a step in the stacked CRS work. Moving normalization, rendering bounds and local scale estimation into math.gl is the right ownership boundary; deck.gl should retain camera/common-space conventions and GPU scale-field resources. Resolving asynchronously in View and consuming synchronously in Viewport also makes sense.
There is still room to improve math.gl usage: standard built-in descriptors should eventually come from a synchronous math.gl factory/export, and future source-CRS work should consider math.gl's direct CRS-pair converters rather than always routing through WGS84. Inline comments capture these follow-ups and cache retry behavior.
Known limitation: the existing unresolved base Viewport({crs}) shader-origin issue remains in this commit. The author has assigned it to #10874; this approval of the stacked integration does not mean that path is ready to release independently. Please retain regression coverage for finite GPU uniforms and CPU/GPU agreement when completing that work.
Validation: reviewed the viewport/CRS integration, related tests and documentation, and math.gl v5.0.0-alpha.17 descriptor/scale implementation. GitHub CI for this exact head passes test-coverage, test-webgpu, test-python and test-website. Local tests were not run because the environment's configured network proxy was unavailable.
| /** Standard geocentric metre coordinates on the existing deck.gl sphere. | ||
| * Common-space orientation and radius remain the responsibility of GlobeViewport. | ||
| */ | ||
| export const GLOBE_CRS: CRSDescriptor = { |
There was a problem hiding this comment.
Non-blocking math.gl follow-up: can we upstream a synchronous descriptor factory/export for this standard geocentric sphere (and WGS84), then keep only deck-specific common-space orientation and OSMTile512 adaptation here? Calling the geocentric plugin directly preserves synchronous built-in construction, which is useful, but manually assembling units, bounds, normalization and conversion adapters duplicates the descriptor contract implemented by math.gl getCRS. A parity test against getCRS for the same sphere definition would help prevent drift until a synchronous API exists. Preserve the current radius/altitude semantics when doing this.
| const geographic = | ||
| sourceCrs.signature === WGS84_CRS.signature | ||
| ? position | ||
| : sourceCrs.converter.WGS84.to(position); |
There was a problem hiding this comment.
Non-blocking for this WGS84-oriented step: for the upcoming arbitrary source-CRS pipeline, consider preparing math.gl direct source-to-target converters during async resolution. alpha.17 getCRS(definition, {converters: [...]}) already supports these. Always converting source -> WGS84 -> target adds two conversions, including an avoidable inverse/forward round trip when source and target are identical, and can introduce intermediate datum/domain constraints. Keep the dispatch through built-in viewport hooks where Mercator altitude or globe orientation requires it; the generic/custom path is the candidate for direct conversion.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort 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 5a955fc. Configure here.

For #10739
TL;DR
Change List
@math.gl/projection alpha.17crs: CRSDescriptorproperty, dropslongitudelatitude, no longer contains web-mercator projection as geospatial fallbackOSMTile512describes MVT coordinate space.proj=geocentand are aligned to deck.gl common space with viewMatrix. Winding direction is not affected. AddearthModeloption to switch between WGS84 ellipsoid and v9.4/maplibre sphere.projection,toBoundsandgetDistanceScaleoptions. Use math.gl-resolved CRS descriptor to handle coordinate conversion, normalization, bounds, and distance scales.fromCrsin preparation for layer-owned source CRSprojectPosition(position, {sourceCrs})for explicit input CRS conversionNote
High Risk
Breaking changes to base Viewport geospatial defaults and CustomProjectionView API, plus broad refactors of Mercator, globe, and projection shaders that affect coordinate conversion and meter sizing across the stack.
Overview
This PR moves deck.gl’s viewport and experimental custom-projection stack onto
@math.gl/projectionCRS descriptors, instead of app-supplied converters and implicit Mercator fromlongitude/latitude._CustomProjectionView/ viewport / controller now take a requiredcrs(EPSG, PROJ, etc.), resolve it asynchronously viainitialize(), and treat layer positions, camera center, picking, andmaxBoundsas WGS84. Conversion, normalization, rendering bounds, and ground-meter scales come from the descriptor;projection,fromCrs/toCrs,getDistanceScale, andtoBoundsare removed.ProjectionConverteris dropped from public exports.The base
Viewportgains optionalcrs,targetToCommonMatrix, andprojectPosition(..., { sourceCrs }); it no longer auto-selects Web Mercator from lat/lng.WebMercatorViewport,FirstPersonViewport, andGlobeViewportwire in built-in descriptors (OSMTile512, geocentric globe CRS) while keeping their existing camera/shader behavior.resolveCRScaches math.gl loads;ViewManagertracks failed view init so retries work after errors.Aggregation uses a lightweight
AggregationViewportfor linear scaling of preprojected coordinates. Shaderproject_size_to_pixeldrops a custom-geospatial special case; meter sizing follows descriptor Jacobian / texture sampling. Docs, upgrade guide, custom-projection demo, and tests are updated accordingly.Reviewed by Cursor Bugbot for commit 98bd478. Bugbot is set up for automated code reviews on this repo. Configure here.