From 8b6f8dde716a8da1b1caf665ed6e91921352780c Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Fri, 15 May 2015 16:17:20 -0400
Subject: [PATCH] add multiple gik blocks

---
 js/threeViews/Highlighter.js | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/js/threeViews/Highlighter.js b/js/threeViews/Highlighter.js
index abbda29d..7e13ea62 100644
--- a/js/threeViews/Highlighter.js
+++ b/js/threeViews/Highlighter.js
@@ -70,7 +70,7 @@ Highlighter = Backbone.View.extend({
 
         var highlightedPos = highlighted.myParent.calcHighlighterPosition(intersection.face, intersection.point);
         this.index = highlightedPos.index;
-        this.position = highlightedPos.position;
+        this.position = highlightedPos.position;//todo used just for gik
         if (!highlightedPos.direction) {//may be hovering over a face that we shouldn't highlight
             this.hide();
             return;
@@ -229,7 +229,7 @@ GIKHighlighter = Highlighter.extend({
             this.mesh.translateX(-this.mesh.scale.x/2+this.mesh.scale.z/2);
         }
         else {
-            this.mesh.rotation.set(0, 0,0);
+            this.mesh.rotation.set(0,0,0);
             this.mesh.translateX(-this.mesh.scale.x/2+this.mesh.scale.z/2);
         }
     },
@@ -239,6 +239,24 @@ GIKHighlighter = Highlighter.extend({
         this._setPosition(this.position, this.direction);//position of center point
         this._setRotation(this.direction, this.index);
         dmaGlobals.three.render();
+    },
+
+    addRemoveVoxel: function(shouldAdd){
+
+        if (shouldAdd){
+            if (!this.isVisible() || !this.highlightedObject) return;
+            var position = this._getNextCellPosition();
+            var min;
+            if (this.mesh.rotation.z == 0) min = {x:position.x-(dmaGlobals.lattice.get("gikLength")-1), y:position.y, z:position.z};
+            else min = {x:position.x, y:position.y-(dmaGlobals.lattice.get("gikLength")-1), z:position.z};
+            var range = {min:min, max:position};
+            dmaGlobals.lattice.addCellsInRange(range);
+        } else {
+            if (!this.highlightedObject) return;
+            if (!(this.highlightedObject instanceof DMACell)) return;
+            dmaGlobals.lattice.removeCell(this.highlightedObject);
+        }
+        this.setNothingHighlighted();
     }
 });
 
-- 
GitLab