From a5d43248ef4a7322523f15010818ff423b49f60d Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Wed, 1 Jul 2015 10:48:23 +0200 Subject: [PATCH] Corrected setSize on viewport cameras --- js/prototype/OldFixedCamera.js | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/js/prototype/OldFixedCamera.js b/js/prototype/OldFixedCamera.js index ae0967d..281cc4e 100644 --- a/js/prototype/OldFixedCamera.js +++ b/js/prototype/OldFixedCamera.js @@ -139,3 +139,57 @@ OldFixedCamera.prototype.containsObject = function(object) { return object === this.mesh; }; +OldFixedCamera.prototype.setSize = function(size) { + + var direction = this.target.clone(); + direction.sub(this.position); + direction.normalize(); + + var left = Tools.cross(direction, this.up); + var other = Tools.cross(direction, left); + left.normalize(); + other.normalize(); + left = Tools.mul(left, size); + other = Tools.mul(other, size); + + this.mesh.geometry.vertices = [ + Tools.sum(Tools.sum(this.position, left), other), + Tools.diff(Tools.sum(this.position, other),left), + Tools.diff(Tools.diff(this.position, left),other), + Tools.sum(Tools.diff(this.position, other), left) + ]; + + this.mesh.geometry.verticesNeedUpdate = true; + + (function(self, direction, left, other, size) { + + var tmp_direction = Tools.mul(direction, -2 * size); + var target = Tools.sum(self.position, tmp_direction); + + var vertices = [ + Tools.sum(Tools.sum(self.position, left), other), + Tools.diff(Tools.sum(self.position, other),left), + Tools.diff(Tools.diff(self.position, left),other), + Tools.sum(Tools.diff(self.position, other), left), + Tools.sum(Tools.sum(self.position, left), other), + Tools.sum(Tools.diff(self.position, other), left), + + Tools.sum(self.position, tmp_direction), + Tools.sum(Tools.sum(self.position, left), other), + + Tools.sum(self.position, tmp_direction), + Tools.diff(Tools.sum(self.position, other),left), + + Tools.sum(self.position, tmp_direction), + Tools.diff(Tools.diff(self.position, left),other), + + Tools.sum(self.position, tmp_direction), + Tools.sum(Tools.diff(self.position, other), left) + ]; + + self.line.geometry.vertices = vertices; + self.line.geometry.verticesNeedUpdate = true; + + })(this, direction, left, other, size); + +};