@@ -12,6 +12,8 @@ import {GlobeTransform} from '../geo/projection/globe_transform';
1212import { getZoomAdjustment } from '../geo/projection/globe_utils' ;
1313import { GlobeCameraHelper } from '../geo/projection/globe_camera_helper' ;
1414import { MercatorCameraHelper } from '../geo/projection/mercator_camera_helper' ;
15+ import { getMercatorHorizon } from '../geo/projection/mercator_utils' ;
16+ import Point from '@mapbox/point-geometry' ;
1517
1618import type { GlobeProjection } from '../geo/projection/globe_projection' ;
1719import type { Terrain } from '../render/terrain' ;
@@ -908,6 +910,24 @@ describe('easeTo', () => {
908910 expect ( fixedLngLat ( camera . getCenter ( ) ) ) . toEqual ( { lng : 170.3125 , lat : 0 } ) ;
909911 } ) ;
910912
913+ test ( 'offset computed from inertia (small) does not cross horizon when pitched' , ( ) => {
914+ const camera = createCamera ( { pitch : 85 , zoom : 10 } ) ;
915+ const easeOptions = camera . cameraHelper . handlePanInertia ( new Point ( 0 , 100 ) , camera . transform ) ;
916+ expect ( easeOptions . easingOffset . mag ( ) ) . toBeLessThan ( Math . abs ( getMercatorHorizon ( camera . transform ) ) ) ;
917+ } ) ;
918+
919+ test ( 'offset computed from inertia (large) does not cross horizon when pitched' , ( ) => {
920+ const camera = createCamera ( { pitch : 85 , zoom : 10 } ) ;
921+ const easeOptions = camera . cameraHelper . handlePanInertia ( new Point ( 0 , 500 ) , camera . transform ) ;
922+ expect ( easeOptions . easingOffset . mag ( ) ) . toBeLessThan ( Math . abs ( getMercatorHorizon ( camera . transform ) ) ) ;
923+ } ) ;
924+
925+ test ( 'offset computed from inertia (large) does not cross horizon when pitched and rotated' , ( ) => {
926+ const camera = createCamera ( { pitch : 85 , bearing : 135 , zoom : 10 } ) ;
927+ const easeOptions = camera . cameraHelper . handlePanInertia ( new Point ( 0 , 500 ) , camera . transform ) ;
928+ expect ( easeOptions . easingOffset . mag ( ) ) . toBeLessThan ( Math . abs ( getMercatorHorizon ( camera . transform ) ) ) ;
929+ } ) ;
930+
911931 test ( 'zooms with specified offset' , ( ) => {
912932 const camera = createCamera ( ) ;
913933 camera . easeTo ( { zoom : 3.2 , offset : [ 100 , 0 ] , duration : 0 } ) ;
@@ -2917,6 +2937,24 @@ describe('easeTo globe projection', () => {
29172937 expect ( fixedLngLat ( camera . getCenter ( ) ) ) . toEqual ( { lng : - 175.50457909 , lat : 0 } ) ;
29182938 } ) ;
29192939
2940+ test ( 'offset computed from inertia (small) does not cross horizon when pitched' , ( ) => {
2941+ const camera = createCameraGlobe ( { pitch : 85 , zoom : 10 } ) ;
2942+ const easeOptions = camera . cameraHelper . handlePanInertia ( new Point ( 0 , 100 ) , camera . transform ) ;
2943+ expect ( easeOptions . easingOffset . mag ( ) ) . toBeLessThan ( Math . abs ( getMercatorHorizon ( camera . transform ) ) ) ;
2944+ } ) ;
2945+
2946+ test ( 'offset computed from inertia (large) does not cross horizon when pitched' , ( ) => {
2947+ const camera = createCameraGlobe ( { pitch : 85 , zoom : 10 } ) ;
2948+ const easeOptions = camera . cameraHelper . handlePanInertia ( new Point ( 0 , 500 ) , camera . transform ) ;
2949+ expect ( easeOptions . easingOffset . mag ( ) ) . toBeLessThan ( Math . abs ( getMercatorHorizon ( camera . transform ) ) ) ;
2950+ } ) ;
2951+
2952+ test ( 'offset computed from inertia (large) does not cross horizon when pitched and rotated' , ( ) => {
2953+ const camera = createCameraGlobe ( { pitch : 85 , bearing : 135 , zoom : 10 } ) ;
2954+ const easeOptions = camera . cameraHelper . handlePanInertia ( new Point ( 0 , 500 ) , camera . transform ) ;
2955+ expect ( easeOptions . easingOffset . mag ( ) ) . toBeLessThan ( Math . abs ( getMercatorHorizon ( camera . transform ) ) ) ;
2956+ } ) ;
2957+
29202958 test ( 'zooms with specified offset' , ( ) => {
29212959 const camera = createCameraGlobe ( ) ;
29222960 camera . easeTo ( { zoom : 3.2 , offset : [ 100 , 0 ] , duration : 0 } ) ;
0 commit comments