From 33e170315c3601407432cf496beb8dff6469f628 Mon Sep 17 00:00:00 2001 From: David Back Date: Fri, 6 Jul 2018 15:38:40 -0700 Subject: [PATCH] recurse on children of children --- .../system/libraries/entitySelectionTool.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 86c92174e1..26000d86c7 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -180,6 +180,17 @@ SelectionManager = (function() { that.selections = []; that._update(true); }; + + that.addChildrenEntities = function(parentEntityID, entityList) { + var children = Entities.getChildrenIDs(parentEntityID); + for (var i = 0; i < children.length; i++) { + var childID = children[i]; + if (entityList.indexOf(childID) < 0) { + entityList.push(childID); + } + that.addChildrenEntities(childID, entityList); + } + }; that.duplicateSelection = function() { var entitiesToDuplicate = []; @@ -192,13 +203,7 @@ SelectionManager = (function() { if (entitiesToDuplicate.indexOf(originalEntityID) < 0) { entitiesToDuplicate.push(originalEntityID); } - var children = Entities.getChildrenIDs(originalEntityID); - for (var i = 0; i < children.length; i++) { - var childID = children[i]; - if (entitiesToDuplicate.indexOf(childID) < 0) { - entitiesToDuplicate.push(childID); - } - } + that.addChildrenEntities(originalEntityID, entitiesToDuplicate); }); // duplicate entities from above and store their original to new entity mappings and children needing re-parenting