80 lines
1.8 KiB
JavaScript
80 lines
1.8 KiB
JavaScript
/**
|
|
* Raw Light API object - should always correspond with the Light Schema
|
|
* @constructor
|
|
* @param apiLight
|
|
* @param position
|
|
* @param decay
|
|
* @param distance
|
|
* @param power
|
|
* @param shadow
|
|
*/
|
|
R3.D3.API.Light.Point = function(
|
|
apiLight,
|
|
position,
|
|
decay,
|
|
distance,
|
|
power,
|
|
shadow
|
|
) {
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiLight)) {
|
|
apiLight = {
|
|
lightType : R3.D3.API.Light.LIGHT_TYPE_POINT
|
|
};
|
|
}
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiLight.lightType)) {
|
|
apiLight.lightType = R3.D3.API.Light.LIGHT_TYPE_POINT;
|
|
}
|
|
|
|
/**
|
|
* Light shines from the top
|
|
*/
|
|
if (R3.Utils.UndefinedOrNull(position)) {
|
|
position = new R3.API.Vector3(0,0,0);
|
|
}
|
|
this.position = position;
|
|
|
|
/**
|
|
* In physically correct mode, decay is 2
|
|
*/
|
|
if (R3.Utils.UndefinedOrNull(decay)) {
|
|
decay = 1;
|
|
}
|
|
this.decay = decay;
|
|
|
|
/**
|
|
* In physically correct mode, decay is 2
|
|
*/
|
|
if (R3.Utils.UndefinedOrNull(distance)) {
|
|
distance = 0;
|
|
}
|
|
this.distance = distance;
|
|
|
|
if (R3.Utils.UndefinedOrNull(power)) {
|
|
power = 4 * Math.PI;
|
|
}
|
|
this.power = power;
|
|
|
|
/**
|
|
* It's important not to create the shadow so our runtime component can know whether we loaded from API or not
|
|
*/
|
|
if (R3.Utils.UndefinedOrNull(shadow)) {
|
|
shadow = null;
|
|
}
|
|
this.shadow = shadow;
|
|
|
|
R3.D3.API.Light.call(
|
|
this,
|
|
apiLight.id,
|
|
apiLight.name,
|
|
apiLight.lightType,
|
|
apiLight.color,
|
|
apiLight.intensity,
|
|
apiLight.parentScene,
|
|
apiLight.parentEntity
|
|
);
|
|
};
|
|
|
|
R3.D3.API.Light.Point.prototype = Object.create(R3.D3.API.Light.prototype);
|
|
R3.D3.API.Light.Point.prototype.constructor = R3.D3.API.Light.Point; |