From 8ff5e82d842a575e0194833774d67fd63659384c Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Fri, 30 Jan 2015 16:52:50 -0500 Subject: [PATCH] check if a cell is already in a spot before adding a new one --- js/models/lattice.js | 2 +- js/threeViews/threeView.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/models/lattice.js b/js/models/lattice.js index 5d414822..31b6a4e7 100644 --- a/js/models/lattice.js +++ b/js/models/lattice.js @@ -60,7 +60,7 @@ Lattice = Backbone.Model.extend({ } var index = this._subtract(position, this.get("cellsMin")); - cells[index.x][index.y][index.z] = new DMACell(this.get("cellMode"), position, scale); + if (!cells[index.x][index.y][index.z]) cells[index.x][index.y][index.z] = new DMACell(this.get("cellMode"), position, scale); this.set("numCells", this.get("numCells")+1); window.three.render(); }, diff --git a/js/threeViews/threeView.js b/js/threeViews/threeView.js index 00f3b6e6..6e5c4774 100644 --- a/js/threeViews/threeView.js +++ b/js/threeViews/threeView.js @@ -80,7 +80,7 @@ ThreeView = Backbone.View.extend({ _mouseUp: function(){ this.mouseIsDown = false; - if (this.highlighter.visible) this._addRemoveVoxel(!this.appState.get("deleteMode")); + this._addRemoveVoxel(!this.appState.get("deleteMode")); }, _mouseDown: function(){ @@ -179,7 +179,7 @@ ThreeView = Backbone.View.extend({ _addRemoveVoxel: function(shouldAdd){ if (shouldAdd){ -// if (!this.highlighter.visible) return; + if (!this.highlighter.visible) return; this.lattice.addCell(this.highlighter.geometry.vertices[0]); } else { if (this.currentIntersectedCell === this.basePlane) return; -- GitLab