@@ -733,6 +733,7 @@ export class MeshGradientRenderer extends BaseRenderer {
733733 ) as HTMLCanvasElement ;
734734 private targetSize = Vec2 . fromValues ( 0 , 0 ) ;
735735 private currentSize = Vec2 . fromValues ( 0 , 0 ) ;
736+ private isNoCover = true ;
736737 private meshStates : MeshState [ ] = [ ] ;
737738 private _disposed = false ;
738739
@@ -812,16 +813,34 @@ export class MeshGradientRenderer extends BaseRenderer {
812813 latestMeshState . mesh . bind ( ) ;
813814 // 考虑到我们并不逐帧更新网格控制点,因此也不需要重复调用 updateMesh
814815 if ( this . manualControl ) latestMeshState . mesh . updateMesh ( ) ;
815- latestMeshState . alpha = Math . min ( 1 , latestMeshState . alpha + delta / 500 ) ;
816- if ( latestMeshState . alpha >= 1 ) {
817- const deleted = this . meshStates . splice ( 0 , this . meshStates . length - 1 ) ;
816+ if ( this . isNoCover ) {
817+ for ( const state of this . meshStates ) {
818+ state . alpha = Math . max ( 0 , state . alpha - delta / 500 ) ;
819+ }
820+ const deleted = this . meshStates . filter ( ( s ) => s . alpha === 0 ) ;
821+ this . meshStates = this . meshStates . filter ( ( s ) => s . alpha > 0 ) ;
818822 for ( const state of deleted ) {
819823 state . mesh . dispose ( ) ;
820824 state . texture . dispose ( ) ;
821825 }
822- }
823- if ( this . meshStates . length === 1 && latestMeshState . alpha >= 1 ) {
824- canBeStatic = true ;
826+ if ( this . meshStates . length === 0 ) {
827+ canBeStatic = true ;
828+ }
829+ } else {
830+ latestMeshState . alpha = Math . min (
831+ 1 ,
832+ latestMeshState . alpha + delta / 500 ,
833+ ) ;
834+ if ( latestMeshState . alpha >= 1 ) {
835+ const deleted = this . meshStates . splice ( 0 , this . meshStates . length - 1 ) ;
836+ for ( const state of deleted ) {
837+ state . mesh . dispose ( ) ;
838+ state . texture . dispose ( ) ;
839+ }
840+ }
841+ if ( this . meshStates . length === 1 && latestMeshState . alpha >= 1 ) {
842+ canBeStatic = true ;
843+ }
825844 }
826845 }
827846
@@ -922,11 +941,16 @@ export class MeshGradientRenderer extends BaseRenderer {
922941 this . requestTick ( ) ;
923942 }
924943 override async setAlbum (
925- albumSource : string | HTMLImageElement | HTMLVideoElement ,
944+ albumSource ? : string | HTMLImageElement | HTMLVideoElement ,
926945 isVideo ?: boolean ,
927946 ) : Promise < void > {
928- if ( typeof albumSource === "string" && albumSource . trim ( ) . length === 0 )
929- throw new Error ( "Empty album url" ) ;
947+ if (
948+ albumSource === undefined ||
949+ ( typeof albumSource === "string" && albumSource . trim ( ) . length === 0 )
950+ ) {
951+ this . isNoCover = true ;
952+ return ;
953+ }
930954 let res : HTMLImageElement | HTMLVideoElement | null = null ;
931955 let remainRetryTimes = 5 ;
932956 while ( ! res && remainRetryTimes > 0 ) {
@@ -947,7 +971,12 @@ export class MeshGradientRenderer extends BaseRenderer {
947971 remainRetryTimes -- ;
948972 }
949973 }
950- if ( ! res ) return ;
974+ if ( ! res ) {
975+ console . error ( "Failed to load album resource" , albumSource ) ;
976+ this . isNoCover = true ;
977+ return ;
978+ }
979+ this . isNoCover = false ;
951980 // resize image
952981 const c = this . reduceImageSizeCanvas ;
953982 const ctx = c . getContext ( "2d" , {
0 commit comments