From d96f95a7e9b52765137c2c8d1d27eb93f9eba776 Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 16 Feb 2017 10:05:59 +0200 Subject: [PATCH] Updated edit.js and selection tool Last selected entity will now be yellow instead of orange --- scripts/system/edit.js | 8 +------ .../system/libraries/entitySelectionTool.js | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index afb171e936..1c76e03efd 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1115,7 +1115,6 @@ function recursiveDelete(entities, childrenList) { } } function unparentSelectedEntities() { - print("unparenting2 Selected Entities"); if (SelectionManager.hasSelection()) { var selectedEntities = selectionManager.selections; selectedEntities.forEach(function (id, index) { @@ -1128,7 +1127,6 @@ function unparentSelectedEntities() { } function parentSelectedEntities() { - print("parenting selected Entities"); if (SelectionManager.hasSelection()) { var selectedEntities = selectionManager.selections; if (selectedEntities.length <= 1) { @@ -1137,16 +1135,12 @@ function parentSelectedEntities() { } var lastEntityId = selectedEntities[selectedEntities.length-1]; - print("last " + lastEntityId); selectedEntities.forEach(function (id, index) { if (lastEntityId !== id) { - print("iterating2 " + id); - // OK time to check why this breaks! Entities.editEntity(id, {parentID: lastEntityId}) } }); - Window.notify("Entities Parented"); } else { Window.notifyEditError("You have nothing selected") @@ -1384,7 +1378,7 @@ Controller.keyReleaseEvent.connect(function (event) { grid.setPosition(newPosition); } } else if (event.text === 'p' && event.isControl ) { - if (event.isShifted) { + if (event.isAlt) { unparentSelectedEntities(); } else { parentSelectedEntities(); diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index b9bae72d14..146dc1894b 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -1170,14 +1170,14 @@ SelectionDisplay = (function() { // determine which bottom corner we are closest to /*------------------------------ example: - + BRF +--------+ BLF | | | | BRN +--------+ BLN - + * - + ------------------------------*/ var cameraPosition = Camera.getPosition(); @@ -2189,8 +2189,12 @@ SelectionDisplay = (function() { offset = Vec3.multiplyQbyV(properties.rotation, offset); var boxPosition = Vec3.sum(properties.position, offset); + var color = {red: 255, green: 153, blue: 0}; + if (i >= selectionManager.selections.length - 1) color = {red: 255, green: 255, blue: 0}; + Overlays.editOverlay(selectionBoxes[i], { position: boxPosition, + color: color, rotation: properties.rotation, dimensions: properties.dimensions, visible: true, @@ -2395,7 +2399,7 @@ SelectionDisplay = (function() { if (wantDebug) { print("Start Elevation: " + translateXZTool.startingElevation + ", elevation: " + elevation); } - if ((translateXZTool.startingElevation > 0.0 && elevation < MIN_ELEVATION) || + if ((translateXZTool.startingElevation > 0.0 && elevation < MIN_ELEVATION) || (translateXZTool.startingElevation < 0.0 && elevation > -MIN_ELEVATION)) { if (wantDebug) { print("too close to horizon!"); @@ -3857,7 +3861,7 @@ SelectionDisplay = (function() { }; that.mousePressEvent = function(event) { - var wantDebug = false; + var wantDebug = false; if (!event.isLeftButton && !that.triggered) { // if another mouse button than left is pressed ignore it return false; @@ -3883,7 +3887,7 @@ SelectionDisplay = (function() { if (result.intersects) { - + if (wantDebug) { print("something intersects... "); print(" result.overlayID:" + result.overlayID + "[" + overlayNames[result.overlayID] + "]"); @@ -3983,7 +3987,7 @@ SelectionDisplay = (function() { if (wantDebug) { print("rotate handle case..."); } - + // After testing our stretch handles, then check out rotate handles Overlays.editOverlay(yawHandle, { @@ -4205,7 +4209,7 @@ SelectionDisplay = (function() { case selectionBox: activeTool = translateXZTool; translateXZTool.pickPlanePosition = result.intersection; - translateXZTool.greatestDimension = Math.max(Math.max(SelectionManager.worldDimensions.x, SelectionManager.worldDimensions.y), + translateXZTool.greatestDimension = Math.max(Math.max(SelectionManager.worldDimensions.x, SelectionManager.worldDimensions.y), SelectionManager.worldDimensions.z); if (wantDebug) { print("longest dimension: " + translateXZTool.greatestDimension); @@ -4214,7 +4218,7 @@ SelectionDisplay = (function() { translateXZTool.startingElevation = translateXZTool.elevation(pickRay.origin, translateXZTool.pickPlanePosition); print(" starting elevation: " + translateXZTool.startingElevation); } - + mode = translateXZTool.mode; activeTool.onBegin(event); somethingClicked = 'selectionBox';