XVideoRawYUV.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. class XVideoRawYUV {
  2. constructor(e, t) {
  3. E(this, "scene");
  4. E(this, "_videoRawYUVTexture");
  5. E(this, "videosResOriArray");
  6. E(this, "_currentVideoId");
  7. this.scene = e,
  8. this._videoRawYUVTexture = [],
  9. this.videosResOriArray = t,
  10. this._currentVideoId = -1;
  11. for (let r = 0; r < t.length; ++r)
  12. (n=>{
  13. const o = RawTexture.CreateLuminanceTexture(null, t[n].width, t[n].height * 1.5, this.scene, !1, !0);
  14. o.name = "videoTex_" + t[n].width + "_" + t[n].height,
  15. this._videoRawYUVTexture.push(o)
  16. }
  17. )(r)
  18. }
  19. inRange(e) {
  20. return e >= 0 && e < this._videoRawYUVTexture.length
  21. }
  22. getVideoYUVTex(e) {
  23. return this.inRange(e) ? this._videoRawYUVTexture[e] : null
  24. }
  25. findId(e, t) {
  26. let r = 0;
  27. for (let n = 0; n < this.videosResOriArray.length; ++n)
  28. if (this.videosResOriArray[n].width == e && this.videosResOriArray[n].height == t) {
  29. r = n;
  30. break
  31. }
  32. return r
  33. }
  34. getCurrentVideoTexId() {
  35. return this._currentVideoId
  36. }
  37. setCurrentVideoTexId(e) {
  38. this._currentVideoId = e
  39. }
  40. }