From 223350b7be507b67365d84e8fa3aca6fac4389cf Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 20 Jun 2018 16:21:29 -0700 Subject: [PATCH] remove logging, play with debounce times --- .../system/particle_explorer/hifi-entity-ui.js | 16 ++++++---------- .../particle_explorer/particleExplorerTool.js | 10 +++++----- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 6ad3ed011c..36505a0b7f 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -44,6 +44,7 @@ and If there is any changes to either the Entities or properties of **/ var RADIANS_PER_DEGREE = Math.PI / 180; +var DEBOUNCE_TIMEOUT = 125; var roundFloat = function (input, round) { round = round ? round : 1000; @@ -58,17 +59,16 @@ var roundFloat = function (input, round) { function HifiEntityUI(parent) { this.parent = parent; - console.log("Creating a new Entity UI instance!"); + var self = this; this.settingsUpdateLock = false; this.webBridgeSync = _.debounce(function (id, val) { if (self.EventBridge && !self.settingsUpdateLock) { - console.log(id + " " + val + " " + self.webBridgeSync); var sendPackage = {}; sendPackage[id] = val; self.submitChanges(sendPackage); } - }, 125); + }, DEBOUNCE_TIMEOUT); } HifiEntityUI.prototype = { @@ -159,7 +159,6 @@ HifiEntityUI.prototype = { var self = this; var fields = document.getElementsByTagName("input"); - console.log("Locking Settings Update while filling input Fields."); self.settingsUpdateLock = true; if (!currentProperties.locked) { for (var i = 0; i < fields.length; i++) { @@ -238,9 +237,8 @@ HifiEntityUI.prototype = { } // Now unlocking settings Update lock for sending messages on callbacks. setTimeout(function () { - console.log("Unlocking UI"); self.settingsUpdateLock = false; - }, 50); + }, DEBOUNCE_TIMEOUT * 2.5); }, connect: function (EventBridge) { this.EventBridge = EventBridge; @@ -276,7 +274,6 @@ HifiEntityUI.prototype = { if (!currentProperties.colorFinish || !currentProperties.colorFinish.red) { currentProperties.colorFinish = currentProperties.color; } - console.log("Got ScriptEvent particle_settings", data); self.fillFields(currentProperties); // Do expected property match with structure; } else if (data.messageType === 'particle_close') { @@ -285,7 +282,6 @@ HifiEntityUI.prototype = { }); }, build: function () { - console.log("Building UI Anew"); var self = this; var sections = Object.keys(this.structure); this.builtRows = {}; @@ -541,7 +537,7 @@ HifiEntityUI.prototype = { textureImage.classList.remove("no-preview"); textureImage.classList.add("no-texture"); } - }, 250); + }, DEBOUNCE_TIMEOUT * 2); textureUrl.oninput = function (event) { // Add throttle @@ -728,4 +724,4 @@ HifiEntityUI.prototype = { } return row; } -}; +}; \ No newline at end of file diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index f9f4842411..a1f06fda35 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -54,7 +54,6 @@ ParticleExplorerTool = function() { Entities.editEntity(that.activeParticleEntity, data.updatedSettings); for (var key in data.updatedSettings) { - print(key + " " + that.activeParticleProperties.hasOwnProperty(key) + " " + data.updatedSettings[key]) if (that.activeParticleProperties.hasOwnProperty(key)) { that.activeParticleProperties[key] = data.updatedSettings[key]; } @@ -65,10 +64,11 @@ ParticleExplorerTool = function() { var entityProps = Entities.getEntityProperties(that.activeParticleProperties, optionalProps); var needsUpdate = false; for (var i = 0; i < optionalProps.length; i++) { - if (data.updatedSettings[fallbackProps[Math.floor(i / 2)]]) { - var prop = optionalProps[i * 2]; - if (!that.activeParticleProperties[prop] || !that.activeParticleProperties[prop].red) { - that.activeParticleProperties[prop] = entityProps[fallbackProps[Math.floor(i / 2)]]; + var fallback = fallbackProps[Math.floor(i / 2)]; + if (data.updatedSettings[fallback]) { + var prop = optionalProps[i]; + if (!that.activeParticleProperties[prop] || (fallback === "color" && !that.activeParticleProperties[prop].red)) { + that.activeParticleProperties[prop] = entityProps[fallback]; needsUpdate = true; } }