|
@@ -467,6 +467,7 @@ this.createJSON = function () {
|
|
var structure = viewer.utils.createJSON(viewer.root);
|
|
var structure = viewer.utils.createJSON(viewer.root);
|
|
var asText = JSON.stringify(structure);
|
|
var asText = JSON.stringify(structure);
|
|
actionsBuilderJsonInput.value = asText;
|
|
actionsBuilderJsonInput.value = asText;
|
|
|
|
+ console.log(asText);
|
|
};
|
|
};
|
|
this.loadFromJSON = function () {
|
|
this.loadFromJSON = function () {
|
|
var json = actionsBuilderJsonInput.value;
|
|
var json = actionsBuilderJsonInput.value;
|
|
@@ -604,6 +605,9 @@ var ActionsBuilder;
|
|
var targetParameterNameSelect = null;
|
|
var targetParameterNameSelect = null;
|
|
var propertyPathSelect = null;
|
|
var propertyPathSelect = null;
|
|
var propertyPathOptionalSelect = null;
|
|
var propertyPathOptionalSelect = null;
|
|
|
|
+ var booleanSelect = null;
|
|
|
|
+ var propertyInput = null;
|
|
|
|
+ var propertyPathIndice = 0;
|
|
if (properties.length === 0) {
|
|
if (properties.length === 0) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -636,6 +640,7 @@ var ActionsBuilder;
|
|
targetParameterNameSelect.onchange = this._parameterTargetNameChanged(targetParameterSelect, targetParameterNameSelect, i);
|
|
targetParameterNameSelect.onchange = this._parameterTargetNameChanged(targetParameterSelect, targetParameterNameSelect, i);
|
|
}
|
|
}
|
|
else if (properties[i].text === "propertyPath") {
|
|
else if (properties[i].text === "propertyPath") {
|
|
|
|
+ propertyPathIndice = i;
|
|
// Create property path select
|
|
// Create property path select
|
|
propertyPathSelect = document.createElement("select");
|
|
propertyPathSelect = document.createElement("select");
|
|
propertyPathSelect.className = "ParametersElementSelectClass";
|
|
propertyPathSelect.className = "ParametersElementSelectClass";
|
|
@@ -645,7 +650,7 @@ var ActionsBuilder;
|
|
propertyPathOptionalSelect.className = "ParametersElementSelectClass";
|
|
propertyPathOptionalSelect.className = "ParametersElementSelectClass";
|
|
this.parametersContainer.appendChild(propertyPathOptionalSelect);
|
|
this.parametersContainer.appendChild(propertyPathOptionalSelect);
|
|
// Events and configure
|
|
// Events and configure
|
|
- (this._propertyPathSelectChanged(targetParameterSelect, propertyPathSelect, propertyPathOptionalSelect, i))(null);
|
|
|
|
|
|
+ (this._propertyPathSelectChanged(targetParameterSelect, propertyPathSelect, propertyPathOptionalSelect, null, null, i))(null);
|
|
var property = this._action.propertiesResults[i].value.split(".");
|
|
var property = this._action.propertiesResults[i].value.split(".");
|
|
if (property.length > 0) {
|
|
if (property.length > 0) {
|
|
if (property.length === 1) {
|
|
if (property.length === 1) {
|
|
@@ -667,7 +672,7 @@ var ActionsBuilder;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
targetParameterSelect.onchange = this._parameterTargetChanged(targetParameterSelect, targetParameterNameSelect, propertyPathSelect, propertyPathOptionalSelect, i - 1);
|
|
targetParameterSelect.onchange = this._parameterTargetChanged(targetParameterSelect, targetParameterNameSelect, propertyPathSelect, propertyPathOptionalSelect, i - 1);
|
|
- propertyPathSelect.onchange = this._propertyPathSelectChanged(targetParameterSelect, propertyPathSelect, propertyPathOptionalSelect, i);
|
|
|
|
|
|
+ propertyPathSelect.onchange = this._propertyPathSelectChanged(targetParameterSelect, propertyPathSelect, propertyPathOptionalSelect, null, null, i);
|
|
propertyPathOptionalSelect.onchange = this._additionalPropertyPathSelectChanged(propertyPathSelect, propertyPathOptionalSelect, i);
|
|
propertyPathOptionalSelect.onchange = this._additionalPropertyPathSelectChanged(propertyPathSelect, propertyPathOptionalSelect, i);
|
|
}
|
|
}
|
|
else if (properties[i].text === "operator") {
|
|
else if (properties[i].text === "operator") {
|
|
@@ -689,22 +694,40 @@ var ActionsBuilder;
|
|
soundSelect.onchange = this._soundSelectChanged(soundSelect, i);
|
|
soundSelect.onchange = this._soundSelectChanged(soundSelect, i);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- if (propertiesResults[i].value === "true" || propertiesResults[i].value === "false") {
|
|
|
|
- var booleanSelect = document.createElement("select");
|
|
|
|
- booleanSelect.className = "ParametersElementSelectClass";
|
|
|
|
- this.parametersContainer.appendChild(booleanSelect);
|
|
|
|
- // Configure event
|
|
|
|
- (this._booleanSelectChanged(booleanSelect, i))(null);
|
|
|
|
- booleanSelect.value = propertiesResults[i].value;
|
|
|
|
- booleanSelect.onchange = this._booleanSelectChanged(booleanSelect, i);
|
|
|
|
|
|
+ var isBoolean = propertiesResults[i].value === "true" || propertiesResults[i].value === "false";
|
|
|
|
+ var object = this._getObjectFromType(targetParameterSelect.value);
|
|
|
|
+ if (object !== null) {
|
|
|
|
+ var property = this._action.propertiesResults[i - 1].value.split(".");
|
|
|
|
+ for (var j = 0; j < property.length && object !== undefined; j++) {
|
|
|
|
+ object = object[property[j]];
|
|
|
|
+ if (j === property.length - 1) {
|
|
|
|
+ isBoolean = isBoolean || typeof object === "boolean";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ booleanSelect = document.createElement("select");
|
|
|
|
+ booleanSelect.className = "ParametersElementSelectClass";
|
|
|
|
+ this.parametersContainer.appendChild(booleanSelect);
|
|
|
|
+ // Configure event
|
|
|
|
+ (this._booleanSelectChanged(booleanSelect, i))(null);
|
|
|
|
+ booleanSelect.value = propertiesResults[i].value;
|
|
|
|
+ booleanSelect.onchange = this._booleanSelectChanged(booleanSelect, i);
|
|
|
|
+ propertyInput = document.createElement("input");
|
|
|
|
+ propertyInput.value = propertiesResults[i].value;
|
|
|
|
+ propertyInput.className = "ParametersElementInputClass";
|
|
|
|
+ this.parametersContainer.appendChild(propertyInput);
|
|
|
|
+ // Configure event
|
|
|
|
+ propertyInput.onkeyup = this._propertyInputChanged(propertyInput, i);
|
|
|
|
+ if (properties[i].text === "value") {
|
|
|
|
+ propertyPathSelect.onchange = this._propertyPathSelectChanged(targetParameterSelect, propertyPathSelect, propertyPathOptionalSelect, booleanSelect, propertyInput, propertyPathIndice);
|
|
|
|
+ }
|
|
|
|
+ if (isBoolean) {
|
|
|
|
+ this._viewer.utils.setElementVisible(booleanSelect, true);
|
|
|
|
+ this._viewer.utils.setElementVisible(propertyInput, false);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- var propertyInput = document.createElement("input");
|
|
|
|
- propertyInput.value = propertiesResults[i].value;
|
|
|
|
- propertyInput.className = "ParametersElementInputClass";
|
|
|
|
- this.parametersContainer.appendChild(propertyInput);
|
|
|
|
- // Configure event
|
|
|
|
- propertyInput.onkeyup = this._propertyInputChanged(propertyInput, i);
|
|
|
|
|
|
+ this._viewer.utils.setElementVisible(booleanSelect, false);
|
|
|
|
+ this._viewer.utils.setElementVisible(propertyInput, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -798,7 +821,7 @@ var ActionsBuilder;
|
|
* @param additionalPropertyPathSelect: the additional propertyPath select element
|
|
* @param additionalPropertyPathSelect: the additional propertyPath select element
|
|
* @param indice: the properties indice in action.properties
|
|
* @param indice: the properties indice in action.properties
|
|
*/
|
|
*/
|
|
- Parameters.prototype._propertyPathSelectChanged = function (targetParameterSelect, propertyPathSelect, additionalPropertyPathSelect, indice) {
|
|
|
|
|
|
+ Parameters.prototype._propertyPathSelectChanged = function (targetParameterSelect, propertyPathSelect, additionalPropertyPathSelect, booleanSelect, propertyInput, indice) {
|
|
var _this = this;
|
|
var _this = this;
|
|
return function (event) {
|
|
return function (event) {
|
|
if (propertyPathSelect.options.length === 0) {
|
|
if (propertyPathSelect.options.length === 0) {
|
|
@@ -815,6 +838,27 @@ var ActionsBuilder;
|
|
else {
|
|
else {
|
|
// Set property
|
|
// Set property
|
|
_this._action.propertiesResults[indice].value = propertyPathSelect.value;
|
|
_this._action.propertiesResults[indice].value = propertyPathSelect.value;
|
|
|
|
+ if (booleanSelect !== null && propertyInput !== null) {
|
|
|
|
+ var object = _this._getObjectFromType(targetParameterSelect.value);
|
|
|
|
+ var isBoolean = false;
|
|
|
|
+ if (object !== null) {
|
|
|
|
+ var property = _this._action.propertiesResults[indice].value.split(".");
|
|
|
|
+ for (var j = 0; j < property.length; j++) {
|
|
|
|
+ object = object[property[j]];
|
|
|
|
+ if (j === property.length - 1) {
|
|
|
|
+ isBoolean = isBoolean || typeof object === "boolean";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (isBoolean) {
|
|
|
|
+ _this._viewer.utils.setElementVisible(booleanSelect, true);
|
|
|
|
+ _this._viewer.utils.setElementVisible(propertyInput, false);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ _this._viewer.utils.setElementVisible(booleanSelect, false);
|
|
|
|
+ _this._viewer.utils.setElementVisible(propertyInput, true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// Configure addition property
|
|
// Configure addition property
|
|
_this._fillAdditionalPropertyPath(targetParameterSelect, propertyPathSelect, additionalPropertyPathSelect);
|
|
_this._fillAdditionalPropertyPath(targetParameterSelect, propertyPathSelect, additionalPropertyPathSelect);
|
|
@@ -900,10 +944,17 @@ var ActionsBuilder;
|
|
option.value = options[i].targetType;
|
|
option.value = options[i].targetType;
|
|
targetParameterSelect.options.add(option);
|
|
targetParameterSelect.options.add(option);
|
|
}
|
|
}
|
|
|
|
+ targetParameterSelect.value = _this._action.propertiesResults[indice].targetType;
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
_this._action.propertiesResults[indice].targetType = targetParameterSelect.value;
|
|
_this._action.propertiesResults[indice].targetType = targetParameterSelect.value;
|
|
- _this._action.propertiesResults[indice].value = "";
|
|
|
|
|
|
+ var names = _this._getListFromType(targetParameterSelect.value);
|
|
|
|
+ if (names !== null && names.length > 0) {
|
|
|
|
+ _this._action.propertiesResults[indice].value = names[0];
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ _this._action.propertiesResults[indice].value = "";
|
|
|
|
+ }
|
|
if (propertyPathSelect !== null) {
|
|
if (propertyPathSelect !== null) {
|
|
_this._action.propertiesResults[indice + 1].value = ""; // propertyPath
|
|
_this._action.propertiesResults[indice + 1].value = ""; // propertyPath
|
|
}
|
|
}
|
|
@@ -918,11 +969,12 @@ var ActionsBuilder;
|
|
targetParameterNameSelect.options.add(option);
|
|
targetParameterNameSelect.options.add(option);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ targetParameterNameSelect.value = _this._action.propertiesResults[indice].value;
|
|
// Clear property path
|
|
// Clear property path
|
|
if (propertyPathSelect !== null) {
|
|
if (propertyPathSelect !== null) {
|
|
propertyPathSelect.options.length = 0;
|
|
propertyPathSelect.options.length = 0;
|
|
additionalPropertyPathSelect.options.length = 0;
|
|
additionalPropertyPathSelect.options.length = 0;
|
|
- _this._propertyPathSelectChanged(targetParameterSelect, propertyPathSelect, additionalPropertyPathSelect, indice + 1)(null);
|
|
|
|
|
|
+ _this._propertyPathSelectChanged(targetParameterSelect, propertyPathSelect, additionalPropertyPathSelect, null, null, indice + 1)(null);
|
|
}
|
|
}
|
|
_this._sortList(targetParameterNameSelect);
|
|
_this._sortList(targetParameterNameSelect);
|
|
_this._sortList(targetParameterSelect);
|
|
_this._sortList(targetParameterSelect);
|
|
@@ -973,21 +1025,37 @@ var ActionsBuilder;
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
};
|
|
};
|
|
|
|
+ Parameters.prototype._getListFromType = function (type) {
|
|
|
|
+ if (type === "MeshProperties" || type === "Mesh") {
|
|
|
|
+ return ActionsBuilder.SceneElements.MESHES;
|
|
|
|
+ }
|
|
|
|
+ if (type === "LightProperties" || type === "Light") {
|
|
|
|
+ return ActionsBuilder.SceneElements.LIGHTS;
|
|
|
|
+ }
|
|
|
|
+ if (type === "CameraProperties" || type === "Camera") {
|
|
|
|
+ return ActionsBuilder.SceneElements.CAMERAS;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ };
|
|
/*
|
|
/*
|
|
* Returns the object in function of the given type
|
|
* Returns the object in function of the given type
|
|
* @param type: the target type
|
|
* @param type: the target type
|
|
*/
|
|
*/
|
|
Parameters.prototype._getObjectFromType = function (type) {
|
|
Parameters.prototype._getObjectFromType = function (type) {
|
|
if (type === "MeshProperties" || type === "Mesh") {
|
|
if (type === "MeshProperties" || type === "Mesh") {
|
|
|
|
+ this._currentObject = ActionsBuilder.SceneElements.MESH;
|
|
return ActionsBuilder.SceneElements.MESH;
|
|
return ActionsBuilder.SceneElements.MESH;
|
|
}
|
|
}
|
|
if (type === "LightProperties" || type === "Light") {
|
|
if (type === "LightProperties" || type === "Light") {
|
|
|
|
+ this._currentObject = ActionsBuilder.SceneElements.LIGHT;
|
|
return ActionsBuilder.SceneElements.LIGHT;
|
|
return ActionsBuilder.SceneElements.LIGHT;
|
|
}
|
|
}
|
|
if (type === "CameraProperties" || type === "Camera") {
|
|
if (type === "CameraProperties" || type === "Camera") {
|
|
|
|
+ this._currentObject = ActionsBuilder.SceneElements.CAMERA;
|
|
return ActionsBuilder.SceneElements.CAMERA;
|
|
return ActionsBuilder.SceneElements.CAMERA;
|
|
}
|
|
}
|
|
if (type === "SceneProperties" || type === "Scene") {
|
|
if (type === "SceneProperties" || type === "Scene") {
|
|
|
|
+ this._currentObject = ActionsBuilder.SceneElements.SCENE;
|
|
return ActionsBuilder.SceneElements.SCENE;
|
|
return ActionsBuilder.SceneElements.SCENE;
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
@@ -1944,6 +2012,7 @@ var ActionsBuilder;
|
|
this.utils = new ActionsBuilder.Utils(this);
|
|
this.utils = new ActionsBuilder.Utils(this);
|
|
// Finish
|
|
// Finish
|
|
this.parameters.parametersHelpElement.textContent = Viewer._DEFAULT_INFO_MESSAGE;
|
|
this.parameters.parametersHelpElement.textContent = Viewer._DEFAULT_INFO_MESSAGE;
|
|
|
|
+ this.onResize(null);
|
|
}
|
|
}
|
|
Object.defineProperty(Viewer, "NODE_WIDTH", {
|
|
Object.defineProperty(Viewer, "NODE_WIDTH", {
|
|
get: function () {
|
|
get: function () {
|