@babylonjs/loaders 7.24.0 → 7.25.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. package/OBJ/mtlFileLoader.js +1 -1
  2. package/OBJ/mtlFileLoader.js.map +1 -1
  3. package/glTF/2.0/Extensions/EXT_lights_image_based.js +1 -2
  4. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
  5. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +1 -1
  6. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  7. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +2 -1
  8. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
  9. package/glTF/2.0/Extensions/KHR_materials_dispersion.js +0 -1
  10. package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
  11. package/glTF/2.0/Extensions/KHR_materials_iridescence.js +1 -1
  12. package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
  13. package/glTF/2.0/Extensions/KHR_materials_specular.js +2 -2
  14. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  15. package/glTF/2.0/Extensions/KHR_materials_transmission.js +1 -1
  16. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  17. package/glTF/2.0/Extensions/KHR_materials_volume.js +1 -2
  18. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  19. package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +1 -0
  20. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +1 -0
  21. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
  22. package/glTF/2.0/glTFLoader.js +1 -1
  23. package/glTF/2.0/glTFLoader.js.map +1 -1
  24. package/glTF/2.0/index.d.ts +1 -0
  25. package/glTF/2.0/index.js +1 -0
  26. package/glTF/2.0/index.js.map +1 -1
  27. package/glTF/glTFFileLoader.js +1 -1
  28. package/glTF/glTFFileLoader.js.map +1 -1
  29. package/package.json +4 -4
@@ -211,7 +211,7 @@ export class MTLFileLoader {
211
211
  lastDelimiter = value.lastIndexOf("/");
212
212
  }
213
213
  if (lastDelimiter > -1) {
214
- url += value.substr(lastDelimiter + 1);
214
+ url += value.substring(lastDelimiter + 1);
215
215
  }
216
216
  else {
217
217
  url += value;
@@ -1 +1 @@
1
- {"version":3,"file":"mtlFileLoader.js","sourceRoot":"","sources":["../../../../dev/loaders/src/OBJ/mtlFileLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,OAAO,EAAE,sDAAwC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,sDAAwC;AAInE;;GAEG;AACH,MAAM,OAAO,aAAa;IAA1B;QAMI;;WAEG;QACI,cAAS,GAAuB,EAAE,CAAC;IA+M9C,CAAC;IA7MG;;;;;;;;;;OAUG;IACI,QAAQ,CAAC,KAAY,EAAE,IAA0B,EAAE,OAAe,EAAE,cAAwC;QAC/G,IAAI,IAAI,YAAY,WAAW,EAAE;YAC7B,OAAO;SACV;QAED,+BAA+B;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,kCAAkC;QAClC,MAAM,iBAAiB,GAAG,KAAK,CAAC;QAChC,uBAAuB;QACvB,IAAI,KAAe,CAAC;QACpB,cAAc;QACd,IAAI,QAAQ,GAA+B,IAAI,CAAC;QAEhD,mBAAmB;QACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAE7B,wBAAwB;YACxB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;gBAC7C,SAAS;aACZ;YAED,mCAAmC;YACnC,MAAM,GAA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;SACf;QAED,IAAI,GAAG,GAAG,OAAO,CAAC;QAClB,wBAAwB;QACxB,IAAI,OAAO,KAAK,OAAO,EAAE;YACrB,IAAI,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,aAAa,KAAK,CAAC,CAAC,EAAE;gBACtB,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;aAC1C;YAED,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE;gBACpB,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;aAC1C;iBAAM;gBACH,GAAG,IAAI,KAAK,CAAC;aAChB;SACJ;QACD,uBAAuB;aAClB;YACD,GAAG,IAAI,KAAK,CAAC;SAChB;QAED,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1E,CAAC;;AAtND;;GAEG;AACW,8BAAgB,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\nimport { StandardMaterial } from \"core/Materials/standardMaterial\";\r\n\r\nimport type { Scene } from \"core/scene\";\r\nimport type { AssetContainer } from \"core/assetContainer\";\r\n/**\r\n * Class reading and parsing the MTL file bundled with the obj file.\r\n */\r\nexport class MTLFileLoader {\r\n /**\r\n * Invert Y-Axis of referenced textures on load\r\n */\r\n public static INVERT_TEXTURE_Y = true;\r\n\r\n /**\r\n * All material loaded from the mtl will be set here\r\n */\r\n public materials: StandardMaterial[] = [];\r\n\r\n /**\r\n * This function will read the mtl file and create each material described inside\r\n * This function could be improve by adding :\r\n * -some component missing (Ni, Tf...)\r\n * -including the specific options available\r\n *\r\n * @param scene defines the scene the material will be created in\r\n * @param data defines the mtl data to parse\r\n * @param rootUrl defines the rooturl to use in order to load relative dependencies\r\n * @param assetContainer defines the asset container to store the material in (can be null)\r\n */\r\n public parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, assetContainer: Nullable<AssetContainer>): void {\r\n if (data instanceof ArrayBuffer) {\r\n return;\r\n }\r\n\r\n //Split the lines from the file\r\n const lines = data.split(\"\\n\");\r\n // whitespace char ie: [ \\t\\r\\n\\f]\r\n const delimiter_pattern = /\\s+/;\r\n //Array with RGB colors\r\n let color: number[];\r\n //New material\r\n let material: Nullable<StandardMaterial> = null;\r\n\r\n //Look at each line\r\n for (let i = 0; i < lines.length; i++) {\r\n const line = lines[i].trim();\r\n\r\n // Blank line or comment\r\n if (line.length === 0 || line.charAt(0) === \"#\") {\r\n continue;\r\n }\r\n\r\n //Get the first parameter (keyword)\r\n const pos = line.indexOf(\" \");\r\n let key = pos >= 0 ? line.substring(0, pos) : line;\r\n key = key.toLowerCase();\r\n\r\n //Get the data following the key\r\n const value: string = pos >= 0 ? line.substring(pos + 1).trim() : \"\";\r\n\r\n //This mtl keyword will create the new material\r\n if (key === \"newmtl\") {\r\n //Check if it is the first material.\r\n // Materials specifications are described after this keyword.\r\n if (material) {\r\n //Add the previous material in the material array.\r\n this.materials.push(material);\r\n }\r\n //Create a new material.\r\n // value is the name of the material read in the mtl file\r\n\r\n scene._blockEntityCollection = !!assetContainer;\r\n material = new StandardMaterial(value, scene);\r\n material._parentContainer = assetContainer;\r\n scene._blockEntityCollection = false;\r\n } else if (key === \"kd\" && material) {\r\n // Diffuse color (color under white light) using RGB values\r\n\r\n //value = \"r g b\"\r\n color = <number[]>value.split(delimiter_pattern, 3).map(parseFloat);\r\n //color = [r,g,b]\r\n //Set tghe color into the material\r\n material.diffuseColor = Color3.FromArray(color);\r\n } else if (key === \"ka\" && material) {\r\n // Ambient color (color under shadow) using RGB values\r\n\r\n //value = \"r g b\"\r\n color = <number[]>value.split(delimiter_pattern, 3).map(parseFloat);\r\n //color = [r,g,b]\r\n //Set tghe color into the material\r\n material.ambientColor = Color3.FromArray(color);\r\n } else if (key === \"ks\" && material) {\r\n // Specular color (color when light is reflected from shiny surface) using RGB values\r\n\r\n //value = \"r g b\"\r\n color = <number[]>value.split(delimiter_pattern, 3).map(parseFloat);\r\n //color = [r,g,b]\r\n //Set the color into the material\r\n material.specularColor = Color3.FromArray(color);\r\n } else if (key === \"ke\" && material) {\r\n // Emissive color using RGB values\r\n color = value.split(delimiter_pattern, 3).map(parseFloat);\r\n material.emissiveColor = Color3.FromArray(color);\r\n } else if (key === \"ns\" && material) {\r\n //value = \"Integer\"\r\n material.specularPower = parseFloat(value);\r\n } else if (key === \"d\" && material) {\r\n //d is dissolve for current material. It mean alpha for BABYLON\r\n material.alpha = parseFloat(value);\r\n\r\n //Texture\r\n //This part can be improved by adding the possible options of texture\r\n } else if (key === \"map_ka\" && material) {\r\n // ambient texture map with a loaded image\r\n //We must first get the folder of the image\r\n material.ambientTexture = MTLFileLoader._GetTexture(rootUrl, value, scene);\r\n } else if (key === \"map_kd\" && material) {\r\n // Diffuse texture map with a loaded image\r\n material.diffuseTexture = MTLFileLoader._GetTexture(rootUrl, value, scene);\r\n } else if (key === \"map_ks\" && material) {\r\n // Specular texture map with a loaded image\r\n //We must first get the folder of the image\r\n material.specularTexture = MTLFileLoader._GetTexture(rootUrl, value, scene);\r\n } else if (key === \"map_ns\") {\r\n //Specular\r\n //Specular highlight component\r\n //We must first get the folder of the image\r\n //\r\n //Not supported by BABYLON\r\n //\r\n // continue;\r\n } else if (key === \"map_bump\" && material) {\r\n //The bump texture\r\n const values = value.split(delimiter_pattern);\r\n const bumpMultiplierIndex = values.indexOf(\"-bm\");\r\n let bumpMultiplier: Nullable<string> = null;\r\n\r\n if (bumpMultiplierIndex >= 0) {\r\n bumpMultiplier = values[bumpMultiplierIndex + 1];\r\n values.splice(bumpMultiplierIndex, 2); // remove\r\n }\r\n\r\n material.bumpTexture = MTLFileLoader._GetTexture(rootUrl, values.join(\" \"), scene);\r\n if (material.bumpTexture && bumpMultiplier !== null) {\r\n material.bumpTexture.level = parseFloat(bumpMultiplier);\r\n }\r\n } else if (key === \"map_d\" && material) {\r\n // The dissolve of the material\r\n material.opacityTexture = MTLFileLoader._GetTexture(rootUrl, value, scene);\r\n\r\n //Options for illumination\r\n } else if (key === \"illum\") {\r\n //Illumination\r\n if (value === \"0\") {\r\n //That mean Kd == Kd\r\n } else if (value === \"1\") {\r\n //Color on and Ambient on\r\n } else if (value === \"2\") {\r\n //Highlight on\r\n } else if (value === \"3\") {\r\n //Reflection on and Ray trace on\r\n } else if (value === \"4\") {\r\n //Transparency: Glass on, Reflection: Ray trace on\r\n } else if (value === \"5\") {\r\n //Reflection: Fresnel on and Ray trace on\r\n } else if (value === \"6\") {\r\n //Transparency: Refraction on, Reflection: Fresnel off and Ray trace on\r\n } else if (value === \"7\") {\r\n //Transparency: Refraction on, Reflection: Fresnel on and Ray trace on\r\n } else if (value === \"8\") {\r\n //Reflection on and Ray trace off\r\n } else if (value === \"9\") {\r\n //Transparency: Glass on, Reflection: Ray trace off\r\n } else if (value === \"10\") {\r\n //Casts shadows onto invisible surfaces\r\n }\r\n } else {\r\n // console.log(\"Unhandled expression at line : \" + i +'\\n' + \"with value : \" + line);\r\n }\r\n }\r\n //At the end of the file, add the last material\r\n if (material) {\r\n this.materials.push(material);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the texture for the material.\r\n *\r\n * If the material is imported from input file,\r\n * We sanitize the url to ensure it takes the texture from aside the material.\r\n *\r\n * @param rootUrl The root url to load from\r\n * @param value The value stored in the mtl\r\n * @param scene\r\n * @returns The Texture\r\n */\r\n private static _GetTexture(rootUrl: string, value: string, scene: Scene): Nullable<Texture> {\r\n if (!value) {\r\n return null;\r\n }\r\n\r\n let url = rootUrl;\r\n // Load from input file.\r\n if (rootUrl === \"file:\") {\r\n let lastDelimiter = value.lastIndexOf(\"\\\\\");\r\n if (lastDelimiter === -1) {\r\n lastDelimiter = value.lastIndexOf(\"/\");\r\n }\r\n\r\n if (lastDelimiter > -1) {\r\n url += value.substr(lastDelimiter + 1);\r\n } else {\r\n url += value;\r\n }\r\n }\r\n // Not from input file.\r\n else {\r\n url += value;\r\n }\r\n\r\n return new Texture(url, scene, false, MTLFileLoader.INVERT_TEXTURE_Y);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"mtlFileLoader.js","sourceRoot":"","sources":["../../../../dev/loaders/src/OBJ/mtlFileLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,OAAO,EAAE,sDAAwC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,sDAAwC;AAInE;;GAEG;AACH,MAAM,OAAO,aAAa;IAA1B;QAMI;;WAEG;QACI,cAAS,GAAuB,EAAE,CAAC;IA+M9C,CAAC;IA7MG;;;;;;;;;;OAUG;IACI,QAAQ,CAAC,KAAY,EAAE,IAA0B,EAAE,OAAe,EAAE,cAAwC;QAC/G,IAAI,IAAI,YAAY,WAAW,EAAE;YAC7B,OAAO;SACV;QAED,+BAA+B;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,kCAAkC;QAClC,MAAM,iBAAiB,GAAG,KAAK,CAAC;QAChC,uBAAuB;QACvB,IAAI,KAAe,CAAC;QACpB,cAAc;QACd,IAAI,QAAQ,GAA+B,IAAI,CAAC;QAEhD,mBAAmB;QACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAE7B,wBAAwB;YACxB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;gBAC7C,SAAS;aACZ;YAED,mCAAmC;YACnC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,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O,CAAC;QAClB,wBAAwB;QACxB,IAAI,OAAO,KAAK,OAAO,EAAE;YACrB,IAAI,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,aAAa,KAAK,CAAC,CAAC,EAAE;gBACtB,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;aAC1C;YAED,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE;gBACpB,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;aAC7C;iBAAM;gBACH,GAAG,IAAI,KAAK,CAAC;aAChB;SACJ;QACD,uBAAuB;aAClB;YACD,GAAG,IAAI,KAAK,CAAC;SAChB;QAED,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1E,CAAC;;AAtND;;GAEG;AACW,8BAAgB,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\nimport { StandardMaterial } from \"core/Materials/standardMaterial\";\r\n\r\nimport type { Scene } from \"core/scene\";\r\nimport type { AssetContainer } from \"core/assetContainer\";\r\n/**\r\n * Class reading and parsing the MTL file bundled with the obj file.\r\n */\r\nexport class MTLFileLoader {\r\n /**\r\n * Invert Y-Axis of referenced textures on load\r\n */\r\n public static INVERT_TEXTURE_Y = true;\r\n\r\n /**\r\n * All material loaded from the mtl will be set here\r\n */\r\n public materials: StandardMaterial[] = [];\r\n\r\n /**\r\n * This function will read the mtl file and create each material described inside\r\n * This function could be improve by adding :\r\n * -some component missing (Ni, Tf...)\r\n * -including the specific options available\r\n *\r\n * @param scene defines the scene the material will be created in\r\n * @param data defines the mtl data to parse\r\n * @param rootUrl defines the rooturl to use in order to load relative dependencies\r\n * @param assetContainer defines the asset container to store the material in (can be null)\r\n */\r\n public parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, assetContainer: Nullable<AssetContainer>): void {\r\n if (data instanceof ArrayBuffer) {\r\n return;\r\n }\r\n\r\n //Split the lines from the file\r\n const lines = data.split(\"\\n\");\r\n // whitespace char ie: [ \\t\\r\\n\\f]\r\n const delimiter_pattern = /\\s+/;\r\n //Array with RGB colors\r\n let color: number[];\r\n //New material\r\n let material: Nullable<StandardMaterial> = null;\r\n\r\n //Look at each line\r\n for (let i = 0; i < lines.length; i++) {\r\n const line = lines[i].trim();\r\n\r\n // Blank line or comment\r\n if (line.length === 0 || line.charAt(0) === \"#\") {\r\n continue;\r\n }\r\n\r\n //Get the first parameter (keyword)\r\n const pos = line.indexOf(\" \");\r\n let key = pos >= 0 ? line.substring(0, pos) : line;\r\n key = key.toLowerCase();\r\n\r\n //Get the data following the key\r\n const value: string = pos >= 0 ? line.substring(pos + 1).trim() : \"\";\r\n\r\n //This mtl keyword will create the new material\r\n if (key === \"newmtl\") {\r\n //Check if it is the first material.\r\n // Materials specifications are described after this keyword.\r\n if (material) {\r\n //Add the previous material in the material array.\r\n this.materials.push(material);\r\n }\r\n //Create a new material.\r\n // value is the name of the material read in the mtl file\r\n\r\n scene._blockEntityCollection = !!assetContainer;\r\n material = new StandardMaterial(value, scene);\r\n material._parentContainer = assetContainer;\r\n scene._blockEntityCollection = false;\r\n } else if (key === \"kd\" && material) {\r\n // Diffuse color (color under white light) using RGB values\r\n\r\n //value = \"r g b\"\r\n color = <number[]>value.split(delimiter_pattern, 3).map(parseFloat);\r\n //color = [r,g,b]\r\n //Set tghe color into the material\r\n material.diffuseColor = Color3.FromArray(color);\r\n } else if (key === \"ka\" && material) {\r\n // Ambient color (color under shadow) using RGB values\r\n\r\n //value = \"r g b\"\r\n color = <number[]>value.split(delimiter_pattern, 3).map(parseFloat);\r\n //color = [r,g,b]\r\n //Set tghe color into the material\r\n material.ambientColor = Color3.FromArray(color);\r\n } else if (key === \"ks\" && material) {\r\n // Specular color (color when light is reflected from shiny surface) using RGB values\r\n\r\n //value = \"r g b\"\r\n color = <number[]>value.split(delimiter_pattern, 3).map(parseFloat);\r\n //color = [r,g,b]\r\n //Set the color into the material\r\n material.specularColor = Color3.FromArray(color);\r\n } else if (key === \"ke\" && material) {\r\n // Emissive color using RGB values\r\n color = value.split(delimiter_pattern, 3).map(parseFloat);\r\n material.emissiveColor = Color3.FromArray(color);\r\n } else if (key === \"ns\" && material) {\r\n //value = \"Integer\"\r\n material.specularPower = parseFloat(value);\r\n } else if (key === \"d\" && material) {\r\n //d is dissolve for current material. It mean alpha for BABYLON\r\n material.alpha = parseFloat(value);\r\n\r\n //Texture\r\n //This part can be improved by adding the possible options of texture\r\n } else if (key === \"map_ka\" && material) {\r\n // ambient texture map with a loaded image\r\n //We must first get the folder of the image\r\n material.ambientTexture = MTLFileLoader._GetTexture(rootUrl, value, scene);\r\n } else if (key === \"map_kd\" && material) {\r\n // Diffuse texture map with a loaded image\r\n material.diffuseTexture = MTLFileLoader._GetTexture(rootUrl, value, scene);\r\n } else if (key === \"map_ks\" && material) {\r\n // Specular texture map with a loaded image\r\n //We must first get the folder of the image\r\n material.specularTexture = MTLFileLoader._GetTexture(rootUrl, value, scene);\r\n } else if (key === \"map_ns\") {\r\n //Specular\r\n //Specular highlight component\r\n //We must first get the folder of the image\r\n //\r\n //Not supported by BABYLON\r\n //\r\n // continue;\r\n } else if (key === \"map_bump\" && material) {\r\n //The bump texture\r\n const values = value.split(delimiter_pattern);\r\n const bumpMultiplierIndex = values.indexOf(\"-bm\");\r\n let bumpMultiplier: Nullable<string> = null;\r\n\r\n if (bumpMultiplierIndex >= 0) {\r\n bumpMultiplier = values[bumpMultiplierIndex + 1];\r\n values.splice(bumpMultiplierIndex, 2); // remove\r\n }\r\n\r\n material.bumpTexture = MTLFileLoader._GetTexture(rootUrl, values.join(\" \"), scene);\r\n if (material.bumpTexture && bumpMultiplier !== null) {\r\n material.bumpTexture.level = parseFloat(bumpMultiplier);\r\n }\r\n } else if (key === \"map_d\" && material) {\r\n // The dissolve of the material\r\n material.opacityTexture = MTLFileLoader._GetTexture(rootUrl, value, scene);\r\n\r\n //Options for illumination\r\n } else if (key === \"illum\") {\r\n //Illumination\r\n if (value === \"0\") {\r\n //That mean Kd == Kd\r\n } else if (value === \"1\") {\r\n //Color on and Ambient on\r\n } else if (value === \"2\") {\r\n //Highlight on\r\n } else if (value === \"3\") {\r\n //Reflection on and Ray trace on\r\n } else if (value === \"4\") {\r\n //Transparency: Glass on, Reflection: Ray trace on\r\n } else if (value === \"5\") {\r\n //Reflection: Fresnel on and Ray trace on\r\n } else if (value === \"6\") {\r\n //Transparency: Refraction on, Reflection: Fresnel off and Ray trace on\r\n } else if (value === \"7\") {\r\n //Transparency: Refraction on, Reflection: Fresnel on and Ray trace on\r\n } else if (value === \"8\") {\r\n //Reflection on and Ray trace off\r\n } else if (value === \"9\") {\r\n //Transparency: Glass on, Reflection: Ray trace off\r\n } else if (value === \"10\") {\r\n //Casts shadows onto invisible surfaces\r\n }\r\n } else {\r\n // console.log(\"Unhandled expression at line : \" + i +'\\n' + \"with value : \" + line);\r\n }\r\n }\r\n //At the end of the file, add the last material\r\n if (material) {\r\n this.materials.push(material);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the texture for the material.\r\n *\r\n * If the material is imported from input file,\r\n * We sanitize the url to ensure it takes the texture from aside the material.\r\n *\r\n * @param rootUrl The root url to load from\r\n * @param value The value stored in the mtl\r\n * @param scene\r\n * @returns The Texture\r\n */\r\n private static _GetTexture(rootUrl: string, value: string, scene: Scene): Nullable<Texture> {\r\n if (!value) {\r\n return null;\r\n }\r\n\r\n let url = rootUrl;\r\n // Load from input file.\r\n if (rootUrl === \"file:\") {\r\n let lastDelimiter = value.lastIndexOf(\"\\\\\");\r\n if (lastDelimiter === -1) {\r\n lastDelimiter = value.lastIndexOf(\"/\");\r\n }\r\n\r\n if (lastDelimiter > -1) {\r\n url += value.substring(lastDelimiter + 1);\r\n } else {\r\n url += value;\r\n }\r\n }\r\n // Not from input file.\r\n else {\r\n url += value;\r\n }\r\n\r\n return new Texture(url, scene, false, MTLFileLoader.INVERT_TEXTURE_Y);\r\n }\r\n}\r\n"]}
@@ -1,4 +1,3 @@
1
- import { Scalar } from "@babylonjs/core/Maths/math.scalar.js";
2
1
  import { SphericalHarmonics, SphericalPolynomial } from "@babylonjs/core/Maths/sphericalPolynomial.js";
3
2
  import { Quaternion, Matrix } from "@babylonjs/core/Maths/math.vector.js";
4
3
  import { RawCubeTexture } from "@babylonjs/core/Materials/Textures/rawCubeTexture.js";
@@ -94,7 +93,7 @@ export class EXT_lights_image_based {
94
93
  sphericalHarmonics.convertIrradianceToLambertianRadiance();
95
94
  const sphericalPolynomial = SphericalPolynomial.FromHarmonics(sphericalHarmonics);
96
95
  // Compute the lod generation scale to fit exactly to the number of levels available.
97
- const lodGenerationScale = (imageData.length - 1) / Scalar.Log2(light.specularImageSize);
96
+ const lodGenerationScale = (imageData.length - 1) / Math.log2(light.specularImageSize);
98
97
  return babylonTexture.updateRGBDAsync(imageData, sphericalPolynomial, lodGenerationScale);
99
98
  });
100
99
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_lights_image_based.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,6CAA+B;AAChD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,qDAAuC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,6CAA+B;AAE5D,OAAO,EAAE,cAAc,EAAE,6DAA+C;AAKxE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,wBAAwB,CAAC;AAsBtC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO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AE;wBACjD,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;qBAC3C;oBAED,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,cAAc,CAAC,0BAA0B,EAAE,CAAC,CAAC;iBACrF;gBAED,IAAI,CAAC,KAAK,CAAC,sBAAsB,EAAE;oBAC/B,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,uCAAuC,CAAC,CAAC;iBACtE;gBAED,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,SAAS,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBACtF,kBAAkB,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;gBAEjD,kBAAkB,CAAC,qCAAqC,EAAE,CAAC;gBAC3D,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBAElF,qFAAqF;gBACrF,MAAM,kBAAkB,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;gBACzF,OAAO,cAAc,CAAC,eAAe,CAAC,SAAS,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,CAAC;YAC9F,CAAC,CAAC,CAAC;SACN;QAED,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;YAC3B,OAAO,KAAK,CAAC,eAAgB,CAAC;QAClC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Scalar } from \"core/Maths/math.scalar\";\r\nimport { SphericalHarmonics, SphericalPolynomial } from \"core/Maths/sphericalPolynomial\";\r\nimport { Quaternion, Matrix } from \"core/Maths/math.vector\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { RawCubeTexture } from \"core/Materials/Textures/rawCubeTexture\";\r\n\r\nimport type { IEXTLightsImageBased_LightReferenceImageBased, IEXTLightsImageBased_LightImageBased, IEXTLightsImageBased } from \"babylonjs-gltf2interface\";\r\nimport type { IScene } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"EXT_lights_image_based\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the EXT_lights_image_based extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"EXT_lights_image_based\"]: {};\r\n }\r\n}\r\n\r\ndeclare module \"babylonjs-gltf2interface\" {\r\n /** @internal */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n interface IEXTLightsImageBased_LightImageBased {\r\n _babylonTexture?: BaseTexture;\r\n _loaded?: Promise<void>;\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_lights_image_based/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class EXT_lights_image_based implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n private _lights?: IEXTLightsImageBased_LightImageBased[];\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n delete this._lights;\r\n }\r\n\r\n /** @internal */\r\n public onLoading(): void {\r\n const extensions = this._loader.gltf.extensions;\r\n if (extensions && extensions[this.name]) {\r\n const extension = extensions[this.name] as IEXTLightsImageBased;\r\n this._lights = extension.lights;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IEXTLightsImageBased_LightReferenceImageBased>(context, scene, this.name, (extensionContext, extension) => {\r\n this._loader._allMaterialsDirtyRequired = true;\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n promises.push(this._loader.loadSceneAsync(context, scene));\r\n\r\n this._loader.logOpen(`${extensionContext}`);\r\n\r\n const light = ArrayItem.Get(`${extensionContext}/light`, this._lights, extension.light);\r\n promises.push(\r\n this._loadLightAsync(`/extensions/${this.name}/lights/${extension.light}`, light).then((texture) => {\r\n this._loader.babylonScene.environmentTexture = texture;\r\n })\r\n );\r\n\r\n this._loader.logClose();\r\n\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadLightAsync(context: string, light: IEXTLightsImageBased_LightImageBased): Promise<BaseTexture> {\r\n if (!light._loaded) {\r\n const promises = new Array<Promise<any>>();\r\n\r\n this._loader.logOpen(`${context}`);\r\n\r\n const imageData = new Array<Array<ArrayBufferView>>(light.specularImages.length);\r\n for (let mipmap = 0; mipmap < light.specularImages.length; mipmap++) {\r\n const faces = light.specularImages[mipmap];\r\n imageData[mipmap] = new Array<ArrayBufferView>(faces.length);\r\n for (let face = 0; face < faces.length; face++) {\r\n const specularImageContext = `${context}/specularImages/${mipmap}/${face}`;\r\n this._loader.logOpen(`${specularImageContext}`);\r\n\r\n const index = faces[face];\r\n const image = ArrayItem.Get(specularImageContext, this._loader.gltf.images, index);\r\n promises.push(\r\n this._loader.loadImageAsync(`/images/${index}`, image).then((data) => {\r\n imageData[mipmap][face] = data;\r\n })\r\n );\r\n\r\n this._loader.logClose();\r\n }\r\n }\r\n\r\n this._loader.logClose();\r\n\r\n light._loaded = Promise.all(promises).then(() => {\r\n const babylonTexture = new RawCubeTexture(this._loader.babylonScene, null, light.specularImageSize);\r\n babylonTexture.name = light.name || \"environment\";\r\n light._babylonTexture = babylonTexture;\r\n\r\n if (light.intensity != undefined) {\r\n babylonTexture.level = light.intensity;\r\n }\r\n\r\n if (light.rotation) {\r\n let rotation = Quaternion.FromArray(light.rotation);\r\n\r\n // Invert the rotation so that positive rotation is counter-clockwise.\r\n if (!this._loader.babylonScene.useRightHandedSystem) {\r\n rotation = Quaternion.Inverse(rotation);\r\n }\r\n\r\n Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix());\r\n }\r\n\r\n if (!light.irradianceCoefficients) {\r\n throw new Error(`${context}: Irradiance coefficients are missing`);\r\n }\r\n\r\n const sphericalHarmonics = SphericalHarmonics.FromArray(light.irradianceCoefficients);\r\n sphericalHarmonics.scaleInPlace(light.intensity);\r\n\r\n sphericalHarmonics.convertIrradianceToLambertianRadiance();\r\n const sphericalPolynomial = SphericalPolynomial.FromHarmonics(sphericalHarmonics);\r\n\r\n // Compute the lod generation scale to fit exactly to the number of levels available.\r\n const lodGenerationScale = (imageData.length - 1) / Scalar.Log2(light.specularImageSize);\r\n return babylonTexture.updateRGBDAsync(imageData, sphericalPolynomial, lodGenerationScale);\r\n });\r\n }\r\n\r\n return light._loaded.then(() => {\r\n return light._babylonTexture!;\r\n });\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new EXT_lights_image_based(loader));\r\n"]}
1
+ {"version":3,"file":"EXT_lights_image_based.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,mBAAm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;QAClC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { SphericalHarmonics, SphericalPolynomial } from \"core/Maths/sphericalPolynomial\";\r\nimport { Quaternion, Matrix } from \"core/Maths/math.vector\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { RawCubeTexture } from \"core/Materials/Textures/rawCubeTexture\";\r\n\r\nimport type { IEXTLightsImageBased_LightReferenceImageBased, IEXTLightsImageBased_LightImageBased, IEXTLightsImageBased } from \"babylonjs-gltf2interface\";\r\nimport type { IScene } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"EXT_lights_image_based\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the EXT_lights_image_based extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"EXT_lights_image_based\"]: {};\r\n }\r\n}\r\n\r\ndeclare module \"babylonjs-gltf2interface\" {\r\n /** @internal */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n interface IEXTLightsImageBased_LightImageBased {\r\n _babylonTexture?: BaseTexture;\r\n _loaded?: Promise<void>;\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_lights_image_based/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class EXT_lights_image_based implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n private _lights?: IEXTLightsImageBased_LightImageBased[];\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n delete this._lights;\r\n }\r\n\r\n /** @internal */\r\n public onLoading(): void {\r\n const extensions = this._loader.gltf.extensions;\r\n if (extensions && extensions[this.name]) {\r\n const extension = extensions[this.name] as IEXTLightsImageBased;\r\n this._lights = extension.lights;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IEXTLightsImageBased_LightReferenceImageBased>(context, scene, this.name, (extensionContext, extension) => {\r\n this._loader._allMaterialsDirtyRequired = true;\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n promises.push(this._loader.loadSceneAsync(context, scene));\r\n\r\n this._loader.logOpen(`${extensionContext}`);\r\n\r\n const light = ArrayItem.Get(`${extensionContext}/light`, this._lights, extension.light);\r\n promises.push(\r\n this._loadLightAsync(`/extensions/${this.name}/lights/${extension.light}`, light).then((texture) => {\r\n this._loader.babylonScene.environmentTexture = texture;\r\n })\r\n );\r\n\r\n this._loader.logClose();\r\n\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadLightAsync(context: string, light: IEXTLightsImageBased_LightImageBased): Promise<BaseTexture> {\r\n if (!light._loaded) {\r\n const promises = new Array<Promise<any>>();\r\n\r\n this._loader.logOpen(`${context}`);\r\n\r\n const imageData = new Array<Array<ArrayBufferView>>(light.specularImages.length);\r\n for (let mipmap = 0; mipmap < light.specularImages.length; mipmap++) {\r\n const faces = light.specularImages[mipmap];\r\n imageData[mipmap] = new Array<ArrayBufferView>(faces.length);\r\n for (let face = 0; face < faces.length; face++) {\r\n const specularImageContext = `${context}/specularImages/${mipmap}/${face}`;\r\n this._loader.logOpen(`${specularImageContext}`);\r\n\r\n const index = faces[face];\r\n const image = ArrayItem.Get(specularImageContext, this._loader.gltf.images, index);\r\n promises.push(\r\n this._loader.loadImageAsync(`/images/${index}`, image).then((data) => {\r\n imageData[mipmap][face] = data;\r\n })\r\n );\r\n\r\n this._loader.logClose();\r\n }\r\n }\r\n\r\n this._loader.logClose();\r\n\r\n light._loaded = Promise.all(promises).then(() => {\r\n const babylonTexture = new RawCubeTexture(this._loader.babylonScene, null, light.specularImageSize);\r\n babylonTexture.name = light.name || \"environment\";\r\n light._babylonTexture = babylonTexture;\r\n\r\n if (light.intensity != undefined) {\r\n babylonTexture.level = light.intensity;\r\n }\r\n\r\n if (light.rotation) {\r\n let rotation = Quaternion.FromArray(light.rotation);\r\n\r\n // Invert the rotation so that positive rotation is counter-clockwise.\r\n if (!this._loader.babylonScene.useRightHandedSystem) {\r\n rotation = Quaternion.Inverse(rotation);\r\n }\r\n\r\n Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix());\r\n }\r\n\r\n if (!light.irradianceCoefficients) {\r\n throw new Error(`${context}: Irradiance coefficients are missing`);\r\n }\r\n\r\n const sphericalHarmonics = SphericalHarmonics.FromArray(light.irradianceCoefficients);\r\n sphericalHarmonics.scaleInPlace(light.intensity);\r\n\r\n sphericalHarmonics.convertIrradianceToLambertianRadiance();\r\n const sphericalPolynomial = SphericalPolynomial.FromHarmonics(sphericalHarmonics);\r\n\r\n // Compute the lod generation scale to fit exactly to the number of levels available.\r\n const lodGenerationScale = (imageData.length - 1) / Math.log2(light.specularImageSize);\r\n return babylonTexture.updateRGBDAsync(imageData, sphericalPolynomial, lodGenerationScale);\r\n });\r\n }\r\n\r\n return light._loaded.then(() => {\r\n return light._babylonTexture!;\r\n });\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new EXT_lights_image_based(loader));\r\n"]}
@@ -54,7 +54,7 @@ export class KHR_materials_clearcoat {
54
54
  }
55
55
  if (properties.clearcoatTexture) {
56
56
  promises.push(this._loader.loadTextureInfoAsync(`${context}/clearcoatTexture`, properties.clearcoatTexture, (texture) => {
57
- texture.name = `${babylonMaterial.name} (ClearCoat Intensity)`;
57
+ texture.name = `${babylonMaterial.name} (ClearCoat)`;
58
58
  babylonMaterial.clearCoat.texture = texture;
59
59
  }));
60
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_clearcoat.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAavC;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,uBAAuB;IAkBhC;;OAEG;IACH,YAAY,MAAkB;QApB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAQf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,2BAA2B,CAAC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAC9F,OAAO,UAAU,CAAC,kBAAkB,CAAyB,OA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Ae,CAAC,QAAQ,EAAE,CAAC,oBAAoB,CAAC;YACpF,eAAe,CAAC,gBAAgB,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC,oBAAoB,CAAC;YACnF,IAAI,UAAU,CAAC,sBAAsB,CAAC,KAAK,IAAI,SAAS,EAAE;gBACtD,eAAe,CAAC,SAAS,CAAC,WAAY,CAAC,KAAK,GAAG,UAAU,CAAC,sBAAsB,CAAC,KAAK,CAAC;aAC1F;SACJ;QAED,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\n\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsClearcoat } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_clearcoat\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_clearcoat extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_clearcoat\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)\r\n * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_clearcoat implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 190;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsClearcoat>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadClearCoatPropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadClearCoatPropertiesAsync(context: string, properties: IKHRMaterialsClearcoat, babylonMaterial: Material): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n babylonMaterial.clearCoat.isEnabled = true;\r\n babylonMaterial.clearCoat.useRoughnessFromMainTexture = false;\r\n babylonMaterial.clearCoat.remapF0OnInterfaceChange = false;\r\n\r\n if (properties.clearcoatFactor != undefined) {\r\n babylonMaterial.clearCoat.intensity = properties.clearcoatFactor;\r\n } else {\r\n babylonMaterial.clearCoat.intensity = 0;\r\n }\r\n\r\n if (properties.clearcoatTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/clearcoatTexture`, properties.clearcoatTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (ClearCoat Intensity)`;\r\n babylonMaterial.clearCoat.texture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.clearcoatRoughnessFactor != undefined) {\r\n babylonMaterial.clearCoat.roughness = properties.clearcoatRoughnessFactor;\r\n } else {\r\n babylonMaterial.clearCoat.roughness = 0;\r\n }\r\n\r\n if (properties.clearcoatRoughnessTexture) {\r\n (properties.clearcoatRoughnessTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/clearcoatRoughnessTexture`, properties.clearcoatRoughnessTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (ClearCoat Roughness)`;\r\n babylonMaterial.clearCoat.textureRoughness = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.clearcoatNormalTexture) {\r\n (properties.clearcoatNormalTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/clearcoatNormalTexture`, properties.clearcoatNormalTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (ClearCoat Normal)`;\r\n babylonMaterial.clearCoat.bumpTexture = texture;\r\n })\r\n );\r\n\r\n babylonMaterial.invertNormalMapX = !babylonMaterial.getScene().useRightHandedSystem;\r\n babylonMaterial.invertNormalMapY = babylonMaterial.getScene().useRightHandedSystem;\r\n if (properties.clearcoatNormalTexture.scale != undefined) {\r\n babylonMaterial.clearCoat.bumpTexture!.level = properties.clearcoatNormalTexture.scale;\r\n }\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_clearcoat(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_clearcoat.js","sourceRoot":"","sources":["../../../../../../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AAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\n\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsClearcoat } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_clearcoat\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_clearcoat extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_clearcoat\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)\r\n * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_clearcoat implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 190;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsClearcoat>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadClearCoatPropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadClearCoatPropertiesAsync(context: string, properties: IKHRMaterialsClearcoat, babylonMaterial: Material): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n babylonMaterial.clearCoat.isEnabled = true;\r\n babylonMaterial.clearCoat.useRoughnessFromMainTexture = false;\r\n babylonMaterial.clearCoat.remapF0OnInterfaceChange = false;\r\n\r\n if (properties.clearcoatFactor != undefined) {\r\n babylonMaterial.clearCoat.intensity = properties.clearcoatFactor;\r\n } else {\r\n babylonMaterial.clearCoat.intensity = 0;\r\n }\r\n\r\n if (properties.clearcoatTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/clearcoatTexture`, properties.clearcoatTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (ClearCoat)`;\r\n babylonMaterial.clearCoat.texture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.clearcoatRoughnessFactor != undefined) {\r\n babylonMaterial.clearCoat.roughness = properties.clearcoatRoughnessFactor;\r\n } else {\r\n babylonMaterial.clearCoat.roughness = 0;\r\n }\r\n\r\n if (properties.clearcoatRoughnessTexture) {\r\n (properties.clearcoatRoughnessTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/clearcoatRoughnessTexture`, properties.clearcoatRoughnessTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (ClearCoat Roughness)`;\r\n babylonMaterial.clearCoat.textureRoughness = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.clearcoatNormalTexture) {\r\n (properties.clearcoatNormalTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/clearcoatNormalTexture`, properties.clearcoatNormalTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (ClearCoat Normal)`;\r\n babylonMaterial.clearCoat.bumpTexture = texture;\r\n })\r\n );\r\n\r\n babylonMaterial.invertNormalMapX = !babylonMaterial.getScene().useRightHandedSystem;\r\n babylonMaterial.invertNormalMapY = babylonMaterial.getScene().useRightHandedSystem;\r\n if (properties.clearcoatNormalTexture.scale != undefined) {\r\n babylonMaterial.clearCoat.bumpTexture!.level = properties.clearcoatNormalTexture.scale;\r\n }\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_clearcoat(loader));\r\n"]}
@@ -37,7 +37,6 @@ export class KHR_materials_diffuse_transmission {
37
37
  loadMaterialPropertiesAsync(context, material, babylonMaterial) {
38
38
  return GLTFLoader.LoadExtensionAsync(context, material, this.name, (extensionContext, extension) => {
39
39
  const promises = new Array();
40
- promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
41
40
  promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
42
41
  promises.push(this._loadTranslucentPropertiesAsync(extensionContext, material, babylonMaterial, extension));
43
42
  return Promise.all(promises).then(() => { });
@@ -70,6 +69,7 @@ export class KHR_materials_diffuse_transmission {
70
69
  if (extension.diffuseTransmissionTexture) {
71
70
  extension.diffuseTransmissionTexture.nonColorData = true;
72
71
  promises.push(this._loader.loadTextureInfoAsync(`${context}/diffuseTransmissionTexture`, extension.diffuseTransmissionTexture).then((texture) => {
72
+ texture.name = `${babylonMaterial.name} (Diffuse Transmission)`;
73
73
  pbrMaterial.subSurface.translucencyIntensityTexture = texture;
74
74
  }));
75
75
  }
@@ -81,6 +81,7 @@ export class KHR_materials_diffuse_transmission {
81
81
  }
82
82
  if (extension.diffuseTransmissionColorTexture) {
83
83
  promises.push(this._loader.loadTextureInfoAsync(`${context}/diffuseTransmissionColorTexture`, extension.diffuseTransmissionColorTexture).then((texture) => {
84
+ texture.name = `${babylonMaterial.name} (Diffuse Transmission Color)`;
84
85
  pbrMaterial.subSurface.translucencyColorTexture = texture;
85
86
  }));
86
87
  }
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_diffuse_transmission.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,oCAAoC,CAAC;AAalD;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,kCAAkC;IAkB3C;;OAEG;IACH,YAAY,MAAkB;QApB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAQf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,MAAM,CAAC,MAAM,CAAC,sBAAsB,GAAG,IAAI,CAAC;SAC/C;IACL,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;OA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A+B,CAAC,CAAC,IAAI,CAAC,CAAC,OAAoB,EAAE,EAAE;gBACrJ,WAAW,CAAC,UAAU,CAAC,wBAAwB,GAAG,OAAO,CAAC;YAC9D,CAAC,CAAC,CACL,CAAC;SACL;QAED,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,kCAAkC,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsDiffuseTransmission } from \"babylonjs-gltf2interface\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_diffuse_transmission\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_diffuse_transmission extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_diffuse_transmission\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)\r\n * !!! Experimental Extension Subject to Changes !!!\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_diffuse_transmission implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 174;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n if (this.enabled) {\r\n loader.parent.transparencyAsCoverage = true;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsDiffuseTransmission>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadTranslucentPropertiesAsync(extensionContext, material, babylonMaterial, extension));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadTranslucentPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsDiffuseTransmission): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const pbrMaterial = babylonMaterial as PBRMaterial;\r\n\r\n // Enables \"translucency\" texture which represents diffusely-transmitted light.\r\n pbrMaterial.subSurface.isTranslucencyEnabled = true;\r\n\r\n // Since this extension models thin-surface transmission only, we must make the\r\n // internal IOR == 1.0 and set the thickness to 0.\r\n pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;\r\n pbrMaterial.subSurface.minimumThickness = 0.0;\r\n pbrMaterial.subSurface.maximumThickness = 0.0;\r\n\r\n // Tint color will be used for transmission.\r\n pbrMaterial.subSurface.useAlbedoToTintTranslucency = false;\r\n\r\n if (extension.diffuseTransmissionFactor !== undefined) {\r\n pbrMaterial.subSurface.translucencyIntensity = extension.diffuseTransmissionFactor;\r\n } else {\r\n pbrMaterial.subSurface.translucencyIntensity = 0.0;\r\n pbrMaterial.subSurface.isTranslucencyEnabled = false;\r\n return Promise.resolve();\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n pbrMaterial.subSurface.useGltfStyleTextures = true;\r\n\r\n if (extension.diffuseTransmissionTexture) {\r\n (extension.diffuseTransmissionTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/diffuseTransmissionTexture`, extension.diffuseTransmissionTexture).then((texture: BaseTexture) => {\r\n pbrMaterial.subSurface.translucencyIntensityTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (extension.diffuseTransmissionColorFactor !== undefined) {\r\n pbrMaterial.subSurface.translucencyColor = Color3.FromArray(extension.diffuseTransmissionColorFactor);\r\n } else {\r\n pbrMaterial.subSurface.translucencyColor = Color3.White();\r\n }\r\n\r\n if (extension.diffuseTransmissionColorTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/diffuseTransmissionColorTexture`, extension.diffuseTransmissionColorTexture).then((texture: BaseTexture) => {\r\n pbrMaterial.subSurface.translucencyColorTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_diffuse_transmission(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_diffuse_transmission.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WA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r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsDiffuseTransmission } from \"babylonjs-gltf2interface\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_diffuse_transmission\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_diffuse_transmission extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_diffuse_transmission\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)\r\n * !!! Experimental Extension Subject to Changes !!!\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_diffuse_transmission implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 174;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n if (this.enabled) {\r\n loader.parent.transparencyAsCoverage = true;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsDiffuseTransmission>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadTranslucentPropertiesAsync(extensionContext, material, babylonMaterial, extension));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadTranslucentPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsDiffuseTransmission): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const pbrMaterial = babylonMaterial as PBRMaterial;\r\n\r\n // Enables \"translucency\" texture which represents diffusely-transmitted light.\r\n pbrMaterial.subSurface.isTranslucencyEnabled = true;\r\n\r\n // Since this extension models thin-surface transmission only, we must make the\r\n // internal IOR == 1.0 and set the thickness to 0.\r\n pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;\r\n pbrMaterial.subSurface.minimumThickness = 0.0;\r\n pbrMaterial.subSurface.maximumThickness = 0.0;\r\n\r\n // Tint color will be used for transmission.\r\n pbrMaterial.subSurface.useAlbedoToTintTranslucency = false;\r\n\r\n if (extension.diffuseTransmissionFactor !== undefined) {\r\n pbrMaterial.subSurface.translucencyIntensity = extension.diffuseTransmissionFactor;\r\n } else {\r\n pbrMaterial.subSurface.translucencyIntensity = 0.0;\r\n pbrMaterial.subSurface.isTranslucencyEnabled = false;\r\n return Promise.resolve();\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n pbrMaterial.subSurface.useGltfStyleTextures = true;\r\n\r\n if (extension.diffuseTransmissionTexture) {\r\n (extension.diffuseTransmissionTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/diffuseTransmissionTexture`, extension.diffuseTransmissionTexture).then((texture: BaseTexture) => {\r\n texture.name = `${babylonMaterial.name} (Diffuse Transmission)`;\r\n pbrMaterial.subSurface.translucencyIntensityTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (extension.diffuseTransmissionColorFactor !== undefined) {\r\n pbrMaterial.subSurface.translucencyColor = Color3.FromArray(extension.diffuseTransmissionColorFactor);\r\n } else {\r\n pbrMaterial.subSurface.translucencyColor = Color3.White();\r\n }\r\n\r\n if (extension.diffuseTransmissionColorTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/diffuseTransmissionColorTexture`, extension.diffuseTransmissionColorTexture).then((texture: BaseTexture) => {\r\n texture.name = `${babylonMaterial.name} (Diffuse Transmission Color)`;\r\n pbrMaterial.subSurface.translucencyColorTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_diffuse_transmission(loader));\r\n"]}
@@ -33,7 +33,6 @@ export class KHR_materials_dispersion {
33
33
  loadMaterialPropertiesAsync(context, material, babylonMaterial) {
34
34
  return GLTFLoader.LoadExtensionAsync(context, material, this.name, (extensionContext, extension) => {
35
35
  const promises = new Array();
36
- promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
37
36
  promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
38
37
  promises.push(this._loadDispersionPropertiesAsync(extensionContext, material, babylonMaterial, extension));
39
38
  return Promise.all(promises).then(() => { });
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_dispersion.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAI7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAA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AAyB,EAAE,SAAkC;QACtI,IAAI,CAAC,CAAC,eAAe,YAAY,WAAW,CAAC,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,+BAA+B,CAAC,CAAC;SAC9D;QAED,+EAA+E;QAC/E,2GAA2G;QAC3G,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE;YAC1E,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;QACD,eAAe,CAAC,UAAU,CAAC,mBAAmB,GAAG,IAAI,CAAC;QACtD,eAAe,CAAC,UAAU,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;QAC7D,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsDispersion } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_dispersion\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_dispersion extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_dispersion\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/87bd64a7f5e23c84b6aef2e6082069583ed0ddb4/extensions/2.0/Khronos/KHR_materials_dispersion/README.md)\r\n * @experimental\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_dispersion implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 174;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsDispersion>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadDispersionPropertiesAsync(extensionContext, material, babylonMaterial, extension));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadDispersionPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsDispersion): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n // If transparency isn't enabled already, this extension shouldn't do anything.\r\n // i.e. it requires either the KHR_materials_transmission or KHR_materials_diffuse_transmission extensions.\r\n if (!babylonMaterial.subSurface.isRefractionEnabled || !extension.dispersion) {\r\n return Promise.resolve();\r\n }\r\n babylonMaterial.subSurface.isDispersionEnabled = true;\r\n babylonMaterial.subSurface.dispersion = extension.dispersion;\r\n return Promise.resolve();\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_dispersion(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_dispersion.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAI7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,0BAA0B,CAAC;AAaxC;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,wBAAwB;IAkBjC;;OAEG;IACH,YAAY,MAAkB;QApB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAQf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,2BAA2B,CAAC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAC9F,OAAO,UAAU,CAAC,kBAAkB,CAA0B,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,EAAE;YACxH,MAAM,QAAQ,GAAG,IAAI,KAAK,EAAgB,CAAC;YAC3C,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;YAC5F,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,gBAAgB,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC;YAC3G,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,8BAA8B,CAAC,OAAe,EAAE,QAAmB,EAAE,eAAyB,EAAE,SAAkC;QACtI,IAAI,CAAC,CAAC,eAAe,YAAY,WAAW,CAAC,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,+BAA+B,CAAC,CAAC;SAC9D;QAED,+EAA+E;QAC/E,2GAA2G;QAC3G,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE;YAC1E,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;QACD,eAAe,CAAC,UAAU,CAAC,mBAAmB,GAAG,IAAI,CAAC;QACtD,eAAe,CAAC,UAAU,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;QAC7D,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsDispersion } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_dispersion\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_dispersion extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_dispersion\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/87bd64a7f5e23c84b6aef2e6082069583ed0ddb4/extensions/2.0/Khronos/KHR_materials_dispersion/README.md)\r\n * @experimental\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_dispersion implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 174;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsDispersion>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadDispersionPropertiesAsync(extensionContext, material, babylonMaterial, extension));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadDispersionPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsDispersion): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n // If transparency isn't enabled already, this extension shouldn't do anything.\r\n // i.e. it requires either the KHR_materials_transmission or KHR_materials_diffuse_transmission extensions.\r\n if (!babylonMaterial.subSurface.isRefractionEnabled || !extension.dispersion) {\r\n return Promise.resolve();\r\n }\r\n babylonMaterial.subSurface.isDispersionEnabled = true;\r\n babylonMaterial.subSurface.dispersion = extension.dispersion;\r\n return Promise.resolve();\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_dispersion(loader));\r\n"]}
@@ -49,7 +49,7 @@ export class KHR_materials_iridescence {
49
49
  babylonMaterial.iridescence.maximumThickness = properties.iridescenceThicknessMaximum ?? 400;
50
50
  if (properties.iridescenceTexture) {
51
51
  promises.push(this._loader.loadTextureInfoAsync(`${context}/iridescenceTexture`, properties.iridescenceTexture, (texture) => {
52
- texture.name = `${babylonMaterial.name} (Iridescence Intensity)`;
52
+ texture.name = `${babylonMaterial.name} (Iridescence)`;
53
53
  babylonMaterial.iridescence.texture = texture;
54
54
  }));
55
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_iridescence.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAazC;;GAEG;AACH,gE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AAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\n\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsIridescence } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_iridescence\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_iridescence extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_iridescence\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_iridescence/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_iridescence implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 195;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsIridescence>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadIridescencePropertiesAsync(context: string, properties: IKHRMaterialsIridescence, babylonMaterial: Material): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n babylonMaterial.iridescence.isEnabled = true;\r\n\r\n babylonMaterial.iridescence.intensity = properties.iridescenceFactor ?? 0;\r\n babylonMaterial.iridescence.indexOfRefraction = properties.iridescenceIor ?? (properties as any).iridescenceIOR ?? 1.3;\r\n babylonMaterial.iridescence.minimumThickness = properties.iridescenceThicknessMinimum ?? 100;\r\n babylonMaterial.iridescence.maximumThickness = properties.iridescenceThicknessMaximum ?? 400;\r\n\r\n if (properties.iridescenceTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/iridescenceTexture`, properties.iridescenceTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Iridescence Intensity)`;\r\n babylonMaterial.iridescence.texture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.iridescenceThicknessTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/iridescenceThicknessTexture`, properties.iridescenceThicknessTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Iridescence Thickness)`;\r\n babylonMaterial.iridescence.thicknessTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_iridescence(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_iridescence.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAazC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,yBAAyB;IAkBlC;;OAEG;IACH,YAAY,MAAkB;QApB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAQf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,2BAA2B,CAAC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAC9F,OAAO,UAAU,CAAC,kBAAkB,CAA2B,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,EAAE;YACzH,MAAM,QAAQ,GAAG,IAAI,KAAK,EAAgB,CAAC;YAC3C,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;YAC5F,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,gBAAgB,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC;YAClG,OA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,8BAA8B,EAAE,UAAU,CAAC,2BAA2B,EAAE,CAAC,OAAO,EAAE,EAAE;gBAC5H,OAAO,CAAC,IAAI,GAAG,GAAG,eAAe,CAAC,IAAI,0BAA0B,CAAC;gBACjE,eAAe,CAAC,WAAW,CAAC,gBAAgB,GAAG,OAAO,CAAC;YAC3D,CAAC,CAAC,CACL,CAAC;SACL;QAED,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\n\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsIridescence } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_iridescence\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_iridescence extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_iridescence\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_iridescence/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_iridescence implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 195;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsIridescence>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadIridescencePropertiesAsync(context: string, properties: IKHRMaterialsIridescence, babylonMaterial: Material): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n babylonMaterial.iridescence.isEnabled = true;\r\n\r\n babylonMaterial.iridescence.intensity = properties.iridescenceFactor ?? 0;\r\n babylonMaterial.iridescence.indexOfRefraction = properties.iridescenceIor ?? (properties as any).iridescenceIOR ?? 1.3;\r\n babylonMaterial.iridescence.minimumThickness = properties.iridescenceThicknessMinimum ?? 100;\r\n babylonMaterial.iridescence.maximumThickness = properties.iridescenceThicknessMaximum ?? 400;\r\n\r\n if (properties.iridescenceTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/iridescenceTexture`, properties.iridescenceTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Iridescence)`;\r\n babylonMaterial.iridescence.texture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.iridescenceThicknessTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/iridescenceThicknessTexture`, properties.iridescenceThicknessTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Iridescence Thickness)`;\r\n babylonMaterial.iridescence.thicknessTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_iridescence(loader));\r\n"]}
@@ -52,14 +52,14 @@ export class KHR_materials_specular {
52
52
  if (properties.specularTexture) {
53
53
  properties.specularTexture.nonColorData = true;
54
54
  promises.push(this._loader.loadTextureInfoAsync(`${context}/specularTexture`, properties.specularTexture, (texture) => {
55
- texture.name = `${babylonMaterial.name} (Specular F0 Strength)`;
55
+ texture.name = `${babylonMaterial.name} (Specular)`;
56
56
  babylonMaterial.metallicReflectanceTexture = texture;
57
57
  babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true;
58
58
  }));
59
59
  }
60
60
  if (properties.specularColorTexture) {
61
61
  promises.push(this._loader.loadTextureInfoAsync(`${context}/specularColorTexture`, properties.specularColorTexture, (texture) => {
62
- texture.name = `${babylonMaterial.name} (Specular F0 Color)`;
62
+ texture.name = `${babylonMaterial.name} (Specular Color)`;
63
63
  babylonMaterial.reflectanceTexture = texture;
64
64
  }));
65
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_specular.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE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,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\n\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport type { IKHRMaterialsSpecular } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_specular\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_specular extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_specular\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_specular implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 190;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsSpecular>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadSpecularPropertiesAsync(context: string, properties: IKHRMaterialsSpecular, babylonMaterial: Material): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n if (properties.specularFactor !== undefined) {\r\n babylonMaterial.metallicF0Factor = properties.specularFactor;\r\n }\r\n\r\n if (properties.specularColorFactor !== undefined) {\r\n babylonMaterial.metallicReflectanceColor = Color3.FromArray(properties.specularColorFactor);\r\n }\r\n\r\n if (properties.specularTexture) {\r\n (properties.specularTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/specularTexture`, properties.specularTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Specular F0 Strength)`;\r\n babylonMaterial.metallicReflectanceTexture = texture;\r\n babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true;\r\n })\r\n );\r\n }\r\n\r\n if (properties.specularColorTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/specularColorTexture`, properties.specularColorTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Specular F0 Color)`;\r\n babylonMaterial.reflectanceTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_specular(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_specular.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE/C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,wBAAwB,CAAC;AAatC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,sBAAsB;IAkB/B;;OAEG;IACH,YAAY,MAAkB;QApB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAQf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,2BAA2B,CAAC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAC9F,OAAO,UAAU,CAAC,kBAAkB,CAAwB,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,EAAE;YACtH,MAAM,QAAQ,GAAG,IAAI,KAAK,EAAgB,CAAC;YAC3C,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;YAC5F,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,gBAAgB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AU,CAAC,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE;gBAC9G,OAAO,CAAC,IAAI,GAAG,GAAG,eAAe,CAAC,IAAI,mBAAmB,CAAC;gBAC1D,eAAe,CAAC,kBAAkB,GAAG,OAAO,CAAC;YACjD,CAAC,CAAC,CACL,CAAC;SACL;QAED,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\n\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport type { IKHRMaterialsSpecular } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_specular\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_specular extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_specular\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_specular implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 190;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsSpecular>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadSpecularPropertiesAsync(context: string, properties: IKHRMaterialsSpecular, babylonMaterial: Material): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n if (properties.specularFactor !== undefined) {\r\n babylonMaterial.metallicF0Factor = properties.specularFactor;\r\n }\r\n\r\n if (properties.specularColorFactor !== undefined) {\r\n babylonMaterial.metallicReflectanceColor = Color3.FromArray(properties.specularColorFactor);\r\n }\r\n\r\n if (properties.specularTexture) {\r\n (properties.specularTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/specularTexture`, properties.specularTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Specular)`;\r\n babylonMaterial.metallicReflectanceTexture = texture;\r\n babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true;\r\n })\r\n );\r\n }\r\n\r\n if (properties.specularColorTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/specularColorTexture`, properties.specularColorTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Specular Color)`;\r\n babylonMaterial.reflectanceTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_specular(loader));\r\n"]}
@@ -254,7 +254,6 @@ export class KHR_materials_transmission {
254
254
  loadMaterialPropertiesAsync(context, material, babylonMaterial) {
255
255
  return GLTFLoader.LoadExtensionAsync(context, material, this.name, (extensionContext, extension) => {
256
256
  const promises = new Array();
257
- promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
258
257
  promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
259
258
  promises.push(this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension));
260
259
  return Promise.all(promises).then(() => { });
@@ -292,6 +291,7 @@ export class KHR_materials_transmission {
292
291
  if (extension.transmissionTexture) {
293
292
  extension.transmissionTexture.nonColorData = true;
294
293
  return this._loader.loadTextureInfoAsync(`${context}/transmissionTexture`, extension.transmissionTexture, undefined).then((texture) => {
294
+ texture.name = `${babylonMaterial.name} (Transmission)`;
295
295
  pbrMaterial.subSurface.refractionIntensityTexture = texture;
296
296
  pbrMaterial.subSurface.useGltfStyleTextures = true;
297
297
  });