remove logging, play with debounce times

This commit is contained in:
SamGondelman 2018-06-20 16:21:29 -07:00
parent ae19f16c3d
commit 223350b7be
2 changed files with 11 additions and 15 deletions

View file

@ -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 RADIANS_PER_DEGREE = Math.PI / 180;
var DEBOUNCE_TIMEOUT = 125;
var roundFloat = function (input, round) { var roundFloat = function (input, round) {
round = round ? round : 1000; round = round ? round : 1000;
@ -58,17 +59,16 @@ var roundFloat = function (input, round) {
function HifiEntityUI(parent) { function HifiEntityUI(parent) {
this.parent = parent; this.parent = parent;
console.log("Creating a new Entity UI instance!");
var self = this; var self = this;
this.settingsUpdateLock = false; this.settingsUpdateLock = false;
this.webBridgeSync = _.debounce(function (id, val) { this.webBridgeSync = _.debounce(function (id, val) {
if (self.EventBridge && !self.settingsUpdateLock) { if (self.EventBridge && !self.settingsUpdateLock) {
console.log(id + " " + val + " " + self.webBridgeSync);
var sendPackage = {}; var sendPackage = {};
sendPackage[id] = val; sendPackage[id] = val;
self.submitChanges(sendPackage); self.submitChanges(sendPackage);
} }
}, 125); }, DEBOUNCE_TIMEOUT);
} }
HifiEntityUI.prototype = { HifiEntityUI.prototype = {
@ -159,7 +159,6 @@ HifiEntityUI.prototype = {
var self = this; var self = this;
var fields = document.getElementsByTagName("input"); var fields = document.getElementsByTagName("input");
console.log("Locking Settings Update while filling input Fields.");
self.settingsUpdateLock = true; self.settingsUpdateLock = true;
if (!currentProperties.locked) { if (!currentProperties.locked) {
for (var i = 0; i < fields.length; i++) { for (var i = 0; i < fields.length; i++) {
@ -238,9 +237,8 @@ HifiEntityUI.prototype = {
} }
// Now unlocking settings Update lock for sending messages on callbacks. // Now unlocking settings Update lock for sending messages on callbacks.
setTimeout(function () { setTimeout(function () {
console.log("Unlocking UI");
self.settingsUpdateLock = false; self.settingsUpdateLock = false;
}, 50); }, DEBOUNCE_TIMEOUT * 2.5);
}, },
connect: function (EventBridge) { connect: function (EventBridge) {
this.EventBridge = EventBridge; this.EventBridge = EventBridge;
@ -276,7 +274,6 @@ HifiEntityUI.prototype = {
if (!currentProperties.colorFinish || !currentProperties.colorFinish.red) { if (!currentProperties.colorFinish || !currentProperties.colorFinish.red) {
currentProperties.colorFinish = currentProperties.color; currentProperties.colorFinish = currentProperties.color;
} }
console.log("Got ScriptEvent particle_settings", data);
self.fillFields(currentProperties); self.fillFields(currentProperties);
// Do expected property match with structure; // Do expected property match with structure;
} else if (data.messageType === 'particle_close') { } else if (data.messageType === 'particle_close') {
@ -285,7 +282,6 @@ HifiEntityUI.prototype = {
}); });
}, },
build: function () { build: function () {
console.log("Building UI Anew");
var self = this; var self = this;
var sections = Object.keys(this.structure); var sections = Object.keys(this.structure);
this.builtRows = {}; this.builtRows = {};
@ -541,7 +537,7 @@ HifiEntityUI.prototype = {
textureImage.classList.remove("no-preview"); textureImage.classList.remove("no-preview");
textureImage.classList.add("no-texture"); textureImage.classList.add("no-texture");
} }
}, 250); }, DEBOUNCE_TIMEOUT * 2);
textureUrl.oninput = function (event) { textureUrl.oninput = function (event) {
// Add throttle // Add throttle
@ -728,4 +724,4 @@ HifiEntityUI.prototype = {
} }
return row; return row;
} }
}; };

View file

@ -54,7 +54,6 @@ ParticleExplorerTool = function() {
Entities.editEntity(that.activeParticleEntity, data.updatedSettings); Entities.editEntity(that.activeParticleEntity, data.updatedSettings);
for (var key in data.updatedSettings) { for (var key in data.updatedSettings) {
print(key + " " + that.activeParticleProperties.hasOwnProperty(key) + " " + data.updatedSettings[key])
if (that.activeParticleProperties.hasOwnProperty(key)) { if (that.activeParticleProperties.hasOwnProperty(key)) {
that.activeParticleProperties[key] = data.updatedSettings[key]; that.activeParticleProperties[key] = data.updatedSettings[key];
} }
@ -65,10 +64,11 @@ ParticleExplorerTool = function() {
var entityProps = Entities.getEntityProperties(that.activeParticleProperties, optionalProps); var entityProps = Entities.getEntityProperties(that.activeParticleProperties, optionalProps);
var needsUpdate = false; var needsUpdate = false;
for (var i = 0; i < optionalProps.length; i++) { for (var i = 0; i < optionalProps.length; i++) {
if (data.updatedSettings[fallbackProps[Math.floor(i / 2)]]) { var fallback = fallbackProps[Math.floor(i / 2)];
var prop = optionalProps[i * 2]; if (data.updatedSettings[fallback]) {
if (!that.activeParticleProperties[prop] || !that.activeParticleProperties[prop].red) { var prop = optionalProps[i];
that.activeParticleProperties[prop] = entityProps[fallbackProps[Math.floor(i / 2)]]; if (!that.activeParticleProperties[prop] || (fallback === "color" && !that.activeParticleProperties[prop].red)) {
that.activeParticleProperties[prop] = entityProps[fallback];
needsUpdate = true; needsUpdate = true;
} }
} }