Browse Source

gearvr component test

Nikolay Suslov 7 years ago
parent
commit
a2a4c2089d

+ 18 - 0
public/gearvr/assets.json

@@ -0,0 +1,18 @@
+{
+    "bg":{
+        "tag": "img",
+        "src": "/../assets/bg.jpg"
+    },
+    "sky":{
+        "tag": "img",
+        "src": "/../assets/skyes/sky3.jpg"
+    },
+    "plane":{
+        "tag": "a-asset-item",
+        "src": "/../assets/plane.dae"
+    },
+     "bg2":{
+        "tag": "img",
+        "src": "/../assets/checker.jpg"
+    }
+}

+ 8 - 0
public/gearvr/index.vwf.config.yaml

@@ -0,0 +1,8 @@
+---
+info:
+  title: "GearVR Example App"
+model:
+  vwf/model/aframe:
+view:
+  vwf/view/aframe:
+  vwf/view/editor-new:

+ 135 - 0
public/gearvr/index.vwf.yaml

@@ -0,0 +1,135 @@
+# A-Frame & VWF simple scene
+# Copyright 2017 Krestianstvo.org project
+---
+extends: http://vwf.example.com/aframe/ascene.vwf
+properties:
+  fog: "type: linear; color: #ECECEC; far: 30; near: 0"
+  assets: "assets.json"
+children:
+  myLight:
+    extends: http://vwf.example.com/aframe/alight.vwf
+    properties:
+      type: "point"
+      color: "white"
+      position: "0 10 5"
+      rotation: "0 0 0"
+  model:
+    extends: http://vwf.example.com/aframe/acolladamodel.vwf
+    properties:
+      src: "#plane"
+      position: "-1.0 1.7 -3"
+      rotation: "0 -45 0"
+      scale: "10 10 10"
+  spaceText:
+    extends: http://vwf.example.com/aframe/atext.vwf
+    properties:
+      value: "Virtual World Framework & A-Frame"
+      color: "#ddd"
+      position: "-2 2.5 -2"
+  spaceText2:
+    extends: http://vwf.example.com/aframe/atext.vwf
+    properties:
+      value: "Project by Krestianstvo.org"
+      color: "#aaa"
+      position: "1 3 -4"
+  boxAnim:
+    extends: http://vwf.example.com/aframe/abox.vwf
+    properties:
+      position: "0 0 -3"
+      rotation: "0 0 0"
+      color: "#3c7249"
+      depth: 2
+      height: 1
+      width: 1
+  box:
+    extends: http://vwf.example.com/aframe/abox.vwf
+    properties:
+      position: "-1 0.5 -3"
+      rotation: "0 -30 0"
+      color: "#3c7249"
+      depth: 2
+      height: 1
+      width: 1
+      clickable: true
+    events:
+      clickEvent:
+    methods:
+      clickEventMethod:
+        body: |
+          if (this.clickable) {
+          let genColor = this.generateColor();
+          this.color = genColor 
+          }
+      generateColor:
+        body: |
+          var letters = '0123456789ABCDEF';
+          var color = '#';
+          for (var i = 0; i < 6; i++) {
+          color += letters[Math.floor(this.random() * 16)];
+          } return color 
+    scripts:
+      - |
+        this.clickEvent = function(){
+          this.clickEventMethod();
+         }
+  controller:
+    extends: http://vwf.example.com/aframe/aentity.vwf
+    properties:
+      position: "0 0 -1"
+      color: "green"
+      depth: 1
+    children:
+      gearvr-controls:
+        extends: http://vwf.example.com/aframe/gearvr-controlsComponent.vwf
+  sphere:
+    extends: http://vwf.example.com/aframe/asphere.vwf
+    properties:
+      position: "1 1.25 -4"
+      color: "#e0e014"
+      radius: 1
+      wireframe: true
+    children:
+      box2:
+        extends: http://vwf.example.com/aframe/abox.vwf
+        properties:
+          src: "#bg"
+          position: "2 -0.75 0"
+          color: "#2167a5"
+          depth: 1
+        children:
+          interpolation:
+            extends: http://vwf.example.com/aframe/interpolation-component.vwf
+            properties:
+              enabled: true
+              duration: 50
+              deltaPos: 0.1
+              deltaRot: 1
+        methods:
+          run:
+            body: |
+              var time = vwf.now;
+              let pos = AFRAME.utils.coordinates.parse(this.position);
+              this.position = [pos.x, pos.y, Math.sin(time)]
+              this.future( 0.01 ).run();  // schedule the next step
+  sky:
+    extends: http://vwf.example.com/aframe/asky.vwf
+    properties:
+      color: "#ECECEC"
+      src: "#sky"
+      fog: false
+  groundPlane:
+    extends: http://vwf.example.com/aframe/aplane.vwf
+    properties:
+      height: 50
+      width: 50
+      repeat: "10 10"
+      rotation: "-90 0 0"
+      color: "white"
+      wireframe: false
+      src: "#bg2"
+methods:
+  initialize:
+    body: |
+      var runBox = vwf_view.kernel.find("", "/sphere/box2")[0];
+      console.log(runBox);
+      vwf_view.kernel.callMethod(runBox, "run");

BIN
public/gearvr/webimg.jpg


+ 6 - 0
public/webapps.json

@@ -19,5 +19,11 @@
         "title":"L-System parser example in Ohm and VWF",
         "imgUrl": "./ohmlang-lsys/webimg.jpg",
         "text": "Example app with L-System grammar"
+    },
+
+    "gearvr":{
+        "title":"GearVR controller",
+        "imgUrl": "",
+        "text": "Example app with GearVR"
     }
 }

+ 114 - 0
support/client/lib/vwf/model/aframeComponent.js

@@ -305,6 +305,60 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                 }
 
 
+                if (value === undefined && aframeObject.el.getAttribute(aframeObject.compName)) {
+                    
+                                        value = propertyValue;
+                    
+                                        //let parentNodeAF = self.state.kernel.find(node.parentID);
+                    
+                                        // aframeObject.el.setAttribute('line', 'color')
+                                        let parentNodeAF = aframeObject.el;
+                    
+                                        switch (propertyName) {
+                    
+                                            case "armModel":
+                    
+                                                parentNodeAF.setAttribute(aframeObject.compName, { armModel: propertyValue });
+                                                break;
+                    
+                                            case "buttonColor":
+                    
+                                                parentNodeAF.setAttribute(aframeObject.compName, { buttonColor: propertyValue });
+                                                break;
+                    
+                                            case "buttonTouchedColor":
+                    
+                                                parentNodeAF.setAttribute(aframeObject.compName, 'buttonTouchedColor', propertyValue);
+                                                break;
+                    
+                                            case "buttonHighlightColor":
+                                                parentNodeAF.setAttribute(aframeObject.compName, 'buttonHighlightColor', propertyValue);
+                                                break;
+                    
+                                            case "hand":
+                    
+                                                parentNodeAF.setAttribute(aframeObject.compName, 'hand', propertyValue);
+                                                break;
+                    
+                                            case "model":
+
+                                                parentNodeAF.setAttribute(aframeObject.compName, 'model', propertyValue);
+                                                break;
+
+                                            case "rotationOffset":
+
+                                                parentNodeAF.setAttribute(aframeObject.compName, 'rotationOffset', propertyValue);
+                                                break;
+
+                                            default:
+                                                value = undefined;
+                                                break;
+                                        }
+                    
+                                    }
+
+
+
 
             }
 
@@ -402,6 +456,47 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                 }
 
 
+                if (value === undefined && isGearVRControlsDefinition(node.prototypes)) {
+                    value = propertyValue;
+
+                    // let parentNodeAF = self.state.nodes[node.parentID].aframeObj;
+                    let parentNodeAF = aframeObject.el;
+
+                    switch (propertyName) {
+
+                        case "armModel":
+
+                            value = AFRAME.utils.coordinates.stringify(parentNodeAF.getAttribute(aframeObject.compName).armModel);
+                            break;
+
+                        case "buttonColor":
+                            value = AFRAME.utils.coordinates.stringify(parentNodeAF.getAttribute(aframeObject.compName).buttonColor);
+                            break;
+
+                        case "buttonTouchedColor":
+                            value = parentNodeAF.getAttribute(aframeObject.compName).buttonTouchedColor;
+                            break;
+
+                        case "buttonHighlightColor":
+                            value = parentNodeAF.getAttribute(aframeObject.compName).buttonHighlightColor;
+                            break;
+
+                        case "hand":
+                            value = parentNodeAF.getAttribute(aframeObject.compName).hand;
+                            break;
+
+                            case "model":
+                            value = parentNodeAF.getAttribute(aframeObject.compName).model;
+                            break;
+                    
+                            case "rotationOffset":
+                            value = parentNodeAF.getAttribute(aframeObject.compName).rotationOffset;
+                            break;
+
+                    }
+                }
+
+
 
             }
 
@@ -451,6 +546,16 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
         return found;
     }
 
+    function isGearVRControlsDefinition(prototypes) {
+        var found = false;
+        if (prototypes) {
+            for (var i = 0; i < prototypes.length && !found; i++) {
+                found = (prototypes[i] == "http://vwf.example.com/aframe/gearvr-controlsComponent.vwf");
+            }
+        }
+        return found;
+    }
+
     function isComponentNodeDefinition(prototypes) {
         var found = false;
         if (prototypes) {
@@ -505,6 +610,15 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
 
         }
 
+        if (self.state.isComponentClass(protos, "http://vwf.example.com/aframe/gearvr-controlsComponent.vwf")) {
+            
+ 
+                // aframeObj.el.setAttribute(node.type, {});
+             aframeObj.compName = "gearvr-controls";
+             aframeObj.el.setAttribute(aframeObj.compName, {});
+ 
+         }
+
 
         return aframeObj;
     }

+ 12 - 0
support/proxy/vwf.example.com/aframe/gearvr-controlsComponent.vwf.yaml

@@ -0,0 +1,12 @@
+#https://aframe.io/docs/master/components/gearvr-controls.html
+---
+extends: http://vwf.example.com/aframe/aentityComponent.vwf
+type: "component"
+properties:
+  armModel:
+  buttonColor:
+  buttonTouchedColor:
+  buttonHighlightColor:
+  hand:
+  model:
+  rotationOffset: