From 8f53e1731b1f8c556a88c84ba85dd73764c4f613 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 28 Oct 2014 12:40:44 -0700 Subject: [PATCH] Add selectionManager.setSelections and hasSelection --- examples/libraries/entitySelectionTool.js | 24 +++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index 25342e7f44..f1ce6fc659 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -45,8 +45,20 @@ SelectionManager = (function() { that.eventListener = func; }; + that.hasSelection = function() { + return that.selections.length > 0; + }; + + that.setSelections = function(entityIDs) { + that.selections = []; + for (var i = 0; i < entityIDs.length; i++) { + that.selections.push(entityIDs[i]); + } + + that._update(); + }; + that.addEntity = function(entityID) { - print("Adding: " + entityID.id); var idx = that.selections.indexOf(entityID); if (idx == -1) { that.selections.push(entityID); @@ -77,8 +89,6 @@ SelectionManager = (function() { that.worldDimensions = null; that.worldPosition = null; } else if (that.selections.length == 1) { - SelectionDisplay.setSpaceMode(SPACE_LOCAL); - var properties = Entities.getEntityProperties(that.selections[0]); that.localDimensions = properties.dimensions; that.localPosition = properties.position; @@ -86,10 +96,9 @@ SelectionManager = (function() { that.worldDimensions = properties.boundingBox.dimensions; that.worldPosition = properties.boundingBox.center; - } else { - // For 1+ selections we can only modify selections in world space - SelectionDisplay.setSpaceMode(SPACE_WORLD); + SelectionDisplay.setSpaceMode(SPACE_LOCAL); + } else { that.localRotation = null; that.localDimensions = null; that.localPosition = null; @@ -122,6 +131,9 @@ SelectionManager = (function() { y: brn.y + (that.worldDimensions.y / 2), z: brn.z + (that.worldDimensions.z / 2), }; + + // For 1+ selections we can only modify selections in world space + SelectionDisplay.setSpaceMode(SPACE_WORLD); } if (that.eventListener) {