Skip to content

feat(GlobeController): terrain-aware default#10379

Open
charlieforward9 wants to merge 1 commit into
masterfrom
codex/globe-controller-terrain
Open

feat(GlobeController): terrain-aware default#10379
charlieforward9 wants to merge 1 commit into
masterfrom
codex/globe-controller-terrain

Conversation

@charlieforward9

@charlieforward9 charlieforward9 commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Goal

Make the default GlobeView controller terrain-aware — following picked 3D terrain during navigation — without applications swapping controller classes, and without the globe inheriting Web-Mercator (MapController) semantics.

Approach (updated)

An earlier revision had GlobeController extend TerrainController extends MapController, which required a normalize:false / maxBounds band-aid to stop Mercator constraints from leaking onto the globe (they inflated globe zoom and halved the pan rate). This reworks it as a mixin so the globe stays free of Mercator semantics:

  • New withTerrain(Base) mixin — holds the terrain-follow logic (per-frame altitude polling via pickPosition, altitude smoothing, viewport rebasing), retyped to a generic controller state.
  • TerrainController = withTerrain(MapController) — behavior, props, and instanceof MapController unchanged.
  • GlobeController = withTerrain(Controller) — terrain-aware without inheriting MapController; the Mercator band-aid is removed (constrained globe pan/zoom is now structurally correct rather than patched).
  • rotationPivot + _getAltitude moved to the base Controller — so the globe inherits rotate-around-the-picked-3D-point. MapController keeps only its Mercator position/maxBounds handling in setProps.
  • GlobeViewport#panByPosition3D — globe-native 3D anchor used by terrain rebasing and the rotation pivot.

Public API is unchanged: MapView → MapController, GlobeView → GlobeController, identical exports.

Tests (25/25 headless)

  • controllers.spec — terrain-aware default now asserts instanceof GlobeController + rotationPivot: '3d' (no longer instanceof TerrainController).
  • view-states.spec — constrained globe pan/zoom correct without the band-aid.
  • globe-viewport.specpanByPosition3D.

@coveralls

coveralls commented Jun 13, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 83.589% (+0.2%) from 83.424% — codex/globe-controller-terrain into master

@charlieforward9 charlieforward9 self-assigned this Jun 13, 2026
@charlieforward9 charlieforward9 requested review from chrisgervang and felixpalmer and removed request for felixpalmer June 13, 2026 17:18
@charlieforward9 charlieforward9 marked this pull request as ready for review June 13, 2026 17:18
@charlieforward9 charlieforward9 changed the title [codex] Add terrain-aware GlobeController default feat(GlobeController): Add terrain-aware GlobeController default Jun 13, 2026
@charlieforward9 charlieforward9 changed the title feat(GlobeController): Add terrain-aware GlobeController default feat(GlobeController): terrain-aware default Jun 13, 2026
@chrisgervang

Copy link
Copy Markdown
Collaborator

Any limitations or drawbacks to changing the base class?

Is the old behavior available with a prop change, or is this backwards compatible OOB? (Note on upgrade guide if there's a change to default behavior)

@charlieforward9 charlieforward9 force-pushed the codex/globe-controller-terrain branch from cb10b51 to ff43398 Compare June 16, 2026 16:25
@charlieforward9

Copy link
Copy Markdown
Collaborator Author

@chrisgervang

I was noticing some issues with interactivity when extending the MapController within the GlobeController.

I experiemented with a terrain mixin for controllers that can be applied ontop of MapController and GlobeController independently, and believe this is a much more robust approach to getting terrain handling to work for any controller without duplicating a bunch of logic

Lets see what @felixpalmer thinks?

@chrisgervang

Copy link
Copy Markdown
Collaborator

Yeah I think it'd be ideal to keep the inheritance tree shallow and instead composite this enhancement in with something like a mixin or just two independent implementations.

@charlieforward9 charlieforward9 force-pushed the codex/globe-controller-terrain branch from ff43398 to 480a5ad Compare June 16, 2026 16:53
Extract terrain-following into a reusable withTerrain(Base) mixin so GlobeController
is terrain-aware WITHOUT inheriting MapController (removing the maxBounds/normalize
band-aid). TerrainController becomes withTerrain(MapController); public API unchanged.

Move rotationPivot + _getAltitude to the base Controller so the globe inherits
rotate-around-pivot; MapController keeps only its mercator position/maxBounds in setProps.
Add GlobeViewport.panByPosition3D for 3D-anchored panning.
@charlieforward9 charlieforward9 force-pushed the codex/globe-controller-terrain branch from 480a5ad to 1610755 Compare June 16, 2026 17:36
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