debugging js

This commit is contained in:
SamGondelman 2018-06-19 16:36:13 -07:00
parent de5fcccc7b
commit 2f0877dc0f
2 changed files with 24 additions and 4 deletions

View file

@ -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 = "°";

View file

@ -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();
}