@@ -70,7 +70,10 @@ function configureOptions(inputOptions: CubemapLayerConstructorOptions | true, d
70
70
71
71
// path / faces will not be defined at this point
72
72
// 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 ;
74
77
}
75
78
76
79
class CubemapLayer implements CustomLayerInterface {
@@ -346,6 +349,7 @@ class CubemapLayer implements CustomLayerInterface {
346
349
}
347
350
this . imageIsAnimating = false ;
348
351
this . imageFadeInDelta = 0.0 ;
352
+ return ;
349
353
} ;
350
354
351
355
requestAnimationFrame ( animateIn ) ;
@@ -362,7 +366,7 @@ class CubemapLayer implements CustomLayerInterface {
362
366
return Promise . resolve ( ) ; // If already animating, just resolve
363
367
}
364
368
return new Promise ( ( resolve ) => {
365
- const animateIn = ( ) => {
369
+ const animateOut = ( ) => {
366
370
this . imageFadeInDelta = Math . min ( this . imageFadeInDelta + 0.05 , 1.0 ) ;
367
371
this . currentFadeOpacity = lerp ( 1.0 , 0.0 , this . imageFadeInDelta ) ;
368
372
this . map . triggerRepaint ( ) ;
@@ -373,10 +377,10 @@ class CubemapLayer implements CustomLayerInterface {
373
377
resolve ( ) ;
374
378
return ;
375
379
}
376
- requestAnimationFrame ( animateIn ) ;
380
+ requestAnimationFrame ( animateOut ) ;
377
381
} ;
378
382
379
- requestAnimationFrame ( animateIn ) ;
383
+ requestAnimationFrame ( animateOut ) ;
380
384
} ) ;
381
385
}
382
386
@@ -500,17 +504,20 @@ class CubemapLayer implements CustomLayerInterface {
500
504
* Finally, it calls `updateCubemap` to apply the changes and trigger a repaint of the map.
501
505
*/
502
506
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
-
508
507
const facesKey = JSON . stringify ( cubemap . faces ?? cubemap . preset ?? cubemap . path ) ;
509
508
510
509
if ( facesKey && this . currentFacesDefinitionKey !== facesKey ) {
511
510
await this . setCubemapFaces ( cubemap ) ;
512
511
}
513
512
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
+
514
521
this . updateCubemap ( ) ;
515
522
}
516
523
0 commit comments