xushiting 3 vuotta sitten
vanhempi
commit
250dce181d
1 muutettua tiedostoa jossa 28 lisäystä ja 24 poistoa
  1. 28 24
      src/XMaterialComponent.js

+ 28 - 24
src/XMaterialComponent.js

@@ -4,7 +4,7 @@ import Logger from "./Logger.js"
 
 window.generateRandomArray = ()=>{
     var rnd=[];
-    for(let i=0;i< 512*1024;i++)
+    for(let i=0;i< 1728*720;i++)
     {
         rnd[i] = Math.floor(Math.random()*255);
     }
@@ -13,7 +13,7 @@ window.generateRandomArray = ()=>{
 
 window.updateTexture = (yuv)=>
 {
-    let Y = yuv.subarray(0, 512*1024);
+    let Y = yuv.subarray(0, 1728*720);
     window._videoRawYTexture.update(Y)
     window._videoRawYTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
     Y = undefined;
@@ -66,6 +66,7 @@ export default class XMaterialComponent {
             // resolve(!0)
         }));
 
+        /*
         E(this, "_initPureVideoContent", focal_width_height=>{
             if(this._inputYUV420){
                 if(this._videoRawYUVTexArray.getVideoYUVTex(0) != null){
@@ -76,20 +77,21 @@ export default class XMaterialComponent {
                     })
                 }
             }
-            // else{
-            //     this._videoElement = e.videoElement;
-            //     this._videoTexture || (this._videoTexture = new VideoTexture("InterVideoTexture",this._videoElement,this.scene,!0,!1));
-            //     BABYLON.Texture.WhenAllReady([this._videoTexture], ()=>{
-            //         this._changePureVideoLowModelShaderCanvasSize({
-            //             width: this._videoElement.height,
-            //             height: this._videoElement.width,
-            //             fov: e.fov
-            //         })
-            //     });
-            //     this._lowModelShader.setTexture("texture_video", this._videoTexture);
-            //     this._lowModelShader.setFloat("isYUV", 0);
-            // }
+            else{
+                this._videoElement = e.videoElement;
+                this._videoTexture || (this._videoTexture = new VideoTexture("InterVideoTexture",this._videoElement,this.scene,!0,!1));
+                BABYLON.Texture.WhenAllReady([this._videoTexture], ()=>{
+                    this._changePureVideoLowModelShaderCanvasSize({
+                        width: this._videoElement.height,
+                        height: this._videoElement.width,
+                        fov: e.fov
+                    })
+                });
+                this._lowModelShader.setTexture("texture_video", this._videoTexture);
+                this._lowModelShader.setFloat("isYUV", 0);
+            }
         });
+        */
 
         E(this, "_changePureVideoLowModelShaderCanvasSize", e=>{
             var lowModelShader;
@@ -136,7 +138,7 @@ export default class XMaterialComponent {
 
                 if(window.testPlane != null){
                     if(window.testPlane.material == null){
-                        /*
+                        
                         BABYLON.Effect.ShadersStore['customVertexShader'] = `
                             precision highp float; 
                             attribute vec2 uv;
@@ -177,27 +179,29 @@ export default class XMaterialComponent {
                               attributes: ['uv', 'position'],
                               uniforms: ['view', 'projection', 'worldViewProjection', 'world'],
                             },
-                        )*/
+                        )
                         
                         window._videoRawYTexture = BABYLON.RawTexture.CreateLuminanceTexture(
                             null,
-                            512,
-                            1024,
+                            1728,
+                            720,
                             this.scene,
                             true,
                             true,
                           )
 
-                       // window.testPlane.material.setTexture('chrominanceYTexture', window._videoRawYTexture)
+                        window.testPlane.material.setTexture('chrominanceYTexture', window._videoRawYTexture)
                         
                        
                         
-                        window.testPlane.material = new BABYLON.StandardMaterial("xsttest",this.scene);
-                        window.testPlane.material.diffuseTexture = window._videoRawYTexture
+                        // window.testPlane.material = new BABYLON.StandardMaterial("xsttest",this.scene);
+                        // window.testPlane.material.diffuseTexture = window._videoRawYTexture
                         
                         window.testPlane.material.backFaceCulling = false;//Allways show the front and the back of an element
                         window.setInterval( ()=>{
-                            window.updateTexture( new Uint8Array(window.generateRandomArray()) );
+                            //window.updateTexture( new Uint8Array(window.generateRandomArray()) );
+                            window._videoRawYTexture.update(stream)
+                            window._videoRawYTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
                         }, 60);
                     }
                 }
@@ -337,7 +341,7 @@ export default class XMaterialComponent {
     }
     _prepareRender(focal_width_height) {
         if(focal_width_height){
-            this._initPureVideoContent(focal_width_height)
+            //this._initPureVideoContent(focal_width_height)
             this._updatePureVideoShaderInput()
         }
     }