All files / engine/Source/Scene DirectionalLight.js

100% Statements 7/7
100% Branches 6/6
100% Functions 1/1
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                                        13x 12x 11x 1x               10x             10x             10x        
import Cartesian3 from "../Core/Cartesian3.js";
import Check from "../Core/Check.js";
import Color from "../Core/Color.js";
import DeveloperError from "../Core/DeveloperError.js";
 
/**
 * A light that gets emitted in a single direction from infinitely far away.
 *
 * @param {object} options Object with the following properties:
 * @param {Cartesian3} options.direction The direction in which light gets emitted.
 * @param {Color} [options.color=Color.WHITE] The color of the light.
 * @param {number} [options.intensity=1.0] The intensity of the light.
 *
 * @exception {DeveloperError} options.direction cannot be zero-length
 *
 * @alias DirectionalLight
 * @constructor
 */
function DirectionalLight(options) {
  //>>includeStart('debug', pragmas.debug);
  Check.typeOf.object("options", options);
  Check.typeOf.object("options.direction", options.direction);
  if (Cartesian3.equals(options.direction, Cartesian3.ZERO)) {
    throw new DeveloperError("options.direction cannot be zero-length");
  }
  //>>includeEnd('debug');
 
  /**
   * The direction in which light gets emitted.
   * @type {Cartesian3}
   */
  this.direction = Cartesian3.clone(options.direction);
 
  /**
   * The color of the light.
   * @type {Color}
   * @default Color.WHITE
   */
  this.color = Color.clone(options.color ?? Color.WHITE);
 
  /**
   * The intensity of the light.
   * @type {number}
   * @default 1.0
   */
  this.intensity = options.intensity ?? 1.0;
}
 
export default DirectionalLight;