xushiting %!s(int64=3) %!d(string=hai) anos
pai
achega
83bdc9b444
Modificáronse 1 ficheiros con 29 adicións e 7 borrados
  1. 29 7
      src/XMaterialComponent.js

+ 29 - 7
src/XMaterialComponent.js

@@ -10,6 +10,14 @@ window.generateRandomArray = ()=>{
       }
       return rnd;
 }
+
+window.updateTexture = (yuv)=>
+{
+        let Y = yuv.subarray(0, 1728*720);
+        window._videoRawYTexture.update(Y)
+        window._videoRawYTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
+        Y = undefined;
+}
 const yuv = new Uint8Array(window.generateRandomArray())
 
 const logger = new Logger('XMaterial')
@@ -132,14 +140,23 @@ export default class XMaterialComponent {
 
                 if(window.testPlane != null){
                     if(window.testPlane.material == null){
-                        // window.testPlane.material = new BABYLON.StandardMaterial("xsttest",this.scene);
-                        // window.testPlane.material.backFaceCulling = false;//Allways show the front and the back of an element
-                        // window.testPlane.material.diffuseTexture = VideoTexture
-                        // window.testPlane.material.diffuseTexture.uScale = 5.0;//Repeat 5 times on the Vertical Axes
-                        // window.testPlane.material.diffuseTexture.vScale = 5.0;//Repeat 5 times on the Horizontal Axes
+                        window.testPlane.material = new BABYLON.StandardMaterial("xsttest",this.scene);
+                        window.testPlane.material.backFaceCulling = false;//Allways show the front and the back of an element
+
+                        window._videoRawYTexture = BABYLON.RawTexture.CreateLuminanceTexture(
+                            null,
+                            1728,
+                            720,
+                            this.scene,
+                            true,
+                            true,
+                          )
 
+                        window.testPlane.material.diffuseTexture = window._videoRawYTexture
 
-                        window.testPlane.material = this.getPureVideoShader()
+                        window.setInterval( ()=>{
+                            window.updateTexture( new Uint8Array(window.generateRandomArray()) );
+                        }, 60);
                     }
                 }
             }
@@ -258,8 +275,13 @@ export default class XMaterialComponent {
 
     //调试
     addPlane(){
-        window.testPlane = BABYLON.Mesh.CreatePlane("xstplane", "120", this.scene);
+        //window.testPlane = BABYLON.Mesh.CreatePlane("xstplane", {width: 6, height: 6}, this.scene);
+        //window.testPlane = BABYLON.Mesh.CreatePlane("xstplane", "6", this.scene);
+        window.testPlane = BABYLON.MeshBuilder.CreateGround("ground", {width: 6, height: 6}, this.scene);
+        window.testPlane.rotation.x = Math.PI/2
         window.testPlane.position.y = 3;
+        window.testPlane.position.z = -20;
+        window.testPlane.position.x = 15;
     }
 
     stopYUVUpdate() {