Browse Source

work on editor

Nikolay Suslov 4 years ago
parent
commit
d9bea73e63

+ 4 - 1
public/defaults/proxy/vwf.example.com/aframe/aentity.js

@@ -37,6 +37,7 @@ this.showCloseGizmo = function () {
 this.translationFromValue = function (propertyValue) {
 this.translationFromValue = function (propertyValue) {
 
 
     var value = goog.vec.Vec3.create();
     var value = goog.vec.Vec3.create();
+
     if (propertyValue.hasOwnProperty('x')) {
     if (propertyValue.hasOwnProperty('x')) {
         value = goog.vec.Vec3.createFromValues(propertyValue.x, propertyValue.y, propertyValue.z)
         value = goog.vec.Vec3.createFromValues(propertyValue.x, propertyValue.y, propertyValue.z)
     }
     }
@@ -44,8 +45,10 @@ this.translationFromValue = function (propertyValue) {
         value = goog.vec.Vec3.createFromArray(propertyValue);
         value = goog.vec.Vec3.createFromArray(propertyValue);
     }
     }
     else if (typeof propertyValue === 'string') {
     else if (typeof propertyValue === 'string') {
-        let val = AFRAME.utils.coordinates.parse(propertyValue);
+
+        let val = propertyValue.includes(',') ? AFRAME.utils.coordinates.parse(propertyValue.split(',').join(' ')) : AFRAME.utils.coordinates.parse(propertyValue);
         value = goog.vec.Vec3.createFromValues(val.x, val.y, val.z)
         value = goog.vec.Vec3.createFromValues(val.x, val.y, val.z)
+        
     } else if (propertyValue.hasOwnProperty('0')) {
     } else if (propertyValue.hasOwnProperty('0')) {
         value = goog.vec.Vec3.createFromValues(propertyValue[0], propertyValue[1], propertyValue[2])
         value = goog.vec.Vec3.createFromValues(propertyValue[0], propertyValue[1], propertyValue[2])
     }
     }

+ 12 - 0
public/helpers.js

@@ -449,6 +449,18 @@ class Helpers {
 
 
     }
     }
     
     
+   testJSON (text) {
+        if (typeof text!=="string"){
+            return false;
+        }
+        try{
+            JSON.parse(text);
+            return true;
+        }
+        catch (error){
+            return false;
+        }
+    }
 
 
 }
 }
 
 

+ 10 - 2
public/lib/widgets.js

@@ -86,13 +86,21 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
             }
             }
 
 
             inputTextFieldStandart(obj){
             inputTextFieldStandart(obj){
+                var propValue = obj.value;
+                if (_app.helpers.testJSON(obj.value)){
+                    propValue = JSON.parse(obj.value);
+                }  else {
+                propValue = obj.value;
+            }
+
                 return {
                 return {
                     $cell: true,
                     $cell: true,
                     $type: "div",
                     $type: "div",
                     class: "mdc-text-field text-field mdc-ripple-upgraded",
                     class: "mdc-text-field text-field mdc-ripple-upgraded",
+                    _mdc: null,
                     $init: function(){
                     $init: function(){
                     //new mdc.mdc.notchedOutline.MDCNotchedOutline(document.querySelector('.mdc-notched-outline'));
                     //new mdc.mdc.notchedOutline.MDCNotchedOutline(document.querySelector('.mdc-notched-outline'));
-                       new mdc.textField.MDCTextField.attachTo(this);
+                       this._mdc = new mdc.textField.MDCTextField.attachTo(this);
                     },
                     },
                     $components:[
                     $components:[
                         {
                         {
@@ -100,7 +108,7 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
                             type: "text",
                             type: "text",
                             id: obj.id,
                             id: obj.id,
                             class: "mdc-text-field__input",
                             class: "mdc-text-field__input",
-                            value: obj.value,
+                            value: propValue,
                             onchange: obj.change
                             onchange: obj.change
                         },
                         },
                         {
                         {

+ 11 - 2
public/vwf/model/aframe.js

@@ -72,7 +72,10 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                         if (Array.isArray(propertyValue)) {
                         if (Array.isArray(propertyValue)) {
                             aframeObject.setAttribute(propertyName, { x: propertyValue[0], y: propertyValue[1], z: propertyValue[2] })
                             aframeObject.setAttribute(propertyName, { x: propertyValue[0], y: propertyValue[1], z: propertyValue[2] })
                         } else if (typeof propertyValue === 'string') {
                         } else if (typeof propertyValue === 'string') {
-                            aframeObject.setAttribute(propertyName, AFRAME.utils.coordinates.parse(propertyValue))
+
+                            propertyValue.includes(',') ? aframeObject.setAttribute(propertyName, AFRAME.utils.coordinates.parse(propertyValue.split(',').join(' '))) : aframeObject.setAttribute(propertyName, AFRAME.utils.coordinates.parse(propertyValue))
+
+                            //aframeObject.setAttribute(propertyName, AFRAME.utils.coordinates.parse(propertyValue))
                         } else if (propertyValue.hasOwnProperty('0')) {
                         } else if (propertyValue.hasOwnProperty('0')) {
                             aframeObject.setAttribute(propertyName, { x: propertyValue[0], y: propertyValue[1], z: propertyValue[2] })
                             aframeObject.setAttribute(propertyName, { x: propertyValue[0], y: propertyValue[1], z: propertyValue[2] })
                         }
                         }
@@ -88,8 +91,14 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                         value = goog.vec.Vec3.createFromArray(propertyValue);
                         value = goog.vec.Vec3.createFromArray(propertyValue);
                     }
                     }
                     else if (typeof propertyValue === 'string') {
                     else if (typeof propertyValue === 'string') {
-                        let val = AFRAME.utils.coordinates.parse(propertyValue);
+
+                        let val = propertyValue.includes(',') ? AFRAME.utils.coordinates.parse(propertyValue.split(',').join(' ')) : AFRAME.utils.coordinates.parse(propertyValue);
                         value = goog.vec.Vec3.createFromValues(val.x, val.y, val.z)
                         value = goog.vec.Vec3.createFromValues(val.x, val.y, val.z)
+
+                        // let val = AFRAME.utils.coordinates.parse(propertyValue);
+                        // value = goog.vec.Vec3.createFromValues(val.x, val.y, val.z)
+
+
                     }  else if (propertyValue.hasOwnProperty('0')) {
                     }  else if (propertyValue.hasOwnProperty('0')) {
                         value = goog.vec.Vec3.createFromValues(propertyValue[0], propertyValue[1], propertyValue[2])
                         value = goog.vec.Vec3.createFromValues(propertyValue[0], propertyValue[1], propertyValue[2])
                     }
                     }

+ 2 - 0
public/vwf/model/aframe/addon/aframe-components.js

@@ -205,6 +205,8 @@ AFRAME.registerComponent('cursor-listener', {
 
 
 AFRAME.registerComponent('aabb-collider-listener', {
 AFRAME.registerComponent('aabb-collider-listener', {
 
 
+    // If the target collidable object is moving, set <a-entity data-aabb-collider-dynamic> on the target. By default, collidable objects are presumed to be static for performance purposes.
+
     init: function () {
     init: function () {
 
 
         // let self = this;
         // let self = this;

+ 73 - 22
public/vwf/view/editor-new.js

@@ -1166,14 +1166,34 @@ define([
                                                 "label": this._prop.name,
                                                 "label": this._prop.name,
                                                 "value": this._prop.getValue(),
                                                 "value": this._prop.getValue(),
                                                 "change": function (e) {
                                                 "change": function (e) {
-                                                    let propValue = this.value;
-                                                    try {
-                                                        propValue = JSON.parse(propValue);
-                                                        self.kernel.setProperty(this._currentNode, this._prop.name, propValue);
-                                                    } catch (e) {
-                                                        // restore the original value on error
-                                                        this.value = propValue;
-                                                    }
+
+
+                                                       //set property
+
+                                                let value = this.value;
+                                                var propValue = value;
+
+                                              
+                                            if (_app.helpers.testJSON(value)){
+                                                        propValue = JSON.parse(value);
+                                                    }  else {
+                                                    propValue = value;
+                                                }
+
+                                                self.kernel.setProperty(this._currentNode, this._prop.name, propValue);
+
+
+                                                    // let propValue = this.value;
+                                                    // try {
+                                                    //     propValue = JSON.parse(propValue);
+                                                    //     self.kernel.setProperty(this._currentNode, this._prop.name, propValue);
+                                                    // } catch (e) {
+                                                    //     // restore the original value on error
+                                                    //     this.value = propValue;
+                                                    // }
+
+
+
                                                 }
                                                 }
                                             })
                                             })
                                         ]
                                         ]
@@ -1348,15 +1368,33 @@ define([
                                             "label": m.name,
                                             "label": m.name,
                                             "value": m.getValue(),
                                             "value": m.getValue(),
                                             "change": function (e) {
                                             "change": function (e) {
-                                                let propValue = this.value;
-                                                try {
-                                                    propValue = JSON.parse(propValue);
-                                                    self.kernel.setProperty(this._currentNode, m.name, propValue);
+                                                //set property
 
 
-                                                } catch (e) {
-                                                    // restore the original value on error
-                                                    this.value = propValue;
+                                                let value = this.value;
+                                                var propValue = value;
+
+                                              
+                                            if (_app.helpers.testJSON(value)){
+                                                        propValue = JSON.parse(value);
+                                                    }  else {
+                                                    propValue = value;
+                                                    //this.value = JSON.parse(JSON.stringify(propValue));
                                                 }
                                                 }
+
+                                                 self.kernel.setProperty(this._currentNode, m.name, propValue);
+                                                 //this.value = propValue.toString();
+
+                                                // let propValue = this.value;
+                                                // try {
+                                                //     propValue = JSON.parse(propValue);
+                                                //     self.kernel.setProperty(this._currentNode, m.name, propValue);
+
+                                                // } catch (e) {
+                                                //     // restore the original value on error
+                                                //     this.value = propValue;
+                                                // }
+
+
                                             }
                                             }
                                         })
                                         })
 
 
@@ -2458,15 +2496,28 @@ define([
                                                     let editor = document.querySelector("#propAceEditor").env.editor;
                                                     let editor = document.querySelector("#propAceEditor").env.editor;
                                                     let value = editor.getValue();
                                                     let value = editor.getValue();
 
 
-                                                    try {
-                                                        let propValue = (this._prop.type == 'simple') ? (JSON.parse(value)) : (value)
-                                                        //propValue = JSON.parse(value);
-                                                        self.kernel.setProperty(this._editorNode, this._propName, propValue);
+                                                    var propValue = value;
 
 
-                                                    } catch (e) {
-                                                        // restore the original value on error
-                                                        this.value = propValue;
+                                                    if (this._prop.type == 'simple') {
+                                                        if (_app.helpers.testJSON(value)){
+                                                            propValue = JSON.parse(value);
+                                                        } 
+                                                    } else {
+                                                        propValue = value;
                                                     }
                                                     }
+                                                    
+                                                     self.kernel.setProperty(this._editorNode, this._propName, propValue);
+
+
+                                                    // try {
+                                                    //     let propValue = (this._prop.type == 'simple') ? (JSON.parse(value)) : (value)
+                                                    //     //propValue = JSON.parse(value);
+                                                    //     self.kernel.setProperty(this._editorNode, this._propName, propValue);
+
+                                                    // } catch (e) {
+                                                    //     // restore the original value on error
+                                                    //     this.value = propValue;
+                                                    // }
 
 
                                                 }
                                                 }
                                             }
                                             }