From 2f0877dc0f58599f6dfa3b1ba3f8a08f3371564a Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 19 Jun 2018 16:36:13 -0700 Subject: [PATCH] debugging js --- .../particle_explorer/hifi-entity-ui.js | 9 +++++---- .../particle_explorer/particleExplorerTool.js | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index a04c3a8f5d..a9ebaea1c4 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -61,6 +61,7 @@ function HifiEntityUI(parent) { var self = this; this.webBridgeSync = _.debounce(function (id, val) { + console.log(id + " " + val + " " + self.webBridgeSync); if (self.EventBridge) { var sendPackage = {}; sendPackage[id] = val; @@ -256,10 +257,10 @@ HifiEntityUI.prototype = { if (!currentProperties.radiusFinish) { currentProperties.radiusFinish = currentProperties.particleRadius; } - if (!currentProperties.colorStart.red) { + if (!currentProperties.colorStart || !currentProperties.colorStart.red) { currentProperties.colorStart = currentProperties.color; } - if (!currentProperties.colorFinish.red) { + if (!currentProperties.colorFinish || !currentProperties.colorFinish.red) { currentProperties.colorFinish = currentProperties.color; } self.fillFields(currentProperties); @@ -573,7 +574,7 @@ HifiEntityUI.prototype = { inputField.onchange = inputField.oninput; slider.oninput = function (event) { inputField.value = event.target.value; - self.webBridgeSync(group.id, slider.value); + self.webBridgeSync(group.id, inputField.value); }; inputField.id = group.id; @@ -598,7 +599,7 @@ HifiEntityUI.prototype = { } else { inputField.value = Math.ceil(event.target.value); } - self.webBridgeSync(group.id, slider.value * RADIANS_PER_DEGREE); + self.webBridgeSync(group.id, inputField.value * RADIANS_PER_DEGREE); }; var degrees = document.createElement("label"); degrees.innerHTML = "°"; diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index de2cb0bd8b..f9f4842411 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -54,11 +54,30 @@ 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]; } } + var optionalProps = ["alphaStart", "alphaFinish", "radiusStart", "radiusFinish", "colorStart", "colorFinish"]; + var fallbackProps = ["alpha", "particleRadius", "color"]; + 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)]]; + needsUpdate = true; + } + } + } + + if (needsUpdate) { + sendActiveParticleProperties(); + } + } else if (data.messageType === "page_loaded") { sendActiveParticleProperties(); }