1 |
- {"ast":null,"code":"import { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial.js\";\nimport { GLTFLoader } from \"../glTFLoader.js\";\nconst NAME = \"KHR_materials_anisotropy\";\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_anisotropy)\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class KHR_materials_anisotropy {\n /**\n * @internal\n */\n constructor(loader) {\n /**\n * The name of this extension.\n */\n this.name = NAME;\n /**\n * Defines a number that determines the order the extensions are applied.\n */\n this.order = 195;\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n /** @internal */\n dispose() {\n this._loader = null;\n }\n /**\n * @internal\n */\n loadMaterialPropertiesAsync(context, material, babylonMaterial) {\n return GLTFLoader.LoadExtensionAsync(context, material, this.name, (extensionContext, extension) => {\n const promises = new Array();\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\n promises.push(this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial));\n return Promise.all(promises).then(() => {});\n });\n }\n _loadIridescencePropertiesAsync(context, properties, babylonMaterial) {\n var _properties$anisotrop, _properties$anisotrop2;\n if (!(babylonMaterial instanceof PBRMaterial)) {\n throw new Error(`${context}: Material type not supported`);\n }\n const promises = new Array();\n babylonMaterial.anisotropy.isEnabled = true;\n babylonMaterial.anisotropy.intensity = (_properties$anisotrop = properties.anisotropyStrength) !== null && _properties$anisotrop !== void 0 ? _properties$anisotrop : 0;\n babylonMaterial.anisotropy.angle = (_properties$anisotrop2 = properties.anisotropyRotation) !== null && _properties$anisotrop2 !== void 0 ? _properties$anisotrop2 : 0;\n if (properties.anisotropyTexture) {\n promises.push(this._loader.loadTextureInfoAsync(`${context}/anisotropyTexture`, properties.anisotropyTexture, texture => {\n texture.name = `${babylonMaterial.name} (Anisotropy Intensity)`;\n babylonMaterial.anisotropy.texture = texture;\n }));\n }\n return Promise.all(promises).then(() => {});\n }\n}\nGLTFLoader.RegisterExtension(NAME, loader => new KHR_materials_anisotropy(loader));","map":{"version":3,"names":["PBRMaterial","GLTFLoader","NAME","KHR_materials_anisotropy","constructor","loader","name","order","_loader","enabled","isExtensionUsed","dispose","loadMaterialPropertiesAsync","context","material","babylonMaterial","LoadExtensionAsync","extensionContext","extension","promises","Array","push","_loadIridescencePropertiesAsync","Promise","all","then","properties","_properties$anisotrop","_properties$anisotrop2","Error","anisotropy","isEnabled","intensity","anisotropyStrength","angle","anisotropyRotation","anisotropyTexture","loadTextureInfoAsync","texture","RegisterExtension"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_anisotropy.js"],"sourcesContent":["import { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial.js\";\nimport { GLTFLoader } from \"../glTFLoader.js\";\nconst NAME = \"KHR_materials_anisotropy\";\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_anisotropy)\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class KHR_materials_anisotropy {\n /**\n * @internal\n */\n constructor(loader) {\n /**\n * The name of this extension.\n */\n this.name = NAME;\n /**\n * Defines a number that determines the order the extensions are applied.\n */\n this.order = 195;\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n /** @internal */\n dispose() {\n this._loader = null;\n }\n /**\n * @internal\n */\n loadMaterialPropertiesAsync(context, material, babylonMaterial) {\n return GLTFLoader.LoadExtensionAsync(context, material, this.name, (extensionContext, extension) => {\n const promises = new Array();\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\n promises.push(this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial));\n return Promise.all(promises).then(() => { });\n });\n }\n _loadIridescencePropertiesAsync(context, properties, babylonMaterial) {\n if (!(babylonMaterial instanceof PBRMaterial)) {\n throw new Error(`${context}: Material type not supported`);\n }\n const promises = new Array();\n babylonMaterial.anisotropy.isEnabled = true;\n babylonMaterial.anisotropy.intensity = properties.anisotropyStrength ?? 0;\n babylonMaterial.anisotropy.angle = properties.anisotropyRotation ?? 0;\n if (properties.anisotropyTexture) {\n promises.push(this._loader.loadTextureInfoAsync(`${context}/anisotropyTexture`, properties.anisotropyTexture, (texture) => {\n texture.name = `${babylonMaterial.name} (Anisotropy Intensity)`;\n babylonMaterial.anisotropy.texture = texture;\n }));\n }\n return Promise.all(promises).then(() => { });\n }\n}\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_anisotropy(loader));\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,8CAA8C;AAC1E,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,MAAMC,IAAI,GAAG,0BAA0B;AACvC;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,CAAC;EAClC;AACJ;AACA;EACIC,WAAWA,CAACC,MAAM,EAAE;IAChB;AACR;AACA;IACQ,IAAI,CAACC,IAAI,GAAGJ,IAAI;IAChB;AACR;AACA;IACQ,IAAI,CAACK,KAAK,GAAG,GAAG;IAChB,IAAI,CAACC,OAAO,GAAGH,MAAM;IACrB,IAAI,CAACI,OAAO,GAAG,IAAI,CAACD,OAAO,CAACE,eAAe,CAACR,IAAI,CAAC;EACrD;EACA;EACAS,OAAOA,CAAA,EAAG;IACN,IAAI,CAACH,OAAO,GAAG,IAAI;EACvB;EACA;AACJ;AACA;EACII,2BAA2BA,CAACC,OAAO,EAAEC,QAAQ,EAAEC,eAAe,EAAE;IAC5D,OAAOd,UAAU,CAACe,kBAAkB,CAACH,OAAO,EAAEC,QAAQ,EAAE,IAAI,CAACR,IAAI,EAAE,CAACW,gBAAgB,EAAEC,SAAS,KAAK;MAChG,MAAMC,QAAQ,GAAG,IAAIC,KAAK,CAAC,CAAC;MAC5BD,QAAQ,CAACE,IAAI,CAAC,IAAI,CAACb,OAAO,CAACI,2BAA2B,CAACC,OAAO,EAAEC,QAAQ,EAAEC,eA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