/
DirectionalLight.js
50 lines (45 loc) · 1.52 KB
/
DirectionalLight.js
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
import Cartesian3 from "../Core/Cartesian3.js";
import Check from "../Core/Check.js";
import Color from "../Core/Color.js";
import defaultValue from "../Core/defaultValue.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(defaultValue(options.color, Color.WHITE));
/**
* The intensity of the light.
* @type {Number}
* @default 1.0
*/
this.intensity = defaultValue(options.intensity, 1.0);
}
export default DirectionalLight;