From 88c983cd3ba3ce0922d21f5627472abc57a9fa1f Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 3 Oct 2014 03:12:09 -0700 Subject: [PATCH] dry up some code --- examples/libraries/entitySelectionTool.js | 52 +++++------------------ 1 file changed, 11 insertions(+), 41 deletions(-) diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index 48477765c5..53ee4119a4 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -881,31 +881,11 @@ SelectionDisplay = (function () { switch(result.overlayID) { case grabberMoveUp: mode = "TRANSLATE_UP_DOWN"; - - pickRay = Camera.computePickRay(event.x, event.y); - lastPlaneIntersection = rayPlaneIntersection(pickRay, selectedEntityPropertiesOriginalPosition, - Quat.getFront(lastAvatarOrientation)); - if (wantDebug) { - print("mousePressEvent()...... " + overlayNames[result.overlayID]); - print(" event.y:" + event.y); - Vec3.print(" lastPlaneIntersection:", lastPlaneIntersection); - Vec3.print(" originalPosition:", selectedEntityPropertiesOriginalPosition); - } somethingClicked = true; break; case grabberRBN: mode = "STRETCH_RBN"; - - pickRay = Camera.computePickRay(event.x, event.y); - lastPlaneIntersection = rayPlaneIntersection(pickRay, selectedEntityPropertiesOriginalPosition, - Quat.getFront(lastAvatarOrientation)); - if (wantDebug) { - print("mousePressEvent()...... " + overlayNames[result.overlayID]); - print(" event.y:" + event.y); - Vec3.print(" lastPlaneIntersection:", lastPlaneIntersection); - Vec3.print(" originalPosition:", selectedEntityPropertiesOriginalPosition); - } somethingClicked = true; break; @@ -913,17 +893,6 @@ SelectionDisplay = (function () { case grabberEdgeTN: case grabberEdgeBN: mode = "STRETCH_NEAR"; - - pickRay = Camera.computePickRay(event.x, event.y); - lastPlaneIntersection = rayPlaneIntersection(pickRay, selectedEntityPropertiesOriginalPosition, - Quat.getFront(lastAvatarOrientation)); - if (wantDebug) { - print("mousePressEvent()...... " + overlayNames[result.overlayID]); - print(" event.y:" + event.y); - Vec3.print(" lastPlaneIntersection:", lastPlaneIntersection); - Vec3.print(" originalPosition:", selectedEntityPropertiesOriginalPosition); - print(" mode:" + mode); - } somethingClicked = true; break; @@ -956,16 +925,6 @@ SelectionDisplay = (function () { switch(result.overlayID) { case selectionBox: mode = "TRANSLATE_XZ"; - - pickRay = Camera.computePickRay(event.x, event.y); - lastPlaneIntersection = rayPlaneIntersection(pickRay, selectedEntityPropertiesOriginalPosition, - Quat.getFront(lastAvatarOrientation)); - if (wantDebug) { - print("mousePressEvent()...... " + overlayNames[result.overlayID]); - print(" event.y:" + event.y); - Vec3.print(" lastPlaneIntersection:", lastPlaneIntersection); - Vec3.print(" originalPosition:", selectedEntityPropertiesOriginalPosition); - } somethingClicked = true; break; default: @@ -976,6 +935,17 @@ SelectionDisplay = (function () { } } + if (somethingClicked) { + pickRay = Camera.computePickRay(event.x, event.y); + lastPlaneIntersection = rayPlaneIntersection(pickRay, selectedEntityPropertiesOriginalPosition, + Quat.getFront(lastAvatarOrientation)); + if (wantDebug) { + print("mousePressEvent()...... " + overlayNames[result.overlayID]); + Vec3.print(" lastPlaneIntersection:", lastPlaneIntersection); + Vec3.print(" originalPosition:", selectedEntityPropertiesOriginalPosition); + } + } + // reset everything as intersectable... // TODO: we could optimize this since some of these were already flipped back Overlays.editOverlay(selectionBox, { ignoreRayIntersection: false });