From de13f9de8702c3f50ec5ba8f3c35d0b5900f9fd2 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Tue, 10 Mar 2015 22:41:48 -0400
Subject: [PATCH] highlighter feel is better

---
 js/threeViews/ThreeView.js | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/js/threeViews/ThreeView.js b/js/threeViews/ThreeView.js
index c8d8e620..1cec6490 100644
--- a/js/threeViews/ThreeView.js
+++ b/js/threeViews/ThreeView.js
@@ -88,18 +88,17 @@ ThreeView = Backbone.View.extend({
         var vector = new THREE.Vector2(2*(e.pageX-this.$el.offset().left)/this.$el.width()-1, 1-2*(e.pageY-this.$el.offset().top)/this.$el.height());
         this.mouseProjection.setFromCamera(vector, this.model.camera);
 
-        //check if we're in the same spot
-        if (this.highlighter.isVisible()){
-            if(this.mouseProjection.intersectObject(this.highlighter.mesh, false).length > 0) return;
-        }
-
-        var intersections = this.mouseProjection.intersectObjects(this.model.cells.concat(this.model.basePlane), false);
+        var objsToIntersect = this.model.cells.concat(this.model.basePlane);
+        if (this.highlighter.isVisible()) objsToIntersect = objsToIntersect.concat(this.highlighter.mesh);
+        var intersections = this.mouseProjection.intersectObjects(objsToIntersect, false);
         if (intersections.length == 0) {//no intersections
             this.highlighter.setNothingHighlighted();
             this._setNoPartIntersections();
             return;
         }
 
+        if(intersections[0].object == this.highlighter.mesh) return;
+
         this.highlighter.highlight(intersections[0]);
 
         if (this.mouseIsDown) {
-- 
GitLab