From df2a24c1fae87ff5919e4845189739172769bd2a Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Sat, 17 Jan 2015 13:12:56 -0500
Subject: [PATCH] three out of global scope, clearall down't remove
 fillGeometry

---
 js/main.js            | 6 +++---
 js/views/navbar.js    | 2 +-
 js/views/threeView.js | 3 ++-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/js/main.js b/js/main.js
index 094b51c6..ec7d2762 100644
--- a/js/main.js
+++ b/js/main.js
@@ -7,10 +7,10 @@ $(function(){
 
     window.workers = persistentWorkers(8);
 
-    three = new ThreeView();
+    var three = new ThreeView();//singleton, my threejs view
 
     //init models and views
-    var fillGeometry = new FillGeometry();//singleton
+    var fillGeometry = new FillGeometry();//singleton, mesh to fill with lattice
     three.setFillGeometry(fillGeometry);
     new ImportView({model: fillGeometry});
 
@@ -20,7 +20,7 @@ $(function(){
 
 
 
-    setupNavBar();
+    setupNavBar(three);
 
 
 
diff --git a/js/views/navbar.js b/js/views/navbar.js
index e48dbf05..a97bc86a 100644
--- a/js/views/navbar.js
+++ b/js/views/navbar.js
@@ -3,7 +3,7 @@
  */
 
 
-function setupNavBar(){
+function setupNavBar(three){
 
     var allMenus = $(".navMenu");
     var allNavMenuLinks = $(".menuHoverControls");
diff --git a/js/views/threeView.js b/js/views/threeView.js
index 8684c4f5..8513e291 100644
--- a/js/views/threeView.js
+++ b/js/views/threeView.js
@@ -6,6 +6,7 @@ ThreeView = Backbone.View.extend({
 
     el: "#threeContainer",
 
+    //this could break off into a model
     camera: new THREE.PerspectiveCamera(60, window.innerWidth/window.innerHeight, 1, 1000),
     scene: new THREE.Scene(),
     renderer: new THREE.WebGLRenderer({antialias:false}),
@@ -90,7 +91,7 @@ ThreeView = Backbone.View.extend({
         var children = this.scene.children;
         for (var i=children.length;i>=0;i--){
             var object = children[i];
-            if (object instanceof THREE.Mesh){
+            if (object instanceof THREE.Mesh && object != this.fillGeometry.get("mesh")){
                 this.scene.remove(object);
             }
         }
-- 
GitLab