dc746d3dcf400d1201e3fef58fee1dfc356187d6eebf9395fec076aefa3a64c2.json 9.8 KB

1
  1. {"ast":null,"code":"import { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial.js\";\nimport { GLTFLoader } from \"../glTFLoader.js\";\nconst NAME = \"KHR_materials_iridescence\";\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_iridescence/README.md)\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class KHR_materials_iridescence {\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$iridescen, _ref, _properties$iridescen2, _properties$iridescen3, _properties$iridescen4;\n if (!(babylonMaterial instanceof PBRMaterial)) {\n throw new Error(`${context}: Material type not supported`);\n }\n const promises = new Array();\n babylonMaterial.iridescence.isEnabled = true;\n babylonMaterial.iridescence.intensity = (_properties$iridescen = properties.iridescenceFactor) !== null && _properties$iridescen !== void 0 ? _properties$iridescen : 0;\n babylonMaterial.iridescence.indexOfRefraction = (_ref = (_properties$iridescen2 = properties.iridescenceIor) !== null && _properties$iridescen2 !== void 0 ? _properties$iridescen2 : properties.iridescenceIOR) !== null && _ref !== void 0 ? _ref : 1.3;\n babylonMaterial.iridescence.minimumThickness = (_properties$iridescen3 = properties.iridescenceThicknessMinimum) !== null && _properties$iridescen3 !== void 0 ? _properties$iridescen3 : 100;\n babylonMaterial.iridescence.maximumThickness = (_properties$iridescen4 = properties.iridescenceThicknessMaximum) !== null && _properties$iridescen4 !== void 0 ? _properties$iridescen4 : 400;\n if (properties.iridescenceTexture) {\n promises.push(this._loader.loadTextureInfoAsync(`${context}/iridescenceTexture`, properties.iridescenceTexture, texture => {\n texture.name = `${babylonMaterial.name} (Iridescence Intensity)`;\n babylonMaterial.iridescence.texture = texture;\n }));\n }\n if (properties.iridescenceThicknessTexture) {\n promises.push(this._loader.loadTextureInfoAsync(`${context}/iridescenceThicknessTexture`, properties.iridescenceThicknessTexture, texture => {\n texture.name = `${babylonMaterial.name} (Iridescence Thickness)`;\n babylonMaterial.iridescence.thicknessTexture = texture;\n }));\n }\n return Promise.all(promises).then(() => {});\n }\n}\nGLTFLoader.RegisterExtension(NAME, loader => new KHR_materials_iridescence(loader));","map":{"version":3,"names":["PBRMaterial","GLTFLoader","NAME","KHR_materials_iridescence","constructor","loader","name","order","_loader","enabled","isExtensionUsed","dispose","loadMaterialPropertiesAsync","context","material","babylonMaterial","LoadExtensionAsync","extensionContext","extension","promises","Array","push","_loadIridescencePropertiesAsync","Promise","all","then","properties","_properties$iridescen","_ref","_properties$iridescen2","_properties$iridescen3","_properties$iridescen4","Error","iridescence","isEnabled","intensity","iridescenceFactor","indexOfRefraction","iridescenceIor","iridescenceIOR","minimumThickness","iridescenceThicknessMinimum","maximumThickness","iridescenceThicknessMaximum","iridescenceTexture","loadTextureInfoAsync","texture","iridescenceThicknessTexture","thicknessTexture","RegisterExtension"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_iridescence.js"],"sourcesContent":["import { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial.js\";\nimport { GLTFLoader } from \"../glTFLoader.js\";\nconst NAME = \"KHR_materials_iridescence\";\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_iridescence/README.md)\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class KHR_materials_iridescence {\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.iridescence.isEnabled = true;\n babylonMaterial.iridescence.intensity = properties.iridescenceFactor ?? 0;\n babylonMaterial.iridescence.indexOfRefraction = properties.iridescenceIor ?? properties.iridescenceIOR ?? 1.3;\n babylonMaterial.iridescence.minimumThickness = properties.iridescenceThicknessMinimum ?? 100;\n babylonMaterial.iridescence.maximumThickness = properties.iridescenceThicknessMaximum ?? 400;\n if (properties.iridescenceTexture) {\n promises.push(this._loader.loadTextureInfoAsync(`${context}/iridescenceTexture`, properties.iridescenceTexture, (texture) => {\n texture.name = `${babylonMaterial.name} (Iridescence Intensity)`;\n babylonMaterial.iridescence.texture = texture;\n }));\n }\n if (properties.iridescenceThicknessTexture) {\n promises.push(this._loader.loadTextureInfoAsync(`${context}/iridescenceThicknessTexture`, properties.iridescenceThicknessTexture, (texture) => {\n texture.name = `${babylonMaterial.name} (Iridescence Thickness)`;\n babylonMaterial.iridescence.thicknessTexture = texture;\n }));\n }\n return Promise.all(promises).then(() => { });\n }\n}\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_iridescence(loader));\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,8CAA8C;AAC1E,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,MAAMC,IAAI,GAAG,2BAA2B;AACxC;AACA;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,CAAC;EACnC;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,eAAe,CAAC,CAAC;MAC3FI,QAAQ,CAACE,IAAI,CAAC,IAAI,CAACC,+BAA+B,CAACL,gBAAgB,EAAEC,SAAS,EAAEH,eAAe,CAAC,CAAC;MACjG,OAAOQ,OAAO,CAACC,GAAG,CAACL,QAAQ,CAAC,CAACM,IAAI,CAAC,MAAM,CAAE,CAAC,CAAC;IAChD,CAAC,CAAC;EACN;EACAH,+BAA+BA,CAACT,OAAO,EAAEa,UAAU,EAAEX,eAAe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