26a023f81978326fc384e1f020680b814a2306301d65985009aa0c62f7cdb994.json 5.9 KB

1
  1. {"ast":null,"code":"import { WebGPUEngine } from \"../../webgpuEngine.js\";\nfunction IsExternalTexture(texture) {\n return texture && texture.underlyingResource !== undefined ? true : false;\n}\nWebGPUEngine.prototype.updateVideoTexture = function (texture, video, invertY) {\n var _texture$_hardwareTex;\n if (!texture || texture._isDisabled) {\n return;\n }\n if (this._videoTextureSupported === undefined) {\n this._videoTextureSupported = true;\n }\n let gpuTextureWrapper = texture._hardwareTexture;\n if (!((_texture$_hardwareTex = texture._hardwareTexture) !== null && _texture$_hardwareTex !== void 0 && _texture$_hardwareTex.underlyingResource)) {\n gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture);\n }\n if (IsExternalTexture(video)) {\n if (video.isReady()) {\n try {\n this._textureHelper.copyVideoToTexture(video, texture, gpuTextureWrapper.format, !invertY);\n if (texture.generateMipMaps) {\n this._generateMipmaps(texture);\n }\n } catch (e) {\n // WebGPU doesn't support video element who are not playing so far\n // Ignore this error ensures we can start a video texture in a paused state\n }\n texture.isReady = true;\n }\n } else if (video) {\n this.createImageBitmap(video).then(bitmap => {\n this._textureHelper.updateTexture(bitmap, texture, texture.width, texture.height, texture.depth, gpuTextureWrapper.format, 0, 0, !invertY, false, 0, 0);\n if (texture.generateMipMaps) {\n this._generateMipmaps(texture);\n }\n texture.isReady = true;\n }).catch(() => {\n // Sometimes createImageBitmap(video) fails with \"Failed to execute 'createImageBitmap' on 'Window': The provided element's player has no current data.\"\n // Just keep going on\n texture.isReady = true;\n });\n }\n};","map":{"version":3,"names":["WebGPUEngine","IsExternalTexture","texture","underlyingResource","undefined","prototype","updateVideoTexture","video","invertY","_texture$_hardwareTex","_isDisabled","_videoTextureSupported","gpuTextureWrapper","_hardwareTexture","_textureHelper","createGPUTextureForInternalTexture","isReady","copyVideoToTexture","format","generateMipMaps","_generateMipmaps","e","createImageBitmap","then","bitmap","updateTexture","width","height","depth","catch"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/WebGPU/Extensions/engine.videoTexture.js"],"sourcesContent":["import { WebGPUEngine } from \"../../webgpuEngine.js\";\nfunction IsExternalTexture(texture) {\n return texture && texture.underlyingResource !== undefined ? true : false;\n}\nWebGPUEngine.prototype.updateVideoTexture = function (texture, video, invertY) {\n if (!texture || texture._isDisabled) {\n return;\n }\n if (this._videoTextureSupported === undefined) {\n this._videoTextureSupported = true;\n }\n let gpuTextureWrapper = texture._hardwareTexture;\n if (!texture._hardwareTexture?.underlyingResource) {\n gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture);\n }\n if (IsExternalTexture(video)) {\n if (video.isReady()) {\n try {\n this._textureHelper.copyVideoToTexture(video, texture, gpuTextureWrapper.format, !invertY);\n if (texture.generateMipMaps) {\n this._generateMipmaps(texture);\n }\n }\n catch (e) {\n // WebGPU doesn't support video element who are not playing so far\n // Ignore this error ensures we can start a video texture in a paused state\n }\n texture.isReady = true;\n }\n }\n else if (video) {\n this.createImageBitmap(video)\n .then((bitmap) => {\n this._textureHelper.updateTexture(bitmap, texture, texture.width, texture.height, texture.depth, gpuTextureWrapper.format, 0, 0, !invertY, false, 0, 0);\n if (texture.generateMipMaps) {\n this._generateMipmaps(texture);\n }\n texture.isReady = true;\n })\n .catch(() => {\n // Sometimes createImageBitmap(video) fails with \"Failed to execute 'createImageBitmap' on 'Window': The provided element's player has no current data.\"\n // Just keep going on\n texture.isReady = true;\n });\n }\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,uBAAuB;AACpD,SAASC,iBAAiBA,CAACC,OAAO,EAAE;EAChC,OAAOA,OAAO,IAAIA,OAAO,CAACC,kBAAkB,KAAKC,SAAS,GAAG,IAAI,GAAG,KAAK;AAC7E;AACAJ,YAAY,CAACK,SAAS,CAACC,kBAAkB,GAAG,UAAUJ,OAAO,EAAEK,KAAK,EAAEC,OAAO,EAAE;EAAA,IAAAC,qBAAA;EAC3E,IAAI,C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