From 4842de8f070f79d3be11254dceeafda6ab9cccf3 Mon Sep 17 00:00:00 2001 From: Menithal Date: Sun, 4 Jun 2017 00:03:14 +0300 Subject: [PATCH] Fixed issue with orientation --- scripts/system/edit.js | 22 ++++---------- .../particle_explorer/hifi-entity-ui.js | 30 ++++++++++--------- .../particle_explorer/particleExplorer.html | 2 +- .../particle_explorer/particleExplorer.js | 6 +++- .../particle_explorer/particleExplorerTool.js | 8 ++++- 5 files changed, 35 insertions(+), 33 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 1c4e41da60..1af928c64a 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -80,22 +80,7 @@ selectionManager.addEventListener(function () { } var type = Entities.getEntityProperties(selectedEntityID, "type").type; if (type === "ParticleEffect") { - // Destroy the old particles web view first - particleExplorerTool.destroyWebView(); - particleExplorerTool.createWebView(); - var properties = Entities.getEntityProperties(selectedEntityID); - var particleData = { - messageType: "particle_settings", - currentProperties: properties - }; - selectedParticleEntityID = selectedEntityID; - particleExplorerTool.setActiveParticleEntity(selectedParticleEntityID); - particleData.emitOrientation = Quat.safeEulerAngles(particleData.emitOrientation); - particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); - - // Switch to particle explorer - var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - tablet.sendToQml({method: 'selectTab', params: {id: 'particle'}}); + selectParticleEntity(selectedEntityID); } else { needToDestroyParticleExplorer = true; } @@ -2078,6 +2063,10 @@ var selectedParticleEntityID = null; function selectParticleEntity(entityID) { var properties = Entities.getEntityProperties(entityID); + + if(properties.emitOrientation) { + properties.emitOrientation = Quat.safeEulerAngles(properties.emitOrientation); + } var particleData = { messageType: "particle_settings", currentProperties: properties @@ -2087,6 +2076,7 @@ function selectParticleEntity(entityID) { selectedParticleEntity = entityID; particleExplorerTool.setActiveParticleEntity(entityID); + particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); // Switch to particle explorer diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 06adddab6a..66f8e74b1c 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -45,8 +45,9 @@ and If there is any changes to either the Entities or properties of var RADIAN = Math.PI / 180; -var roundFloat = function (input) { - return Math.floor(parseFloat(input) * 1000)/1000; +var roundFloat = function (input, round) { + round = round ? round: 1000; + return Math.round(parseFloat(input) * round)/round; }; function HifiEntityUI(parent) { @@ -186,9 +187,9 @@ HifiEntityUI.prototype = { var red = document.getElementById(value + "-red"); var blue = document.getElementById(value + "-blue"); var green = document.getElementById(value + "-green"); - red.value = roundFloat(property.red); - blue.value = roundFloat(property.blue); - green.value = roundFloat(property.green); + red.value = parseInt(property.red); + blue.value = parseInt(property.blue); + green.value = parseInt(property.green); red.oninput({ target: red @@ -197,18 +198,19 @@ HifiEntityUI.prototype = { var x = document.getElementById(value + "-x"); var y = document.getElementById(value + "-y"); var z = document.getElementById(value + "-z"); - // crashes here. - x.value = roundFloat(property.x); - y.value = roundFloat(property.y); - z.value = roundFloat(property.z); + + x.value = roundFloat(property.x, 100); + y.value = roundFloat(property.y, 100); + z.value = roundFloat(property.z, 100); } else if (field.className.indexOf("pyr") !== -1) { var pitch = document.getElementById(value + "-Pitch"); var yaw = document.getElementById(value + "-Yaw"); var roll = document.getElementById(value + "-Roll"); - // crashes here. - pitch.value = roundFloat(property.x); - yaw.value = roundFloat(property.y); - roll.value = roundFloat(property.z); + + pitch.value = roundFloat(property.x, 100); + yaw.value = roundFloat(property.y, 100); + roll.value = roundFloat(property.z, 100); + } } } @@ -301,7 +303,7 @@ HifiEntityUI.prototype = { sectionDivBody.style.maxHeight = "0px"; } else { sectionDivBody.className += " visible"; - sectionDivBody.style.maxHeight = height; + sectionDivBody.style.maxHeight = (animationWrapper.clientHeight) + "px"; } // sectionDivBody.style.display = collapsed ? "none": "block"; dropDown.innerHTML = collapsed ? "L" : "M"; diff --git a/scripts/system/particle_explorer/particleExplorer.html b/scripts/system/particle_explorer/particleExplorer.html index f1afc25d82..0f014e9fa8 100644 --- a/scripts/system/particle_explorer/particleExplorer.html +++ b/scripts/system/particle_explorer/particleExplorer.html @@ -23,7 +23,7 @@ - + diff --git a/scripts/system/particle_explorer/particleExplorer.js b/scripts/system/particle_explorer/particleExplorer.js index c16ac79b82..82c74da0f5 100644 --- a/scripts/system/particle_explorer/particleExplorer.js +++ b/scripts/system/particle_explorer/particleExplorer.js @@ -149,7 +149,11 @@ id: "emitOrientation", unit: "deg", name: "Emit Orientation", - type: "VectorQuaternion" + type: "VectorQuaternion", + defaultRange: { + min: 0, + step: 0.01 + } }, { type: "Row" }, { diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index 46bc0323c5..0603583e2b 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -37,8 +37,14 @@ ParticleExplorerTool = function() { that.webEventReceived = function(data) { var data = JSON.parse(data); if (data.messageType === "settings_update") { - data.updatedSettings.emitOrientation = Quat.fromVec3Degrees(data.updatedSettings.emitOrientation); + if (data.updatedSettings.emitOrientation) { + data.updatedSettings.emitOrientation = Quat.fromVec3Degrees(data.updatedSettings.emitOrientation); + } Entities.editEntity(that.activeParticleEntity, data.updatedSettings); + + if ( data.updatedSettings.emitOrientation ) { + print('-settings-udate- ' + that.activeParticleEntity + ' - ' + JSON.stringify(data.updatedSettings)); + } } }