Sfoglia il codice sorgente

move avatar to model

Nikolay Suslov 7 anni fa
parent
commit
a689df41fe

+ 4 - 1
support/client/lib/vwf/model/aframe/aframe-master.js

@@ -74306,9 +74306,12 @@ Component.prototype = {
 
       // Update component.
       this.update(oldData);
+
+	  //remove the limit for now
+
       // Limit event to fire once every 200ms.
       //this.throttledEmitComponentChanged(oldData);
-	  
+
 	  el.emit('componentchanged', {
 		  id: this.id,
 		  name: this.name,

+ 5 - 45
support/client/lib/vwf/view/aframe.js

@@ -107,59 +107,19 @@ define(["module", "vwf/view", "jquery", "jquery-ui"], function (module, view, $)
     });
 
     function createAvatar(nodeID) {
+
         let avatarID = self.kernel.moniker();
         var nodeName = 'avatar-' + avatarID;
 
-        var nodeColor = getRandomColor();
-
         var newNode = {
             "id": nodeName,
             "uri": nodeName,
-            "extends": "http://vwf.example.com/aframe/aentity.vwf",
-            "properties": {
-                "position": [0, 0, 0],
-                "interpolation": "50ms"
-            },
-            "methods": {
-            },
-            "scripts": [],
-            "children": {
-                "avatarBodyNode": {
-                    "extends": "http://vwf.example.com/aframe/abox.vwf",
-                    "properties": {
-                    "color": nodeColor,
-                    "position": [0, 0, 0.5]
-            },
-            "methods": {
-            },
-            "scripts": [],
-                },
-                "avatarNameNode": {
-                    "extends": "http://vwf.example.com/aframe/atext.vwf",
-                    "properties": {
-                        "color": nodeColor,
-                        "value": avatarID,
-                        "side": "double",
-                        "position": [0, 1, 0]
-                    },
-                    "methods": {
-                    },
-                    "scripts": []
-                }
-            }
-        };
+            "extends": "http://vwf.example.com/aframe/avatar.vwf",
+        }
 
         vwf_view.kernel.createChild(nodeID, nodeName, newNode);
-
-    }
-
-    function getRandomColor() {
-        var letters = '0123456789ABCDEF';
-        var color = '#';
-        for (var i = 0; i < 6; i++) {
-            color += letters[Math.floor(Math.random() * 16)];
-        }
-        return color;
+        vwf_view.kernel.callMethod(nodeName, "createAvatarBody");
+        
     }
 
 });

+ 39 - 0
support/proxy/vwf.example.com/aframe/avatar.vwf.yaml

@@ -0,0 +1,39 @@
+# avatar
+# Copyright 2017 Krestianstvo.org project
+---
+extends: http://vwf.example.com/aframe/aentity.vwf
+properties:
+methods:
+    createAvatarBody:
+        body: |
+            let myColor = this.getRandomColor();
+            var newNode = 
+            {
+                "extends": "http://vwf.example.com/aframe/abox.vwf",
+                "properties": {
+                    "color": myColor,
+                    "position": [0, 0, 0.5]
+                },
+              "children": {
+                "avatarNameNode": {
+                    "extends": "http://vwf.example.com/aframe/atext.vwf",
+                    "properties": {
+                        "color": myColor,
+                        "value": this.id,
+                        "side": "double",
+                        "rotation": [0, 180, 0],
+                        "position": [0, 1, 0.5]
+                    }
+                  }
+                } 
+              };
+              this.position = [0, 0, 0];
+              this.interpolation = "50ms";
+              this.children.create( "avatarBody", newNode );
+    getRandomColor:
+        body: |
+          var letters = '0123456789ABCDEF';
+          var color = '#';
+          for (var i = 0; i < 6; i++) {
+              color += letters[Math.floor(this.random() * 16)]; }
+          return color;