@@ -139,6 +139,7 @@ class WebGlDisplay extends BasicDisplay {
139
139
private maxPitchGridTopWorld : number [ ] ;
140
140
// vertical offset from top of the screen to the "horizon line" in screen pixels.
141
141
protected horizonY : number ;
142
+
142
143
constructor ( mapEl : HTMLElement , renderTileSize : number , devicePixelRatio : number | string , renderOptions ?: RenderOptions ) {
143
144
super (
144
145
mapEl ,
@@ -578,12 +579,15 @@ class WebGlDisplay extends BasicDisplay {
578
579
}
579
580
580
581
protected pitchMapOffsetY ( pitch : number = this . rx ) {
581
- const { w, h} = this ;
582
- const [ x , maxPitchGridOffset ] = this . maxPitchGridTopWorld ;
583
- const matrix = this . render . updateMapGridMatrix ( pitch , w , h ) ;
584
- const y = this . project ( x , maxPitchGridOffset , 0 , 0 , 0 , matrix ) [ 1 ] ;
585
- this . horizonY = ( 1 - y ) * h / 2 ;
586
- return this . horizonY ;
582
+ let horizonY = 0 ;
583
+ if ( pitch > MAX_PITCH_GRID ) {
584
+ const { w, h} = this ;
585
+ const [ x , maxPitchGridOffset ] = this . maxPitchGridTopWorld ;
586
+ const matrix = this . render . updateMapGridMatrix ( pitch , w , h ) ;
587
+ const y = this . project ( x , maxPitchGridOffset , 0 , 0 , 0 , matrix ) [ 1 ] ;
588
+ horizonY = ( 1 - y ) * h / 2 ;
589
+ }
590
+ return this . horizonY = horizonY ;
587
591
}
588
592
589
593
protected viewport ( dirty ?: boolean ) {
0 commit comments