DirectionalLight.js 1.5 KB

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