Fixed issue with orientation

This commit is contained in:
Menithal 2017-06-04 00:03:14 +03:00
parent e76dfe4182
commit 4842de8f07
5 changed files with 35 additions and 33 deletions

View file

@ -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

View file

@ -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";

View file

@ -23,7 +23,7 @@
<script type="text/javascript" src="../html/js/colpick.js"></script>
<script type="text/javascript" src="underscore-min.js"></script>
<script type="text/javascript" src="hifi-entity-ui.js"></script>
<script type="text/javascript" src="hifi-entity-ui.js?v1"></script>
<link rel="stylesheet" type="text/css" href="../html/css/hifi-style.css">
<link rel="stylesheet" type="text/css" href="../html/css/edit-style.css">

View file

@ -149,7 +149,11 @@
id: "emitOrientation",
unit: "deg",
name: "Emit Orientation",
type: "VectorQuaternion"
type: "VectorQuaternion",
defaultRange: {
min: 0,
step: 0.01
}
},
{ type: "Row" },
{

View file

@ -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));
}
}
}