r3-legacy/src/game-lib-d3-api-light.js

124 lines
2.6 KiB
JavaScript
Raw Normal View History

2016-11-29 12:54:25 +01:00
/**
* 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
2017-01-02 17:05:40 +01:00
* @param parentEntity
2016-11-29 12:54:25 +01:00
* @constructor
*/
GameLib.D3.API.Light = function(
id,
lightType,
name,
color,
intensity,
position,
targetPosition,
quaternion,
rotation,
scale,
distance,
decay,
power,
angle,
2017-01-02 17:05:40 +01:00
penumbra,
parentEntity
2016-11-29 12:54:25 +01:00
) {
2017-01-02 17:05:40 +01:00
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_LIGHT,
null,
null,
parentEntity
);
2016-12-15 14:53:39 +01:00
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
2016-11-29 12:54:25 +01:00
}
this.id = id;
2016-12-15 14:53:39 +01:00
if (GameLib.Utils.UndefinedOrNull(lightType)) {
2016-11-29 12:54:25 +01:00
lightType = GameLib.D3.Light.LIGHT_TYPE_AMBIENT;
}
this.lightType = lightType;
2016-12-15 14:53:39 +01:00
if (GameLib.Utils.UndefinedOrNull(name)) {
2016-11-29 12:54:25 +01:00
name = 'Light (' + lightType + ')';
}
this.name = name;
2016-12-15 14:53:39 +01:00
if (GameLib.Utils.UndefinedOrNull(color)) {
2016-12-02 13:00:56 +01:00
color = new GameLib.D3.API.Color(1,1,1,1);
2016-11-29 12:54:25 +01:00
}
this.color = color;
2016-12-15 14:53:39 +01:00
if (GameLib.Utils.UndefinedOrNull(intensity)) {
2016-11-29 12:54:25 +01:00
intensity = 1;
}
this.intensity = intensity;
if (typeof position == 'undefined') {
2016-12-15 14:53:39 +01:00
position = new GameLib.API.Vector3(0,10,0);
2016-11-29 12:54:25 +01:00
}
this.position = position;
if (typeof targetPosition == 'undefined') {
2016-12-15 14:53:39 +01:00
targetPosition = new GameLib.API.Vector3(0,0,0);
2016-11-29 12:54:25 +01:00
}
this.targetPosition = targetPosition;
if (typeof quaternion == 'undefined'){
2016-12-15 14:53:39 +01:00
quaternion = new GameLib.API.Quaternion();
2016-11-29 12:54:25 +01:00
}
this.quaternion = quaternion;
if (typeof rotation == 'undefined'){
2016-12-15 14:53:39 +01:00
rotation = new GameLib.API.Vector3(0,0,0);
2016-11-29 12:54:25 +01:00
}
this.rotation = rotation;
if (typeof scale == 'undefined'){
2016-12-15 14:53:39 +01:00
scale = new GameLib.API.Vector3(1,1,1);
2016-11-29 12:54:25 +01:00
}
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;
2017-01-02 17:05:40 +01:00
};
GameLib.D3.API.Light.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Light.prototype.constructor = GameLib.D3.API.Light;