1 |
- {"ast":null,"code":"import { ThinEngine } from \"../../Engines/thinEngine.js\";\nThinEngine.prototype.updateVideoTexture = function (texture, video, invertY) {\n if (!texture || texture._isDisabled) {\n return;\n }\n const glformat = this._getInternalFormat(texture.format);\n const internalFormat = this._getRGBABufferInternalSizedFormat(0, texture.format);\n const wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);\n this._unpackFlipY(!invertY); // Video are upside down by default\n try {\n // Testing video texture support\n if (this._videoTextureSupported === undefined) {\n // clear old errors just in case.\n this._gl.getError();\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, glformat, this._gl.UNSIGNED_BYTE, video);\n if (this._gl.getError() !== 0) {\n this._videoTextureSupported = false;\n } else {\n this._videoTextureSupported = true;\n }\n }\n // Copy video through the current working canvas if video texture is not supported\n if (!this._videoTextureSupported) {\n if (!texture._workingCanvas) {\n texture._workingCanvas = this.createCanvas(texture.width, texture.height);\n const context = texture._workingCanvas.getContext(\"2d\");\n if (!context) {\n throw new Error(\"Unable to get 2d context\");\n }\n texture._workingContext = context;\n texture._workingCanvas.width = texture.width;\n texture._workingCanvas.height = texture.height;\n }\n texture._workingContext.clearRect(0, 0, texture.width, texture.height);\n texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, glformat, this._gl.UNSIGNED_BYTE, texture._workingCanvas);\n } else {\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, glformat, this._gl.UNSIGNED_BYTE, video);\n }\n if (texture.generateMipMaps) {\n this._gl.generateMipmap(this._gl.TEXTURE_2D);\n }\n if (!wasPreviouslyBound) {\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\n }\n // this.resetTextureCache();\n texture.isReady = true;\n } catch (ex) {\n // Something unexpected\n // Let's disable the texture\n texture._isDisabled = true;\n }\n};","map":{"version":3,"names":["ThinEngine","prototype","updateVideoTexture","texture","video","invertY","_isDisabled","glformat","_getInternalFormat","format","internalFormat","_getRGBABufferInternalSizedFormat","wasPreviouslyBound","_bindTextureDirectly","_gl","TEXTURE_2D","_unpackFlipY","_videoTextureSupported","undefined","getError","texImage2D","UNSIGNED_BYTE","_workingCanvas","createCanvas","width","height","context","getContext","Error","_workingContext","clearRect","drawImage","videoWidth","videoHeight","generateMipMaps","generateMipmap","isReady","ex"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/Extensions/engine.videoTexture.js"],"sourcesContent":["import { ThinEngine } from \"../../Engines/thinEngine.js\";\n\nThinEngine.prototype.updateVideoTexture = function (texture, video, invertY) {\n if (!texture || texture._isDisabled) {\n return;\n }\n const glformat = this._getInternalFormat(texture.format);\n const internalFormat = this._getRGBABufferInternalSizedFormat(0, texture.format);\n const wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);\n this._unpackFlipY(!invertY); // Video are upside down by default\n try {\n // Testing video texture support\n if (this._videoTextureSupported === undefined) {\n // clear old errors just in case.\n this._gl.getError();\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, glformat, this._gl.UNSIGNED_BYTE, video);\n if (this._gl.getError() !== 0) {\n this._videoTextureSupported = false;\n }\n else {\n this._videoTextureSupported = true;\n }\n }\n // Copy video through the current working canvas if video texture is not supported\n if (!this._videoTextureSupported) {\n if (!texture._workingCanvas) {\n texture._workingCanvas = this.createCanvas(texture.width, texture.height);\n const context = texture._workingCanvas.getContext(\"2d\");\n if (!context) {\n throw new Error(\"Unable to get 2d context\");\n }\n texture._workingContext = context;\n texture._workingCanvas.width = texture.width;\n texture._workingCanvas.height = texture.height;\n }\n texture._workingContext.clearRect(0, 0, texture.width, texture.height);\n texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, glformat, this._gl.UNSIGNED_BYTE, texture._workingCanvas);\n }\n else {\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, glformat, this._gl.UNSIGNED_BYTE, video);\n }\n if (texture.generateMipMaps) {\n this._gl.generateMipmap(this._gl.TEXTURE_2D);\n }\n if (!wasPreviouslyBound) {\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\n }\n // this.resetTextureCache();\n texture.isReady = true;\n }\n catch (ex) {\n // Something unexpected\n // Let's disable the texture\n texture._isDisabled = true;\n }\n};\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,6BAA6B;AAExDA,UAAU,CAACC,SAAS,CAACC,kBAAkB,GAAG,UAAUC,OAAO,EAAEC,KAAK,EAAEC,OAAO,EAAE;EACzE,IAAI,CAACF,OAAO,IAAIA,OAAO,CAACG,WAAW,EAAE;IACjC;EACJ;EACA,MAAMC,QAAQ,GAAG,IAAI,CAACC,kBAAkB,CAACL,OAAO,CAACM,MAAM,CAAC;EACxD,MAAMC,cAAc,GAAG,IAAI,CAACC,iCAAiC,CAAC,CAAC,EAAER,OAAO,CAACM,MAAM,CAAC;EAChF,MAAMG,kBAAkB,GAAG,IAAI,CAACC,oBAAoB,CAAC,IAAI,CAACC,GAAG,CAACC,UAAU,EAAEZ,OAAO,EAAE,IAAI,CAAC;EACxF,IAAI,CAACa,YAAY,CAAC,CAACX,OAAO,CAAC,CAAC,CAAC;EAC7B,IAAI;IACA;IACA,IAAI,IAAI,CAACY,sBAAsB,KAAKC,SAAS,EAAE;MAC3C;MACA,IAAI,CAACJ,GAAG,CAACK,QAAQ,CAAC,CAAC;MACnB,IAAI,CAACL,GAAG,CAACM,UAAU,CAAC,IAAI,CAACN,GAAG,CAACC,UAAU,EAAE,CAAC,EAAEL,cAAc,EAAEH,QAAQ,EAAE,IAAI,CAACO,GAAG,CAACO,aAAa,EAAEjB,KAAK,CAAC;MACpG,IAAI,IAAI,CAACU,GAAG,CAACK,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE;QAC3B,IAAI,CAAC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