From d1f5bf2e3cdf9c68229dded470df12adc90140e9 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:27:30 -0800 Subject: [PATCH] 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