mirror of
https://github.com/openglobus/openglobus.git
synced 2025-12-08 19:25:27 +00:00
Low altitude camera earth enlightening.
This commit is contained in:
parent
9e02131b55
commit
9984caa5c1
@ -49,6 +49,8 @@ og.control.Sun = function (options) {
|
||||
* @type {Number}
|
||||
*/
|
||||
this._prevDate = 0;
|
||||
|
||||
this._lightOn = false;
|
||||
};
|
||||
|
||||
og.inheritance.extend(og.control.Sun, og.control.BaseControl);
|
||||
@ -81,9 +83,32 @@ og.control.Sun.prototype._draw = function () {
|
||||
|
||||
this._currDate = this.renderer.handler.clock.currentDate;
|
||||
|
||||
if (Math.abs(this._currDate - this._prevDate) > 0.00034 && this.active) {
|
||||
this._prevDate = this._currDate;
|
||||
this.sunlight.setPosition(og.astro.earth.getSunPosition(this._currDate));
|
||||
if (this.renderer.activeCamera.getHeight() < 3923410) {
|
||||
this._lightOn = true;
|
||||
this._f = 1;
|
||||
if (this._k >= 0) {
|
||||
this._k -= 0.01;
|
||||
var rot = og.math.Quaternion.getRotationBetweenVectors(this.sunlight._position.normal(), this.renderer.activeCamera.eye.normal());
|
||||
var r = rot.slerp(og.math.Quaternion.IDENTITY, this._k).normalize();
|
||||
this.sunlight.setPosition(r.mulVec3(this.sunlight._position));
|
||||
} else {
|
||||
this.sunlight.setPosition(this.renderer.activeCamera.eye.scaleTo(149600000000));
|
||||
}
|
||||
} else {
|
||||
this._k = 1;
|
||||
if (this._f >= 0) {
|
||||
this._f -= 0.01;
|
||||
var rot = og.math.Quaternion.getRotationBetweenVectors(this.sunlight._position.normal(), og.astro.earth.getSunPosition(this._currDate).normal());
|
||||
var r = rot.slerp(og.math.Quaternion.IDENTITY, this._f).normalize();
|
||||
this.sunlight.setPosition(r.mulVec3(this.sunlight._position));
|
||||
} else {
|
||||
if (Math.abs(this._currDate - this._prevDate) > 0.00034 && this.active || this._lightOn) {
|
||||
this._lightOn = false;
|
||||
this._prevDate = this._currDate;
|
||||
this.sunlight.setPosition(og.astro.earth.getSunPosition(this._currDate));
|
||||
this._f = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -164,6 +164,15 @@ og.LightSource.prototype.setPosition = function (position) {
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns light source position, or if it is a directional type sets light direction vector.
|
||||
* @public
|
||||
* @returns {og.math.Vector3} - Light source position/direction.
|
||||
*/
|
||||
og.LightSource.prototype.getPosition = function () {
|
||||
return this._position.clone();
|
||||
};
|
||||
|
||||
/**
|
||||
* Set ambient color.
|
||||
* @public
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user