cb6648a3b0b4b12568b850229087b49b7ed435c15e21f5f51ca043b45edc4d11.json 11 KB

1
  1. {"ast":null,"code":"import { SphericalPolynomial } from \"../../../Maths/sphericalPolynomial.js\";\nimport { DDSTools } from \"../../../Misc/dds.js\";\n/**\n * Implementation of the DDS Texture Loader.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _DDSTextureLoader {\n constructor() {\n /**\n * Defines whether the loader supports cascade loading the different faces.\n */\n this.supportCascades = true;\n }\n /**\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\n * @param imgs contains the cube maps\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(imgs, texture, createPolynomials, onLoad) {\n const engine = texture.getEngine();\n let info;\n let loadMipmap = false;\n let maxLevel = 1000;\n if (Array.isArray(imgs)) {\n for (let index = 0; index < imgs.length; index++) {\n const data = imgs[index];\n info = DDSTools.GetDDSInfo(data);\n texture.width = info.width;\n texture.height = info.height;\n loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;\n engine._unpackFlipY(info.isCompressed);\n DDSTools.UploadDDSLevels(engine, texture, data, info, loadMipmap, 6, -1, index);\n if (!info.isFourCC && info.mipmapCount === 1) {\n engine.generateMipMapsForCubemap(texture);\n } else {\n maxLevel = info.mipmapCount - 1;\n }\n }\n } else {\n const data = imgs;\n info = DDSTools.GetDDSInfo(data);\n texture.width = info.width;\n texture.height = info.height;\n if (createPolynomials) {\n info.sphericalPolynomial = new SphericalPolynomial();\n }\n loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;\n engine._unpackFlipY(info.isCompressed);\n DDSTools.UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);\n if (!info.isFourCC && info.mipmapCount === 1) {\n // Do not unbind as we still need to set the parameters.\n engine.generateMipMapsForCubemap(texture, false);\n } else {\n maxLevel = info.mipmapCount - 1;\n }\n }\n engine._setCubeMapTextureParams(texture, loadMipmap, maxLevel);\n texture.isReady = true;\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n if (onLoad) {\n onLoad({\n isDDS: true,\n width: texture.width,\n info,\n data: imgs,\n texture\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 info = DDSTools.GetDDSInfo(data);\n const loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && Math.max(info.width, info.height) >> info.mipmapCount - 1 === 1;\n callback(info.width, info.height, loadMipmap, info.isFourCC, () => {\n DDSTools.UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);\n });\n }\n}","map":{"version":3,"names":["SphericalPolynomial","DDSTools","_DDSTextureLoader","constructor","supportCascades","loadCubeData","imgs","texture","createPolynomials","onLoad","engine","getEngine","info","loadMipmap","maxLevel","Array","isArray","index","length","data","GetDDSInfo","width","height","isRGB","isLuminance","mipmapCount","generateMipMaps","_unpackFlipY","isCompressed","UploadDDSLevels","isFourCC","generateMipMapsForCubemap","sphericalPolynomial","_setCubeMapTextureParams","isReady","onLoadedObservable","notifyObservers","clear","isDDS","loadData","callback","Math","max"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader.js"],"sourcesContent":["import { SphericalPolynomial } from \"../../../Maths/sphericalPolynomial.js\";\nimport { DDSTools } from \"../../../Misc/dds.js\";\n/**\n * Implementation of the DDS Texture Loader.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class _DDSTextureLoader {\n constructor() {\n /**\n * Defines whether the loader supports cascade loading the different faces.\n */\n this.supportCascades = true;\n }\n /**\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\n * @param imgs contains the cube maps\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(imgs, texture, createPolynomials, onLoad) {\n const engine = texture.getEngine();\n let info;\n let loadMipmap = false;\n let maxLevel = 1000;\n if (Array.isArray(imgs)) {\n for (let index = 0; index < imgs.length; index++) {\n const data = imgs[index];\n info = DDSTools.GetDDSInfo(data);\n texture.width = info.width;\n texture.height = info.height;\n loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;\n engine._unpackFlipY(info.isCompressed);\n DDSTools.UploadDDSLevels(engine, texture, data, info, loadMipmap, 6, -1, index);\n if (!info.isFourCC && info.mipmapCount === 1) {\n engine.generateMipMapsForCubemap(texture);\n }\n else {\n maxLevel = info.mipmapCount - 1;\n }\n }\n }\n else {\n const data = imgs;\n info = DDSTools.GetDDSInfo(data);\n texture.width = info.width;\n texture.height = info.height;\n if (createPolynomials) {\n info.sphericalPolynomial = new SphericalPolynomial();\n }\n loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;\n engine._unpackFlipY(info.isCompressed);\n DDSTools.UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);\n if (!info.isFourCC && info.mipmapCount === 1) {\n // Do not unbind as we still need to set the parameters.\n engine.generateMipMapsForCubemap(texture, false);\n }\n else {\n maxLevel = info.mipmapCount - 1;\n }\n }\n engine._setCubeMapTextureParams(texture, loadMipmap, maxLevel);\n texture.isReady = true;\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n if (onLoad) {\n onLoad({ isDDS: true, width: texture.width, info, data: imgs, texture });\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 info = DDSTools.GetDDSInfo(data);\n const loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && Math.max(info.width, info.height) >> (info.mipmapCount - 1) === 1;\n callback(info.width, info.height, loadMipmap, info.isFourCC, () => {\n DDSTools.UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);\n });\n }\n}\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,uCAAuC;AAC3E,SAASC,QAAQ,QAAQ,sBAAsB;AAC/C;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,CAAC;EAC3BC,WAAWA,CAAA,EAAG;IACV;AACR;AACA;IACQ,IAAI,CAACC,eAAe,GAAG,IAAI;EAC/B;EACA;AACJ;AACA;AACA;AACA;AACA;AACA;EACIC,YAAYA,CAACC,IAAI,EAAEC,OAAO,EAAEC,iBAAiB,EAAEC,MAAM,EAAE;IACnD,MAAMC,MAAM,GAAGH,OAAO,CAACI,SAAS,CAAC,CAAC;IAClC,IAAIC,IAAI;IACR,IAAIC,UAAU,GAAG,KAAK;IACtB,IAAIC,QAAQ,GAAG,IAAI;IACnB,IAAIC,KAAK,CAACC,OAAO,CAACV,IAAI,CAAC,EAAE;MACrB,KAAK,IAAIW,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGX,IAAI,CAACY,MAAM,EAAED,KAAK,EAAE,EAAE;QAC9C,MAAME,IAAI,GAAGb,IAAI,CAACW,KAAK,CAAC;QACxBL,IAAI,GAAGX,QAAQ,CAACmB,UAAU,CAACD,IAAI,CAAC;QAChCZ,OAAO,CAACc,KAAK,GAAGT,IAAI,CAACS,KAAK;QAC1Bd,OAAO,CAACe,MAAM,GAAGV,IAAI,CAACU,MAAM;QAC5BT,UAAU,GAAG,CAACD,IAAI,CAACW,KAAK,IAAIX,IAAI,CAACY,WAAW,IAAIZ,IAAI,CAACa,WAAW,GAAG,CAAC,KAAKlB,OAAO,CAACmB,eAAe;QAChGhB,MAAM,CAACiB,YAAY,CAACf,IAAI,CAACgB,YAAY,CAAC;QACtC3B,QAAQ,CAAC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