@@ -424,35 +424,33 @@ function drawIce() {
424424 const { temp, h} = cells ;
425425 Math . random = aleaPRNG ( seed ) ;
426426
427- const ICEBERG_MAX_TEMP = 1 ;
428- const ICE_SHIELD_MAX_TEMP = - 8 ;
427+ const ICEBERG_MAX_TEMP = 0 ;
428+ const GLACIER_MAX_TEMP = - 8 ;
429+ const minMaxTemp = d3 . min ( temp ) ;
429430
430- // very cold: draw ice shields
431+ // cold land : draw glaciers
431432 {
432433 const type = "iceShield" ;
433- const getType = cellId => ( temp [ cellId ] <= ICE_SHIELD_MAX_TEMP ? type : null ) ;
434+ const getType = cellId => ( h [ cellId ] >= 20 && temp [ cellId ] <= GLACIER_MAX_TEMP ? type : null ) ;
434435 const isolines = getIsolines ( grid , getType , { polygons : true } ) ;
435436 isolines [ type ] ?. polygons ?. forEach ( points => {
436437 const clipped = clipPoly ( points ) ;
437438 ice . append ( "polygon" ) . attr ( "points" , clipped ) . attr ( "type" , type ) ;
438439 } ) ;
439440 }
440441
441- // mildly cold: draw icebergs
442+ // cold water : draw icebergs
442443 for ( const cellId of grid . cells . i ) {
443444 const t = temp [ cellId ] ;
444- if ( t > ICEBERG_MAX_TEMP ) continue ; // too warm: no icebergs
445- if ( t <= ICE_SHIELD_MAX_TEMP ) continue ; // already drawn as ice shield
446445 if ( h [ cellId ] >= 20 ) continue ; // no icebergs on land
446+ if ( t > ICEBERG_MAX_TEMP ) continue ; // too warm: no icebergs
447447 if ( features [ cells . f [ cellId ] ] . type === "lake" ) continue ; // no icebers on lakes
448+ if ( P ( 0.8 ) ) continue ; // skip most of eligible cells
448449
449- const tNormalized = normalize ( t , - 8 , 2 ) ;
450- const randomFactor = t > - 5 ? 0.4 + rand ( ) * 1.2 : 1 ;
451- if ( P ( tNormalized ** 0.5 * randomFactor ) ) continue ; // cold: skip some cells
452-
453- let defaultSize = 1 - tNormalized ; // iceberg size: 0 = zero size, 1 = full size
454- if ( cells . t [ cellId ] === - 1 ) defaultSize /= 1.3 ; // coasline: smaller icebergs
455- const size = minmax ( rn ( defaultSize * randomFactor , 2 ) , 0.08 , 1 ) ;
450+ const randomFactor = 0.8 + rand ( ) * 0.4 ; // random size factor
451+ let baseSize = ( 1 - normalize ( t , minMaxTemp , 1 ) ) * 0.8 ; // size: 0 = zero size, 1 = full size
452+ if ( cells . t [ cellId ] === - 1 ) baseSize /= 1.3 ; // coasline: smaller icebergs
453+ const size = minmax ( rn ( baseSize * randomFactor , 2 ) , 0.1 , 1 ) ;
456454
457455 const [ cx , cy ] = grid . points [ cellId ] ;
458456 const points = getGridPolygon ( cellId ) . map ( ( [ x , y ] ) => [ rn ( lerp ( cx , x , size ) , 2 ) , rn ( lerp ( cy , y , size ) , 2 ) ] ) ;
0 commit comments