Skip to content

Commit

Permalink
further safety against numerical issues near the horizon
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanMOlson committed Oct 22, 2024
1 parent 4edc371 commit 338c78b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ui/handler_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,11 @@ export class HandlerManager {
if (this._map.cameraHelper.useGlobeControls && !tr.isPointOnMapSurface(around)) {
around = tr.centerPoint;
}
const preZoomAroundLoc = tr.screenPointToLocation(panDelta ? around.sub(panDelta) : around);
// If we are rotating about the center point, avoid numerical issues near the horizon by using the transform's
// center directly, instead of computing it from the screen point
const preZoomAroundLoc = around.distSqr(tr.centerPoint) < 1.0e-2 ?
tr.center :
tr.screenPointToLocation(panDelta ? around.sub(panDelta) : around);

if (!terrain) {
// Apply zoom, bearing, pitch, roll
Expand Down

0 comments on commit 338c78b

Please sign in to comment.