1 |
- {"ast":null,"code":"import _asyncToGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { PostProcess } from \"../PostProcesses/postProcess.js\";\nimport { ApplyPostProcess } from \"./textureTools.js\";\n/**\n * Class used to host RGBD texture specific utilities\n */\nexport class RGBDTextureTools {\n /**\n * Expand the RGBD Texture from RGBD to Half Float if possible.\n * @param texture the texture to expand.\n */\n static ExpandRGBDTexture(texture) {\n const internalTexture = texture._texture;\n if (!internalTexture || !texture.isRGBD) {\n return;\n }\n // Gets everything ready.\n const engine = internalTexture.getEngine();\n const caps = engine.getCaps();\n const isReady = internalTexture.isReady;\n let expandTexture = false;\n // If half float available we can uncompress the texture\n if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {\n expandTexture = true;\n internalTexture.type = 2;\n }\n // If full float available we can uncompress the texture\n else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {\n expandTexture = true;\n internalTexture.type = 1;\n }\n if (expandTexture) {\n // Do not use during decode.\n internalTexture.isReady = false;\n internalTexture._isRGBD = false;\n internalTexture.invertY = false;\n }\n const expandRGBDTexture = /*#__PURE__*/function () {\n var _ref = _asyncToGenerator(function* () {\n const isWebGPU = engine.isWebGPU;\n const shaderLanguage = isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */;\n internalTexture.isReady = false;\n if (isWebGPU) {\n yield Promise.all([import(\"../ShadersWGSL/rgbdDecode.fragment.js\"), import(\"../ShadersWGSL/rgbdEncode.fragment.js\")]);\n } else {\n yield Promise.all([import(\"../Shaders/rgbdDecode.fragment.js\"), import(\"../Shaders/rgbdEncode.fragment.js\")]);\n }\n // Expand the texture if possible\n // Simply run through the decode PP.\n const rgbdPostProcess = new PostProcess(\"rgbdDecode\", \"rgbdDecode\", null, null, 1, null, 3, engine, false, undefined, internalTexture.type, undefined, null, false, undefined, shaderLanguage);\n rgbdPostProcess.externalTextureSamplerBinding = true;\n // Hold the output of the decoding.\n const expandedTexture = engine.createRenderTargetTexture(internalTexture.width, {\n generateDepthBuffer: false,\n generateMipMaps: false,\n generateStencilBuffer: false,\n samplingMode: internalTexture.samplingMode,\n type: internalTexture.type,\n format: 5\n });\n rgbdPostProcess.onEffectCreatedObservable.addOnce(e => {\n e.executeWhenCompiled(() => {\n // PP Render Pass\n rgbdPostProcess.onApply = effect => {\n effect._bindTexture(\"textureSampler\", internalTexture);\n effect.setFloat2(\"scale\", 1, 1);\n };\n texture.getScene().postProcessManager.directRender([rgbdPostProcess], expandedTexture, true);\n // Cleanup\n engine.restoreDefaultFramebuffer();\n engine._releaseTexture(internalTexture);\n if (rgbdPostProcess) {\n rgbdPostProcess.dispose();\n }\n // Internal Swap\n expandedTexture._swapAndDie(internalTexture);\n // Ready to get rolling again.\n internalTexture.isReady = true;\n });\n });\n });\n return function expandRGBDTexture() {\n return _ref.apply(this, arguments);\n };\n }();\n if (expandTexture) {\n if (isReady) {\n expandRGBDTexture();\n } else {\n texture.onLoadObservable.addOnce(expandRGBDTexture);\n }\n }\n }\n /**\n * Encode the texture to RGBD if possible.\n * @param internalTexture the texture to encode\n * @param scene the scene hosting the texture\n * @param outputTextureType type of the texture in which the encoding is performed\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\n */\n static EncodeTextureToRGBD(internalTexture, scene, outputTextureType = 0) {\n return ApplyPostProcess(\"rgbdEncode\", internalTexture, scene, outputTextureType, 1, 5);\n }\n}","map":{"version":3,"names":["PostProcess","ApplyPostProcess","RGBDTextureTools","ExpandRGBDTexture","texture","internalTexture","_texture","isRGBD","engine","getEngine","caps","getCaps","isReady","expandTexture","textureHalfFloatRender","textureHalfFloatLinearFiltering","type","textureFloatRender","textureFloatLinearFiltering","_isRGBD","invertY","expandRGBDTexture","_ref","_asyncToGenerator","isWebGPU","shaderLanguage","Promise","all","rgbdPostProcess","undefined","externalTextureSamplerBinding","expandedTexture","createRenderTargetTexture","width","generateDepthBuffer","generateMipMaps","generateStencilBuffer","samplingMode","format","onEffectCreatedObservable","addOnce","e","executeWhenCompiled","onApply","effect","_bindTexture","setFloat2","getScene","postProcessManager","directRender","restoreDefaultFramebuffer","_releaseTexture","dispose","_swapAndDie","apply","arguments","onLoadObservable","EncodeTextureToRGBD","scene","outputTextureType"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Misc/rgbdTextureTools.js"],"sourcesContent":["\nimport { PostProcess } from \"../PostProcesses/postProcess.js\";\nimport { ApplyPostProcess } from \"./textureTools.js\";\n/**\n * Class used to host RGBD texture specific utilities\n */\nexport class RGBDTextureTools {\n /**\n * Expand the RGBD Texture from RGBD to Half Float if possible.\n * @param texture the texture to expand.\n */\n static ExpandRGBDTexture(texture) {\n const internalTexture = texture._texture;\n if (!internalTexture || !texture.isRGBD) {\n return;\n }\n // Gets everything ready.\n const engine = internalTexture.getEngine();\n const caps = engine.getCaps();\n const isReady = internalTexture.isReady;\n let expandTexture = false;\n // If half float available we can uncompress the texture\n if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {\n expandTexture = true;\n internalTexture.type = 2;\n }\n // If full float available we can uncompress the texture\n else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {\n expandTexture = true;\n internalTexture.type = 1;\n }\n if (expandTexture) {\n // Do not use during decode.\n internalTexture.isReady = false;\n internalTexture._isRGBD = false;\n internalTexture.invertY = false;\n }\n const expandRGBDTexture = async () => {\n const isWebGPU = engine.isWebGPU;\n const shaderLanguage = isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */;\n internalTexture.isReady = false;\n if (isWebGPU) {\n await Promise.all([import(\"../ShadersWGSL/rgbdDecode.fragment.js\"), import(\"../ShadersWGSL/rgbdEncode.fragment.js\")]);\n }\n else {\n await Promise.all([import(\"../Shaders/rgbdDecode.fragment.js\"), import(\"../Shaders/rgbdEncode.fragment.js\")]);\n }\n // Expand the texture if possible\n // Simply run through the decode PP.\n const rgbdPostProcess = new PostProcess(\"rgbdDecode\", \"rgbdDecode\", null, null, 1, null, 3, engine, false, undefined, internalTexture.type, undefined, null, false, undefined, shaderLanguage);\n rgbdPostProcess.externalTextureSamplerBinding = true;\n // Hold the output of the decoding.\n const expandedTexture = engine.createRenderTargetTexture(internalTexture.width, {\n generateDepthBuffer: false,\n generateMipMaps: false,\n generateStencilBuffer: false,\n samplingMode: internalTexture.samplingMode,\n type: internalTexture.type,\n format: 5,\n });\n rgbdPostProcess.onEffectCreatedObservable.addOnce((e) => {\n e.executeWhenCompiled(() => {\n // PP Render Pass\n rgbdPostProcess.onApply = (effect) => {\n effect._bindTexture(\"textureSampler\", internalTexture);\n effect.setFloat2(\"scale\", 1, 1);\n };\n texture.getScene().postProcessManager.directRender([rgbdPostProcess], expandedTexture, true);\n // Cleanup\n engine.restoreDefaultFramebuffer();\n engine._releaseTexture(internalTexture);\n if (rgbdPostProcess) {\n rgbdPostProcess.dispose();\n }\n // Internal Swap\n expandedTexture._swapAndDie(internalTexture);\n // Ready to get rolling again.\n internalTexture.isReady = true;\n });\n });\n };\n if (expandTexture) {\n if (isReady) {\n expandRGBDTexture();\n }\n else {\n texture.onLoadObservable.addOnce(expandRGBDTexture);\n }\n }\n }\n /**\n * Encode the texture to RGBD if possible.\n * @param internalTexture the texture to encode\n * @param scene the scene hosting the texture\n * @param outputTextureType type of the texture in which the encoding is performed\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\n */\n static EncodeTextureToRGBD(internalTexture, scene, outputTextureType = 0) {\n return ApplyPostProcess(\"rgbdEncode\", internalTexture, scene, outputTextureType, 1, 5);\n }\n}\n"],"mappings":";AACA,SAASA,WAAW,QAAQ,iCAAiC;AAC7D,SAASC,gBAAgB,QAAQ,mBAAmB;AACpD;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EAC1B;AACJ;AACA;AACA;EACI,OAAOC,iBAAiBA,CAACC,OAAO,EAAE;IAC9B,MAAMC,eAAe,GAAGD,OAAO,CAACE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