From 03cec8cb54b31aa043d00aed560e0db9ffd9c650 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 30 May 2018 17:15:33 +1200 Subject: [PATCH 1/5] Fix properties not populating particle explorer tab --- scripts/system/edit.js | 11 +++----- .../particle_explorer/particleExplorerTool.js | 26 ++++++++++++++++--- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index f549c7dd85..9285023ed8 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -2366,22 +2366,19 @@ var selectedParticleEntity = 0; var selectedParticleEntityID = null; function selectParticleEntity(entityID) { - var properties = Entities.getEntityProperties(entityID); selectedParticleEntityID = entityID; + + var properties = Entities.getEntityProperties(entityID); if (properties.emitOrientation) { properties.emitOrientation = Quat.safeEulerAngles(properties.emitOrientation); } - var particleData = { - messageType: "particle_settings", - currentProperties: properties - }; + particleExplorerTool.destroyWebView(); particleExplorerTool.createWebView(); selectedParticleEntity = entityID; particleExplorerTool.setActiveParticleEntity(entityID); - - particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); + particleExplorerTool.setActiveParticleProperties(properties); // Switch to particle explorer var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index d85fc169b1..016691e2b6 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -16,37 +16,55 @@ var PARTICLE_EXPLORER_HTML_URL = Script.resolvePath('particleExplorer.html'); ParticleExplorerTool = function() { var that = {}; + that.activeParticleEntity = 0; + that.activeParticleProperties = {}; + that.createWebView = function() { that.webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); that.webView.setVisible = function(value) {}; that.webView.webEventReceived.connect(that.webEventReceived); - } + }; that.destroyWebView = function() { if (!that.webView) { return; } that.activeParticleEntity = 0; + that.activeParticleProperties = {}; var messageData = { messageType: "particle_close" }; that.webView.emitScriptEvent(JSON.stringify(messageData)); + }; + + function sendActiveParticleProperies() { + that.webView.emitScriptEvent(JSON.stringify({ + messageType: "particle_settings", + currentProperties: that.activeParticleProperties + })); } that.webEventReceived = function(data) { - var data = JSON.parse(data); + data = JSON.parse(data); if (data.messageType === "settings_update") { if (data.updatedSettings.emitOrientation) { data.updatedSettings.emitOrientation = Quat.fromVec3Degrees(data.updatedSettings.emitOrientation); } Entities.editEntity(that.activeParticleEntity, data.updatedSettings); + } else if (data.messageType === "page_loaded") { + sendActiveParticleProperies(); } - } + }; that.setActiveParticleEntity = function(id) { that.activeParticleEntity = id; - } + }; + + that.setActiveParticleProperties = function(properties) { + that.activeParticleProperties = properties; + sendActiveParticleProperies(); + }; return that; }; From 8c9bdf51a7077b11347951c723d9b7e90a4fff6f Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 30 May 2018 17:16:08 +1200 Subject: [PATCH 2/5] Remove superfluous variable --- scripts/system/edit.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 9285023ed8..05f5e3cb19 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -2362,7 +2362,6 @@ var showMenuItem = propertyMenu.addMenuItem("Show in Marketplace"); var propertiesTool = new PropertiesTool(); var particleExplorerTool = new ParticleExplorerTool(); -var selectedParticleEntity = 0; var selectedParticleEntityID = null; function selectParticleEntity(entityID) { @@ -2376,7 +2375,6 @@ function selectParticleEntity(entityID) { particleExplorerTool.destroyWebView(); particleExplorerTool.createWebView(); - selectedParticleEntity = entityID; particleExplorerTool.setActiveParticleEntity(entityID); particleExplorerTool.setActiveParticleProperties(properties); @@ -2401,13 +2399,13 @@ entityListTool.webView.webEventReceived.connect(function (data) { var ids = data.entityIds; if (ids.length === 1) { if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect") { - if (JSON.stringify(selectedParticleEntity) === JSON.stringify(ids[0])) { + if (JSON.stringify(selectedParticleEntityID) === JSON.stringify(ids[0])) { // This particle entity is already selected, so return return; } // Destroy the old particles web view first } else { - selectedParticleEntity = 0; + selectedParticleEntityID = 0; particleExplorerTool.destroyWebView(); } } From 3c5a779a9843329d519d2d96cac168bd2a03fad3 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 1 Jun 2018 09:36:28 +1200 Subject: [PATCH 3/5] Don't modify function parameter --- scripts/system/particle_explorer/particleExplorerTool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index 016691e2b6..0543cfc56b 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -45,8 +45,8 @@ ParticleExplorerTool = function() { })); } - that.webEventReceived = function(data) { - data = JSON.parse(data); + that.webEventReceived = function(message) { + var data = JSON.parse(message); if (data.messageType === "settings_update") { if (data.updatedSettings.emitOrientation) { data.updatedSettings.emitOrientation = Quat.fromVec3Degrees(data.updatedSettings.emitOrientation); From b4b63187aedcb2e9cd6037c123ff365675cb7587 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 5 Jun 2018 08:48:10 +1200 Subject: [PATCH 4/5] Fix typo --- scripts/system/particle_explorer/particleExplorerTool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index 0543cfc56b..5e5be9ead0 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -38,7 +38,7 @@ ParticleExplorerTool = function() { that.webView.emitScriptEvent(JSON.stringify(messageData)); }; - function sendActiveParticleProperies() { + function sendActiveParticleProperties() { that.webView.emitScriptEvent(JSON.stringify({ messageType: "particle_settings", currentProperties: that.activeParticleProperties @@ -53,7 +53,7 @@ ParticleExplorerTool = function() { } Entities.editEntity(that.activeParticleEntity, data.updatedSettings); } else if (data.messageType === "page_loaded") { - sendActiveParticleProperies(); + sendActiveParticleProperties(); } }; @@ -63,7 +63,7 @@ ParticleExplorerTool = function() { that.setActiveParticleProperties = function(properties) { that.activeParticleProperties = properties; - sendActiveParticleProperies(); + sendActiveParticleProperties(); }; return that; From 32c21a1397b048d7aff3fde7a77aec40f966dcfc Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 7 Jun 2018 12:22:56 +1200 Subject: [PATCH 5/5] Fix particle property value reverting to old value when switch tabs --- scripts/system/particle_explorer/particleExplorerTool.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index 5e5be9ead0..de2cb0bd8b 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -52,6 +52,13 @@ ParticleExplorerTool = function() { data.updatedSettings.emitOrientation = Quat.fromVec3Degrees(data.updatedSettings.emitOrientation); } Entities.editEntity(that.activeParticleEntity, data.updatedSettings); + + for (var key in data.updatedSettings) { + if (that.activeParticleProperties.hasOwnProperty(key)) { + that.activeParticleProperties[key] = data.updatedSettings[key]; + } + } + } else if (data.messageType === "page_loaded") { sendActiveParticleProperties(); }