@@ -70,7 +70,10 @@ function configureOptions(inputOptions: CubemapLayerConstructorOptions | true, d
7070
7171 // path / faces will not be defined at this point
7272 // so we don't need to delete them
73- return outputOptions as CubemapLayerConstructorOptions ;
73+ return {
74+ ...outputOptions ,
75+ color : outputOptions . color ?? cubemapPresets [ presetName ] . color ?? "hsl(233,100%,92%)" ,
76+ } as CubemapLayerConstructorOptions ;
7477}
7578
7679class CubemapLayer implements CustomLayerInterface {
@@ -346,6 +349,7 @@ class CubemapLayer implements CustomLayerInterface {
346349 }
347350 this . imageIsAnimating = false ;
348351 this . imageFadeInDelta = 0.0 ;
352+ return ;
349353 } ;
350354
351355 requestAnimationFrame ( animateIn ) ;
@@ -362,7 +366,7 @@ class CubemapLayer implements CustomLayerInterface {
362366 return Promise . resolve ( ) ; // If already animating, just resolve
363367 }
364368 return new Promise ( ( resolve ) => {
365- const animateIn = ( ) => {
369+ const animateOut = ( ) => {
366370 this . imageFadeInDelta = Math . min ( this . imageFadeInDelta + 0.05 , 1.0 ) ;
367371 this . currentFadeOpacity = lerp ( 1.0 , 0.0 , this . imageFadeInDelta ) ;
368372 this . map . triggerRepaint ( ) ;
@@ -373,10 +377,10 @@ class CubemapLayer implements CustomLayerInterface {
373377 resolve ( ) ;
374378 return ;
375379 }
376- requestAnimationFrame ( animateIn ) ;
380+ requestAnimationFrame ( animateOut ) ;
377381 } ;
378382
379- requestAnimationFrame ( animateIn ) ;
383+ requestAnimationFrame ( animateOut ) ;
380384 } ) ;
381385 }
382386
@@ -500,17 +504,20 @@ class CubemapLayer implements CustomLayerInterface {
500504 * Finally, it calls `updateCubemap` to apply the changes and trigger a repaint of the map.
501505 */
502506 public async setCubemap ( cubemap : CubemapDefinition ) : Promise < void > {
503- const color = parseColorStringToVec4 ( cubemap . color ) ;
504- if ( cubemap . color && this . targetBgColor . toString ( ) !== color . toString ( ) ) {
505- this . setBgColor ( color ) ;
506- }
507-
508507 const facesKey = JSON . stringify ( cubemap . faces ?? cubemap . preset ?? cubemap . path ) ;
509508
510509 if ( facesKey && this . currentFacesDefinitionKey !== facesKey ) {
511510 await this . setCubemapFaces ( cubemap ) ;
512511 }
513512
513+ const color = parseColorStringToVec4 ( cubemap . color ) ;
514+ if ( cubemap . color && this . targetBgColor . toString ( ) !== color . toString ( ) ) {
515+ this . setBgColor ( color ) ;
516+ } else if ( cubemap . preset && cubemap . preset in cubemapPresets ) {
517+ const preset = cubemapPresets [ cubemap . preset ] ;
518+ this . setBgColor ( parseColorStringToVec4 ( preset . color ) ) ;
519+ }
520+
514521 this . updateCubemap ( ) ;
515522 }
516523
0 commit comments