From 3efbbd07c0d8bb6b3b501720e9b3af31024d13e1 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Wed, 27 May 2015 13:02:36 -0700
Subject: [PATCH] part highlighting removed for now

---
 js/cells/DMACell.js        |  2 +-
 js/lattice/Lattice.js      |  2 ++
 js/models/ThreeModel.js    | 33 +++++++++++----------------------
 js/threeViews/ThreeView.js | 16 ++++++++--------
 4 files changed, 22 insertions(+), 31 deletions(-)

diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js
index 7adc5cba..2575f0f6 100644
--- a/js/cells/DMACell.js
+++ b/js/cells/DMACell.js
@@ -156,7 +156,7 @@ DMACell.prototype.destroy = function(){
     this.destroyStarted = true;
     if (this.object3D) {
         if (this.superCell) this.object3D.parent.remove(this.object3D);
-        else if (this.indices) globals.three.sceneRemove(this.object3D, "cell");
+        if (this.indices) globals.three.sceneRemove(this.object3D, "cell");
         this.object3D.myParent = null;
 //            this.object3D.dispose();
 //            geometry.dispose();
diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js
index 79fa84da..9c05d633 100644
--- a/js/lattice/Lattice.js
+++ b/js/lattice/Lattice.js
@@ -376,6 +376,8 @@ Lattice = Backbone.Model.extend({
 
     _updateLatticeType: function(arg1, arg2, arg3, loadingFromFile){//do not clear cells if loading from file (cells array contains important metadata)
 
+        if (this.previous("connectionType") == "gik") this.clearCells();
+
         this._setToDefaultsSilently();
         this._setDefaultCellMode();
 
diff --git a/js/models/ThreeModel.js b/js/models/ThreeModel.js
index 809f598b..4c96beec 100644
--- a/js/models/ThreeModel.js
+++ b/js/models/ThreeModel.js
@@ -11,7 +11,7 @@ function ThreeModel(){
 
     //store all meshes to highlight
     var cells = [];
-    var parts = [];
+//    var parts = [];
     var basePlane = [];
 
     var animationLoopRunning = false;
@@ -63,7 +63,7 @@ function ThreeModel(){
                 cells.push(child.children[0]);
             });
         } else if (type == "part"){//todo change this
-            parts.push(object);
+//            parts.push(object);
         } else if (type == "basePlane"){
             basePlane.push(object);
         }
@@ -71,36 +71,25 @@ function ThreeModel(){
 
     function sceneRemove(object, type){
 
-        var objectToRemove = getParentObject(object);
-
         if (type == "cell"){
-            cells.splice(cells.indexOf(objectToRemove.children[0]), 1);
+            cells.splice(cells.indexOf(object.children[0]), 1);
         } else if (type == "part"){
-            parts.splice(parts.indexOf(objectToRemove), 1);
+//            parts.splice(parts.indexOf(object), 1);
         } else if (type == "basePlane"){
             basePlane.splice(0, basePlane.length);//delete array without removing reference
         }
-        scene.remove(objectToRemove);
+        scene.remove(object);
     }
 
     function removeAllCells(){
         _.each(cells, function(cell){
-            var objectToRemove = getParentObject(cell);
-            scene.remove(objectToRemove);
-        });
-        _.each(parts, function(part){
-            scene.remove(part);
+            scene.remove(cell);
         });
+//        _.each(parts, function(part){
+//            scene.remove(part);
+//        });
         cells.splice(0, cells.length);
-        parts.splice(0, parts.length);
-    }
-
-    function getParentObject(object){
-        var objectToRemove = object;
-        if (object.parent && object.parent.type != "Scene") {
-            objectToRemove = object.parent;
-        }
-        return objectToRemove;
+//        parts.splice(0, parts.length);
     }
 
     function startAnimationLoop(){
@@ -144,7 +133,7 @@ function ThreeModel(){
         domElement: renderer.domElement,
         camera: camera,
         cells: cells,
-        parts: parts,
+//        parts: parts,
         basePlane: basePlane,
         removeAllCells: removeAllCells
     }
diff --git a/js/threeViews/ThreeView.js b/js/threeViews/ThreeView.js
index 779d9a69..5661095b 100644
--- a/js/threeViews/ThreeView.js
+++ b/js/threeViews/ThreeView.js
@@ -113,14 +113,14 @@ ThreeView = Backbone.View.extend({
             }
         }
 
-        if (globals.appState.get("cellMode") == "part"){//additionally check for part intersections in part mode
-            var partIntersections = this.mouseProjection.intersectObjects(this.model.parts, false);
-            if (partIntersections.length == 0) {
-                this._setNoPartIntersections();
-                return;
-            }
-            this._handlePartIntersections(partIntersections, intersections[0].distance);
-        }
+//        if (globals.appState.get("cellMode") == "part"){//additionally check for part intersections in part mode
+//            var partIntersections = this.mouseProjection.intersectObjects(this.model.parts, false);
+//            if (partIntersections.length == 0) {
+//                this._setNoPartIntersections();
+//                return;
+//            }
+//            this._handlePartIntersections(partIntersections, intersections[0].distance);
+//        }
     },
 
     ////////////////////////////////////////////////////////////////////////////////
-- 
GitLab