Skip to content

Commit f4a6497

Browse files
committed
further safety against numerical issues near the horizon
1 parent 8c2bb04 commit f4a6497

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ui/handler_manager.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,11 @@ export class HandlerManager {
527527
if (this._map.cameraHelper.useGlobeControls && !tr.isPointOnMapSurface(around)) {
528528
around = tr.centerPoint;
529529
}
530-
const preZoomAroundLoc = tr.screenPointToLocation(panDelta ? around.sub(panDelta) : around);
530+
// If we are rotating about the center point, avoid numerical issues near the horizon by using the transform's
531+
// center directly, instead of computing it from the screen point
532+
const preZoomAroundLoc = around.distSqr(tr.centerPoint) < 1.0e-2 ?
533+
tr.center :
534+
tr.screenPointToLocation(panDelta ? around.sub(panDelta) : around);
531535

532536
if (!terrain) {
533537
// Apply zoom, bearing, pitch, roll

0 commit comments

Comments
 (0)