1 |
- {"ast":null,"code":"import { LoadTextureFromTranscodeResult, TranscodeAsync } from \"../../../Misc/basis.js\";\nimport { Tools } from \"../../../Misc/tools.js\";\n/**\n * Loader for .basis file format\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _BasisTextureLoader {\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 * @param onError defines the callback to trigger in case of error\n */\n loadCubeData(data, texture, createPolynomials, onLoad, onError) {\n if (Array.isArray(data)) {\n return;\n }\n const caps = texture.getEngine().getCaps();\n const transcodeConfig = {\n supportedCompressionFormats: {\n etc1: caps.etc1 ? true : false,\n s3tc: caps.s3tc ? true : false,\n pvrtc: caps.pvrtc ? true : false,\n etc2: caps.etc2 ? true : false,\n astc: caps.astc ? true : false,\n bc7: caps.bptc ? true : false\n }\n };\n TranscodeAsync(data, transcodeConfig).then(result => {\n const hasMipmap = result.fileInfo.images[0].levels.length > 1 && texture.generateMipMaps;\n LoadTextureFromTranscodeResult(texture, result);\n texture.getEngine()._setCubeMapTextureParams(texture, hasMipmap);\n texture.isReady = true;\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n if (onLoad) {\n onLoad();\n }\n }).catch(err => {\n const errorMessage = \"Failed to transcode Basis file, transcoding may not be supported on this device\";\n Tools.Warn(errorMessage);\n texture.isReady = true;\n if (onError) {\n onError(err);\n }\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 */\n loadData(data, texture, callback) {\n const caps = texture.getEngine().getCaps();\n const transcodeConfig = {\n supportedCompressionFormats: {\n etc1: caps.etc1 ? true : false,\n s3tc: caps.s3tc ? true : false,\n pvrtc: caps.pvrtc ? true : false,\n etc2: caps.etc2 ? true : false,\n astc: caps.astc ? true : false,\n bc7: caps.bptc ? true : false\n }\n };\n TranscodeAsync(data, transcodeConfig).then(result => {\n const rootImage = result.fileInfo.images[0].levels[0];\n const hasMipmap = result.fileInfo.images[0].levels.length > 1 && texture.generateMipMaps;\n callback(rootImage.width, rootImage.height, hasMipmap, result.format !== -1, () => {\n LoadTextureFromTranscodeResult(texture, result);\n });\n }).catch(err => {\n Tools.Warn(\"Failed to transcode Basis file, transcoding may not be supported on this device\");\n Tools.Warn(`Failed to transcode Basis file: ${err}`);\n callback(0, 0, false, false, () => {}, true);\n });\n }\n}","map":{"version":3,"names":["LoadTextureFromTranscodeResult","TranscodeAsync","Tools","_BasisTextureLoader","constructor","supportCascades","loadCubeData","data","texture","createPolynomials","onLoad","onError","Array","isArray","caps","getEngine","getCaps","transcodeConfig","supportedCompressionFormats","etc1","s3tc","pvrtc","etc2","astc","bc7","bptc","then","result","hasMipmap","fileInfo","images","levels","length","generateMipMaps","_setCubeMapTextureParams","isReady","onLoadedObservable","notifyObservers","clear","catch","err","errorMessage","Warn","loadData","callback","rootImage","width","height","format"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Textures/Loaders/basisTextureLoader.js"],"sourcesContent":["import { LoadTextureFromTranscodeResult, TranscodeAsync } from \"../../../Misc/basis.js\";\nimport { Tools } from \"../../../Misc/tools.js\";\n/**\n * Loader for .basis file format\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _BasisTextureLoader {\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 * @param onError defines the callback to trigger in case of error\n */\n loadCubeData(data, texture, createPolynomials, onLoad, onError) {\n if (Array.isArray(data)) {\n return;\n }\n const caps = texture.getEngine().getCaps();\n const transcodeConfig = {\n supportedCompressionFormats: {\n etc1: caps.etc1 ? true : false,\n s3tc: caps.s3tc ? true : false,\n pvrtc: caps.pvrtc ? true : false,\n etc2: caps.etc2 ? true : false,\n astc: caps.astc ? true : false,\n bc7: caps.bptc ? true : false,\n },\n };\n TranscodeAsync(data, transcodeConfig)\n .then((result) => {\n const hasMipmap = result.fileInfo.images[0].levels.length > 1 && texture.generateMipMaps;\n LoadTextureFromTranscodeResult(texture, result);\n texture.getEngine()._setCubeMapTextureParams(texture, hasMipmap);\n texture.isReady = true;\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n if (onLoad) {\n onLoad();\n }\n })\n .catch((err) => {\n const errorMessage = \"Failed to transcode Basis file, transcoding may not be supported on this device\";\n Tools.Warn(errorMessage);\n texture.isReady = true;\n if (onError) {\n onError(err);\n }\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 */\n loadData(data, texture, callback) {\n const caps = texture.getEngine().getCaps();\n const transcodeConfig = {\n supportedCompressionFormats: {\n etc1: caps.etc1 ? true : false,\n s3tc: caps.s3tc ? true : false,\n pvrtc: caps.pvrtc ? true : false,\n etc2: caps.etc2 ? true : false,\n astc: caps.astc ? true : false,\n bc7: caps.bptc ? true : false,\n },\n };\n TranscodeAsync(data, transcodeConfig)\n .then((result) => {\n const rootImage = result.fileInfo.images[0].levels[0];\n const hasMipmap = result.fileInfo.images[0].levels.length > 1 && texture.generateMipMaps;\n callback(rootImage.width, rootImage.height, hasMipmap, result.format !== -1, () => {\n LoadTextureFromTranscodeResult(texture, result);\n });\n })\n .catch((err) => {\n Tools.Warn(\"Failed to transcode Basis file, transcoding may not be supported on this device\");\n Tools.Warn(`Failed to transcode Basis file: ${err}`);\n callback(0, 0,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