1 |
- {"ast":null,"code":"import { RGBE_ReadHeader, RGBE_ReadPixels } from \"../../../Misc/HighDynamicRange/hdr.js\";\n\n/**\n * Implementation of the HDR Texture Loader.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _HDRTextureLoader {\n constructor() {\n /**\n * Defines whether the loader supports cascade loading the different faces.\n */\n this.supportCascades = false;\n }\n /**\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\n */\n loadCubeData() {\n // eslint-disable-next-line no-throw-literal\n throw \".env not supported in Cube.\";\n }\n /**\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\n * @param data contains the texture data\n * @param texture defines the BabylonJS internal texture\n * @param callback defines the method to call once ready to upload\n */\n loadData(data, texture, callback) {\n const uint8array = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n const hdrInfo = RGBE_ReadHeader(uint8array);\n const pixelsDataRGB32 = RGBE_ReadPixels(uint8array, hdrInfo);\n const pixels = hdrInfo.width * hdrInfo.height;\n const pixelsDataRGBA32 = new Float32Array(pixels * 4);\n for (let i = 0; i < pixels; i += 1) {\n pixelsDataRGBA32[i * 4] = pixelsDataRGB32[i * 3];\n pixelsDataRGBA32[i * 4 + 1] = pixelsDataRGB32[i * 3 + 1];\n pixelsDataRGBA32[i * 4 + 2] = pixelsDataRGB32[i * 3 + 2];\n pixelsDataRGBA32[i * 4 + 3] = 1;\n }\n callback(hdrInfo.width, hdrInfo.height, texture.generateMipMaps, false, () => {\n const engine = texture.getEngine();\n texture.type = 1;\n texture.format = 5;\n texture._gammaSpace = false;\n engine._uploadDataToTextureDirectly(texture, pixelsDataRGBA32);\n });\n }\n}","map":{"version":3,"names":["RGBE_ReadHeader","RGBE_ReadPixels","_HDRTextureLoader","constructor","supportCascades","loadCubeData","loadData","data","texture","callback","uint8array","Uint8Array","buffer","byteOffset","byteLength","hdrInfo","pixelsDataRGB32","pixels","width","height","pixelsDataRGBA32","Float32Array","i","generateMipMaps","engine","getEngine","type","format","_gammaSpace","_uploadDataToTextureDirectly"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Textures/Loaders/hdrTextureLoader.js"],"sourcesContent":["import { RGBE_ReadHeader, RGBE_ReadPixels } from \"../../../Misc/HighDynamicRange/hdr.js\";\n\n/**\n * Implementation of the HDR Texture Loader.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _HDRTextureLoader {\n constructor() {\n /**\n * Defines whether the loader supports cascade loading the different faces.\n */\n this.supportCascades = false;\n }\n /**\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\n */\n loadCubeData() {\n // eslint-disable-next-line no-throw-literal\n throw \".env not supported in Cube.\";\n }\n /**\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\n * @param data contains the texture data\n * @param texture defines the BabylonJS internal texture\n * @param callback defines the method to call once ready to upload\n */\n loadData(data, texture, callback) {\n const uint8array = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n const hdrInfo = RGBE_ReadHeader(uint8array);\n const pixelsDataRGB32 = RGBE_ReadPixels(uint8array, hdrInfo);\n const pixels = hdrInfo.width * hdrInfo.height;\n const pixelsDataRGBA32 = new Float32Array(pixels * 4);\n for (let i = 0; i < pixels; i += 1) {\n pixelsDataRGBA32[i * 4] = pixelsDataRGB32[i * 3];\n pixelsDataRGBA32[i * 4 + 1] = pixelsDataRGB32[i * 3 + 1];\n pixelsDataRGBA32[i * 4 + 2] = pixelsDataRGB32[i * 3 + 2];\n pixelsDataRGBA32[i * 4 + 3] = 1;\n }\n callback(hdrInfo.width, hdrInfo.height, texture.generateMipMaps, false, () => {\n const engine = texture.getEngine();\n texture.type = 1;\n texture.format = 5;\n texture._gammaSpace = false;\n engine._uploadDataToTextureDirectly(texture, pixelsDataRGBA32);\n });\n }\n}\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,eAAe,QAAQ,uCAAuC;;AAExF;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,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