|
@@ -1,25 +1,6 @@
|
|
import XVideoRawYUV from "./XVideoRawYUV"
|
|
import XVideoRawYUV from "./XVideoRawYUV"
|
|
import Logger from "./Logger.js"
|
|
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')
|
|
const logger = new Logger('XMaterial')
|
|
export default class XMaterialComponent {
|
|
export default class XMaterialComponent {
|
|
constructor(e, t) {
|
|
constructor(e, t) {
|
|
@@ -105,6 +86,7 @@ export default class XMaterialComponent {
|
|
var o, a;
|
|
var o, a;
|
|
fov == -1 && (fov = this.yuvInfo.fov);
|
|
fov == -1 && (fov = this.yuvInfo.fov);
|
|
if (this._isUpdateYUV == !0) {
|
|
if (this._isUpdateYUV == !0) {
|
|
|
|
+ console.log('执行:updateRawYUVData')
|
|
const s = {
|
|
const s = {
|
|
width: width,
|
|
width: width,
|
|
height: height,
|
|
height: height,
|
|
@@ -133,74 +115,6 @@ export default class XMaterialComponent {
|
|
}
|
|
}
|
|
//(o = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || o.update(stream),
|
|
//(o = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || o.update(stream),
|
|
//(a = this._videoRawYUVTexArray.getVideoYUVTex(videosResOriArrayIndex)) == null || a.updateSamplingMode(BABYLON.Texture.BILINEAR_SAMPLINGMODE)
|
|
//(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,
|
|
this.shaderMode = t.shaderMode,
|
|
t.yuvInfo != null && (this.yuvInfo = t.yuvInfo),
|
|
t.yuvInfo != null && (this.yuvInfo = t.yuvInfo),
|
|
t.panoInfo != null && this.setPanoInfo(t.panoInfo)
|
|
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() {
|
|
stopYUVUpdate() {
|