b1fabac902166eae1116d4573f4bd152c796944394072fe65a7f51f60f542f92.json 11 KB

1
  1. {"ast":null,"code":"import { InternalTexture } from \"../../../Materials/Textures/internalTexture.js\";\nimport { WebGPUTextureHelper } from \"../webgpuTextureHelper.js\";\nimport { ThinWebGPUEngine } from \"../../thinWebGPUEngine.js\";\nThinWebGPUEngine.prototype._createDepthStencilCubeTexture = function (size, options) {\n const internalTexture = new InternalTexture(this, options.generateStencil ? 12 /* InternalTextureSource.DepthStencil */ : 14 /* InternalTextureSource.Depth */);\n internalTexture.isCube = true;\n internalTexture.label = options.label;\n const internalOptions = {\n bilinearFiltering: false,\n comparisonFunction: 0,\n generateStencil: false,\n samples: 1,\n depthTextureFormat: options.generateStencil ? 13 : 14,\n ...options\n };\n internalTexture.format = internalOptions.depthTextureFormat;\n this._setupDepthStencilTexture(internalTexture, size, internalOptions.bilinearFiltering, internalOptions.comparisonFunction, internalOptions.samples);\n this._textureHelper.createGPUTextureForInternalTexture(internalTexture);\n // Now that the hardware texture is created, we can retrieve the GPU format and set the right type to the internal texture\n const gpuTextureWrapper = internalTexture._hardwareTexture;\n internalTexture.type = WebGPUTextureHelper.GetTextureTypeFromFormat(gpuTextureWrapper.format);\n this._internalTexturesCache.push(internalTexture);\n return internalTexture;\n};\nThinWebGPUEngine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad = null, onError = null, format, forcedExtension = null, createPolynomials = false, lodScale = 0, lodOffset = 0, fallback = null, loaderOptions, useSRGBBuffer = false, buffer = null) {\n return this.createCubeTextureBase(rootUrl, scene, files, !!noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, null, (texture, imgs) => {\n const imageBitmaps = imgs; // we will always get an ImageBitmap array in WebGPU\n const width = imageBitmaps[0].width;\n const height = width;\n this._setCubeMapTextureParams(texture, !noMipmap);\n texture.format = format !== null && format !== void 0 ? format : -1;\n const gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture, width, height);\n this._textureHelper.updateCubeTextures(imageBitmaps, gpuTextureWrapper.underlyingResource, width, height, gpuTextureWrapper.format, false, false, 0, 0);\n if (!noMipmap) {\n this._generateMipmaps(texture, this._uploadEncoder);\n }\n texture.isReady = true;\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n if (onLoad) {\n onLoad();\n }\n }, !!useSRGBBuffer, buffer);\n};\nThinWebGPUEngine.prototype._setCubeMapTextureParams = function (texture, loadMipmap, maxLevel) {\n texture.samplingMode = loadMipmap ? 3 : 2;\n texture._cachedWrapU = 0;\n texture._cachedWrapV = 0;\n if (maxLevel) {\n texture._maxLodLevel = maxLevel;\n }\n};\nThinWebGPUEngine.prototype.generateMipMapsForCubemap = function (texture) {\n if (texture.generateMipMaps) {\n var _texture$_hardwareTex;\n const gpuTexture = (_texture$_hardwareTex = texture._hardwareTexture) === null || _texture$_hardwareTex === void 0 ? void 0 : _texture$_hardwareTex.underlyingResource;\n if (!gpuTexture) {\n this._textureHelper.createGPUTextureForInternalTexture(texture);\n }\n this._generateMipmaps(texture);\n }\n};","map":{"version":3,"names":["InternalTexture","WebGPUTextureHelper","ThinWebGPUEngine","prototype","_createDepthStencilCubeTexture","size","options","internalTexture","generateStencil","isCube","label","internalOptions","bilinearFiltering","comparisonFunction","samples","depthTextureFormat","format","_setupDepthStencilTexture","_textureHelper","createGPUTextureForInternalTexture","gpuTextureWrapper","_hardwareTexture","type","GetTextureTypeFromFormat","_internalTexturesCache","push","createCubeTexture","rootUrl","scene","files","noMipmap","onLoad","onError","forcedExtension","createPolynomials","lodScale","lodOffset","fallback","loaderOptions","useSRGBBuffer","buffer","createCubeTextureBase","texture","imgs","imageBitmaps","width","height","_setCubeMapTextureParams","updateCubeTextures","underlyingResource","_generateMipmaps","_uploadEncoder","isReady","onLoadedObservable","notifyObservers","clear","loadMipmap","maxLevel","samplingMode","_cachedWrapU","_cachedWrapV","_maxLodLevel","generateMipMapsForCubemap","generateMipMaps","_texture$_hardwareTex","gpuTexture"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/WebGPU/Extensions/engine.cubeTexture.js"],"sourcesContent":["import { InternalTexture } from \"../../../Materials/Textures/internalTexture.js\";\n\nimport { WebGPUTextureHelper } from \"../webgpuTextureHelper.js\";\nimport { ThinWebGPUEngine } from \"../../thinWebGPUEngine.js\";\nThinWebGPUEngine.prototype._createDepthStencilCubeTexture = function (size, options) {\n const internalTexture = new InternalTexture(this, options.generateStencil ? 12 /* InternalTextureSource.DepthStencil */ : 14 /* InternalTextureSource.Depth */);\n internalTexture.isCube = true;\n internalTexture.label = options.label;\n const internalOptions = {\n bilinearFiltering: false,\n comparisonFunction: 0,\n generateStencil: false,\n samples: 1,\n depthTextureFormat: options.generateStencil ? 13 : 14,\n ...options,\n };\n internalTexture.format = internalOptions.depthTextureFormat;\n this._setupDepthStencilTexture(internalTexture, size, internalOptions.bilinearFiltering, internalOptions.comparisonFunction, internalOptions.samples);\n this._textureHelper.createGPUTextureForInternalTexture(internalTexture);\n // Now that the hardware texture is created, we can retrieve the GPU format and set the right type to the internal texture\n const gpuTextureWrapper = internalTexture._hardwareTexture;\n internalTexture.type = WebGPUTextureHelper.GetTextureTypeFromFormat(gpuTextureWrapper.format);\n this._internalTexturesCache.push(internalTexture);\n return internalTexture;\n};\nThinWebGPUEngine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad = null, onError = null, format, forcedExtension = null, createPolynomials = false, lodScale = 0, lodOffset = 0, fallback = null, loaderOptions, useSRGBBuffer = false, buffer = null) {\n return this.createCubeTextureBase(rootUrl, scene, files, !!noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, null, (texture, imgs) => {\n const imageBitmaps = imgs; // we will always get an ImageBitmap array in WebGPU\n const width = imageBitmaps[0].width;\n const height = width;\n this._setCubeMapTextureParams(texture, !noMipmap);\n texture.format = format ?? -1;\n const gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture, width, height);\n this._textureHelper.updateCubeTextures(imageBitmaps, gpuTextureWrapper.underlyingResource, width, height, gpuTextureWrapper.format, false, false, 0, 0);\n if (!noMipmap) {\n this._generateMipmaps(texture, this._uploadEncoder);\n }\n texture.isReady = true;\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n if (onLoad) {\n onLoad();\n }\n }, !!useSRGBBuffer, buffer);\n};\nThinWebGPUEngine.prototype._setCubeMapTextureParams = function (texture, loadMipmap, maxLevel) {\n texture.samplingMode = loadMipmap ? 3 : 2;\n texture._cachedWrapU = 0;\n texture._cachedWrapV = 0;\n if (maxLevel) {\n texture._maxLodLevel = maxLevel;\n }\n};\nThinWebGPUEngine.prototype.generateMipMapsForCubemap = function (texture) {\n if (texture.generateMipMaps) {\n const gpuTexture = texture._hardwareTexture?.underlyingResource;\n if (!gpuTexture) {\n this._textureHelper.createGPUTextureForInternalTexture(texture);\n }\n this._generateMipmaps(texture);\n }\n};\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,gDAAgD;AAEhF,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5DA,gBAAgB,CAACC,SAAS,CAACC,8BAA8B,GAAG,UAAUC,IAAI,EAAEC,OAAO,EAAE;EACjF,MAAMC,eAAe,GAAG,IAAIP,eAAe,CAAC,IAAI,EAAEM,OAAO,CAACE,eAAe,GAAG,EAAE,CAAC,2CAA2C,EAAE,CAAC,iCAAiC,CAAC;EAC/JD,eAAe,CAACE,MAAM,GAAG,IAAI;EAC7BF,eAAe,CAACG,KAAK,GAAGJ,OAAO,CAACI,KAAK;EACrC,MAAMC,eAAe,GAAG;IACpBC,iBAAiB,EAAE,KAAK;IACxBC,kBAAkB,EAAE,CAAC;IACrBL,eAAe,EAAE,KAAK;IACtBM,OAAO,EAAE,CAAC;IACVC,kBAAkB,EAAET,OAAO,CAACE,eAAe,GAAG,EAAE,GAAG,EAAE;IACrD,GAAGF;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