ソースを参照

加了推流的次数限制,确保当不推流的时候,画面也是正常的。

xushiting 3 年 前
コミット
fdc565ef1c
1 ファイル変更8 行追加3 行削除
  1. 8 3
      src/XMaterialComponent.js

+ 8 - 3
src/XMaterialComponent.js

@@ -21,7 +21,8 @@ window.updateTexture = (yuv)=>
     Y = undefined;
 }
 const yuv = new Uint8Array(window.generateRandomArray())
-
+const renderCount = 100;
+let sub = 0;
 const logger = new Logger('XMaterial')
 export default class XMaterialComponent {
     constructor(e, t) {
@@ -222,8 +223,12 @@ export default class XMaterialComponent {
                         window.testPlane.material.backFaceCulling = false;//Allways show the front and the back of an element
 
                         // window.updateTexture( new Uint8Array(window.generateRandomArray()) );
-                        window._videoRawYTexture.update(stream)
-                        window._videoRawYTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
+                        ++sub
+                        if(sub< renderCount)
+                        {
+                            window._videoRawYTexture.update(stream)
+                            window._videoRawYTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
+                        }
 
                         // this.scene.meshes.forEach(mesh => {
                         //     mesh.material != window.testPlane.material && (mesh.material = window.testPlane.material)