510bef61404888f8825e8b9dcdba1115d91de509f1a3b6ca8ec1fe9498eb986f.json 12 KB

1
  1. {"ast":null,"code":"import { KhronosTextureContainer } from \"../../../Misc/khronosTextureContainer.js\";\nimport { KhronosTextureContainer2 } from \"../../../Misc/khronosTextureContainer2.js\";\nimport { Logger } from \"../../../Misc/logger.js\";\nfunction mapSRGBToLinear(format) {\n switch (format) {\n case 35916:\n return 33776;\n case 35918:\n return 33778;\n case 35919:\n return 33779;\n case 37493:\n return 37492;\n case 37497:\n return 37496;\n case 37495:\n return 37494;\n case 37840:\n return 37808;\n case 36493:\n return 36492;\n }\n return null;\n}\n/**\n * Implementation of the KTX Texture Loader.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _KTXTextureLoader {\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 * @param data contains the texture data\n * @param texture defines the BabylonJS internal texture\n * @param createPolynomials will be true if polynomials have been requested\n * @param onLoad defines the callback to trigger once the texture is ready\n */\n loadCubeData(data, texture, createPolynomials, onLoad) {\n if (Array.isArray(data)) {\n return;\n }\n // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture\n texture._invertVScale = !texture.invertY;\n const engine = texture.getEngine();\n const ktx = new KhronosTextureContainer(data, 6);\n const loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;\n engine._unpackFlipY(true);\n ktx.uploadLevels(texture, texture.generateMipMaps);\n texture.width = ktx.pixelWidth;\n texture.height = ktx.pixelHeight;\n engine._setCubeMapTextureParams(texture, loadMipmap, ktx.numberOfMipmapLevels - 1);\n texture.isReady = true;\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n if (onLoad) {\n onLoad();\n }\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 * @param options\n */\n loadData(data, texture, callback, options) {\n if (KhronosTextureContainer.IsValid(data)) {\n // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture\n texture._invertVScale = !texture.invertY;\n const ktx = new KhronosTextureContainer(data, 1);\n const mappedFormat = mapSRGBToLinear(ktx.glInternalFormat);\n if (mappedFormat) {\n texture.format = mappedFormat;\n texture._useSRGBBuffer = texture.getEngine()._getUseSRGBBuffer(true, texture.generateMipMaps);\n texture._gammaSpace = true;\n } else {\n texture.format = ktx.glInternalFormat;\n }\n callback(ktx.pixelWidth, ktx.pixelHeight, texture.generateMipMaps, true, () => {\n ktx.uploadLevels(texture, texture.generateMipMaps);\n }, ktx.isInvalid);\n } else if (KhronosTextureContainer2.IsValid(data)) {\n const ktx2 = new KhronosTextureContainer2(texture.getEngine());\n ktx2._uploadAsync(data, texture, options).then(() => {\n callback(texture.width, texture.height, texture.generateMipMaps, true, () => {}, false);\n }, error => {\n Logger.Warn(`Failed to load KTX2 texture data: ${error.message}`);\n callback(0, 0, false, false, () => {}, true);\n });\n } else {\n Logger.Error(\"texture missing KTX identifier\");\n callback(0, 0, false, false, () => {}, true);\n }\n }\n}","map":{"version":3,"names":["KhronosTextureContainer","KhronosTextureContainer2","Logger","mapSRGBToLinear","format","_KTXTextureLoader","constructor","supportCascades","loadCubeData","data","texture","createPolynomials","onLoad","Array","isArray","_invertVScale","invertY","engine","getEngine","ktx","loadMipmap","numberOfMipmapLevels","generateMipMaps","_unpackFlipY","uploadLevels","width","pixelWidth","height","pixelHeight","_setCubeMapTextureParams","isReady","onLoadedObservable","notifyObservers","clear","loadData","callback","options","IsValid","mappedFormat","glInternalFormat","_useSRGBBuffer","_getUseSRGBBuffer","_gammaSpace","isInvalid","ktx2","_uploadAsync","then","error","Warn","message","Error"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader.js"],"sourcesContent":["import { KhronosTextureContainer } from \"../../../Misc/khronosTextureContainer.js\";\nimport { KhronosTextureContainer2 } from \"../../../Misc/khronosTextureContainer2.js\";\nimport { Logger } from \"../../../Misc/logger.js\";\n\nfunction mapSRGBToLinear(format) {\n switch (format) {\n case 35916:\n return 33776;\n case 35918:\n return 33778;\n case 35919:\n return 33779;\n case 37493:\n return 37492;\n case 37497:\n return 37496;\n case 37495:\n return 37494;\n case 37840:\n return 37808;\n case 36493:\n return 36492;\n }\n return null;\n}\n/**\n * Implementation of the KTX Texture Loader.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _KTXTextureLoader {\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 * @param data contains the texture data\n * @param texture defines the BabylonJS internal texture\n * @param createPolynomials will be true if polynomials have been requested\n * @param onLoad defines the callback to trigger once the texture is ready\n */\n loadCubeData(data, texture, createPolynomials, onLoad) {\n if (Array.isArray(data)) {\n return;\n }\n // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture\n texture._invertVScale = !texture.invertY;\n const engine = texture.getEngine();\n const ktx = new KhronosTextureContainer(data, 6);\n const loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;\n engine._unpackFlipY(true);\n ktx.uploadLevels(texture, texture.generateMipMaps);\n texture.width = ktx.pixelWidth;\n texture.height = ktx.pixelHeight;\n engine._setCubeMapTextureParams(texture, loadMipmap, ktx.numberOfMipmapLevels - 1);\n texture.isReady = true;\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n if (onLoad) {\n onLoad();\n }\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 * @param options\n */\n loadData(data, texture, callback, options) {\n if (KhronosTextureContainer.IsValid(data)) {\n // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture\n texture._invertVScale = !texture.invertY;\n const ktx = new KhronosTextureContainer(data, 1);\n const mappedFormat = mapSRGBToLinear(ktx.glInternalFormat);\n if (mappedFormat) {\n texture.format = mappedFormat;\n texture._useSRGBBuffer = texture.getEngine()._getUseSRGBBuffer(true, texture.generateMipMaps);\n texture._gammaSpace = true;\n }\n else {\n texture.format = ktx.glInternalFormat;\n }\n callback(ktx.pixelWidth, ktx.pixelHeight, texture.generateMipMaps, true, () => {\n ktx.uploadLevels(texture, texture.generateMipMaps);\n }, ktx.isInvalid);\n }\n else if (KhronosTextureContainer2.IsValid(data)) {\n const ktx2 = new KhronosTextureContainer2(texture.getEngine());\n ktx2._uploadAsync(data, texture, options).then(() => {\n callback(texture.width, texture.height, texture.generateMipMaps, true, () => { }, false);\n }, (error) => {\n Logger.Warn(`Failed to load KTX2 texture data: ${error.message}`);\n callback(0, 0, false, false, () => { }, true);\n });\n }\n else {\n Logger.Error(\"texture missing KTX identifier\");\n callback(0, 0, false, false, () => { }, true);\n }\n }\n}\n"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ,0CAA0C;AAClF,SAASC,wBAAwB,QAAQ,2CAA2C;AACpF,SAASC,MAAM,QAAQ,yBAAyB;AAEhD,SAASC,eAAeA,CAACC,MAAM,EAAE;EAC7B,QAAQA,MAAM;IACV,KAAK,KAAK;MACN,OAAO,KAAK;IAChB,KAAK,KAAK;MACN,OAAO,KAAK;IAChB,KAAK,KAAK;MACN,OAAO,KAAK;IAChB,KAAK,KAAK;MACN,OAAO,KAAK;IAChB,KAAK,KAAK;MACN,OAAO,KAAK;IAChB,KAAK,KAAK;MACN,OAAO,KAAK;IAChB,KAAK,KAAK;MACN,OAAO,KAAK;IAChB,KAAK,KAAK;MACN,OAAO,KAAK;EACpB;EACA,OAAO,IAAI;AACf;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,CAAC;EA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