Browse Source

more on events

Nikolay Suslov 6 years ago
parent
commit
4ebd0440d1

+ 15 - 12
public/defaults/proxy/vwf.example.com/aframe/aentity.js

@@ -64,38 +64,41 @@ this.sendOSC = function (msg) {
 
 }
 
-this.intersectEvent = function () {
-    //this.intersectEventMethod();
-}
-this.clearIntersectEvent = function () {
-    //this.clearIntersectEventMethod();
-}
+// this.clickEvent = function () {
+//     //this.intersectEventMethod();
+// }
 
-this.intersectEventMethod = function () {
+// this.intersectEvent = function () {
+//     //this.intersectEventMethod();
+// }
+// this.clearIntersectEvent = function () {
+//     //this.clearIntersectEventMethod();
+// }
 
+
+this.intersectEventMethod = function () {
     //intersect method
 }
 
-
 this.clearIntersectEventMethod = function () {
-
     //clearIntersect method
-
 }
 
 this.hitstartEventMethod = function () {
-
     //intersect method
 }
 
 
 this.hitendEventMethod = function () {
-
     //clearIntersect method
+}
 
+this.clickEventMethod = function () {
+    //clickEventMethod
 }
 
 
+
 this.setOwner = function (param) {
 
     var clients = this.find("doc('http://vwf.example.com/clients.vwf')")[0];

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

@@ -55,11 +55,13 @@ events:
   clearIntersectEvent:
   hitstartEvent:
   hitendEvent:
+  clickEvent:
 methods:
   intersectEventMethod:
   clearIntersectEventMethod:
   hitstartEventMethod:
   hitendEventMethod:
+  clickEventMethod:
   sendOSC:
     parameters:
       - msg

+ 7 - 7
public/defaults/proxy/vwf.example.com/aframe/ascene.js

@@ -58,7 +58,7 @@ this.sphereProto = function () {
         "properties": {
             "displayName": "sphere",
             "radius": 1,
-            "clickable": true
+            "class": "intersectable"
         },
         children: {
             "material": {
@@ -99,7 +99,7 @@ this.cylinderProto = function () {
             "displayName": "cylinder",
             "radius": 1,
             "height": 1,
-            "clickable": true
+            "class": "clickable"
         },
         children: {
             "material": {
@@ -141,7 +141,7 @@ this.coneProto = function () {
             "radius-bottom": 1,
             "radius-top": 0.01,
             "height": 1,
-            "clickable": true
+            "class": "clickable"
         },
         children: {
             "material": {
@@ -183,7 +183,7 @@ this.textProto = function () {
             "color": "white",
             "value": "Text",
             "side": "double",
-            "clickable": true
+            "class": "clickable"
         },
         children: {
             "interpolation":
@@ -218,7 +218,7 @@ this.cubeProto = function () {
             "height": 1,
             "width": 1,
             "depth": 1,
-            "clickable": true
+            "class": "clickable"
         },
         children: {
             "interpolation":
@@ -264,7 +264,7 @@ this.lightProto = function (lightType) {
         "properties": {
             "displayName": newLightType,
             "type": newLightType,
-            "clickable": true
+            "class": "clickable"
         },
         children: {
             "interpolation":
@@ -348,7 +348,7 @@ this.planeProto = function () {
             "displayName": "plane",
             "height": 1,
             "width": 1,
-            "clickable": true
+            "class": "clickable"
         },
         children: {
             "material": {

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

@@ -132,9 +132,9 @@ this.createAvatarBody = function (nodeDef, modelSrc) {
                                         "extends": "http://vwf.example.com/aframe/aabb-collider-component.vwf",
                                         "type": "component",
                                         "properties": {
-                                            debug: true,
+                                            debug: false,
                                             interval: 10,
-                                            objects: ".aabb"
+                                            objects: ".hit"
                                         }
                                     }
                                 }

+ 9 - 0
public/defaults/proxy/vwf.example.com/aframe/gearvrcontroller.js

@@ -32,6 +32,15 @@ this.simpleDef = {
                         "color": "green"
                     }
                 },
+                "aabb-collider": {
+                    "extends": "http://vwf.example.com/aframe/aabb-collider-component.vwf",
+                    "type": "component",
+                    "properties": {
+                        debug: false,
+                        interval: 10,
+                        objects: ".gearvrhit"
+                    }
+                },
                 "myRayCaster": {
                     "extends": "http://vwf.example.com/aframe/aentity.vwf",
                     "properties": {},

+ 1 - 18
public/defaults/worlds/aframe/index.vwf.yaml

@@ -55,7 +55,7 @@ children:
       depth: 2
       height: 1
       width: 1
-      clickable: true
+      class: "clickable intersectable"
     children:
       material:
         extends: http://vwf.example.com/aframe/aMaterialComponent.vwf
@@ -75,20 +75,14 @@ children:
     methods:
       clickEventMethod:
         body: |
-          if (this.clickable) {
           let genColor = this.generateColor();
           this.material.color = genColor 
-            }
       intersectEventMethod:
         body: |
-          if (this.clickable) {
           this.material.opacity = 0.7
-            }
       clearIntersectEventMethod:
         body: |
-          if (this.clickable) {
           this.material.opacity = 1.0
-            }
       generateColor:
         body: |
           var letters = '0123456789ABCDEF';
@@ -96,17 +90,6 @@ children:
           for (var i = 0; i < 6; i++) {
           color += letters[Math.floor(this.random() * 16)];
           } return color 
-    scripts:
-      - |
-        this.clickEvent = function(){
-          this.clickEventMethod();
-         }
-         this.intersectEvent = function(){
-          this.intersectEventMethod();
-         }
-         this.clearIntersectEvent = function(){
-          this.clearIntersectEventMethod();
-         }
   sphere:
     extends: http://vwf.example.com/aframe/asphere.vwf
     properties:

+ 4 - 15
public/defaults/worlds/aframe2/index.vwf.yaml

@@ -76,7 +76,7 @@ children:
       depth: 2
       height: 1
       width: 1
-      class: "aabb"
+      class: "hit"
     methods:
       hitstartEventMethod:
         body: |
@@ -100,7 +100,7 @@ children:
       depth: 2
       height: 1
       width: 1
-      clickable: true
+      class: "clickable intersectable"
     children:
       material:
         extends: http://vwf.example.com/aframe/aMaterialComponent.vwf
@@ -123,20 +123,14 @@ children:
     methods:
       clickEventMethod:
         body: |
-          if (this.clickable) {
-          let genColor = this.generateColor();
-          this.material.color = genColor 
-            }
+            let genColor = this.generateColor();
+            this.material.color = genColor 
       intersectEventMethod:
         body: |
-          if (this.clickable) {
           this.material.opacity = 0.7
-            }
       clearIntersectEventMethod:
         body: |
-          if (this.clickable) {
           this.material.opacity = 1.0
-            }
       generateColor:
         body: |
           var letters = '0123456789ABCDEF';
@@ -144,11 +138,6 @@ children:
           for (var i = 0; i < 6; i++) {
           color += letters[Math.floor(this.random() * 16)];
           } return color 
-    scripts:
-      - |
-        this.clickEvent = function(){
-          this.clickEventMethod();
-         }
   sphere:
     extends: http://vwf.example.com/aframe/asphere.vwf
     properties:

+ 5 - 6
public/defaults/worlds/gearvr/index.vwf.yaml

@@ -40,21 +40,20 @@ children:
       depth: 1
       height: 1
       width: 1
+      class: "gearvrhit"
     children:    
       material:
         extends: http://vwf.example.com/aframe/aMaterialComponent.vwf
         properties:
           color: "#3c7249"
-      raycaster-listener:
-        extends: http://vwf.example.com/aframe/app-raycaster-listener-component.vwf
+      aabb-collider-listener:
+        extends: http://vwf.example.com/aframe/app-aabb-collider-listener-component.vwf
         type: "component"
-        properties:
-          class: "gearvrcontroller"
     methods:
-      intersectEventMethod:
+      hitstartEventMethod:
         body: |
           this.material.opacity = 0.7
-      clearIntersectEventMethod:
+      hitendEventMethod:
         body: |
           this.material.opacity = 1.0
   newSky:

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

@@ -427,7 +427,18 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                             break;
 
                         case "class":
-                                aframeObject.setAttribute('class', propertyValue);
+                             var newClasses = [];
+                            if (propertyValue.includes(',')){
+                                newClasses = propertyValue.split(',');
+                            } else {
+                                newClasses = propertyValue.split(' ')
+                            }
+                            
+                               // let newClasses = propertyValue.split(','); //trim()
+                                aframeObject.setAttribute('class',"");
+                                newClasses.forEach(el=>{
+                                    aframeObject.classList.add(el.trim());
+                                })
                             break;
 
                         case "ownedBy":
@@ -967,7 +978,8 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                             break;
 
                         case "class":
-                            aframeObject.getAttribute('class');
+                            value = aframeObject.classList.toString();
+                            //aframeObject.getAttribute('class');
                         break;
 
                         // case "look-controls-enabled":

+ 6 - 1
public/vwf/view/aframe.js

@@ -501,6 +501,9 @@ define(["module", "vwf/view"], function (module, view) {
                     let avatar = self.nodes[avatarName];
                     let mode = vwf.getProperty(avatarName, 'selectMode');
 
+
+                    vwf_view.kernel.callMethod(nodeID, "clickEventMethod", [])
+
                     if (mode) {
                         console.log("allow to click!!!")
                         vwf_view.kernel.setProperty(avatarName, 'selectMode', false);
@@ -517,6 +520,8 @@ define(["module", "vwf/view"], function (module, view) {
 
                         }
                     }
+
+
                 }
 
 
@@ -867,7 +872,7 @@ define(["module", "vwf/view"], function (module, view) {
         let cursorEl = document.createElement('a-cursor');
         cursorEl.setAttribute('id', 'cursor-' + avatarName);
         cursorEl.setAttribute('raycaster', {});
-        cursorEl.setAttribute('raycaster', 'objects', '.intersectable');
+        cursorEl.setAttribute('raycaster', 'objects', '.clickable');
         cursorEl.setAttribute('raycaster', 'showLine', false);
 
         if (AFRAME.utils.device.isGearVR()) { }