Преглед на файлове

add getIntersection method

Nikolay Suslov преди 4 години
родител
ревизия
1889e6a301

+ 7 - 0
public/defaults/proxy/aframe/raycasterComponent.vwf.json

@@ -11,5 +11,12 @@
     "recursive": null,
     "showLine": null,
     "useWorldCoordinates": null
+  },
+  "methods":{
+    "getIntersectionPoint":{
+      "parameters": [
+        "nodeID"
+    ]
+    }
   }
 }

+ 4 - 0
public/defaults/proxy/aframe/xrcontroller.js

@@ -70,6 +70,10 @@ this.moveVRController = function(){
     if(controller){
         controller.onMove();
     }
+
+    // let point = this.raycaster.getIntersectionPoint();
+    // console.log('POINT: ', point);
+
 }
 
 this.updateVRControl = function(position, rotation){

+ 32 - 0
public/drivers/model/aframeComponent.js

@@ -1113,6 +1113,38 @@ class AFrameComponentModel extends Fabric {
                     return value;
 
                 },
+                // -- callingMethod ------------------------------------------------------------------------
+
+            callingMethod: function (nodeID, methodName, methodParameters) {
+
+                let self = this;
+                var node = this.state.nodes[nodeID];
+
+                if (!node) return;
+
+                if (node && node.aframeObj) {
+                    let aframeObject = node.aframeObj;
+                    let parentNodeAF = aframeObject.el;
+
+                    if(methodName == "getIntersectionPoint") {
+                        //let nodes = vwf.models["/drivers/model/aframe"].model.state.nodes;
+                        let comp = parentNodeAF.components['raycaster'];
+                        let objID = methodParameters[0];
+                        if (comp.intersectedEls.length>0){
+                            //console.log(comp.intersectedEls);
+                        
+                        let intersecedObj = comp.intersectedEls[0]; //objID ? nodes[objID] : nodes[comp.intersectedEls[0].id];
+                        let intersection = comp.getIntersection(intersecedObj);
+                        if(intersection)
+                            return intersection.point
+
+                        }
+                        return undefined
+
+                    }
+                }
+            },
+
 
                 // -- gettingProperty ----------------------------------------------------------------------