From cddce8f7956951e1763a4bb8ac101b08f0668bb6 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 30 Jan 2015 09:21:27 -0800 Subject: [PATCH 1/2] Update editEntities to always be on + use right click for select --- examples/editEntities.js | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index e2c7a6d435..4605e040fd 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -56,6 +56,11 @@ selectionManager.addEventListener(function() { entityListTool.setVisible(true); hasShownPropertiesTool = true; } + if (!selectionManager.hasSelection()) { + toolBar.setActive(false); + } else { + toolBar.setActive(true); + } }); var windowDimensions = Controller.getViewportDimensions(); @@ -123,11 +128,13 @@ var toolBar = (function () { function initialize() { toolBar = new ToolBar(0, 0, ToolBar.VERTICAL); + // Hide active button for now - this may come back, so not deleting yet. activeButton = toolBar.addTool({ imageURL: toolIconUrl + "models-tool.svg", - subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT }, - width: toolWidth, - height: toolHeight, + // subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT }, + subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: 0, height: 0 }, + width: 0,//toolWidth, + height: 0,//toolHeight, alpha: 0.9, visible: true }, true, false); @@ -543,19 +550,16 @@ function mouseMoveEvent(event) { } mouseHasMovedSincePress = true; - if (isActive) { - // allow the selectionDisplay and cameraManager to handle the event first, if it doesn't handle it, then do our own thing - if (selectionDisplay.mouseMoveEvent(event) || cameraManager.mouseMoveEvent(event)) { - return; - } - lastMousePosition = { x: event.x, y: event.y }; - - highlightEntityUnderCursor(lastMousePosition, false); - idleMouseTimerId = Script.setTimeout(handleIdleMouse, IDLE_MOUSE_TIMEOUT); - } else { - cameraManager.mouseMoveEvent(event); + // allow the selectionDisplay and cameraManager to handle the event first, if it doesn't handle it, then do our own thing + if (selectionDisplay.mouseMoveEvent(event) || cameraManager.mouseMoveEvent(event)) { + return; } + + lastMousePosition = { x: event.x, y: event.y }; + + highlightEntityUnderCursor(lastMousePosition, false); + idleMouseTimerId = Script.setTimeout(handleIdleMouse, IDLE_MOUSE_TIMEOUT); } function handleIdleMouse() { @@ -608,7 +612,7 @@ function mouseReleaseEvent(event) { } function mouseClickEvent(event) { - if (!isActive) { + if (!event.isRightButton) { return; } @@ -619,6 +623,7 @@ function mouseClickEvent(event) { } return; } + toolBar.setActive(true); var pickRay = result.pickRay; var foundEntity = result.entityID; @@ -830,6 +835,8 @@ Controller.keyReleaseEvent.connect(function (event) { // since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items if (event.text == "BACKSPACE" || event.text == "DELETE") { deleteSelectedEntities(); + } else if (event.text == "ESC") { + selectionManager.clearSelections(); } else if (event.text == "TAB") { selectionDisplay.toggleSpaceMode(); } else if (event.text == "f") { @@ -1082,4 +1089,4 @@ PropertiesTool = function(opts) { }; propertiesTool = PropertiesTool(); - +toolBar.setActive(true); From 018a4af9d613fe023b6f98014a346e890df5c398 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 30 Jan 2015 09:22:39 -0800 Subject: [PATCH 2/2] Update camera tool to wrap cursor to window bounds rather than keep at center --- examples/libraries/entityCameraTool.js | 41 ++++++++++++++++++++------ 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/examples/libraries/entityCameraTool.js b/examples/libraries/entityCameraTool.js index f5095bb149..9f53d585d2 100644 --- a/examples/libraries/entityCameraTool.js +++ b/examples/libraries/entityCameraTool.js @@ -208,6 +208,11 @@ CameraManager = function() { if (that.enabled && that.mode != MODE_INACTIVE) { var x = Window.getCursorPositionX(); var y = Window.getCursorPositionY(); + if (!hasDragged) { + that.lastMousePosition.x = x; + that.lastMousePosition.y = y; + hasDragged = true; + } if (that.mode == MODE_ORBIT) { var diffX = x - that.lastMousePosition.x; var diffY = y - that.lastMousePosition.y; @@ -235,9 +240,31 @@ CameraManager = function() { that.moveFocalPoint(dPosition); } - var newX = Window.x + Window.innerWidth / 2; - var newY = Window.y + Window.innerHeight / 2; - Window.setCursorPosition(newX, newY); + + var newX = x; + var newY = y; + var updatePosition = false; + + if (x <= Window.x) { + newX = Window.x + Window.innerWidth; + updatePosition = true; + } else if (x >= (Window.x + Window.innerWidth)) { + newX = Window.x; + updatePosition = true; + } + + if (y <= Window.y) { + newY = Window.y + Window.innerHeight; + updatePosition = true; + } else if (y >= (Window.y + Window.innerHeight)) { + newY = Window.y; + updatePosition = true; + } + + if (updatePosition) { + Window.setCursorPosition(newX, newY); + } + that.lastMousePosition.x = newX; that.lastMousePosition.y = newY; @@ -246,6 +273,7 @@ CameraManager = function() { return false; } + var hasDragged = false; that.mousePressEvent = function(event) { if (cameraTool.mousePressEvent(event)) { return true; @@ -260,12 +288,7 @@ CameraManager = function() { } if (that.mode != MODE_INACTIVE) { - var newX = Window.x + Window.innerWidth / 2; - var newY = Window.y + Window.innerHeight / 2; - Window.setCursorPosition(newX, newY); - that.lastMousePosition.x = newX; - that.lastMousePosition.y = newY; - Window.setCursorVisible(false); + hasDragged = false; return true; }