From e603f69717b8242ff4eb3cc0e24b8d7ac31ac0c5 Mon Sep 17 00:00:00 2001 From: Robin Hawkes Date: Thu, 13 Feb 2014 17:56:01 +0000 Subject: [PATCH] Updated zoom logic --- src/client/webgl/Camera.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/client/webgl/Camera.js b/src/client/webgl/Camera.js index cc2c6cd..2c59267 100644 --- a/src/client/webgl/Camera.js +++ b/src/client/webgl/Camera.js @@ -58,12 +58,28 @@ }; VIZI.Camera.prototype.zoom = function(delta) { + var oldcameraRadius = this.cameraRadius; + this.cameraRadius += delta; + var cameraRadiusDiff = this.cameraRadius - oldcameraRadius; + // Cap zoom to bounds - this.cameraRadius = Math.max(Math.min(this.cameraRadius, 5000), 1000); + if (this.cameraRadius < 1000) { + this.cameraRadius = 1000; + cameraRadiusDiff = 1000 - oldcameraRadius; + } + + if (this.cameraRadius > 5000) { + this.cameraRadius = 5000; + cameraRadiusDiff = 5000 - oldcameraRadius; + } + + this.camera.translateZ( cameraRadiusDiff ); this.updatePosition(); + + this.publish("render"); }; VIZI.Camera.prototype.pan = function(delta3d) {