Browse Source

small fixes

Nikolay Suslov 6 years ago
parent
commit
237ca52176

+ 8 - 5
public/app.js

@@ -1258,7 +1258,10 @@ class App {
     // }
 
     //let myWorlds = await _LCSDB.user(newOwner).get('worlds').once().then();
-    let myWorld = _LCSDB.user(newOwner).get('worlds').get(worldID).put(worldObj);
+    let myWorld =  _LCSDB.user(newOwner).get('worlds').get(worldID).put({});
+    myWorld.put(worldObj, function(res){
+      console.log(res)
+    }); //.get(worldID) let myWorld =
 
     // let myWorld = _LCSDB.user().get(worldID).put(worldObj);
     // _LCSDB.user().get('worlds').set(myWorld);
@@ -1405,10 +1408,10 @@ class App {
     //let objName = loadInfo[ 'save_name' ] +'/'+ "savestate_" + loadInfo[ 'save_revision' ];
     // "savestate_" + loadInfo[ 'save_revision' ] + '/' + loadInfo[ 'save_name' ] + '_vwf_json'
     var docName = 'savestate_/' + root + '/' + filename + '_vwf_json';
-    _LCSDB.user().get('documents').get(root).get(docName).put(stateWithRev, function(res) {
-
+    let myNewWorldState =  _LCSDB.user().get('documents').get(root).get(docName).put({});
+      //_LCSDB.user().get('documents').get(root).get(docName).put(stateWithRev, function(res) {
+    myNewWorldState.put(stateWithRev, function(res) {
       if (res) {
-
         let noty = new Noty({
           text: 'Saved to ' + docName,
           timeout: 2000,
@@ -1440,7 +1443,7 @@ class App {
 
         let docInfoName = 'savestate_/' + root + '/' + filename + '_info_vwf_json';
 
-        _LCSDB.user().get('documents').get(root).get(docInfoName).not(function(res) {
+        _LCSDB.user().get('documents').get(root).get(docInfoName).get('file').not(function(res) {
           _LCSDB.user().get('documents').get(root).get(docInfoName).put(obj);
         });
 

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

@@ -204,4 +204,8 @@ this.getRandomColor = function () {
         color += letters[Math.floor(this.random() * 16)];
     }
     return color;
+}
+
+this.randomize = function () {
+    
 }

+ 1 - 0
public/defaults/proxy/vwf.example.com/aframe/aentity.vwf.yaml

@@ -103,5 +103,6 @@ methods:
   resetVisual:  
   step:
   do:
+  randomize:
 scripts:
   - source: "http://vwf.example.com/aframe/aentity.js"

+ 17 - 4
public/defaults/proxy/vwf.example.com/aframe/avatar.js

@@ -39,14 +39,27 @@ this.modelBodyDef = {
 this.findWorldAvatarCostume = function () {
 
     let scene = this.getScene();
-    let def = scene.defaultAvatarCostume
+    let def = scene.defaultAvatarCostume;
 
+    let allChilds = this.find("//element(*,'http://vwf.example.com/aframe/aentity.vwf')"); //this.children
+    let costumes = allChilds.filter(el => {
+         el.displayName == 'defaultAvatarCostume' 
+        });
+    let avatarCostume = costumes ? costumes[0]: null;
+
+    if (def || avatarCostume) {
+
+    var defID;  
     if (def) {
-        let defID = def.id;
-        let avatarNode = _app.helpers.getNodeDef(defID);
-        return avatarNode
+        defID = def.id;
+    } else if (avatarCostume) {
+        defID = avatarCostume.id;
     }
 
+    let avatarNode = _app.helpers.getNodeDef(defID);
+    return avatarNode
+}
+
     return null
 }