Improved camera movement

Added scale factor to the distance between `FixedCamera.center` and
`FixedCamera.target` so the movement of `PointerCamera` does the
rotation earlier in its movement. Changed threshold to consider the
movement finished so the movement doesn't block the user for long.
This commit is contained in:
Thomas FORGIONE 2015-04-10 09:25:27 +02:00
parent 0037b38357
commit 64c8b7de6d
2 changed files with 3 additions and 4 deletions

View File

@ -13,7 +13,6 @@ var FixedCamera = function(arg1, arg2, arg3, arg4, position, target) {
this.position.z = position.z; this.position.z = position.z;
} }
if (target === undefined) if (target === undefined)
target = new THREE.Vector3(0,0,0); target = new THREE.Vector3(0,0,0);
@ -22,7 +21,7 @@ var FixedCamera = function(arg1, arg2, arg3, arg4, position, target) {
direction.normalize(); direction.normalize();
this.target = this.position.clone(); this.target = this.position.clone();
this.target.add(direction); this.target.add(Tools.mul(direction,10));
this.up = new THREE.Vector3(0,0,1); this.up = new THREE.Vector3(0,0,1);
// Compute corners // Compute corners

View File

@ -56,8 +56,8 @@ PointerCamera.prototype.update = function() {
this.position.add(Tools.mul(position_direction, 0.05)); this.position.add(Tools.mul(position_direction, 0.05));
this.target.add(Tools.mul(target_direction, 0.05)); this.target.add(Tools.mul(target_direction, 0.05));
if (Tools.norm2(Tools.diff(this.position, this.new_position)) < 0.01 && if (Tools.norm2(Tools.diff(this.position, this.new_position)) < 0.1 &&
Tools.norm2(Tools.diff(this.target, this.new_target)) < 0.01) { Tools.norm2(Tools.diff(this.target, this.new_target)) < 0.1) {
// this.position = this.new_position.clone(); // this.position = this.new_position.clone();
// this.target = this.new_target.clone(); // this.target = this.new_target.clone();
this.moving = false; this.moving = false;