xushiting 3 anos atrás
pai
commit
353c9b1836
2 arquivos alterados com 9 adições e 104 exclusões
  1. 8 3
      src/Signal.js
  2. 1 101
      src/XMaterialComponent.js

+ 8 - 3
src/Signal.js

@@ -15,11 +15,13 @@ export default class Signal {
     handleSignal(e) {
         var a, s, l;
         if (!this.signalHandleActived)
+        {
             return;
+        }
         const {signal: t, alreadyUpdateYUV: r} = e;
-        if (this.handleActionResponses(t),
-        this._room.handleSignalHook(t),
-        !r) {
+        this.handleActionResponses(t);
+        //this._room.handleSignalHook(t);
+        if (!r) {
             const u = (a = t.newUserStates) == null ? void 0 : a.find(c=>c.userId === this._room.userId);
             if ((u == null ? void 0 : u.renderInfo) && ((s = this._room._userAvatar) == null ? void 0 : s.isMoving)) {
                 logger.debug("stream stoped, make avatar to stop");
@@ -32,6 +34,9 @@ export default class Signal {
             }
             return
         }
+
+        console.log('执行signal:'+JSON.stringify(t))
+
         this.isUpdatedYUV = r;
         const n = t;
         if (!t) {

+ 1 - 101
src/XMaterialComponent.js

@@ -1,25 +1,6 @@
 import XVideoRawYUV from "./XVideoRawYUV"
 import Logger from "./Logger.js"
 
-
-window.generateRandomArray = ()=>{
-    var rnd=[];
-    for(let i=0;i< 512*1024;i++)
-    {
-        rnd[i] = Math.floor(Math.random()*255);
-    }
-    return rnd;
-}
-
-window.updateTexture = (yuv)=>
-{
-    let Y = yuv.subarray(0, 512*1024);
-    window._videoRawYTexture.update(Y)
-    window._videoRawYTexture.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
-    Y = undefined;
-}
-const yuv = new Uint8Array(window.generateRandomArray())
-
 const logger = new Logger('XMaterial')
 export default class XMaterialComponent {
     constructor(e, t) {
@@ -105,6 +86,7 @@ export default class XMaterialComponent {
             var o, a;
             fov == -1 && (fov = this.yuvInfo.fov);
             if (this._isUpdateYUV == !0) {
+                console.log('执行:updateRawYUVData')
                 const s = {
                     width: width,
                     height: height,
@@ -133,74 +115,6 @@ export default class XMaterialComponent {
                 }
                 //(o = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || o.update(stream),
                 //(a = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || a.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
-
-                if(window.testPlane != null){
-                    if(window.testPlane.material == null){
-                        /*
-                        BABYLON.Effect.ShadersStore['customVertexShader'] = `
-                            precision highp float; 
-                            attribute vec2 uv;
-                            attribute vec3 position;
-                            varying vec2 vUV;
-                            uniform mat4 view;
-                            uniform mat4 projection; 
-                            uniform mat4 world;
-                            uniform mat4 worldViewProjection;
-                            void main()
-                            { 
-                                vUV = uv;
-                                gl_Position = projection * view * world * vec4(position , 1.0); 
-                            }
-                        `;
-                        BABYLON.Effect.ShadersStore["customFragmentShader"]=`
-                            precision highp float;
-                            varying vec2 vUV;
-                            uniform sampler2D chrominanceYTexture;
-                            void main()
-                            {    
-                                vec2 uv = vUV;
-                                vec3 color = vec3(0,0,0);
-                                color = texture2D(chrominanceYTexture, uv).rgb;    
-                                gl_FragColor = vec4( color, 1.0); 
-                            }
-                        `;
-                            
-                        
-                        window.testPlane.material = new BABYLON.ShaderMaterial(
-                            'customShader',
-                            this.scene,
-                            { 
-                              vertex: "custom",
-                              fragment: "custom",
-                            },
-                            {
-                              attributes: ['uv', 'position'],
-                              uniforms: ['view', 'projection', 'worldViewProjection', 'world'],
-                            },
-                        )*/
-                        
-                        window._videoRawYTexture = BABYLON.RawTexture.CreateLuminanceTexture(
-                            null,
-                            512,
-                            1024,
-                            this.scene,
-                            true,
-                            true,
-                          )
-
-                       // 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.backFaceCulling = false;//Allways show the front and the back of an element
-                        window.setInterval( ()=>{
-                            window.updateTexture( new Uint8Array(window.generateRandomArray()) );
-                        }, 60);
-                    }
-                }
             }
         }
         );
@@ -310,20 +224,6 @@ export default class XMaterialComponent {
         this.shaderMode = t.shaderMode,
         t.yuvInfo != null && (this.yuvInfo = t.yuvInfo),
         t.panoInfo != null && this.setPanoInfo(t.panoInfo)
-
-        window.testPlane = null
-        this.addPlane()
-    }
-
-    //调试
-    addPlane(){
-        //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() {