Browse Source

add raycaster to gearvr sample

Nikolay Suslov 6 years ago
parent
commit
eaa657b199

+ 2 - 1
public/defaults/proxy/vwf.example.com/aframe/app-raycaster-listener-component.vwf.yaml

@@ -2,4 +2,5 @@
 ---
 extends: http://vwf.example.com/aframe/aentityComponent.vwf
 type: "component"
-properties:
+properties:
+  class:

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

@@ -167,7 +167,7 @@ this.createAvatarBody = function (nodeDef, modelSrc) {
                                     "type": "component",
                                     "properties": {
                                         recursive: false,
-                                        interval: 1000,
+                                        interval: 100,
                                         far: 3,
                                         objects: ".intersectable"
                                     }

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

@@ -31,6 +31,22 @@ this.simpleDef = {
                     "properties":{
                         "color": "green"
                     }
+                },
+                "myRayCaster": {
+                    "extends": "http://vwf.example.com/aframe/aentity.vwf",
+                    "properties": {},
+                    "children": {
+                        "raycaster": {
+                            "extends": "http://vwf.example.com/aframe/raycasterComponent.vwf",
+                            "type": "component",
+                            "properties": {
+                                recursive: false,
+                                interval: 10,
+                                far: 0.5,
+                                objects: ".gearvrcontroller"
+                            }
+                        }
+                    }
                 }
                 // "rotationText": {
                 //     "extends": "http://vwf.example.com/aframe/atext.vwf",

+ 12 - 0
public/defaults/worlds/gearvr/index.vwf.yaml

@@ -45,6 +45,18 @@ children:
         extends: http://vwf.example.com/aframe/aMaterialComponent.vwf
         properties:
           color: "#3c7249"
+      raycaster-listener:
+        extends: http://vwf.example.com/aframe/app-raycaster-listener-component.vwf
+        type: "component"
+        properties:
+          class: "gearvrcontroller"
+    methods:
+      intersectEventMethod:
+        body: |
+          this.material.opacity = 0.7
+      clearIntersectEventMethod:
+        body: |
+          this.material.opacity = 1.0
   newSky:
     extends: http://vwf.example.com/aframe/aentity.vwf
     children:

+ 57 - 0
public/vwf/model/aframeComponent.js

@@ -314,6 +314,30 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                     }
                 }
 
+
+                if (value === undefined && isARayCasterListenerDefinition(node.prototypes)) {
+                    if (aframeObject.el.getAttribute(aframeObject.compName)) {
+
+                        value = propertyValue;
+                        let parentNodeAF = aframeObject.el;
+
+
+                        switch (propertyName) {
+
+                            case "class":
+                                parentNodeAF.setAttribute('class', propertyValue);
+                                break;
+
+
+                            default:
+                                value = undefined;
+                                break;
+                        }
+
+
+                    }
+                }
+
                 if (value === undefined && isAShadowDefinition(node.prototypes)) {
                     if (aframeObject.el.getAttribute(aframeObject.compName)) {
 
@@ -650,6 +674,27 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                 }
 
 
+                if (value === undefined && isARayCasterListenerDefinition(node.prototypes)) {
+                    
+
+                        value = propertyValue;
+                        let parentNodeAF = aframeObject.el;
+
+
+                        switch (propertyName) {
+
+                            case "class":
+                                parentNodeAF.getAttribute('class');
+                                break;
+
+
+                            default:
+                                value = undefined;
+                                break;
+                        }
+                }
+
+
                 if (value === undefined && isAFogDefinition(node.prototypes)) {
                     value = propertyValue;
 
@@ -1032,6 +1077,18 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
         return found;
     }
 
+    function isARayCasterListenerDefinition(prototypes) {
+        var found = false;
+        if (prototypes) {
+            for (var i = 0; i < prototypes.length && !found; i++) {
+                found = (prototypes[i] ==  "http://vwf.example.com/aframe/app-raycaster-listener-component.vwf");
+            }
+        }
+        return found;
+    }
+
+   
+
     function isALineDefinition(prototypes) {
         var found = false;
         if (prototypes) {