Browse Source

sample aframe-ar world

Nikolay Suslov 6 years ago
parent
commit
35a2182c41

+ 4 - 1
public/defaults/proxy/vwf.example.com/aframe/a-arjs-anchor.vwf.yaml

@@ -4,4 +4,7 @@ extends: http://vwf.example.com/aframe/aentity.vwf
 type: "a-anchor"
 properties:
   hit-testing-enabled:
-  changeMatrixMode:
+  changeMatrixMode:
+  preset:
+  markerType:
+  markerValue:

+ 18 - 0
public/defaults/worlds/aframe-ar/assets.json

@@ -0,0 +1,18 @@
+{
+    "bg2":{
+        "tag": "img",
+        "src": "/defaults/assets/checker.jpg"
+    },
+    "sky":{
+        "tag": "img",
+        "src": "/defaults/assets/skyes/sky3.jpg"
+    },
+    "nwtree-obj":{
+        "tag": "a-asset-item",
+        "src": "/defaults/assets/models/nwtree/model.obj"
+    },
+    "nwtree-mtl":{
+        "tag": "a-asset-item",
+        "src": "/defaults/assets/models/nwtree/materials.mtl"
+    }
+}

+ 70 - 38
public/defaults/worlds/aframe-ar/index.vwf.yaml

@@ -1,56 +1,88 @@
-# A-Frame & VWF simple scene
-# Copyright 2017 Krestianstvo.org project
+# A-Frame & VWF simple scene in AR
+# Copyright 2018 Krestianstvo.org project
 ---
 extends: http://vwf.example.com/aframe/ascene.vwf
 properties:
   transparent: true
+  assets: "assets.json"
 children:
-  arcamera:
-    extends: http://vwf.example.com/aframe/acamera.vwf
+  arcamera:    
+    extends: http://vwf.example.com/aframe/abox.vwf
     properties:
-      look-controls-enabled: false
-      wasd-controls-enabled: false
-      user-height: 0
+      position: "0 0 0"
+      rotation: "0 0 0"
+      opacity: 0.5
+      depth: 0.3
+      width: 0.3
+      height: 0.5
+    children:
+      camera:
+        extends: http://vwf.example.com/aframe/acamera.vwf
+        properties:
+          look-controls-enabled: false
+          wasd-controls-enabled: false
+          user-height: 0
   aranchor:
     extends: http://vwf.example.com/aframe/a-arjs-anchor.vwf
     properties:
+      position: "0 0 -5"
+      hit-testing-enabled: true
+      changeMatrixMode: "modelViewMatrix"
+      preset: "hiro"
+    children:
+      model:
+        extends: http://vwf.example.com/aframe/aobjmodel.vwf
+        properties:
+          src: "#nwtree-obj"
+          mtl: "#nwtree-mtl"
+          position: "0 0.5 0"
+          rotation: "0 -45 0"
+          scale: "2 2 2"
+        children:
+          interpolation:
+            extends: http://vwf.example.com/aframe/interpolation-component.vwf
+            properties:
+              enabled: true
+        methods:
+          run:
+            body: |
+              var time = vwf.now;
+              let rot = this.rotation; //AFRAME.utils.coordinates.parse(this.rotation);
+              this.rotation = [rot[0], rot[1]+2, rot[2]];
+              this.future( 0.05 ).run();  // schedule the next step
+  aranchor2:
+    extends: http://vwf.example.com/aframe/a-arjs-anchor.vwf
+    properties:
+      position: "-5 0 -5"
       hit-testing-enabled: true
-      changeMatrixMode: "cameraTransformMatrix"
+      changeMatrixMode: "modelViewMatrix"
+      preset: "kanji"
     children:
-      sphere:
-        extends: http://vwf.example.com/aframe/asphere.vwf
+      alltext:
+        extends: http://vwf.example.com/aframe/aentity.vwf
         properties:
-          position: "0 0 0"
-          radius: 1
+          position: [0,-1,0]
+          rotation: [-15,0,0]
         children:
-          material:
-            extends: http://vwf.example.com/aframe/aMaterialComponent.vwf
+          spaceText:
+            extends: http://vwf.example.com/aframe/atext.vwf
             properties:
-              color: "#e0e014"
-              wireframe: true
-          box2:
-            extends: http://vwf.example.com/aframe/abox.vwf
+              value: "Happy New Year 2019!"
+              color: "#00ffa5"
+              position: [-2,1,0]
+              rotation: "0 0 15"
+              scale: "4 4 4"
+              side: "double"
+          spaceText2:
+            extends: http://vwf.example.com/aframe/atext.vwf
             properties:
-              position: "0 0.5 0"
-              depth: 1
-            children:
-              material:
-                extends: http://vwf.example.com/aframe/aMaterialComponent.vwf
-                properties:
-                  color: "#2167a5"
-              interpolation:
-                extends: http://vwf.example.com/aframe/interpolation-component.vwf
-                properties:
-                  enabled: true
-            methods:
-              run:
-                body: |
-                  var time = vwf.now;
-                  let rot = this.rotation; //AFRAME.utils.coordinates.parse(this.rotation);
-                  this.rotation = [rot[0], rot[1], Math.sin(time)*100];
-                  this.future( 0.05 ).run();  // schedule the next step
+              value: "Project by Krestianstvo.org"
+              color: "#98b099"
+              position: [0,0.5,0]
+              scale: "2 2 2"
+              side: "double"
 methods:
   initialize:
     body: |
-      let runBox = vwf_view.kernel.find("", "/aranchor/sphere/box2")[0];
-      vwf_view.kernel.callMethod(runBox, "run");
+      var runModel = vwf_view.kernel.find("", "/aranchor/model")[0];
+      vwf_view.kernel.callMethod(runModel, "run");

+ 1 - 1
public/defaults/worlds/aframe-ar/info.json

@@ -8,7 +8,7 @@
             "ru": {
                 "title": "Мир VWF & A-Frame в AR",
                 "imgUrl": "/defaults/worlds/aframe/webimg.jpg",
-                "text": "Пример распределенного приложения, показывающего возможности интеграции Virtual World Framework & A-Frame"
+                "text": "Пример распределенного приложения, показывающего возможности интеграции Virtual World Framework & A-Frame в дополненной реальности"
             }
         }
 }

+ 2 - 2
public/defaults/worlds/multipixel/index.vwf.yaml

@@ -55,8 +55,8 @@ children:
           run:
             body: |
               var time = vwf.now;
-              let rot = AFRAME.utils.coordinates.parse(this.rotation);
-              this.rotation = [rot.x, Math.sin(time)*50, rot.z];
+              let rot = this.rotation; //AFRAME.utils.coordinates.parse(this.rotation);
+              this.rotation = [rot[0], Math.sin(time)*50, rot[2]];
               this.future( 0.01 ).run();  // schedule the next step
   spaceText:
     extends: http://vwf.example.com/aframe/atext.vwf

+ 2 - 2
public/vwf.js

@@ -387,7 +387,7 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
                 { library: "vwf/view/ohm", active: true },
                 { library: "vwf/view/osc", active: true },
 
-                { library: "vwf/view/aframe-arjs", 
+                { library: "vwf/view/aframe-ar-driver", 
                 linkedLibraries: [ "vwf/model/aframe/aframe-master"],
                 active: false
             },
@@ -442,7 +442,7 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
 
                      { library: "vwf/view/ohm", active: true },
                      { library: "vwf/view/osc", active: true },
-                     { library: "vwf/view/aframe-arjs", active: false },
+                     { library: "vwf/view/aframe-ar-driver", active: false },
 
                     { library: "vwf/view/webrtc", active: true}
 

+ 25 - 0
public/vwf/model/aframe.js

@@ -858,6 +858,18 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                             aframeObject.setAttribute('hit-testing-enabled', propertyValue);
                         break;
 
+                        case 'preset':
+                        aframeObject.setAttribute('preset', propertyValue);
+                        break;
+
+                        case 'markerType':
+                        aframeObject.setAttribute('type', propertyValue);
+                        break;
+
+                        case 'markerValue':
+                        aframeObject.setAttribute('velue', propertyValue);
+                        break;
+
                         default:
                             value = undefined;
                             break;
@@ -1283,6 +1295,19 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                         case "hit-testing-enabled":
                             value = aframeObject.getAttribute('hit-testing-enabled');
                             break;
+                        case "preset":
+                            value = aframeObject.getAttribute('preset');
+                            break;
+
+                        case 'markerType':
+                            value = aframeObject.getAttribute('type');
+                            break;
+    
+                        case 'markerValue':
+                            value = aframeObject.getAttribute('value');
+                            break;
+
+
                     }
 
                 }

+ 1 - 1
public/vwf/view/aframe-arjs.js → public/vwf/view/aframe-ar-driver.js

@@ -43,7 +43,7 @@ define(["module", "vwf/view", "vwf/view/arjs/signals/signals", "vwf/view/arjs/af
 			if (self.viewDriver.state.scenes[childID]) {
 				let scene = self.viewDriver.state.scenes[childID];
 				scene.setAttribute('embedded', {});
-				scene.setAttribute('arjs', {trackingMethod: "best", sourceType: "webcam", debugUIEnabled: "true"});
+				scene.setAttribute('arjs', {trackingMethod: "best", sourceType: "webcam", debugUIEnabled: "false"});
 			}
 
 			if (self.viewDriver.state.nodes[childID].extendsID == "http://vwf.example.com/aframe/acamera.vwf") {

+ 1 - 1
public/web/index-app.js

@@ -1015,7 +1015,7 @@ class IndexApp {
                                 }, 
                                     view:{
                                         'vwf/view/aframe' : null,
-                                        'vwf/view/aframe-arjs': null
+                                        'vwf/view/aframe-ar-driver': null
                                         //'vwf/view/editor-new': null
                                 }
                             }