feat(GlobeController): terrain-aware default#10379
Conversation
|
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) |
cb10b51 to
ff43398
Compare
|
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? |
|
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. |
ff43398 to
480a5ad
Compare
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.
480a5ad to
1610755
Compare
Goal
Make the default
GlobeViewcontroller 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 anormalize:false/maxBoundsband-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:withTerrain(Base)mixin — holds the terrain-follow logic (per-frame altitude polling viapickPosition, altitude smoothing, viewport rebasing), retyped to a generic controller state.TerrainController = withTerrain(MapController)— behavior, props, andinstanceof MapControllerunchanged.GlobeController = withTerrain(Controller)— terrain-aware without inheritingMapController; the Mercator band-aid is removed (constrained globe pan/zoom is now structurally correct rather than patched).rotationPivot+_getAltitudemoved to the baseController— so the globe inherits rotate-around-the-picked-3D-point.MapControllerkeeps only its Mercatorposition/maxBoundshandling insetProps.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 assertsinstanceof GlobeController+rotationPivot: '3d'(no longerinstanceof TerrainController).view-states.spec— constrained globe pan/zoom correct without the band-aid.globe-viewport.spec—panByPosition3D.