Smoother camera hermite move
This commit is contained in:
parent
06976bd845
commit
b1cf8afaaf
|
@ -64,7 +64,15 @@ PointerCamera.prototype.constructor = PointerCamera;
|
|||
// Update function
|
||||
PointerCamera.prototype.update = function() {
|
||||
if (this.moving) {
|
||||
// Linear motion
|
||||
this.linearMotion();
|
||||
} else if (this.movingHermite) {
|
||||
this.hermiteMotion();
|
||||
} else {
|
||||
this.normalMotion();
|
||||
}
|
||||
}
|
||||
|
||||
PointerCamera.prototype.linearMotion = function() {
|
||||
var position_direction = Tools.diff(this.new_position, this.position);
|
||||
var target_direction = Tools.diff(this.new_target, this.target);
|
||||
|
||||
|
@ -76,9 +84,9 @@ PointerCamera.prototype.update = function() {
|
|||
this.moving = false;
|
||||
this.anglesFromVectors();
|
||||
}
|
||||
}
|
||||
|
||||
} else if (this.movingHermite) {
|
||||
// Hermite polynom version
|
||||
PointerCamera.prototype.hermiteMotion = function() {
|
||||
var eval = this.hermitePosition.eval(this.t);
|
||||
this.position.x = eval.x;
|
||||
this.position.y = eval.y;
|
||||
|
@ -92,7 +100,9 @@ PointerCamera.prototype.update = function() {
|
|||
this.movingHermite = false;
|
||||
this.anglesFromVectors();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
PointerCamera.prototype.normalMotion = function() {
|
||||
// Update angles
|
||||
if (this.increasePhi) {this.phi += this.sensitivity; this.changed = true; }
|
||||
if (this.decreasePhi) {this.phi -= this.sensitivity; this.changed = true; }
|
||||
|
@ -143,7 +153,6 @@ PointerCamera.prototype.update = function() {
|
|||
this.target = this.position.clone();
|
||||
this.target.add(forward);
|
||||
}
|
||||
}
|
||||
|
||||
PointerCamera.prototype.reset = function() {
|
||||
this.position.copy(new THREE.Vector3(-8.849933489419644, 9.050627639459208, 0.6192960680432451));
|
||||
|
@ -206,7 +215,7 @@ PointerCamera.prototype.moveHermite = function(otherCamera, toSave) {
|
|||
this.hermitePosition = new Hermite.special.Polynom(
|
||||
this.position.clone(),
|
||||
otherCamera.position.clone(),
|
||||
Tools.diff(otherCamera.target, otherCamera.position)
|
||||
Tools.mul(Tools.diff(otherCamera.target, otherCamera.position).normalize(),4)
|
||||
);
|
||||
|
||||
this.hermiteAngles = new Hermite.special.Polynom(
|
||||
|
|
Loading…
Reference in New Issue