101 lines
2.3 KiB
JavaScript
101 lines
2.3 KiB
JavaScript
/**
|
|
* R3.D3.Light.Directional
|
|
* @param graphics R3.GraphicsRuntime
|
|
* @param apiHemisphereLight
|
|
* @constructor
|
|
*/
|
|
R3.D3.Light.Hemisphere = function(
|
|
graphics,
|
|
apiHemisphereLight
|
|
) {
|
|
|
|
this.graphics = graphics;
|
|
this.graphics.isNotThreeThrow();
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiHemisphereLight)) {
|
|
apiHemisphereLight = {
|
|
lightType : R3.D3.API.Light.LIGHT_TYPE_HEMISPHERE
|
|
};
|
|
}
|
|
|
|
R3.D3.API.Light.Hemisphere.call(
|
|
this,
|
|
apiHemisphereLight,
|
|
apiHemisphereLight.position,
|
|
apiHemisphereLight.groundColor
|
|
);
|
|
|
|
this.position = new R3.Vector3(
|
|
this.graphics,
|
|
this.position,
|
|
this
|
|
);
|
|
|
|
this.groundColor = new R3.Color(
|
|
this.graphics,
|
|
this.groundColor,
|
|
this
|
|
);
|
|
|
|
R3.D3.Light.call(
|
|
this,
|
|
this.graphics,
|
|
apiHemisphereLight
|
|
);
|
|
|
|
};
|
|
|
|
R3.D3.Light.Hemisphere.prototype = Object.create(R3.D3.Light.prototype);
|
|
R3.D3.Light.Hemisphere.prototype.constructor = R3.D3.Light.Hemisphere;
|
|
|
|
/**
|
|
* Creates a light instance
|
|
* @returns {*}
|
|
*/
|
|
R3.D3.Light.Hemisphere.prototype.createInstance = function() {
|
|
|
|
this.instance = new THREE.HemisphereLight();
|
|
|
|
this.instance.castShadow = this.castShadow;
|
|
|
|
this.instance.position.x = this.position.x;
|
|
this.instance.position.y = this.position.y;
|
|
this.instance.position.z = this.position.z;
|
|
|
|
R3.D3.Light.prototype.createInstance.call(this);
|
|
};
|
|
|
|
/**
|
|
* Updates the instance with the current state
|
|
*/
|
|
R3.D3.Light.Hemisphere.prototype.updateInstance = function(property, oldTarget) {
|
|
|
|
if (property === 'position') {
|
|
this.instance.position.x = this.position.x;
|
|
this.instance.position.y = this.position.y;
|
|
this.instance.position.z = this.position.z;
|
|
return;
|
|
}
|
|
|
|
if (property === 'groundColor') {
|
|
this.instance.groundColor.set(this.color.toHex());
|
|
return;
|
|
}
|
|
|
|
R3.D3.Light.prototype.updateInstance.call(this, property);
|
|
};
|
|
|
|
/**
|
|
* Converts a R3.D3.Light to a R3.D3.API.Light
|
|
* @returns {R3.D3.API.Light}
|
|
*/
|
|
R3.D3.Light.Hemisphere.prototype.toApiObject = function() {
|
|
|
|
var apiHemisphereLight = R3.D3.Light.prototype.toApiObject.call(this);
|
|
|
|
apiHemisphereLight.position = this.position.toApiObject();
|
|
apiHemisphereLight.groundColor = this.groundColor.toApiObject();
|
|
|
|
return apiHemisphereLight;
|
|
};
|