index.js
function (skyType, sunHeight) {

    var fogColor;
    if (skyType == 'color' || skyType == 'none'){
      fogColor = new THREE.Color(this.data.skyColor);
    }
    else if (skyType == 'gradient'){
      fogColor = new THREE.Color(this.data.horizonColor);
    }
    else if (skyType == 'atmosphere')
    {
      var fogRatios = [        1,       0.5,      0.22,       0.1,      0.05,     0];
      var fogColors = ['#C0CDCF', '#81ADC5', '#525e62', '#2a2d2d', '#141616', '#000'];

      if (sunHeight <= 0) return '#000';

      sunHeight = Math.min(1, sunHeight);

      for (var i = 0; i < fogRatios.length; i++){
        if (sunHeight > fogRatios[i]){
          var c1 = new THREE.Color(fogColors[i - 1]);
          var c2 = new THREE.Color(fogColors[i]);
          var a = (sunHeight - fogRatios[i]) / (fogRatios[i - 1] - fogRatios[i]);
          c2.lerp(c1, a);
          fogColor = c2;
          break;
        }
      }
    }
    // dim down the color
    fogColor.multiplyScalar(0.9);
    // mix it a bit with ground color
    fogColor.lerp(new THREE.Color(this.data.groundColor), 0.3);

    return '#' + fogColor.getHexString();
  }
function (skyType, sunHeight) {

    var fogColor;
    if (skyType == 'color' || skyType == 'none'){
      fogColor = new THREE.Color(this.data.skyColor);
    }
    else if (skyType == 'gradient'){
      fogColor = new THREE.Color(this.data.horizonColor);
    }
    else if (skyType == 'atmosphere')
    {
      var fogRatios = [        1,       0.5,      0.22,       0.1,      0.05,     0];
      var fogColors = ['#C0CDCF', '#81ADC5', '#525e62', '#2a2d2d', '#141616', '#000'];

      if (sunHeight <= 0) return '#000';

      sunHeight = Math.min(1, sunHeight);

      for (var i = 0; i < fogRatios.length; i++){
        if (sunHeight > fogRatios[i]){
          var c1 = new THREE.Color(fogColors[i - 1]);
          var c2 = new THREE.Color(fogColors[i]);
          var a = (sunHeight - fogRatios[i]) / (fogRatios[i - 1] - fogRatios[i]);
          c2.lerp(c1, a);
          fogColor = c2;
          break;
        }
      }
    }
    // dim down the color
    fogColor.multiplyScalar(0.9);
    // mix it a bit with ground color
    fogColor.lerp(new THREE.Color(this.data.groundColor), 0.3);

    return '#' + fogColor.getHexString();
  }
function ( skyType , sunHeight ) { var fogColor ; if ( skyType == 'color' || skyType == 'none' ) { fogColor = new THREE . Color ( this . data . skyColor ) ; } else if ( skyType == 'gradient' ) { fogColor = new THREE . Color ( this . data . horizonColor ) ; } else if ( skyType == 'atmosphere' ) { var fogRatios = [ 1 , 0.5 , 0.22 , 0.1 , 0.05 , 0 ] ; var fogColors = [ '#C0CDCF' , '#81ADC5' , '#525e62' , '#2a2d2d' , '#141616' , '#000' ] ; if ( sunHeight <= 0 ) return '#000' ; sunHeight = Math . min ( 1 , sunHeight ) ; for ( var i = 0 ; i < fogRatios . length ; i ++ ) { if ( sunHeight > fogRatios [ i ] ) { var c1 = new THREE . Color ( fogColors [ i - 1 ] ) ; var c2 = new THREE . Color ( fogColors [ i ] ) ; var a = ( sunHeight - fogRatios [ i ] ) / ( fogRatios [ i - 1 ] - fogRatios [ i ] ) ; c2 . lerp ( c1 , a ) ; fogColor = c2 ; break ; } } } // dim down the color fogColor . multiplyScalar ( 0.9 ) ; // mix it a bit with ground color fogColor . lerp ( new THREE . Color ( this . data . groundColor ) , 0.3 ) ; return '#' + fogColor . getHexString ( ) ; }
returns a fog color from a specific sky type and sun height
returns a fog color from a specific sky type and sun height