From 64c8b7de6d1dd7759c0857c7a7c827694e948a7e Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Fri, 10 Apr 2015 09:25:27 +0200 Subject: [PATCH] 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. --- js/FixedCamera.js | 3 +-- js/PointerCamera.js | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/js/FixedCamera.js b/js/FixedCamera.js index 88c21d1..fe3c46b 100644 --- a/js/FixedCamera.js +++ b/js/FixedCamera.js @@ -13,7 +13,6 @@ var FixedCamera = function(arg1, arg2, arg3, arg4, position, target) { this.position.z = position.z; } - if (target === undefined) target = new THREE.Vector3(0,0,0); @@ -22,7 +21,7 @@ var FixedCamera = function(arg1, arg2, arg3, arg4, position, target) { direction.normalize(); this.target = this.position.clone(); - this.target.add(direction); + this.target.add(Tools.mul(direction,10)); this.up = new THREE.Vector3(0,0,1); // Compute corners diff --git a/js/PointerCamera.js b/js/PointerCamera.js index 167890e..94cd01f 100644 --- a/js/PointerCamera.js +++ b/js/PointerCamera.js @@ -56,8 +56,8 @@ PointerCamera.prototype.update = function() { this.position.add(Tools.mul(position_direction, 0.05)); this.target.add(Tools.mul(target_direction, 0.05)); - if (Tools.norm2(Tools.diff(this.position, this.new_position)) < 0.01 && - Tools.norm2(Tools.diff(this.target, this.new_target)) < 0.01) { + if (Tools.norm2(Tools.diff(this.position, this.new_position)) < 0.1 && + Tools.norm2(Tools.diff(this.target, this.new_target)) < 0.1) { // this.position = this.new_position.clone(); // this.target = this.new_target.clone(); this.moving = false;