@@ -213,20 +213,17 @@ export class GlobeTransform implements ITransform {
213213 // Transition handling
214214 private _lastGlobeStateEnabled : boolean = true ;
215215
216- private _lastLargeZoomStateChange : number = - 1000.0 ;
217- private _lastLargeZoomState : boolean = false ;
218-
219216 /**
220217 * Stores when {@link newFrameUpdate} was last called.
221218 * Serves as a unified clock for globe (instead of each function using a slightly different value from `browser.now()`).
222219 */
223- private _lastUpdateTime = browser . now ( ) ;
220+ private _lastUpdateTimeSeconds = browser . now ( ) / 1000.0 ;
224221 /**
225222 * Stores when switch from globe to mercator or back last occurred, for animation purposes.
226223 * This switch can be caused either by the map passing the threshold zoom level,
227224 * or by {@link setGlobeViewAllowed} being called.
228225 */
229- private _lastGlobeChangeTime : number = browser . now ( ) - 10_000 ; // Ten seconds before transform creation
226+ private _lastGlobeChangeTimeSeconds : number = browser . now ( ) / 1000 - 10 ; // Ten seconds before transform creation
230227
231228 private _skipNextAnimation : boolean = true ;
232229
@@ -351,19 +348,18 @@ export class GlobeTransform implements ITransform {
351348 this . _skipNextAnimation = true ;
352349 }
353350 this . _globeProjectionAllowed = allow ;
354- this . _lastGlobeChangeTime = this . _lastUpdateTime ;
351+ this . _lastGlobeChangeTimeSeconds = this . _lastUpdateTimeSeconds ;
355352 }
356353
357354 /**
358355 * Should be called at the beginning of every frame to synchronize the transform with the underlying projection.
359356 */
360357 newFrameUpdate ( ) : TransformUpdateResult {
361- this . _updateErrorCorrectionValue ( ) ;
362-
363- this . _lastUpdateTime = browser . now ( ) ;
358+ this . _lastUpdateTimeSeconds = browser . now ( ) / 1000.0 ;
364359 const oldGlobeRendering = this . isGlobeRendering ;
365360 this . _globeness = this . _computeGlobenessAnimation ( ) ;
366-
361+ // Everything below this comment must happen AFTER globeness update
362+ this . _updateErrorCorrectionValue ( ) ;
367363 this . _calcMatrices ( ) ;
368364
369365 if ( oldGlobeRendering === this . isGlobeRendering ) {
@@ -400,34 +396,25 @@ export class GlobeTransform implements ITransform {
400396 */
401397 private _computeGlobenessAnimation ( ) : number {
402398 // Update globe transition animation
403- const globeState = this . _globeProjectionAllowed ;
404- const currentTime = this . _lastUpdateTime ;
399+ const globeState = this . _globeProjectionAllowed && this . zoom < globeConstants . maxGlobeZoom ;
400+ const currentTimeSeconds = this . _lastUpdateTimeSeconds ;
405401 if ( globeState !== this . _lastGlobeStateEnabled ) {
406- this . _lastGlobeChangeTime = currentTime ;
402+ this . _lastGlobeChangeTimeSeconds = currentTimeSeconds ;
407403 this . _lastGlobeStateEnabled = globeState ;
408404 }
409405
410406 const oldGlobeness = this . _globeness ;
411407
412408 // Transition parameter, where 0 is the start and 1 is end.
413- const globeTransition = Math . min ( Math . max ( ( currentTime - this . _lastGlobeChangeTime ) / 1000.0 / globeConstants . globeTransitionTimeSeconds , 0.0 ) , 1.0 ) ;
409+ const globeTransition = Math . min ( Math . max ( ( currentTimeSeconds - this . _lastGlobeChangeTimeSeconds ) / globeConstants . globeTransitionTimeSeconds , 0.0 ) , 1.0 ) ;
414410 let newGlobeness = globeState ? globeTransition : ( 1.0 - globeTransition ) ;
415411
416412 if ( this . _skipNextAnimation ) {
417413 newGlobeness = globeState ? 1.0 : 0.0 ;
418- this . _lastGlobeChangeTime = currentTime - globeConstants . globeTransitionTimeSeconds * 1000.0 * 2.0 ;
414+ this . _lastGlobeChangeTimeSeconds = currentTimeSeconds - globeConstants . globeTransitionTimeSeconds * 2.0 ;
419415 this . _skipNextAnimation = false ;
420416 }
421417
422- // Update globe zoom transition
423- const currentZoomState = this . zoom >= globeConstants . maxGlobeZoom ;
424- if ( currentZoomState !== this . _lastLargeZoomState ) {
425- this . _lastLargeZoomState = currentZoomState ;
426- this . _lastLargeZoomStateChange = currentTime ;
427- }
428- const zoomTransition = Math . min ( Math . max ( ( currentTime - this . _lastLargeZoomStateChange ) / 1000.0 / globeConstants . zoomTransitionTimeSeconds , 0.0 ) , 1.0 ) ;
429- const zoomGlobenessBound = currentZoomState ? ( 1.0 - zoomTransition ) : zoomTransition ;
430- newGlobeness = Math . min ( newGlobeness , zoomGlobenessBound ) ;
431418 newGlobeness = easeCubicInOut ( newGlobeness ) ; // Smooth animation
432419
433420 if ( oldGlobeness !== newGlobeness ) {
@@ -443,7 +430,7 @@ export class GlobeTransform implements ITransform {
443430
444431 isRenderingDirty ( ) : boolean {
445432 // Globe transition
446- return ( this . _lastUpdateTime - this . _lastGlobeChangeTime ) / 1000.0 < ( Math . max ( globeConstants . globeTransitionTimeSeconds , globeConstants . zoomTransitionTimeSeconds ) ) ;
433+ return ( this . _lastUpdateTimeSeconds - this . _lastGlobeChangeTimeSeconds ) < globeConstants . globeTransitionTimeSeconds ;
447434 }
448435
449436 getProjectionData ( overscaledTileID : OverscaledTileID , aligned ?: boolean , ignoreTerrainMatrix ?: boolean ) : ProjectionData {
0 commit comments