diff --git a/interface/resources/qml/hifi/tablet/EditTabView.qml b/interface/resources/qml/hifi/tablet/EditTabView.qml index c4927fdfbb..ae83cc3f65 100644 --- a/interface/resources/qml/hifi/tablet/EditTabView.qml +++ b/interface/resources/qml/hifi/tablet/EditTabView.qml @@ -273,10 +273,10 @@ TabView { // This should eventually be done properly so that if more tabs are added // that it would remove by title name instead. function enableParticles(enabled) { - if (enabled && editTabView.children.length < 4) { + if (enabled && editTabView.count < 5) { console.log("ADDING PARTICLES TAB"); editTabView.addTab("P", Qt.createComponent("tabs/ParticleTab.qml")); - } else if (!enabled && editTabView.children.length > 2) { + } else if (!enabled && editTabView.count > 4) { console.log("REMOVING PARTICLES TAB"); editTabView.removeTab(4); } diff --git a/scripts/system/edit.js b/scripts/system/edit.js index ea029d44e5..7b014a7fd9 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -83,8 +83,8 @@ selectionManager.addEventListener(function () { if (type === "ParticleEffect") { // Destroy the old particles web view first - particleExplorerTool.destroyWebView(); - particleExplorerTool.createWebView(); + // particleExplorerTool.destroyWebView(); + particleExplorerTool.bindWebView(); var properties = Entities.getEntityProperties(selectedEntityID); var particleData = { messageType: "particle_settings", @@ -112,7 +112,7 @@ selectionManager.addEventListener(function () { if (needToDestroyParticleExplorer && selectedParticleEntityID !== null) { tablet.sendToQml({method: 'enableParticles', params: {enabled: false}}); selectedParticleEntityID = null; - particleExplorerTool.destroyWebView(); + particleExplorerTool.bindWebView(); } }); @@ -870,13 +870,13 @@ function mouseClickEvent(event) { selectedEntityID = foundEntity; orientation = MyAvatar.orientation; intersection = rayPlaneIntersection(pickRay, P, Quat.getForward(orientation)); - + /* if (event.isShifted) { particleExplorerTool.destroyWebView(); - } + }*/ if (properties.type !== "ParticleEffect") { tablet.sendToQml({method: 'enableParticles', params: {enabled: false}}); - particleExplorerTool.destroyWebView(); + // particleExplorerTool.destroyWebView(); } else { tablet.sendToQml({method: 'enableParticles', params: {enabled: true}}); } @@ -1310,7 +1310,7 @@ function parentSelectedEntities() { function deleteSelectedEntities() { if (SelectionManager.hasSelection()) { selectedParticleEntityID = null; - particleExplorerTool.destroyWebView(); + // particleExplorerTool.destroyWebView(); SelectionManager.saveProperties(); var savedProperties = []; var newSortedSelection = sortSelectedEntities(selectionManager.selections); @@ -2095,8 +2095,8 @@ function selectParticleEntity(entityID) { messageType: "particle_settings", currentProperties: properties }; - particleExplorerTool.destroyWebView(); - particleExplorerTool.createWebView(); + // particleExplorerTool.destroyWebView(); + particleExplorerTool.bindWebView(); selectedParticleEntity = entityID; particleExplorerTool.setActiveParticleEntity(entityID); @@ -2128,7 +2128,7 @@ entityListTool.webView.webEventReceived.connect(function (data) { } else { tablet.sendToQml({method: 'enableParticles', params: {enabled: false}}); selectedParticleEntity = 0; - particleExplorerTool.destroyWebView(); + //particleExplorerTool.destroyWebView(); } } } diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 167a022b58..f9059b9b6b 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -69,7 +69,6 @@ HifiEntityUI.prototype = { data = JSON.parse(data); if (data.messageType === 'particle_settings') { // Update settings - console.log(data); var currentProperties = data.currentProperties; // Do expected property match with structure; Object.keys(currentProperties).forEach(function(value, index) { @@ -81,7 +80,7 @@ HifiEntityUI.prototype = { if (field.className.indexOf("radian") !== -1) { el.value = property / RADIAN; el.onchange({target: el}); - } else if (field.className.indexOf("range") !== -1 || field.className.indexOf("texture") !== -1){ + } else if (field.className.indexOf("range") !== -1 || field.className.indexOf("texture") !== -1) { el.value = property; el.onchange({target: el}); } else if (field.className.indexOf("checkbox") !== -1) { @@ -102,19 +101,16 @@ HifiEntityUI.prototype = { // crashes here. } else if (field.className.indexOf("xyz")) { - + /* var x = document.getElementById(value+"-x"); var y = document.getElementById(value+"-y"); var z = document.getElementById(value+"-z"); // crashes here. - if (value === "emitOrientation") { - - } else { - x.value = property.x; - y.value = property.y; - z.value = property.z; - } + x.value = property.x; + y.value = property.y; + z.value = property.z; + */ } } } @@ -157,7 +153,7 @@ HifiEntityUI.prototype = { for (var property in properties) { - var builtRow = self.addElement(animationWrapper, properties[property]) + var builtRow = self.addElement(animationWrapper, properties[property]); var id = properties[property].id; if (id) { self.builtRows[id] = builtRow; @@ -207,20 +203,14 @@ HifiEntityUI.prototype = { } return label; }, - addVector: function(parent, group){ + addVector: function(parent, group, labels){ var self = this; - var inputs = ["x","y","z"]; + var inputs = labels | ["x","y","z"]; var domArray = []; parent.id = group.id; for (var index in inputs) { var element = document.createElement("input"); - if (group.defaultColor) { - element.value = group.defaultColor[inputs[index]]; - } else if (inputs[index] === "red"){ - element.value = 255; - } else { - element.value = 0; - } + element.setAttribute("type","number"); element.className = inputs[index]; element.id = group.id + "-" + inputs[index]; @@ -232,7 +222,11 @@ HifiEntityUI.prototype = { } this.addLabel(parent, group); - parent.className += " property vector-section xyz"; + var className = ""; + for ( var i = 0; i < inputs.length; i++) { + className += inputs[i]; + } + parent.className += " property vector-section " + className; // Add Tuple and the rest var tupleContainer = document.createElement("div"); @@ -250,7 +244,7 @@ HifiEntityUI.prototype = { parent.appendChild(tupleContainer); }, addVectorQuaternion: function(parent, group) { - this.addVector(parent,group); + this.addVector(parent,group, ["Pitch", "Yaw", "Roll"]); }, addColorPicker: function(parent, group) { var self = this; diff --git a/scripts/system/particle_explorer/particleExplorer.html b/scripts/system/particle_explorer/particleExplorer.html index fd8fec3f21..f1afc25d82 100644 --- a/scripts/system/particle_explorer/particleExplorer.html +++ b/scripts/system/particle_explorer/particleExplorer.html @@ -33,7 +33,6 @@
-
diff --git a/scripts/system/particle_explorer/particleExplorer.js b/scripts/system/particle_explorer/particleExplorer.js index 5807b7d29e..c619d58a33 100644 --- a/scripts/system/particle_explorer/particleExplorer.js +++ b/scripts/system/particle_explorer/particleExplorer.js @@ -81,7 +81,7 @@ id: "emitOrientation", unit: "deg", name: "Emit Orientation", - type: "Vector" + type: "VectorQuaternion" }, { type: "Row" }, { diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index 5e240ed192..3d434b148a 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -16,8 +16,17 @@ var PARTICLE_EXPLORER_HTML_URL = Script.resolvePath(' .html'); ParticleExplorerTool = function() { var that = {}; - - that.createWebView = function() { + var bound = false; + that.bindWebView = function() { + if (!bound) { + that.webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + that.webView.setVisible = function(value) {}; + that.webView.webEventReceived.connect(that.webEventReceived); + bound = true; + } + } + /* + that.createWebView = function() { that.webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); that.webView.setVisible = function(value) {}; that.webView.webEventReceived.connect(that.webEventReceived); @@ -35,16 +44,17 @@ ParticleExplorerTool = function() { that.webView.emitScriptEvent(JSON.stringify(messageData)); } + */ that.webEventReceived = function(data) { - var data = JSON.parse(data); - if (data.messageType === "settings_update") { - Entities.editEntity(that.activeParticleEntity, data.updatedSettings); + var message = JSON.parse(data); + if (message.messageType === "settings_update") { + Entities.editEntity(that.activeParticleEntity, message.updatedSettings); } - } + }; that.setActiveParticleEntity = function(id) { that.activeParticleEntity = id; - } + }; return that; };