@@ -44,8 +44,8 @@ export class RenderCamera {
4444
4545 private _state : State ;
4646
47- private _currentBearings : number [ ] [ ] ;
48- private _previousBearings : number [ ] [ ] ;
47+ private _currentBearings : { x : number [ ] [ ] , y : number [ ] [ ] } ;
48+ private _previousBearings : { x : number [ ] [ ] , y : number [ ] [ ] } ;
4949
5050 private _currentFov : number ;
5151 private _previousFov : number ;
@@ -92,8 +92,8 @@ export class RenderCamera {
9292
9393 this . _state = null ;
9494
95- this . _currentBearings = [ ] ;
96- this . _previousBearings = [ ] ;
95+ this . _currentBearings = { x : [ ] , y : [ ] } ;
96+ this . _previousBearings = { x : [ ] , y : [ ] } ;
9797
9898 this . _currentFov = this . _initialFov ;
9999 this . _previousFov = this . _initialFov ;
@@ -393,17 +393,30 @@ export class RenderCamera {
393393 this . perspective . aspect ) ;
394394 }
395395
396- private _computeBearings ( transform : Transform ) : number [ ] [ ] {
397- const vertices = [ [ 0 , 0 ] ] ;
398- const directions = [ [ 1 , 0 ] ] ;
399- const pointsPerLine = 25 ;
396+ private _computeBearings ( transform : Transform ) : { x : number [ ] [ ] , y : number [ ] [ ] } {
397+ const yVertices = [ [ 0 , 0 ] ] ;
398+ const yDirections = [ [ 1 , 0 ] ] ;
399+ const yPointsPerLine = 25 ;
400400
401- return Geo . computeBearings (
401+ const y = Geo . computeBearings (
402402 transform ,
403- vertices ,
404- directions ,
405- pointsPerLine ,
403+ yVertices ,
404+ yDirections ,
405+ yPointsPerLine ,
406406 this . _viewportCoords ) ;
407+
408+ const xVertices = [ [ 0 , 0 ] ] ;
409+ const xDirections = [ [ 0 , 1 ] ] ;
410+ const xPointsPerLine = 25 ;
411+
412+ const x = Geo . computeBearings (
413+ transform ,
414+ xVertices ,
415+ xDirections ,
416+ xPointsPerLine ,
417+ this . _viewportCoords ) ;
418+
419+ return { x : x , y : y } ;
407420 }
408421
409422 private _computeRotation ( camera : Camera ) : EulerRotation {
@@ -417,18 +430,25 @@ export class RenderCamera {
417430 }
418431
419432 private _computeVerticalBearingFov (
420- bearings : number [ ] [ ] ,
433+ bearings : { x : number [ ] [ ] , y : number [ ] [ ] } ,
421434 renderMode : RenderMode ,
422435 zoom : number ,
423436 aspect : number ) : number {
424437
425438 const { _spatial} = this ;
426439
427- const projections = bearings
440+ const yProjections = bearings . y
428441 . map ( b => _spatial . projectToPlane ( b , [ 1 , 0 , 0 ] ) )
429442 . map ( p => [ p [ 1 ] , - p [ 2 ] ] ) ;
430443
431- const fovs = projections . map ( p => 2 * _spatial . radToDeg ( Math . abs ( Math . atan2 ( p [ 0 ] , p [ 1 ] ) ) ) ) ;
444+ const xProjections = bearings . x
445+ . map ( b => _spatial . projectToPlane ( b , [ 0 , 1 , 0 ] ) )
446+ . map ( p => [ p [ 0 ] , - p [ 2 ] ] ) ;
447+
448+ const yFovs = yProjections . map ( p => 2 * _spatial . radToDeg ( Math . abs ( Math . atan2 ( p [ 0 ] , p [ 1 ] ) ) ) ) ;
449+ const xFovs = xProjections . map ( p => 2 * _spatial . radToDeg ( Math . abs ( Math . atan2 ( p [ 0 ] / aspect , p [ 1 ] ) ) ) ) ;
450+ const fovs = [ ...yFovs , ...xFovs ] ;
451+
432452 const vFovMin = fovs . length > 0 ? 0.995 * Math . min ( ...fovs ) : 125 ;
433453 const fovMin = this . _fovToZoomedFov ( vFovMin , zoom ) ;
434454 const fovMax = this . _fovToZoomedFov ( 125 , zoom ) ;
0 commit comments