mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:16:58 +02:00
21324: Formatting and PR Feedback Changes
This commit is contained in:
parent
4842de8f07
commit
0edb763dac
2 changed files with 288 additions and 212 deletions
|
@ -43,11 +43,17 @@ and If there is any changes to either the Entities or properties of
|
|||
|
||||
**/
|
||||
|
||||
var RADIAN = Math.PI / 180;
|
||||
var RADIANS_PER_DEGREE = Math.PI / 180;
|
||||
|
||||
var roundFloat = function (input, round) {
|
||||
round = round ? round : 1000;
|
||||
return Math.round(parseFloat(input) * round)/round;
|
||||
var sanitizedInput;
|
||||
if (typeof input === "string") {
|
||||
sanitizedInput = parseFloat(input);
|
||||
} else {
|
||||
sanitizedInput = input;
|
||||
}
|
||||
return Math.round(sanitizedInput * round) / round;
|
||||
};
|
||||
|
||||
function HifiEntityUI(parent) {
|
||||
|
@ -93,7 +99,8 @@ HifiEntityUI.prototype = {
|
|||
|
||||
textures = document.getElementsByClassName("with-texture");
|
||||
for (i = 0; i < textures.length; i++) {
|
||||
textures[i].className = textures[i].className.replace("with-texture", "no-texture");
|
||||
textures[i].classList.remove("with-textures");
|
||||
textures[i].classList.add("no-texture");
|
||||
}
|
||||
|
||||
var textareas = document.getElementsByTagName("textarea");
|
||||
|
@ -110,7 +117,8 @@ HifiEntityUI.prototype = {
|
|||
var key = keys[i];
|
||||
var el = self.builtRows[key];
|
||||
if (el.className.indexOf("checkbox") !== -1) {
|
||||
json[key] = document.getElementById(key).checked ? true: false;
|
||||
json[key] = document.getElementById(key)
|
||||
.checked ? true : false;
|
||||
} else if (el.className.indexOf("vector-section") !== -1) {
|
||||
var vector = {};
|
||||
if (el.className.indexOf("rgb") !== -1) {
|
||||
|
@ -137,7 +145,8 @@ HifiEntityUI.prototype = {
|
|||
}
|
||||
json[key] = vector;
|
||||
} else if (el.className.length > 0) {
|
||||
json[key] = document.getElementById(key).value;
|
||||
json[key] = document.getElementById(key)
|
||||
.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,6 +168,7 @@ HifiEntityUI.prototype = {
|
|||
|
||||
|
||||
for (var e in keys) {
|
||||
if (keys.hasOwnProperty[e]) {
|
||||
var value = keys[e];
|
||||
|
||||
var property = currentProperties[value];
|
||||
|
@ -167,7 +177,7 @@ HifiEntityUI.prototype = {
|
|||
var el = document.getElementById(value);
|
||||
|
||||
if (field.className.indexOf("radian") !== -1) {
|
||||
el.value = property / RADIAN;
|
||||
el.value = property / RADIANS_PER_DEGREE;
|
||||
el.onchange({
|
||||
target: el
|
||||
});
|
||||
|
@ -215,6 +225,7 @@ HifiEntityUI.prototype = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
connect: function (EventBridge) {
|
||||
this.EventBridge = EventBridge;
|
||||
|
@ -272,37 +283,33 @@ HifiEntityUI.prototype = {
|
|||
animationWrapper.className = "section-wrap";
|
||||
|
||||
for (var property in properties) {
|
||||
|
||||
if (properties.hasOwnProperty[property]) {
|
||||
var builtRow = self.addElement(animationWrapper, properties[property]);
|
||||
var id = properties[property].id;
|
||||
if (id) {
|
||||
self.builtRows[id] = builtRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
sectionDivBody.appendChild(animationWrapper);
|
||||
parent.appendChild(sectionDivBody);
|
||||
_.defer(function () {
|
||||
var height = (animationWrapper.clientHeight) + "px";
|
||||
if (collapsed) {
|
||||
sectionDivBody.className = sectionDivBody.className
|
||||
.replace("visible", "")
|
||||
.replace(/\s{2,}/g, " ");
|
||||
|
||||
sectionDivBody.classList.remove("visible");
|
||||
sectionDivBody.style.maxHeight = "0px";
|
||||
} else {
|
||||
sectionDivBody.className += " visible";
|
||||
sectionDivBody.classList.add("visible");
|
||||
sectionDivBody.style.maxHeight = height;
|
||||
}
|
||||
|
||||
sectionDivHeader.onclick = function () {
|
||||
collapsed = !collapsed;
|
||||
if (collapsed) {
|
||||
sectionDivBody.className = sectionDivBody.className
|
||||
.replace("visible", "")
|
||||
.replace(/\s{2,}/g, " ");
|
||||
sectionDivBody.classList.remove("visible");
|
||||
sectionDivBody.style.maxHeight = "0px";
|
||||
} else {
|
||||
sectionDivBody.className += " visible";
|
||||
sectionDivBody.classList.add("visible");
|
||||
sectionDivBody.style.maxHeight = (animationWrapper.clientHeight) + "px";
|
||||
}
|
||||
// sectionDivBody.style.display = collapsed ? "none": "block";
|
||||
|
@ -364,7 +371,8 @@ HifiEntityUI.prototype = {
|
|||
this.addLabel(parent, group);
|
||||
var className = "";
|
||||
for (var i = 0; i < inputs.length; i++) {
|
||||
className += inputs[i].charAt(0).toLowerCase();
|
||||
className += inputs[i].charAt(0)
|
||||
.toLowerCase();
|
||||
}
|
||||
parent.className += " property vector-section " + className;
|
||||
|
||||
|
@ -448,8 +456,10 @@ HifiEntityUI.prototype = {
|
|||
});
|
||||
},
|
||||
onSubmit: function (hsb, hex, rgb, el) {
|
||||
$(el).css('background-color', '#' + hex);
|
||||
$(el).colpickHide();
|
||||
$(el)
|
||||
.css('background-color', '#' + hex);
|
||||
$(el)
|
||||
.colpickHide();
|
||||
domArray[0].value = rgb.r;
|
||||
domArray[1].value = rgb.g;
|
||||
domArray[2].value = rgb.b;
|
||||
|
@ -473,13 +483,14 @@ HifiEntityUI.prototype = {
|
|||
var image = document.createElement("img");
|
||||
var imageLoad = _.debounce(function (url) {
|
||||
if (url.length > 0) {
|
||||
textureImage.className = textureImage.className.replace(' no-texture', ' with-texture');
|
||||
textureImage.classList.remove("no-texture");
|
||||
textureImage.classList.add("with-texture");
|
||||
image.src = url;
|
||||
image.style.display = "block";
|
||||
} else {
|
||||
image.src = "";
|
||||
image.style.display = "none";
|
||||
textureImage.className += " no-texture";
|
||||
textureImage.classList.add("no-texture");
|
||||
}
|
||||
self.webBridgeSync(group.id, url);
|
||||
}, 250);
|
||||
|
@ -544,7 +555,7 @@ HifiEntityUI.prototype = {
|
|||
|
||||
inputField.oninput = function (event) {
|
||||
slider.value = event.target.value;
|
||||
self.webBridgeSync(group.id, slider.value * RADIAN);
|
||||
self.webBridgeSync(group.id, slider.value * RADIANS_PER_DEGREE);
|
||||
};
|
||||
inputField.onchange = inputField.oninput;
|
||||
|
||||
|
@ -555,7 +566,7 @@ HifiEntityUI.prototype = {
|
|||
} else {
|
||||
inputField.value = Math.ceil(event.target.value);
|
||||
}
|
||||
self.webBridgeSync(group.id, slider.value * RADIAN);
|
||||
self.webBridgeSync(group.id, slider.value * RADIANS_PER_DEGREE);
|
||||
};
|
||||
var degrees = document.createElement("label");
|
||||
degrees.innerHTML = "°";
|
||||
|
|
|
@ -25,7 +25,10 @@
|
|||
var properties = "";
|
||||
var menuStructure = {
|
||||
General: [
|
||||
{ type: "Row", id: "export-import-field" },
|
||||
{
|
||||
type: "Row",
|
||||
id: "export-import-field"
|
||||
},
|
||||
{
|
||||
id: "show-properties-button",
|
||||
name: "Show Properties",
|
||||
|
@ -41,10 +44,12 @@
|
|||
insertZone.appendChild(textarea);
|
||||
insertZone.parentNode.parentNode.style.maxHeight =
|
||||
insertZone.parentNode.clientHeight + "px";
|
||||
document.getElementById("export-properties-button").removeAttribute("disabled");
|
||||
document.getElementById("export-properties-button")
|
||||
.removeAttribute("disabled");
|
||||
textarea.onchange = function (e) {
|
||||
if (e.target.value !== properties) {
|
||||
document.getElementById("import-properties-button").removeAttribute("disabled");
|
||||
document.getElementById("import-properties-button")
|
||||
.removeAttribute("disabled");
|
||||
}
|
||||
};
|
||||
textarea.oninput = textarea.onchange;
|
||||
|
@ -55,8 +60,10 @@
|
|||
textarea.remove();
|
||||
insertZone.parentNode.parentNode.style.maxHeight =
|
||||
insertZone.parentNode.clientHeight + "px";
|
||||
document.getElementById("export-properties-button").setAttribute("disabled",true);
|
||||
document.getElementById("import-properties-button").setAttribute("disabled",true);
|
||||
document.getElementById("export-properties-button")
|
||||
.setAttribute("disabled", true);
|
||||
document.getElementById("import-properties-button")
|
||||
.setAttribute("disabled", true);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -89,13 +96,17 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{ type: "Row"},
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "isEmitting",
|
||||
name: "Is Emitting",
|
||||
type: "Boolean"
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "lifespan",
|
||||
name: "Lifespan",
|
||||
|
@ -103,7 +114,9 @@
|
|||
min: 0.01,
|
||||
max: 10
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "maxParticles",
|
||||
name: "Max Particles",
|
||||
|
@ -111,13 +124,17 @@
|
|||
min: 1,
|
||||
max: 10000
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "textures",
|
||||
name: "Textures",
|
||||
type: "Texture"
|
||||
},
|
||||
{ type: "Row" }
|
||||
{
|
||||
type: "Row"
|
||||
}
|
||||
],
|
||||
Emit: [
|
||||
{
|
||||
|
@ -127,14 +144,18 @@
|
|||
max: 1000,
|
||||
min: 1
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "emitSpeed",
|
||||
name: "Emit Speed",
|
||||
type: "SliderFloat",
|
||||
max: 5
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "emitDimensions",
|
||||
name: "Emit Dimension",
|
||||
|
@ -144,7 +165,9 @@
|
|||
step: 0.01
|
||||
}
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "emitOrientation",
|
||||
unit: "deg",
|
||||
|
@ -155,13 +178,17 @@
|
|||
step: 0.01
|
||||
}
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "emitShouldTrail",
|
||||
name: "Emit Should Trail",
|
||||
type: "Boolean"
|
||||
},
|
||||
{ type: "Row" }
|
||||
{
|
||||
type: "Row"
|
||||
}
|
||||
],
|
||||
Radius: [
|
||||
{
|
||||
|
@ -170,28 +197,36 @@
|
|||
type: "SliderFloat",
|
||||
max: 4.0
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "radiusSpread",
|
||||
name: "Radius Spread",
|
||||
type: "SliderFloat",
|
||||
max: 4.0
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "radiusStart",
|
||||
name: "Radius Start",
|
||||
type: "SliderFloat",
|
||||
max: 4.0
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "radiusFinish",
|
||||
name: "Radius Finish",
|
||||
type: "SliderFloat",
|
||||
max: 4.0
|
||||
},
|
||||
{ type: "Row" }
|
||||
{
|
||||
type: "Row"
|
||||
}
|
||||
],
|
||||
Color: [
|
||||
{
|
||||
|
@ -204,7 +239,9 @@
|
|||
blue: 255
|
||||
}
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "colorSpread",
|
||||
name: "Color Spread",
|
||||
|
@ -215,7 +252,9 @@
|
|||
blue: 0
|
||||
}
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "colorStart",
|
||||
name: "Color Start",
|
||||
|
@ -226,7 +265,9 @@
|
|||
blue: 255
|
||||
}
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "colorFinish",
|
||||
name: "Color Finish",
|
||||
|
@ -237,7 +278,9 @@
|
|||
blue: 255
|
||||
}
|
||||
},
|
||||
{ type: "Row" }
|
||||
{
|
||||
type: "Row"
|
||||
}
|
||||
],
|
||||
Acceleration: [
|
||||
{
|
||||
|
@ -248,7 +291,9 @@
|
|||
step: 0.01
|
||||
}
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "accelerationSpread",
|
||||
name: "Acceleration Spread",
|
||||
|
@ -257,7 +302,9 @@
|
|||
step: 0.01
|
||||
}
|
||||
},
|
||||
{ type: "Row" }
|
||||
{
|
||||
type: "Row"
|
||||
}
|
||||
],
|
||||
Alpha: [
|
||||
{
|
||||
|
@ -265,25 +312,33 @@
|
|||
name: "Alpha",
|
||||
type: "SliderFloat"
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "alphaSpread",
|
||||
name: "Alpha Spread",
|
||||
type: "SliderFloat"
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "alphaStart",
|
||||
name: "Alpha Start",
|
||||
type: "SliderFloat"
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "alphaFinish",
|
||||
name: "Alpha Finish",
|
||||
type: "SliderFloat"
|
||||
},
|
||||
{ type: "Row" }
|
||||
{
|
||||
type: "Row"
|
||||
}
|
||||
],
|
||||
Polar: [
|
||||
{
|
||||
|
@ -292,14 +347,18 @@
|
|||
unit: "deg",
|
||||
type: "SliderRadian"
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "polarFinish",
|
||||
name: "Polar Finish",
|
||||
unit: "deg",
|
||||
type: "SliderRadian"
|
||||
},
|
||||
{ type: "Row" }
|
||||
{
|
||||
type: "Row"
|
||||
}
|
||||
],
|
||||
Azimuth: [
|
||||
{
|
||||
|
@ -310,29 +369,35 @@
|
|||
min: -180,
|
||||
max: 0
|
||||
},
|
||||
{ type: "Row" },
|
||||
{
|
||||
type: "Row"
|
||||
},
|
||||
{
|
||||
id: "azimuthFinish",
|
||||
name: "Azimuth Finish",
|
||||
unit: "deg",
|
||||
type: "SliderRadian"
|
||||
},
|
||||
{ type: "Row" }
|
||||
{
|
||||
type: "Row"
|
||||
}
|
||||
]
|
||||
};
|
||||
ui.setUI(menuStructure);
|
||||
ui.setOnSelect(function () {
|
||||
document.getElementById("show-properties-button").removeAttribute("disabled");
|
||||
document.getElementById("export-properties-button").setAttribute("disabled",true);
|
||||
document.getElementById("import-properties-button").setAttribute("disabled",true);
|
||||
document.getElementById("show-properties-button")
|
||||
.removeAttribute("disabled");
|
||||
document.getElementById("export-properties-button")
|
||||
.setAttribute("disabled", true);
|
||||
document.getElementById("import-properties-button")
|
||||
.setAttribute("disabled", true);
|
||||
});
|
||||
ui.build();
|
||||
var overrideLoad = false;
|
||||
if (openEventBridge === undefined) {
|
||||
overrideLoad = true,
|
||||
openEventBridge = function (callback) {
|
||||
callback(
|
||||
{
|
||||
callback({
|
||||
emitWebEvent: function () {},
|
||||
submitChanges: function () {},
|
||||
scriptEventReceived: {
|
||||
|
|
Loading…
Reference in a new issue