src/components/light.js
function (data) {
    var angle = data.angle;
    var color = new THREE.Color(data.color);
    this.rendererSystem.applyColorCorrection(color);
    color = color.getHex();
    var decay = data.decay;
    var distance = data.distance;
    var groundColor = new THREE.Color(data.groundColor);
    this.rendererSystem.applyColorCorrection(groundColor);
    groundColor = groundColor.getHex();
    var intensity = data.intensity;
    var type = data.type;
    var target = data.target;
    var light = null;

    switch (type.toLowerCase()) {
      case 'ambient': {
        return new THREE.AmbientLight(color, intensity);
      }

      case 'directional': {
        light = new THREE.DirectionalLight(color, intensity);
        this.defaultTarget = light.target;
        if (target) {
          if (target.hasLoaded) {
            this.onSetTarget(target, light);
          } else {
            target.addEventListener('loaded', bind(this.onSetTarget, this, target, light));
          }
        }
        return light;
      }

      case 'hemisphere': {
        return new THREE.HemisphereLight(color, groundColor, intensity);
      }

      case 'point': {
        return new THREE.PointLight(color, intensity, distance, decay);
      }

      case 'spot': {
        light = new THREE.SpotLight(color, intensity, distance, degToRad(angle), data.penumbra, decay);
        this.defaultTarget = light.target;
        if (target) {
          if (target.hasLoaded) {
            this.onSetTarget(target, light);
          } else {
            target.addEventListener('loaded', bind(this.onSetTarget, this, target, light));
          }
        }
        return light;
      }

      default: {
        warn('%s is not a valid light type. ' +
           'Choose from ambient, directional, hemisphere, point, spot.', type);
      }
    }
  }
function (data) {
    var angle = data.angle;
    var color = new THREE.Color(data.color);
    this.rendererSystem.applyColorCorrection(color);
    color = color.getHex();
    var decay = data.decay;
    var distance = data.distance;
    var groundColor = new THREE.Color(data.groundColor);
    this.rendererSystem.applyColorCorrection(groundColor);
    groundColor = groundColor.getHex();
    var intensity = data.intensity;
    var type = data.type;
    var target = data.target;
    var light = null;

    switch (type.toLowerCase()) {
      case 'ambient': {
        return new THREE.AmbientLight(color, intensity);
      }

      case 'directional': {
        light = new THREE.DirectionalLight(color, intensity);
        this.defaultTarget = light.target;
        if (target) {
          if (target.hasLoaded) {
            this.onSetTarget(target, light);
          } else {
            target.addEventListener('loaded', bind(this.onSetTarget, this, target, light));
          }
        }
        return light;
      }

      case 'hemisphere': {
        return new THREE.HemisphereLight(color, groundColor, intensity);
      }

      case 'point': {
        return new THREE.PointLight(color, intensity, distance, decay);
      }

      case 'spot': {
        light = new THREE.SpotLight(color, intensity, distance, degToRad(angle), data.penumbra, decay);
        this.defaultTarget = light.target;
        if (target) {
          if (target.hasLoaded) {
            this.onSetTarget(target, light);
          } else {
            target.addEventListener('loaded', bind(this.onSetTarget, this, target, light));
          }
        }
        return light;
      }

      default: {
        warn('%s is not a valid light type. ' +
           'Choose from ambient, directional, hemisphere, point, spot.', type);
      }
    }
  }
function ( data ) { var angle = data . angle ; var color = new THREE . Color ( data . color ) ; this . rendererSystem . applyColorCorrection ( color ) ; color = color . getHex ( ) ; var decay = data . decay ; var distance = data . distance ; var groundColor = new THREE . Color ( data . groundColor ) ; this . rendererSystem . applyColorCorrection ( groundColor ) ; groundColor = groundColor . getHex ( ) ; var intensity = data . intensity ; var type = data . type ; var target = data . target ; var light = null ; switch ( type . toLowerCase ( ) ) { case 'ambient' : { return new THREE . AmbientLight ( color , intensity ) ; } case 'directional' : { light = new THREE . DirectionalLight ( color , intensity ) ; this . defaultTarget = light . target ; if ( target ) { if ( target . hasLoaded ) { this . onSetTarget ( target , light ) ; } else { target . addEventListener ( 'loaded' , bind ( this . onSetTarget , this , target , light ) ) ; } } return light ; } case 'hemisphere' : { return new THREE . HemisphereLight ( color , groundColor , intensity ) ; } case 'point' : { return new THREE . PointLight ( color , intensity , distance , decay ) ; } case 'spot' : { light = new THREE . SpotLight ( color , intensity , distance , degToRad ( angle ) , data . penumbra , decay ) ; this . defaultTarget = light . target ; if ( target ) { if ( target . hasLoaded ) { this . onSetTarget ( target , light ) ; } else { target . addEventListener ( 'loaded' , bind ( this . onSetTarget , this , target , light ) ) ; } } return light ; } default : { warn ( '%s is not a valid light type. ' + 'Choose from ambient, directional, hemisphere, point, spot.' , type ) ; } } }
Creates a new three.js light object given data object defining the light.

@param {object} data
Creates a new three . js light object given data object defining the light .