Skip to content

Commit 3f21cd0

Browse files
committed
change the mercator horizon heuristic to be continuous, and update render tests.
1 parent 7681959 commit 3f21cd0

File tree

6 files changed

+2
-4
lines changed

6 files changed

+2
-4
lines changed

src/geo/projection/mercator_utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,8 @@ export function unprojectFromWorldCoordinates(worldSize: number, point: Point):
8282
* @returns Horizon above center in pixels.
8383
*/
8484
export function getMercatorHorizon(transform: {pitch: number; cameraToCenterDistance: number}): number {
85-
if (transform.pitch > 85.01) {
86-
return Math.tan(degreesToRadians(89 - transform.pitch)) * transform.cameraToCenterDistance;
87-
}
88-
return Math.tan(degreesToRadians(90 - transform.pitch)) * transform.cameraToCenterDistance * 0.85;
85+
return transform.cameraToCenterDistance * Math.min(Math.tan(degreesToRadians(90 - transform.pitch)) * 0.85,
86+
Math.tan(degreesToRadians(89 - transform.pitch)));
8987
}
9088

9189
export function getBasicProjectionData(overscaledTileID: OverscaledTileID, tilePosMatrix?: mat4, ignoreTerrainMatrix?: boolean): ProjectionData {
17 Bytes
Loading
0 Bytes
Loading
-1.1 KB
Loading
-17 Bytes
Loading
-1.48 KB
Loading

0 commit comments

Comments
 (0)