111 lines
2.3 KiB
JavaScript
111 lines
2.3 KiB
JavaScript
|
/**
|
||
|
* Raw Light API object - should always correspond with the Light Schema
|
||
|
* @param id
|
||
|
* @param lightType
|
||
|
* @param name
|
||
|
* @param color
|
||
|
* @param intensity
|
||
|
* @param position
|
||
|
* @param targetPosition
|
||
|
* @param quaternion
|
||
|
* @param rotation
|
||
|
* @param scale
|
||
|
* @param distance
|
||
|
* @param decay
|
||
|
* @param power
|
||
|
* @param angle
|
||
|
* @param penumbra
|
||
|
* @constructor
|
||
|
*/
|
||
|
GameLib.D3.API.Light = function(
|
||
|
id,
|
||
|
lightType,
|
||
|
name,
|
||
|
color,
|
||
|
intensity,
|
||
|
position,
|
||
|
targetPosition,
|
||
|
quaternion,
|
||
|
rotation,
|
||
|
scale,
|
||
|
distance,
|
||
|
decay,
|
||
|
power,
|
||
|
angle,
|
||
|
penumbra
|
||
|
) {
|
||
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||
|
id = GameLib.Utils.RandomId();
|
||
|
}
|
||
|
this.id = id;
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(lightType)) {
|
||
|
lightType = GameLib.D3.Light.LIGHT_TYPE_AMBIENT;
|
||
|
}
|
||
|
this.lightType = lightType;
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||
|
name = 'Light (' + lightType + ')';
|
||
|
}
|
||
|
this.name = name;
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(color)) {
|
||
|
color = new GameLib.D3.API.Color(1,1,1,1);
|
||
|
}
|
||
|
this.color = color;
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(intensity)) {
|
||
|
intensity = 1;
|
||
|
}
|
||
|
this.intensity = intensity;
|
||
|
|
||
|
if (typeof position == 'undefined') {
|
||
|
position = new GameLib.API.Vector3(0,10,0);
|
||
|
}
|
||
|
this.position = position;
|
||
|
|
||
|
if (typeof targetPosition == 'undefined') {
|
||
|
targetPosition = new GameLib.API.Vector3(0,0,0);
|
||
|
}
|
||
|
this.targetPosition = targetPosition;
|
||
|
|
||
|
if (typeof quaternion == 'undefined'){
|
||
|
quaternion = new GameLib.API.Quaternion();
|
||
|
}
|
||
|
this.quaternion = quaternion;
|
||
|
|
||
|
if (typeof rotation == 'undefined'){
|
||
|
rotation = new GameLib.API.Vector3(0,0,0);
|
||
|
}
|
||
|
this.rotation = rotation;
|
||
|
|
||
|
if (typeof scale == 'undefined'){
|
||
|
scale = new GameLib.API.Vector3(1,1,1);
|
||
|
}
|
||
|
this.scale = scale;
|
||
|
|
||
|
if (typeof distance == 'undefined'){
|
||
|
distance = 0;
|
||
|
}
|
||
|
this.distance = distance;
|
||
|
|
||
|
if (typeof decay == 'undefined'){
|
||
|
decay = 1;
|
||
|
}
|
||
|
this.decay = decay;
|
||
|
|
||
|
if (typeof power == 'undefined'){
|
||
|
power = 4 * Math.PI;
|
||
|
}
|
||
|
this.power = power;
|
||
|
|
||
|
if (typeof angle == 'undefined'){
|
||
|
angle = Math.PI / 3;
|
||
|
}
|
||
|
this.angle = angle;
|
||
|
|
||
|
if (typeof penumbra == 'undefined'){
|
||
|
penumbra = 0;
|
||
|
}
|
||
|
this.penumbra = penumbra;
|
||
|
};
|