From 1f5eac07e8f4bef5a8368b42c854f4893657180f Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Mon, 7 Sep 2015 19:42:18 -0400
Subject: [PATCH] generalize orbit controls for all lattices

---
 js/lattice/Lattice.js | 3 ++-
 js/three/ThreeView.js | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js
index ee480c28..8ae26fc7 100644
--- a/js/lattice/Lattice.js
+++ b/js/lattice/Lattice.js
@@ -109,7 +109,8 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
             var cellsMin = this.get("cellsMin");
             var cellsMax = this.get("cellsMax");
             if (cellsMax === null || cellsMin === null) return;
-            if (globals.threeView) globals.threeView.setOrbitControlsFor(this.get("cellsMin").clone(), this.get("cellsMax").clone())
+            var center = cellsMax.clone().sub(cellsMin).divideScalar(2).add(cellsMin);
+            if (globals.threeView && this.getPositionForIndex) globals.threeView.setOrbitControlsFor(this.getPositionForIndex(center));
         },
 
 
diff --git a/js/three/ThreeView.js b/js/three/ThreeView.js
index c2200e79..fee81cc4 100644
--- a/js/three/ThreeView.js
+++ b/js/three/ThreeView.js
@@ -60,8 +60,8 @@ define(['underscore', 'backbone', 'three', 'appState', 'globals', 'lattice', 'or
             this.controls.reset();
         },
 
-        setOrbitControlsFor: function(min, max){
-            this.controls.setTarget(max.sub(min).divideScalar(2).add(min));
+        setOrbitControlsFor: function(center){//lattice min max
+            this.controls.setTarget(center);//center of lattice bounds
         },
 
         ////////////////////////////////////////////////////////////////////////////////
-- 
GitLab