From de0eae5a19afd206538e599bc50f935bf497d366 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Sun, 14 Jun 2015 08:50:55 -0700
Subject: [PATCH] eod

---
 js/cells/DMACell.js                    | 4 ++--
 js/cells/supercells/DMASuperCell.js    | 8 +++++---
 js/highlighter/Highlighter.js          | 1 +
 js/highlighter/SuperCellHighlighter.js | 8 ++++++++
 4 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js
index 1f94204c..bcb3706f 100644
--- a/js/cells/DMACell.js
+++ b/js/cells/DMACell.js
@@ -241,7 +241,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals'],
 
     DMACell.prototype.setMode = function(mode, callback){
 
-        if (mode === undefined) mode = appState.get("cellMode");
+        if (!mode || mode === undefined) mode = appState.get("cellMode");
         var self = this;
 
         switch(mode) {
@@ -284,7 +284,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals'],
                 callback();
                 return;
             }
-            three.conditionalRender();
+            if (!self.superCell) three.conditionalRender();
         }
     };
 
diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js
index 803abd71..84984e07 100644
--- a/js/cells/supercells/DMASuperCell.js
+++ b/js/cells/supercells/DMASuperCell.js
@@ -16,8 +16,10 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'],
         var material = this.getMaterial();
         var range = material.dimensions || appState.get("superCellRange");
         this.cells = this._makeChildCells(range, this.getMaterial());
-    
-        if (!superCell || superCell === undefined) this.setMode();//don't pass a call down to children again
+
+        if (!superCell || superCell === undefined) this.setMode(null, function(){
+            three.conditionalRender();
+        });//don't pass a call down to children again
     }
     DMASuperCell.prototype = Object.create(DMACell.prototype);
 
@@ -39,7 +41,6 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'],
                                 cellMaterial = material.sparseCells[x][y][z].material;
                                 this._makeSubCellForIndex({index: new THREE.Vector3(x,y,z), material:cellMaterial}, function(cell){
                                     var index = cell.getIndex();
-                                    console.log(index);
                                     cells[index.x][index.y][index.z] = cell;
                                 });
                             } else console.warn("no material for composite cell definition subcell");
@@ -58,6 +59,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'],
     DMASuperCell.prototype._makeSubCellForIndex = function(json, callback){
         var subclassFile = lattice.getCellSubclassFile();
         if (json.material && json.material.substr(0,5) == "super") subclassFile = "compositeCell";
+        console.log(subclassFile);
         var self = this;
         require([subclassFile], function(CellSubclass){
             var cell = new CellSubclass(json, self);
diff --git a/js/highlighter/Highlighter.js b/js/highlighter/Highlighter.js
index 2a517004..e812c51d 100644
--- a/js/highlighter/Highlighter.js
+++ b/js/highlighter/Highlighter.js
@@ -21,6 +21,7 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', '
                     opacity:0.4,
                     color:0xffffff
                 }));
+            if (this._makeWireframe) this._makeWireframe();
 
             three.sceneAdd(this.mesh);
             this._setScale();
diff --git a/js/highlighter/SuperCellHighlighter.js b/js/highlighter/SuperCellHighlighter.js
index c66d2fab..85eaa359 100644
--- a/js/highlighter/SuperCellHighlighter.js
+++ b/js/highlighter/SuperCellHighlighter.js
@@ -18,6 +18,14 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', '
             return new THREE.BoxGeometry(lattice.xScale(),lattice.yScale(),lattice.zScale());
         },
 
+        _makeWireframe: function(mesh){
+//            var wireframe = new THREE.BoxHelper(mesh);
+//            wireframe.material.color.set(0x000000);
+//            wireframe.matrixWorld = mesh.matrixWorld;
+//            wireframe.matrixAutoUpdate = true;
+//            mesh.add(wireframe);
+        },
+
         _setScale: function(){
             this.mesh.scale.set(appState.get("superCellRange").x, appState.get("superCellRange").y,
                 appState.get("superCellRange").z);
-- 
GitLab