From 01a00b51278a3666d76e2703e65e5337afad855f Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:40:50 -0800 Subject: [PATCH 1/6] Disable editEntities always-on --- examples/editEntities.js | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 3a70d2020e..3686134a88 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -46,28 +46,8 @@ gridTool.setVisible(false); var entityListTool = EntityListTool(); -var hasShownPropertiesTool = false; - -var entityListVisible = false; - selectionManager.addEventListener(function() { selectionDisplay.updateHandles(); - if (selectionManager.hasSelection() && !hasShownPropertiesTool) { - // Open properties and model list, but force selection of model list tab - propertiesTool.setVisible(false); - entityListTool.setVisible(false); - gridTool.setVisible(false); - propertiesTool.setVisible(true); - entityListTool.setVisible(true); - gridTool.setVisible(true); - Window.setFocus(); - hasShownPropertiesTool = true; - } - if (!selectionManager.hasSelection()) { - toolBar.setActive(false); - } else { - toolBar.setActive(true); - } }); var windowDimensions = Controller.getViewportDimensions(); From 4fbc7a5dcdd13079ed7ab7cdc4299a9f26c82a61 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:42:01 -0800 Subject: [PATCH 2/6] Add focus easing and auto-focus to menu and settings --- examples/editEntities.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 3686134a88..4cc317e8b6 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -74,9 +74,11 @@ var DEFAULT_DIMENSIONS = { }; var MENU_INSPECT_TOOL_ENABLED = "Inspect Tool"; +var MENU_AUTO_FOCUS_ON_SELECT = "Auto Focus on Select"; var MENU_EASE_ON_FOCUS = "Ease Orientation on Focus"; var SETTING_INSPECT_TOOL_ENABLED = "inspectToolEnabled"; +var SETTING_AUTO_FOCUS_ON_SELECT = "autoFocusOnSelect"; var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus"; var modelURLs = [ @@ -515,7 +517,7 @@ function mousePressEvent(event) { if (result !== null) { var currentProperties = Entities.getEntityProperties(result.entityID); cameraManager.enable(); - cameraManager.focus(currentProperties.position, null, true); + cameraManager.focus(currentProperties.position, null, Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); cameraManager.mousePressEvent(event); } } else { @@ -661,9 +663,11 @@ function mouseClickEvent(event) { print("Model selected: " + foundEntity.id); selectionDisplay.select(selectedEntityID, event); - cameraManager.focus(selectionManager.worldPosition, - selectionManager.worldDimensions, - true); + if (Menu.isOptionChecked(MENU_AUTO_FOCUS_ON_SELECT)) { + cameraManager.focus(selectionManager.worldPosition, + selectionManager.worldDimensions, + Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); + } } } } @@ -705,7 +709,9 @@ function setupModelMenus() { Menu.addMenuItem({ menuName: "File", menuItemName: "Import Models", shortcutKey: "CTRL+META+I", afterItem: "Export Models" }); - Menu.addMenuItem({ menuName: "View", menuItemName: MENU_EASE_ON_FOCUS, afterItem: MENU_INSPECT_TOOL_ENABLED, + Menu.addMenuItem({ menuName: "View", menuItemName: MENU_AUTO_FOCUS_ON_SELECT, afterItem: MENU_INSPECT_TOOL_ENABLED, + isCheckable: true, isChecked: Settings.getValue(SETTING_AUTO_FOCUS_ON_SELECT) == "true" }); + Menu.addMenuItem({ menuName: "View", menuItemName: MENU_EASE_ON_FOCUS, afterItem: MENU_AUTO_FOCUS_ON_SELECT, isCheckable: true, isChecked: Settings.getValue(SETTING_EASE_ON_FOCUS) == "true" }); Entities.setLightsArePickable(false); @@ -731,11 +737,12 @@ function cleanupModelMenus() { Menu.removeMenuItem("File", "Import Models"); Menu.removeMenuItem("View", MENU_INSPECT_TOOL_ENABLED); + Menu.removeMenuItem("View", MENU_AUTO_FOCUS_ON_SELECT); Menu.removeMenuItem("View", MENU_EASE_ON_FOCUS); } Script.scriptEnding.connect(function() { - Settings.setValue(SETTING_INSPECT_TOOL_ENABLED, Menu.isOptionChecked(MENU_INSPECT_TOOL_ENABLED)); + Settings.setValue(SETTING_AUTO_FOCUS_ON_SELECT, Menu.isOptionChecked(MENU_AUTO_FOCUS_ON_SELECT)); Settings.setValue(SETTING_EASE_ON_FOCUS, Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); progressDialog.cleanup(); From 09752589b83a166b4bff8e9e72ec31de53e125b5 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:43:28 -0800 Subject: [PATCH 3/6] Reenable on/off button --- examples/editEntities.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 4cc317e8b6..9c4c9a5776 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -120,10 +120,9 @@ var toolBar = (function () { // 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 }, - subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: 0, height: 0 }, - width: 0,//toolWidth, - height: 0,//toolHeight, + subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT }, + width: toolWidth, + height: toolHeight, alpha: 0.9, visible: true }, true, false); @@ -235,7 +234,10 @@ var toolBar = (function () { } else { hasShownPropertiesTool = false; cameraManager.enable(); - grid.setEnabled(true); + entityListTool.setVisible(true); + gridTool.setVisible(true); + propertiesTool.setVisible(true); + Window.setFocus(); } } toolBar.selectTool(activeButton, active); From 36238bb5dfb30873c623da0dbeaac596a8b476a8 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:43:55 -0800 Subject: [PATCH 4/6] Update editEntities to use left click for select --- examples/editEntities.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 9c4c9a5776..c0c74b8f33 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -535,6 +535,9 @@ var idleMouseTimerId = null; var IDLE_MOUSE_TIMEOUT = 200; function mouseMoveEvent(event) { + if (!isActive) { + return; + } if (idleMouseTimerId) { Script.clearTimeout(idleMouseTimerId); } @@ -602,7 +605,7 @@ function mouseReleaseEvent(event) { } function mouseClickEvent(event) { - if (!event.isRightButton) { + if (!event.isLeftButton || !isActive) { return; } From 02d828443b6290cae5297277b5b0988e3d08e97f Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:44:54 -0800 Subject: [PATCH 5/6] Update zoom sensitivity when using keys --- examples/libraries/entityCameraTool.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/libraries/entityCameraTool.js b/examples/libraries/entityCameraTool.js index bf5bf6b105..947da45594 100644 --- a/examples/libraries/entityCameraTool.js +++ b/examples/libraries/entityCameraTool.js @@ -15,8 +15,8 @@ var MOUSE_SENSITIVITY = 0.9; var SCROLL_SENSITIVITY = 0.05; var PAN_ZOOM_SCALE_RATIO = 0.4; -var KEY_ORBIT_SENSITIVITY = 40; -var KEY_ZOOM_SENSITIVITY = 10; +var KEY_ORBIT_SENSITIVITY = 90; +var KEY_ZOOM_SENSITIVITY = 3; // Scaling applied based on the size of the object being focused var FOCUS_ZOOM_SCALE = 1.3; @@ -433,8 +433,13 @@ CameraManager = function() { that.targetYaw += (actions.orbitRight - actions.orbitLeft) * dt * KEY_ORBIT_SENSITIVITY; that.targetPitch += (actions.orbitUp - actions.orbitDown) * dt * KEY_ORBIT_SENSITIVITY; that.targetPitch = clamp(that.targetPitch, -90, 90); - that.targetZoomDistance += (actions.orbitBackward - actions.orbitForward) * dt * KEY_ZOOM_SENSITIVITY; - that.targetZoomDistance = clamp(that.targetZoomDistance, MIN_ZOOM_DISTANCE, MAX_ZOOM_DISTANCE); + + var dZoom = actions.orbitBackward - actions.orbitForward; + if (dZoom) { + dZoom *= that.targetZoomDistance * dt * KEY_ZOOM_SENSITIVITY; + that.targetZoomDistance += dZoom; + that.targetZoomDistance = clamp(that.targetZoomDistance, MIN_ZOOM_DISTANCE, MAX_ZOOM_DISTANCE); + } if (easing) { From 3af025574f0c3eeb7b55554ffbae8347865f537c Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 4 Feb 2015 10:45:07 -0800 Subject: [PATCH 6/6] Decrease distance from object when focusing --- examples/libraries/entityCameraTool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/libraries/entityCameraTool.js b/examples/libraries/entityCameraTool.js index 947da45594..bbd28dd38a 100644 --- a/examples/libraries/entityCameraTool.js +++ b/examples/libraries/entityCameraTool.js @@ -18,8 +18,8 @@ var PAN_ZOOM_SCALE_RATIO = 0.4; var KEY_ORBIT_SENSITIVITY = 90; var KEY_ZOOM_SENSITIVITY = 3; -// Scaling applied based on the size of the object being focused -var FOCUS_ZOOM_SCALE = 1.3; +// Scaling applied based on the size of the object being focused (Larger values focus further away) +var FOCUS_ZOOM_SCALE = 2.3; // Minimum zoom level when focusing on an object var FOCUS_MIN_ZOOM = 0.5;