Changed setPosition to setPosition3v in the lightSource .

This commit is contained in:
Zemledelec 2019-07-17 18:44:11 +03:00
parent 1b72ef45a6
commit 42856fdfe3
2 changed files with 19 additions and 6 deletions

View File

@ -124,9 +124,9 @@ class Sun extends Control {
this._k -= 0.01;
var rot = Quat.getRotationBetweenVectors(this.sunlight._position.normal(), pos.normal());
var r = rot.slerp(Quat.IDENTITY, this._k).normalize();
this.sunlight.setPosition(r.mulVec3(this.sunlight._position));
this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
} else {
this.sunlight.setPosition(pos);
this.sunlight.setPosition3v(pos);
}
} else {
this._k = 1;
@ -134,18 +134,18 @@ class Sun extends Control {
this._f -= 0.01;
var rot = Quat.getRotationBetweenVectors(this.sunlight._position.normal(), getSunPosition(this._currDate).normal());
var r = rot.slerp(Quat.IDENTITY, this._f).normalize();
this.sunlight.setPosition(r.mulVec3(this.sunlight._position));
this.sunlight.setPosition3v(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(getSunPosition(this._currDate));
this.sunlight.setPosition3v(getSunPosition(this._currDate));
this._f = 0;
}
}
}
} else {
this.sunlight.setPosition(getSunPosition(this._currDate));
this.sunlight.setPosition3v(getSunPosition(this._currDate));
}
}
}

View File

@ -161,13 +161,26 @@ class LightSource {
* @param {og.Vec3} position - Light position or direction vector.
* @returns {og.LightSource}
*/
setPosition(position) {
setPosition3v(position) {
this._position.x = position.x;
this._position.y = position.y;
this._position.z = position.z;
return this;
}
/**
* Set light source position, or if it is a directional type sets light direction vector.
* @public
* @param {og.Vec3} position - Light position or direction vector.
* @returns {og.LightSource}
*/
setPosition(x, y, z) {
this._position.x = x;
this._position.y = y;
this._position.z = z;
return this;
}
/**
* Returns light source position, or if it is a directional type sets light direction vector.
* @public