Browse Source

avatar clicks with cursor

Nikolay Suslov 7 years ago
parent
commit
b72453faf0

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

@@ -104,7 +104,11 @@ define(["module", "vwf/view", "jquery", "jquery-ui"], function (module, view, $)
                 case "clickable":
                     if (propertyValue) {
                         aframeObject.addEventListener('click', function (evt) {
+
+                            let cursorID = 'cursor-avatar-'+self.kernel.moniker();
+                           if (evt.detail.cursorEl.id == cursorID) {
                             vwf_view.kernel.fireEvent(nodeId, "clickEvent")
+                           }
                         })
                     }
                     break;
@@ -178,21 +182,7 @@ define(["module", "vwf/view", "jquery", "jquery-ui"], function (module, view, $)
         var newNode = {
             "id": nodeName,
             "uri": nodeName,
-            "extends": "http://vwf.example.com/aframe/avatar.vwf",
-            "children": {
-                  "cursor": {
-                            "extends": "http://vwf.example.com/aframe/acursor.vwf",
-                        },
-                "camera": {
-                    "id": 'camera-' + nodeName,
-                    "extends": "http://vwf.example.com/aframe/acamera.vwf",
-                    "properties": {
-                        "forAvatar": true,
-                        "look-controls-enabled": false,
-                        "wasd-controls": false
-                    }
-                }
-            }
+            "extends": "http://vwf.example.com/aframe/avatar.vwf"
         }
 
         vwf_view.kernel.createChild(nodeID, nodeName, newNode);

+ 19 - 2
support/proxy/vwf.example.com/aframe/avatar.vwf.yaml

@@ -26,11 +26,28 @@ methods:
                         "position": [0, 1, 0.5]
                     }
                   }
-               
                 } 
-              };
+              }
+
+              let cursor = {
+                     "id": 'cursor-' + this.id,
+                     "extends": "http://vwf.example.com/aframe/acursor.vwf"
+              }
+
+              let camera = {
+                   "id": 'camera-' + this.id,
+                    "extends": "http://vwf.example.com/aframe/acamera.vwf",
+                    "properties": {
+                        "forAvatar": true,
+                        "look-controls-enabled": false,
+                        "wasd-controls": false
+                    }
+              }
+
               this.interpolation = "50ms";
               this.children.create( "avatarBody", newNode );
+              this.children.create( "avatarCursor", cursor );
+              this.children.create( "avatarCamera", camera );
     getRandomColor:
         body: |
           var letters = '0123456789ABCDEF';