From b8737ad5257058b6edea3f1fa17514b6a0bec2a4 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:26:07 -0800 Subject: [PATCH 1/8] Update 'f' focus to only work when something is selected --- examples/editEntities.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index e9f42bf74c..fc48cf22b5 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -839,9 +839,11 @@ Controller.keyReleaseEvent.connect(function (event) { selectionDisplay.toggleSpaceMode(); } else if (event.text == "f") { if (isActive) { - cameraManager.focus(selectionManager.worldPosition, - selectionManager.worldDimensions, - Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); + if (selectionManager.hasSelection()) { + cameraManager.focus(selectionManager.worldPosition, + selectionManager.worldDimensions, + Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); + } } } else if (event.text == '[') { if (isActive) { From d1f5bf2e3cdf9c68229dded470df12adc90140e9 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:27:30 -0800 Subject: [PATCH 2/8] Add rotation to properties window --- examples/editEntities.js | 5 +++++ examples/html/entityProperties.html | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/examples/editEntities.js b/examples/editEntities.js index fc48cf22b5..980f38f2cc 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -1004,6 +1004,7 @@ PropertiesTool = function(opts) { }; if (selectionManager.hasSelection()) { data.properties = Entities.getEntityProperties(selectionManager.selections[0]); + data.properties.rotation = Quat.safeEulerAngles(data.properties.rotation); } webView.eventBridge.emitScriptEvent(JSON.stringify(data)); }); @@ -1012,6 +1013,10 @@ PropertiesTool = function(opts) { print(data); data = JSON.parse(data); if (data.type == "update") { + if (data.properties.rotation !== undefined) { + var rotation = data.properties.rotation; + data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z); + } Entities.editEntity(selectionManager.selections[0], data.properties); selectionManager._update(); } diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 17eb0ad88f..d30aac72ee 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -85,6 +85,10 @@ var elRegistrationY = document.getElementById("property-reg-y"); var elRegistrationZ = document.getElementById("property-reg-z"); + var elRotationX = document.getElementById("property-rot-x"); + var elRotationY = document.getElementById("property-rot-y"); + var elRotationZ = document.getElementById("property-rot-z"); + var elLinearVelocityX = document.getElementById("property-lvel-x"); var elLinearVelocityY = document.getElementById("property-lvel-y"); var elLinearVelocityZ = document.getElementById("property-lvel-z"); @@ -181,6 +185,10 @@ elRegistrationY.value = properties.registrationPoint.y.toFixed(2); elRegistrationZ.value = properties.registrationPoint.z.toFixed(2); + elRotationX.value = properties.rotation.x.toFixed(2); + elRotationY.value = properties.rotation.y.toFixed(2); + elRotationZ.value = properties.rotation.z.toFixed(2); + elLinearVelocityX.value = properties.velocity.x.toFixed(2); elLinearVelocityY.value = properties.velocity.y.toFixed(2); elLinearVelocityZ.value = properties.velocity.z.toFixed(2); @@ -302,6 +310,12 @@ elRegistrationY.addEventListener('change', registrationChangeFunction); elRegistrationZ.addEventListener('change', registrationChangeFunction); + var rotationChangeFunction = createEmitVec3PropertyUpdateFunction( + 'rotation', elRotationX, elRotationY, elRotationZ); + elRotationX.addEventListener('change', rotationChangeFunction); + elRotationY.addEventListener('change', rotationChangeFunction); + elRotationZ.addEventListener('change', rotationChangeFunction); + var velocityChangeFunction = createEmitVec3PropertyUpdateFunction( 'velocity', elLinearVelocityX, elLinearVelocityY, elLinearVelocityZ); elLinearVelocityX.addEventListener('change', velocityChangeFunction); @@ -486,6 +500,15 @@ + + Rotation + +
Pitch
+
Yaw
+
Roll
+ + + Linear Velocity From 1a90a810379dd1ad196af9aeafa3792b89fa5d91 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:27:56 -0800 Subject: [PATCH 3/8] Add id to properties window --- examples/editEntities.js | 1 + examples/html/entityProperties.html | 11 +++++++++++ examples/html/style.css | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/examples/editEntities.js b/examples/editEntities.js index 980f38f2cc..ea6496d4f5 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -1003,6 +1003,7 @@ PropertiesTool = function(opts) { type: 'update', }; if (selectionManager.hasSelection()) { + data.id = selectionManager.selections[0].id; data.properties = Entities.getEntityProperties(selectionManager.selections[0]); data.properties.rotation = Quat.safeEulerAngles(data.properties.rotation); } diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index d30aac72ee..a34f7ce13f 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -70,6 +70,7 @@ }; function loaded() { + var elID = document.getElementById("property-id"); var elType = document.getElementById("property-type"); var elLocked = document.getElementById("property-locked"); var elVisible = document.getElementById("property-visible"); @@ -160,6 +161,8 @@ } else { var properties = data.properties; + elID.innerHTML = data.id; + elType.innerHTML = properties.type; elLocked.checked = properties.locked; @@ -451,6 +454,14 @@ + + + ID + + + + + Type diff --git a/examples/html/style.css b/examples/html/style.css index 424933e14e..aa23cf97ab 100644 --- a/examples/html/style.css +++ b/examples/html/style.css @@ -17,6 +17,17 @@ body { user-select: none; } +.selectable { + -webkit-touch-callout: text; + -webkit-user-select: text; + -khtml-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + + cursor: text; +} + .color-box { display: inline-block; width: 20px; From a5cbc9b3e2fa3aa8e3544d30dc66529c4cc785f3 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:28:22 -0800 Subject: [PATCH 4/8] Fix properties window to work with undo/redo --- examples/editEntities.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/editEntities.js b/examples/editEntities.js index ea6496d4f5..b671e45d7c 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -1014,11 +1014,13 @@ PropertiesTool = function(opts) { print(data); data = JSON.parse(data); if (data.type == "update") { + selectionManager.saveProperties(); if (data.properties.rotation !== undefined) { var rotation = data.properties.rotation; data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z); } Entities.editEntity(selectionManager.selections[0], data.properties); + pushCommandForSelections(); selectionManager._update(); } }); From 33b4c614eae17ad3ef7c54a821e929f2ffb0ee52 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:28:57 -0800 Subject: [PATCH 5/8] Add buttons for moving selection to grid and resetting to natural dimensions --- examples/editEntities.js | 48 +++++++++++++++++++++++++++++ examples/html/entityProperties.html | 29 +++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/examples/editEntities.js b/examples/editEntities.js index b671e45d7c..3f133ac0b2 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -1022,6 +1022,54 @@ PropertiesTool = function(opts) { Entities.editEntity(selectionManager.selections[0], data.properties); pushCommandForSelections(); selectionManager._update(); + } else if (data.type == "action") { + if (data.action == "moveSelectionToGrid") { + if (!selectionManager.hasSelection()) { + return; + } + selectionManager.saveProperties(); + var dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2), + var diff = { x: 0, y: dY, z: 0 }; + for (var i = 0; i < SelectionManager.selections.length; i++) { + var properties = SelectionManager.savedProperties[SelectionManager.selections[i].id]; + var newPosition = Vec3.sum(properties.position, diff); + Entities.editEntity(SelectionManager.selections[i], { + position: newPosition, + }); + } + pushCommandForSelections(); + selectionManager._update(); + } else if (data.action == "moveAllToGrid") { + if (!selectionManager.hasSelection()) { + return; + } + selectionManager.saveProperties(); + for (var i = 0; i < SelectionManager.selections.length; i++) { + var properties = SelectionManager.savedProperties[SelectionManager.selections[i].id]; + var bottomY = properties.boundingBox.center.y - properties.boundingBox.dimensions.y / 2; + var dY = grid.getOrigin().y - bottomY; + var diff = { x: 0, y: dY, z: 0 }; + var newPosition = Vec3.sum(properties.position, diff); + Entities.editEntity(SelectionManager.selections[i], { + position: newPosition, + }); + } + pushCommandForSelections(); + selectionManager._update(); + } else if (data.action == "resetToNaturalDimensions") { + if (!selectionManager.hasSelection()) { + return; + } + selectionManager.saveProperties(); + for (var i = 0; i < SelectionManager.selections.length; i++) { + var properties = SelectionManager.savedProperties[SelectionManager.selections[i].id]; + Entities.editEntity(SelectionManager.selections[i], { + dimensions: properties.naturalDimensions, + }); + } + pushCommandForSelections(); + selectionManager._update(); + } } }); diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index a34f7ce13f..48804d475a 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -77,10 +77,13 @@ var elPositionX = document.getElementById("property-pos-x"); var elPositionY = document.getElementById("property-pos-y"); var elPositionZ = document.getElementById("property-pos-z"); + var elMoveSelectionToGrid = document.getElementById("move-selection-to-grid"); + var elMoveAllToGrid = document.getElementById("move-all-to-grid"); var elDimensionsX = document.getElementById("property-dim-x"); var elDimensionsY = document.getElementById("property-dim-y"); var elDimensionsZ = document.getElementById("property-dim-z"); + var elResetToNaturalDimensions = document.getElementById("reset-to-natural-dimensions"); var elRegistrationX = document.getElementById("property-reg-x"); var elRegistrationY = document.getElementById("property-reg-y"); @@ -398,6 +401,25 @@ elTextBackgroundColorGreen.addEventListener('change', textBackgroundColorChangeFunction); elTextBackgroundColorBlue.addEventListener('change', textBackgroundColorChangeFunction); + elMoveSelectionToGrid.addEventListener("click", function() { + EventBridge.emitWebEvent(JSON.stringify({ + type: "action", + action: "moveSelectionToGrid", + })); + }); + elMoveAllToGrid.addEventListener("click", function() { + EventBridge.emitWebEvent(JSON.stringify({ + type: "action", + action: "moveAllToGrid", + })); + }); + elResetToNaturalDimensions.addEventListener("click", function() { + EventBridge.emitWebEvent(JSON.stringify({ + type: "action", + action: "resetToNaturalDimensions", + })); + }); + var resizing = false; var startX = 0; @@ -490,6 +512,10 @@
X
Y
Z
+
+ + +
@@ -508,6 +534,9 @@
X
Y
Z
+
+ +
From dde9b92dbd4a02d630f171a7f1d72dea36236a88 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:31:54 -0800 Subject: [PATCH 6/8] Update SelectionManager -> selectionManager --- examples/editEntities.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 3f133ac0b2..c2f2ad4086 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -1030,10 +1030,10 @@ PropertiesTool = function(opts) { selectionManager.saveProperties(); var dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2), var diff = { x: 0, y: dY, z: 0 }; - for (var i = 0; i < SelectionManager.selections.length; i++) { - var properties = SelectionManager.savedProperties[SelectionManager.selections[i].id]; + for (var i = 0; i < selectionManager.selections.length; i++) { + var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; var newPosition = Vec3.sum(properties.position, diff); - Entities.editEntity(SelectionManager.selections[i], { + Entities.editEntity(selectionManager.selections[i], { position: newPosition, }); } @@ -1044,13 +1044,13 @@ PropertiesTool = function(opts) { return; } selectionManager.saveProperties(); - for (var i = 0; i < SelectionManager.selections.length; i++) { - var properties = SelectionManager.savedProperties[SelectionManager.selections[i].id]; + for (var i = 0; i < selectionManager.selections.length; i++) { + var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; var bottomY = properties.boundingBox.center.y - properties.boundingBox.dimensions.y / 2; var dY = grid.getOrigin().y - bottomY; var diff = { x: 0, y: dY, z: 0 }; var newPosition = Vec3.sum(properties.position, diff); - Entities.editEntity(SelectionManager.selections[i], { + Entities.editEntity(selectionManager.selections[i], { position: newPosition, }); } @@ -1061,9 +1061,9 @@ PropertiesTool = function(opts) { return; } selectionManager.saveProperties(); - for (var i = 0; i < SelectionManager.selections.length; i++) { - var properties = SelectionManager.savedProperties[SelectionManager.selections[i].id]; - Entities.editEntity(SelectionManager.selections[i], { + for (var i = 0; i < selectionManager.selections.length; i++) { + var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; + Entities.editEntity(selectionManager.selections[i], { dimensions: properties.naturalDimensions, }); } From 2fab404f7fee8c04a0fe3ce2e8a117cb00a57b37 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:35:39 -0800 Subject: [PATCH 7/8] Reorganize selectionManager selection checking --- examples/editEntities.js | 79 +++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index c2f2ad4086..0b5c089c07 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -1024,51 +1024,48 @@ PropertiesTool = function(opts) { selectionManager._update(); } else if (data.type == "action") { if (data.action == "moveSelectionToGrid") { - if (!selectionManager.hasSelection()) { - return; - } - selectionManager.saveProperties(); - var dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2), - var diff = { x: 0, y: dY, z: 0 }; - for (var i = 0; i < selectionManager.selections.length; i++) { - var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; - var newPosition = Vec3.sum(properties.position, diff); - Entities.editEntity(selectionManager.selections[i], { - position: newPosition, - }); - } - pushCommandForSelections(); - selectionManager._update(); - } else if (data.action == "moveAllToGrid") { - if (!selectionManager.hasSelection()) { - return; - } - selectionManager.saveProperties(); - for (var i = 0; i < selectionManager.selections.length; i++) { - var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; - var bottomY = properties.boundingBox.center.y - properties.boundingBox.dimensions.y / 2; - var dY = grid.getOrigin().y - bottomY; + if (selectionManager.hasSelection()) { + selectionManager.saveProperties(); + var dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2), var diff = { x: 0, y: dY, z: 0 }; - var newPosition = Vec3.sum(properties.position, diff); - Entities.editEntity(selectionManager.selections[i], { - position: newPosition, - }); + for (var i = 0; i < selectionManager.selections.length; i++) { + var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; + var newPosition = Vec3.sum(properties.position, diff); + Entities.editEntity(selectionManager.selections[i], { + position: newPosition, + }); + } + pushCommandForSelections(); + selectionManager._update(); + } + } else if (data.action == "moveAllToGrid") { + if (selectionManager.hasSelection()) { + selectionManager.saveProperties(); + for (var i = 0; i < selectionManager.selections.length; i++) { + var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; + var bottomY = properties.boundingBox.center.y - properties.boundingBox.dimensions.y / 2; + var dY = grid.getOrigin().y - bottomY; + var diff = { x: 0, y: dY, z: 0 }; + var newPosition = Vec3.sum(properties.position, diff); + Entities.editEntity(selectionManager.selections[i], { + position: newPosition, + }); + } + pushCommandForSelections(); + selectionManager._update(); } - pushCommandForSelections(); - selectionManager._update(); } else if (data.action == "resetToNaturalDimensions") { - if (!selectionManager.hasSelection()) { - return; + if (selectionManager.hasSelection()) { + selectionManager.saveProperties(); + for (var i = 0; i < selectionManager.selections.length; i++) { + var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; + Entities.editEntity(selectionManager.selections[i], { + dimensions: properties.naturalDimensions, + }); + } + pushCommandForSelections(); + selectionManager._update(); } - selectionManager.saveProperties(); - for (var i = 0; i < selectionManager.selections.length; i++) { - var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; - Entities.editEntity(selectionManager.selections[i], { - dimensions: properties.naturalDimensions, - }); - } - pushCommandForSelections(); - selectionManager._update(); } } }); From a9223f58879f2afbb3cef72ffc4181b24a61dbb2 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:45:31 -0800 Subject: [PATCH 8/8] Remove text from label --- examples/html/entityProperties.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 48804d475a..4e22637ad6 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -481,7 +481,7 @@ ID - +