瀏覽代碼

fix loading audio asset

Nikolay Suslov 7 年之前
父節點
當前提交
6640fca1e1

+ 2 - 41
support/client/lib/vwf/model/aframe.js

@@ -642,29 +642,6 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                     }
                 }
 
-                if (value === undefined && aframeObject.nodeName == "A-SOUND") {
-                    value = propertyValue;
-
-                    switch (propertyName) {
-
-                        case "src":
-                            aframeObject.setAttribute('src', propertyValue);
-                            break;
-
-                        case "on":
-                            aframeObject.setAttribute('on', propertyValue);
-                            break;
-
-                        case "autoplay":
-                            aframeObject.setAttribute('autoplay', propertyValue);
-                            break;
-
-                        default:
-                            value = undefined;
-                            break;
-                    }
-                }
-
                 if (value === undefined && aframeObject.nodeName == "A-PLANE") {
                     value = propertyValue;
 
@@ -1153,20 +1130,6 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                     }
                 }
 
-                if (value === undefined && aframeObject.nodeName == "A-SOUND") {
-
-                    switch (propertyName) {
-                        case "src":
-                            value = aframeObject.getAttribute('src');
-                            break;
-                        case "on":
-                            value = aframeObject.getAttribute('on');
-                            break;
-                        case "autoplay":
-                            value = aframeObject.getAttribute('autoplay');
-                            break;
-                    }
-                }
 
                 if (value === undefined && aframeObject.nodeName == "A-GLTF-MODEL") {
                     
@@ -1277,8 +1240,6 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
             aframeObj = document.createElement('a-collada-model');
         } else if (self.state.isAFrameClass(protos, "http://vwf.example.com/aframe/aobjmodel.vwf")) {
             aframeObj = document.createElement('a-obj-model');
-        } else if (self.state.isAFrameClass(protos, "http://vwf.example.com/aframe/asound.vwf")) {
-            aframeObj = document.createElement('a-sound');
          } else if (self.state.isAFrameClass(protos, "http://vwf.example.com/aframe/agltfmodel.vwf")) {
             aframeObj = document.createElement('a-gltf-model');
         } else if (self.state.isAFrameClass(protos, "http://vwf.example.com/aframe/asphere.vwf")) {
@@ -1291,7 +1252,7 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
 
         if (aframeObj.nodeName !== "A-ASSET-ITEM" && 
             aframeObj.nodeName !== "IMG" && 
-            aframeObj.nodeName !== "AUIDO" &&
+            aframeObj.nodeName !== "AUDIO" &&
             aframeObj.nodeName !== "VIDEO"
         ){
             aframeObj.setAttribute('id', node.ID);
@@ -1315,7 +1276,7 @@ define(["module", "vwf/model", "vwf/utility"], function (module, model, utility)
                     //console.info( "Adding child: " + childID + " to " + nodeID );
                     if (node.aframeObj.nodeName !== "A-ASSET-ITEM" &&
                         node.aframeObj.nodeName !== "IMG" &&
-                      node.aframeObj.nodeName !== "AUIDO" &&
+                      node.aframeObj.nodeName !== "AUDIO" &&
                       node.aframeObj.nodeName !== "VIDEO"
                     ){
                     parent.aframeObj.appendChild(node.aframeObj);

+ 11 - 8
support/client/lib/vwf/view/aframe.js

@@ -186,15 +186,18 @@ define(["module", "vwf/view"], function (module, view) {
                     let sound = el[1].aframeObj.getAttribute('sound');
                     if(sound) {
                    
-                    if (sound.src !== ""){
-                       // console.log("my: " + src);
-                        let src = '#' + sound.src.id;
-                        if (src == elID){
-                            let soundID = vwf.find(el[0], 'sound');
-                            self.kernel.callMethod(soundID, "updateSrc", [elID])
-                        }
+                        let soundID = vwf.find(el[0], 'sound');
+                        self.kernel.callMethod(soundID, "refreshSrc", [elID])
+
+                    // if (sound.src !== ""){
+                    //     let src = '#' + sound.src.id;
+                    //     if (src == elID){
+                    //         let soundID = vwf.find(el[0], 'sound');
+                    //         self.kernel.callMethod(soundID, "updateSrc", [elID])
+                    //     }
                         
-                    }
+                    // }
+
                 }
 
                 })

+ 16 - 2
support/proxy/vwf.example.com/aframe/a-sound-component.js

@@ -1,8 +1,22 @@
 this.updateSrc = function(srcID){
 
     if (srcID) {
-        this.src = "";
-        this.src = srcID;
+
+            this.src = "";
+            this.src = srcID;
+        
+    }
+    
+}
+
+this.refreshSrc = function(srcID){
+
+    if (srcID) {
+
+        if (srcID == this.src) {
+            this.src = "";
+            this.src = srcID;
+        }
     }
     
 }

+ 3 - 0
support/proxy/vwf.example.com/aframe/a-sound-component.vwf.yaml

@@ -14,6 +14,9 @@ properties:
   src:
   volume:
 methods:
+  refreshSrc:
+    parameters:
+      - srcID
   updateSrc:
     parameters:
       - srcID

+ 0 - 10
support/proxy/vwf.example.com/aframe/aentity.js

@@ -21,14 +21,4 @@ this.showCloseGizmo = function () {
             this.children.delete(this.gizmo)
         }
     }
-}
-
-this.updateSrc = function(srcID){
-
-    if (srcID) {
-        debugger;
-        this.src = "";
-        this.src = srcID;
-    }
-    
 }

+ 0 - 3
support/proxy/vwf.example.com/aframe/aentity.vwf.yaml

@@ -17,9 +17,6 @@ methods:
     parameters:
       - mode
   showCloseGizmo:
-  updateSrc:
-    parameters:
-      - src
   lookAt:
     parameters:
       - nodeID

+ 0 - 17
support/proxy/vwf.example.com/aframe/aimage.vwf.yaml

@@ -1,17 +0,0 @@
---- 
-extends: http://vwf.example.com/aframe/node.vwf
-type: "a-image"
-properties:
-  color:
-  height:
-  metalness:
-  opacity:
-  repeat:
-  roughness:
-  segments-height:
-  segments-width:
-  shader:
-  side:
-  src:
-  transparent:
-  width:

+ 12 - 9
support/proxy/vwf.example.com/aframe/ascene.js

@@ -549,6 +549,7 @@ this.createImage = function (imgSrc, name, node, avatar) {
         }
  
         let newNode = self.planeProto();
+        newNode.properties.displayName = "image";
         newNode.children.material.properties.src = '#' + child.itemID;
         newNode.properties.position = position;
         newNode.properties.width = child.width;
@@ -601,10 +602,10 @@ this.createVideo = function (vidSrc, name, node, avatar) {
     this.children.create(tagName, tagNode, function( child ) {
 
 
-        // let allNodes = vwf.models["vwf/model/aframe"].model.state.nodes;
-        // let imgAssetNode = allNodes[child.id];
+        let allNodes = vwf.models["vwf/model/aframe"].model.state.nodes;
+        let imgAssetNode = allNodes[child.id];
 
-        // imgAssetNode.aframeObj.onloadeddata = function(){
+        imgAssetNode.aframeObj.onloadeddata = function(){
 
        //console.log(imgAssetNode);
 
@@ -623,19 +624,20 @@ this.createVideo = function (vidSrc, name, node, avatar) {
         }
  
         let newNode = self.planeProto();
+        newNode.properties.displayName = "video";
         newNode.children.material.properties.src = '#' + child.itemID;
         newNode.properties.position = position;
-        newNode.properties.width = 3;
-        newNode.properties.height = 1.75;
-        // newNode.properties.width = child.videoWidth;
-        // newNode.properties.height = child.videoHeight;
-        // newNode.properties.scale = [0.003, 0.003, 0.003];
+        // newNode.properties.width = 3;
+        // newNode.properties.height = 1.75;
+        newNode.properties.width = child.videoWidth;
+        newNode.properties.height = child.videoHeight;
+        newNode.properties.scale = [0.003, 0.003, 0.003];
 
         self.children.create(nodeName, newNode, function( child ) {
             if (avatar) child.lookAt(self.children[avatar].worldPosition)
            });
 
-        //}
+        }
         
        });
 
@@ -698,6 +700,7 @@ this.createAudio = function (itemSrc, name, node, avatar) {
         }
  
         let newNode = self.cubeProto();
+        newNode.properties.displayName = "audio";
         newNode.properties.position = position;
         newNode.children.sound = {
             

+ 0 - 8
support/proxy/vwf.example.com/aframe/asound.vwf.yaml

@@ -1,8 +0,0 @@
-# https://aframe.io/docs/master/primitives/a-sound.html
---- 
-extends: http://vwf.example.com/aframe/aentity.vwf
-type: "a-sound"
-properties:
-  src:
-  on:
-  autoplay: