@babylonjs/loaders 5.21.0 → 5.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. package/OBJ/mtlFileLoader.js +25 -27
  2. package/OBJ/mtlFileLoader.js.map +1 -1
  3. package/OBJ/objFileLoader.js +112 -124
  4. package/OBJ/objFileLoader.js.map +1 -1
  5. package/OBJ/solidParser.js +118 -125
  6. package/OBJ/solidParser.js.map +1 -1
  7. package/STL/stlFileLoader.js +61 -63
  8. package/STL/stlFileLoader.js.map +1 -1
  9. package/glTF/1.0/glTFBinaryExtension.js +26 -30
  10. package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
  11. package/glTF/1.0/glTFLoader.js +409 -432
  12. package/glTF/1.0/glTFLoader.js.map +1 -1
  13. package/glTF/1.0/glTFLoaderUtils.js +33 -37
  14. package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
  15. package/glTF/1.0/glTFMaterialsCommonExtension.js +27 -31
  16. package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
  17. package/glTF/2.0/Extensions/EXT_lights_image_based.js +48 -59
  18. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
  19. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +24 -29
  20. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  21. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +13 -16
  22. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
  23. package/glTF/2.0/Extensions/EXT_texture_webp.js +13 -16
  24. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
  25. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +22 -26
  26. package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
  27. package/glTF/2.0/Extensions/KHR_animation_pointer.js +63 -76
  28. package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -1
  29. package/glTF/2.0/Extensions/KHR_animation_pointer.map.js +90 -120
  30. package/glTF/2.0/Extensions/KHR_animation_pointer.map.js.map +1 -1
  31. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +25 -28
  32. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  33. package/glTF/2.0/Extensions/KHR_lights_punctual.js +27 -30
  34. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  35. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +25 -28
  36. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  37. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +15 -18
  38. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
  39. package/glTF/2.0/Extensions/KHR_materials_ior.js +21 -24
  40. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  41. package/glTF/2.0/Extensions/KHR_materials_iridescence.js +27 -31
  42. package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
  43. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +24 -27
  44. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
  45. package/glTF/2.0/Extensions/KHR_materials_sheen.js +23 -26
  46. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  47. package/glTF/2.0/Extensions/KHR_materials_specular.js +23 -26
  48. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  49. package/glTF/2.0/Extensions/KHR_materials_translucency.js +20 -23
  50. package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
  51. package/glTF/2.0/Extensions/KHR_materials_transmission.js +82 -86
  52. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  53. package/glTF/2.0/Extensions/KHR_materials_unlit.js +19 -22
  54. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  55. package/glTF/2.0/Extensions/KHR_materials_variants.js +79 -97
  56. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
  57. package/glTF/2.0/Extensions/KHR_materials_volume.js +20 -23
  58. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  59. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +6 -8
  60. package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
  61. package/glTF/2.0/Extensions/KHR_texture_basisu.js +13 -16
  62. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
  63. package/glTF/2.0/Extensions/KHR_texture_transform.js +12 -15
  64. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  65. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +12 -15
  66. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
  67. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +77 -95
  68. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
  69. package/glTF/2.0/Extensions/MSFT_lod.js +114 -139
  70. package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
  71. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +12 -15
  72. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
  73. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +12 -15
  74. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
  75. package/glTF/2.0/glTFLoader.js +739 -823
  76. package/glTF/2.0/glTFLoader.js.map +1 -1
  77. package/glTF/glTFFileLoader.js +337 -404
  78. package/glTF/glTFFileLoader.js.map +1 -1
  79. package/glTF/glTFValidation.js +32 -39
  80. package/glTF/glTFValidation.js.map +1 -1
  81. package/legacy/legacy-glTF.js +3 -3
  82. package/legacy/legacy-glTF.js.map +1 -1
  83. package/legacy/legacy-glTF1.js +2 -2
  84. package/legacy/legacy-glTF1.js.map +1 -1
  85. package/legacy/legacy-glTF2.js +12 -12
  86. package/legacy/legacy-glTF2.js.map +1 -1
  87. package/legacy/legacy-objFileLoader.js +2 -2
  88. package/legacy/legacy-objFileLoader.js.map +1 -1
  89. package/legacy/legacy-stlFileLoader.js +2 -2
  90. package/legacy/legacy-stlFileLoader.js.map +1 -1
  91. package/package.json +3 -6
@@ -1,15 +1,15 @@
1
1
  import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
2
  import { GLTFLoader } from "../glTFLoader.js";
3
- var NAME = "KHR_materials_ior";
3
+ const NAME = "KHR_materials_ior";
4
4
  /**
5
5
  * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior)
6
6
  */
7
- var KHR_materials_ior = /** @class */ (function () {
7
+ export class KHR_materials_ior {
8
8
  /**
9
9
  * @param loader
10
10
  * @hidden
11
11
  */
12
- function KHR_materials_ior(loader) {
12
+ constructor(loader) {
13
13
  /**
14
14
  * The name of this extension.
15
15
  */
@@ -22,27 +22,26 @@ var KHR_materials_ior = /** @class */ (function () {
22
22
  this.enabled = this._loader.isExtensionUsed(NAME);
23
23
  }
24
24
  /** @hidden */
25
- KHR_materials_ior.prototype.dispose = function () {
25
+ dispose() {
26
26
  this._loader = null;
27
- };
27
+ }
28
28
  /**
29
29
  * @param context
30
30
  * @param material
31
31
  * @param babylonMaterial
32
32
  * @hidden
33
33
  */
34
- KHR_materials_ior.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
35
- var _this = this;
36
- return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
37
- var promises = new Array();
38
- promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
39
- promises.push(_this._loadIorPropertiesAsync(extensionContext, extension, babylonMaterial));
40
- return Promise.all(promises).then(function () { });
34
+ loadMaterialPropertiesAsync(context, material, babylonMaterial) {
35
+ return GLTFLoader.LoadExtensionAsync(context, material, this.name, (extensionContext, extension) => {
36
+ const promises = new Array();
37
+ promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
38
+ promises.push(this._loadIorPropertiesAsync(extensionContext, extension, babylonMaterial));
39
+ return Promise.all(promises).then(() => { });
41
40
  });
42
- };
43
- KHR_materials_ior.prototype._loadIorPropertiesAsync = function (context, properties, babylonMaterial) {
41
+ }
42
+ _loadIorPropertiesAsync(context, properties, babylonMaterial) {
44
43
  if (!(babylonMaterial instanceof PBRMaterial)) {
45
- throw new Error("".concat(context, ": Material type not supported"));
44
+ throw new Error(`${context}: Material type not supported`);
46
45
  }
47
46
  if (properties.ior !== undefined) {
48
47
  babylonMaterial.indexOfRefraction = properties.ior;
@@ -51,13 +50,11 @@ var KHR_materials_ior = /** @class */ (function () {
51
50
  babylonMaterial.indexOfRefraction = KHR_materials_ior._DEFAULT_IOR;
52
51
  }
53
52
  return Promise.resolve();
54
- };
55
- /**
56
- * Default ior Value from the spec.
57
- */
58
- KHR_materials_ior._DEFAULT_IOR = 1.5;
59
- return KHR_materials_ior;
60
- }());
61
- export { KHR_materials_ior };
62
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_ior(loader); });
53
+ }
54
+ }
55
+ /**
56
+ * Default ior Value from the spec.
57
+ */
58
+ KHR_materials_ior._DEFAULT_IOR = 1.5;
59
+ GLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_ior(loader));
63
60
  //# sourceMappingURL=KHR_materials_ior.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_ior.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_ior.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,IAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC;;GAEG;AACH;IAuBI;;;OAGG;IACH,2BAAY,MAAkB;QArB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QASf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CA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GAAG,CAAC;IA6D/C,wBAAC;CAAA,AAjED,IAiEC;SAjEY,iBAAiB;AAmE9B,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAA7B,CAA6B,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\n\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsIor } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_ior\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior)\r\n */\r\nexport class KHR_materials_ior implements IGLTFLoaderExtension {\r\n /**\r\n * Default ior Value from the spec.\r\n */\r\n private static readonly _DEFAULT_IOR = 1.5;\r\n\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 = 180;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @param loader\r\n * @hidden\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 /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param material\r\n * @param babylonMaterial\r\n * @hidden\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsIor>(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._loadIorPropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadIorPropertiesAsync(context: string, properties: IKHRMaterialsIor, 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 if (properties.ior !== undefined) {\r\n babylonMaterial.indexOfRefraction = properties.ior;\r\n } else {\r\n babylonMaterial.indexOfRefraction = KHR_materials_ior._DEFAULT_IOR;\r\n }\r\n\r\n return Promise.resolve();\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_ior(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_ior.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_ior.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAuB1B;;;OAGG;IACH,YAAY,MAAkB;QArB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QASf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACP,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACI,2BAA2B,CAAC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAC9F,OAAO,UAAU,CAAC,kBAAkB,CAAmB,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,EAAE;YACjH,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,uBAAuB,CAAC,gBAAgB,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC;YAC1F,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,uBAAuB,CAAC,OAAe,EAAE,UAA4B,EAAE,eAAyB;QACpG,IAAI,CAAC,CAAC,eAAe,YAAY,WAAW,CAAC,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,+BAA+B,CAAC,CAAC;SAC9D;QAED,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,EAAE;YAC9B,eAAe,CAAC,iBAAiB,GAAG,UAAU,CAAC,GAAG,CAAC;SACtD;aAAM;YACH,eAAe,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,YAAY,CAAC;SACtE;QAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;;AA/DD;;GAEG;AACqB,8BAAY,GAAG,GAAG,CAAC;AA+D/C,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,iBAAiB,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\n\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsIor } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_ior\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior)\r\n */\r\nexport class KHR_materials_ior implements IGLTFLoaderExtension {\r\n /**\r\n * Default ior Value from the spec.\r\n */\r\n private static readonly _DEFAULT_IOR = 1.5;\r\n\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 = 180;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @param loader\r\n * @hidden\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 /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param material\r\n * @param babylonMaterial\r\n * @hidden\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsIor>(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._loadIorPropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadIorPropertiesAsync(context: string, properties: IKHRMaterialsIor, 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 if (properties.ior !== undefined) {\r\n babylonMaterial.indexOfRefraction = properties.ior;\r\n } else {\r\n babylonMaterial.indexOfRefraction = KHR_materials_ior._DEFAULT_IOR;\r\n }\r\n\r\n return Promise.resolve();\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_ior(loader));\r\n"]}
@@ -1,15 +1,15 @@
1
1
  import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
2
  import { GLTFLoader } from "../glTFLoader.js";
3
- var NAME = "KHR_materials_iridescence";
3
+ const NAME = "KHR_materials_iridescence";
4
4
  /**
5
5
  * [Experimental Spec](https://github.com/KhronosGroup/glTF/pull/2027)
6
6
  */
7
- var KHR_materials_iridescence = /** @class */ (function () {
7
+ export class KHR_materials_iridescence {
8
8
  /**
9
9
  * @param loader
10
10
  * @hidden
11
11
  */
12
- function KHR_materials_iridescence(loader) {
12
+ constructor(loader) {
13
13
  /**
14
14
  * The name of this extension.
15
15
  */
@@ -22,51 +22,47 @@ var KHR_materials_iridescence = /** @class */ (function () {
22
22
  this.enabled = this._loader.isExtensionUsed(NAME);
23
23
  }
24
24
  /** @hidden */
25
- KHR_materials_iridescence.prototype.dispose = function () {
25
+ dispose() {
26
26
  this._loader = null;
27
- };
27
+ }
28
28
  /**
29
29
  * @param context
30
30
  * @param material
31
31
  * @param babylonMaterial
32
32
  * @hidden
33
33
  */
34
- KHR_materials_iridescence.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
35
- var _this = this;
36
- return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
37
- var promises = new Array();
38
- promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
39
- promises.push(_this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial));
40
- return Promise.all(promises).then(function () { });
34
+ loadMaterialPropertiesAsync(context, material, babylonMaterial) {
35
+ return GLTFLoader.LoadExtensionAsync(context, material, this.name, (extensionContext, extension) => {
36
+ const promises = new Array();
37
+ promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
38
+ promises.push(this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial));
39
+ return Promise.all(promises).then(() => { });
41
40
  });
42
- };
43
- KHR_materials_iridescence.prototype._loadIridescencePropertiesAsync = function (context, properties, babylonMaterial) {
44
- var _a, _b, _c, _d, _e;
41
+ }
42
+ _loadIridescencePropertiesAsync(context, properties, babylonMaterial) {
45
43
  if (!(babylonMaterial instanceof PBRMaterial)) {
46
- throw new Error("".concat(context, ": Material type not supported"));
44
+ throw new Error(`${context}: Material type not supported`);
47
45
  }
48
- var promises = new Array();
46
+ const promises = new Array();
49
47
  babylonMaterial.iridescence.isEnabled = true;
50
- babylonMaterial.iridescence.intensity = (_a = properties.iridescenceFactor) !== null && _a !== void 0 ? _a : 0;
51
- babylonMaterial.iridescence.indexOfRefraction = (_c = (_b = properties.iridescenceIor) !== null && _b !== void 0 ? _b : properties.iridescenceIOR) !== null && _c !== void 0 ? _c : 1.3;
52
- babylonMaterial.iridescence.minimumThickness = (_d = properties.iridescenceThicknessMinimum) !== null && _d !== void 0 ? _d : 100;
53
- babylonMaterial.iridescence.maximumThickness = (_e = properties.iridescenceThicknessMaximum) !== null && _e !== void 0 ? _e : 400;
48
+ babylonMaterial.iridescence.intensity = properties.iridescenceFactor ?? 0;
49
+ babylonMaterial.iridescence.indexOfRefraction = properties.iridescenceIor ?? properties.iridescenceIOR ?? 1.3;
50
+ babylonMaterial.iridescence.minimumThickness = properties.iridescenceThicknessMinimum ?? 100;
51
+ babylonMaterial.iridescence.maximumThickness = properties.iridescenceThicknessMaximum ?? 400;
54
52
  if (properties.iridescenceTexture) {
55
- promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/iridescenceTexture"), properties.iridescenceTexture, function (texture) {
56
- texture.name = "".concat(babylonMaterial.name, " (Iridescence Intensity)");
53
+ promises.push(this._loader.loadTextureInfoAsync(`${context}/iridescenceTexture`, properties.iridescenceTexture, (texture) => {
54
+ texture.name = `${babylonMaterial.name} (Iridescence Intensity)`;
57
55
  babylonMaterial.iridescence.texture = texture;
58
56
  }));
59
57
  }
60
58
  if (properties.iridescenceThicknessTexture) {
61
- promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/iridescenceThicknessTexture"), properties.iridescenceThicknessTexture, function (texture) {
62
- texture.name = "".concat(babylonMaterial.name, " (Iridescence Thickness)");
59
+ promises.push(this._loader.loadTextureInfoAsync(`${context}/iridescenceThicknessTexture`, properties.iridescenceThicknessTexture, (texture) => {
60
+ texture.name = `${babylonMaterial.name} (Iridescence Thickness)`;
63
61
  babylonMaterial.iridescence.thicknessTexture = texture;
64
62
  }));
65
63
  }
66
- return Promise.all(promises).then(function () { });
67
- };
68
- return KHR_materials_iridescence;
69
- }());
70
- export { KHR_materials_iridescence };
71
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_iridescence(loader); });
64
+ return Promise.all(promises).then(() => { });
65
+ }
66
+ }
67
+ GLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_iridescence(loader));
72
68
  //# sourceMappingURL=KHR_materials_iridescence.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_iridescence.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_iridescence.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,IAAM,IAAI,GAAG,2BAA2B,CAAC;AAEzC;;GAEG;AACH;IAkBI;;;OAGG;IACH,mCAAY,MAAkB;QArB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QASf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAA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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\n\r\nconst NAME = \"KHR_materials_iridescence\";\r\n\r\n/**\r\n * [Experimental Spec](https://github.com/KhronosGroup/glTF/pull/2027)\r\n */\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 * @param loader\r\n * @hidden\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 /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param material\r\n * @param babylonMaterial\r\n * @hidden\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\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_iridescence(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_iridescence.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_iridescence.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAEzC;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAkBlC;;;OAGG;IACH,YAAY,MAAkB;QArB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QASf,IAAI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terial } 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\n\r\nconst NAME = \"KHR_materials_iridescence\";\r\n\r\n/**\r\n * [Experimental Spec](https://github.com/KhronosGroup/glTF/pull/2027)\r\n */\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 * @param loader\r\n * @hidden\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 /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param material\r\n * @param babylonMaterial\r\n * @hidden\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\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_iridescence(loader));\r\n"]}
@@ -1,16 +1,16 @@
1
1
  import { Color3 } from "@babylonjs/core/Maths/math.color.js";
2
2
  import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
3
3
  import { GLTFLoader } from "../glTFLoader.js";
4
- var NAME = "KHR_materials_pbrSpecularGlossiness";
4
+ const NAME = "KHR_materials_pbrSpecularGlossiness";
5
5
  /**
6
6
  * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
7
7
  */
8
- var KHR_materials_pbrSpecularGlossiness = /** @class */ (function () {
8
+ export class KHR_materials_pbrSpecularGlossiness {
9
9
  /**
10
10
  * @param loader
11
11
  * @hidden
12
12
  */
13
- function KHR_materials_pbrSpecularGlossiness(loader) {
13
+ constructor(loader) {
14
14
  /**
15
15
  * The name of this extension.
16
16
  */
@@ -23,30 +23,29 @@ var KHR_materials_pbrSpecularGlossiness = /** @class */ (function () {
23
23
  this.enabled = this._loader.isExtensionUsed(NAME);
24
24
  }
25
25
  /** @hidden */
26
- KHR_materials_pbrSpecularGlossiness.prototype.dispose = function () {
26
+ dispose() {
27
27
  this._loader = null;
28
- };
28
+ }
29
29
  /**
30
30
  * @param context
31
31
  * @param material
32
32
  * @param babylonMaterial
33
33
  * @hidden
34
34
  */
35
- KHR_materials_pbrSpecularGlossiness.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
36
- var _this = this;
37
- return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
38
- var promises = new Array();
39
- promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
40
- promises.push(_this._loadSpecularGlossinessPropertiesAsync(extensionContext, material, extension, babylonMaterial));
41
- _this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial);
42
- return Promise.all(promises).then(function () { });
35
+ loadMaterialPropertiesAsync(context, material, babylonMaterial) {
36
+ return GLTFLoader.LoadExtensionAsync(context, material, this.name, (extensionContext, extension) => {
37
+ const promises = new Array();
38
+ promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
39
+ promises.push(this._loadSpecularGlossinessPropertiesAsync(extensionContext, material, extension, babylonMaterial));
40
+ this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial);
41
+ return Promise.all(promises).then(() => { });
43
42
  });
44
- };
45
- KHR_materials_pbrSpecularGlossiness.prototype._loadSpecularGlossinessPropertiesAsync = function (context, material, properties, babylonMaterial) {
43
+ }
44
+ _loadSpecularGlossinessPropertiesAsync(context, material, properties, babylonMaterial) {
46
45
  if (!(babylonMaterial instanceof PBRMaterial)) {
47
- throw new Error("".concat(context, ": Material type not supported"));
46
+ throw new Error(`${context}: Material type not supported`);
48
47
  }
49
- var promises = new Array();
48
+ const promises = new Array();
50
49
  babylonMaterial.metallic = null;
51
50
  babylonMaterial.roughness = null;
52
51
  if (properties.diffuseFactor) {
@@ -59,23 +58,21 @@ var KHR_materials_pbrSpecularGlossiness = /** @class */ (function () {
59
58
  babylonMaterial.reflectivityColor = properties.specularFactor ? Color3.FromArray(properties.specularFactor) : Color3.White();
60
59
  babylonMaterial.microSurface = properties.glossinessFactor == undefined ? 1 : properties.glossinessFactor;
61
60
  if (properties.diffuseTexture) {
62
- promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/diffuseTexture"), properties.diffuseTexture, function (texture) {
63
- texture.name = "".concat(babylonMaterial.name, " (Diffuse)");
61
+ promises.push(this._loader.loadTextureInfoAsync(`${context}/diffuseTexture`, properties.diffuseTexture, (texture) => {
62
+ texture.name = `${babylonMaterial.name} (Diffuse)`;
64
63
  babylonMaterial.albedoTexture = texture;
65
64
  }));
66
65
  }
67
66
  if (properties.specularGlossinessTexture) {
68
- promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularGlossinessTexture"), properties.specularGlossinessTexture, function (texture) {
69
- texture.name = "".concat(babylonMaterial.name, " (Specular Glossiness)");
67
+ promises.push(this._loader.loadTextureInfoAsync(`${context}/specularGlossinessTexture`, properties.specularGlossinessTexture, (texture) => {
68
+ texture.name = `${babylonMaterial.name} (Specular Glossiness)`;
70
69
  babylonMaterial.reflectivityTexture = texture;
71
70
  babylonMaterial.reflectivityTexture.hasAlpha = true;
72
71
  }));
73
72
  babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;
74
73
  }
75
- return Promise.all(promises).then(function () { });
76
- };
77
- return KHR_materials_pbrSpecularGlossiness;
78
- }());
79
- export { KHR_materials_pbrSpecularGlossiness };
80
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_pbrSpecularGlossiness(loader); });
74
+ return Promise.all(promises).then(() => { });
75
+ }
76
+ }
77
+ GLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_pbrSpecularGlossiness(loader));
81
78
  //# sourceMappingURL=KHR_materials_pbrSpecularGlossiness.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_pbrSpecularGlossiness.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,IAAM,IAAI,GAAG,qCAAqC,CAAC;AAEnD;;GAEG;AACH;IAkBI;;;OAGG;IACH,6CAAY,MAAkB;QArB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QASf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACP,qDAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACI,yEAA2B,GAAlC,UAAmC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAAlG,iBAQC;QAPG,OAAO,UAAU,CAAC,kBAAkB,CAAqC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,UAAC,gBAAgB,EAAE,SAAS;YAC/H,IAAM,QAAQ,GAAG,IAAI,KAAK,EAAgB,CAAC;YAC3C,QAAQ,CAAC,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,+BAA+B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;YAChG,QAAQ,CAAC,IAAI,CAAC,KAAI,CAAC,sCAAsC,CAAC,gBAAgB,EAAE,QAAQ,EAAE,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AAC,OAAO,CAAC,oBAAoB,CAAC,UAAG,OAAO,oBAAiB,EAAE,UAAU,CAAC,cAAc,EAAE,UAAC,OAAO;gBAC9F,OAAO,CAAC,IAAI,GAAG,UAAG,eAAe,CAAC,IAAI,eAAY,CAAC;gBACnD,eAAe,CAAC,aAAa,GAAG,OAAO,CAAC;YAC5C,CAAC,CAAC,CACL,CAAC;SACL;QAED,IAAI,UAAU,CAAC,yBAAyB,EAAE;YACtC,QAAQ,CAAC,IAAI,CACT,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,UAAG,OAAO,+BAA4B,EAAE,UAAU,CAAC,yBAAyB,EAAE,UAAC,OAAO;gBACpH,OAAO,CAAC,IAAI,GAAG,UAAG,eAAe,CAAC,IAAI,2BAAwB,CAAC;gBAC/D,eAAe,CAAC,mBAAmB,GAAG,OAAO,CAAC;gBAC9C,eAAe,CAAC,mBAAmB,CAAC,QAAQ,GAAG,IAAI,CAAC;YACxD,CAAC,CAAC,CACL,CAAC;YAEF,eAAe,CAAC,uCAAuC,GAAG,IAAI,CAAC;SAClE;QAED,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,cAAO,CAAC,CAAC,CAAC;IAChD,CAAC;IACL,0CAAC;AAAD,CAAC,AA3FD,IA2FC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,mCAAmC,CAAC,MAAM,CAAC,EAA/C,CAA+C,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { Color3 } from \"core/Maths/math.color\";\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 { IKHRMaterialsPbrSpecularGlossiness } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_pbrSpecularGlossiness\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)\r\n */\r\nexport class KHR_materials_pbrSpecularGlossiness 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 = 200;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @param loader\r\n * @hidden\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 /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param material\r\n * @param babylonMaterial\r\n * @hidden\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsPbrSpecularGlossiness>(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._loadSpecularGlossinessPropertiesAsync(extensionContext, material, extension, babylonMaterial));\r\n this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial);\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadSpecularGlossinessPropertiesAsync(context: string, material: IMaterial, properties: IKHRMaterialsPbrSpecularGlossiness, 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.metallic = null;\r\n babylonMaterial.roughness = null;\r\n\r\n if (properties.diffuseFactor) {\r\n babylonMaterial.albedoColor = Color3.FromArray(properties.diffuseFactor);\r\n babylonMaterial.alpha = properties.diffuseFactor[3];\r\n } else {\r\n babylonMaterial.albedoColor = Color3.White();\r\n }\r\n\r\n babylonMaterial.reflectivityColor = properties.specularFactor ? Color3.FromArray(properties.specularFactor) : Color3.White();\r\n babylonMaterial.microSurface = properties.glossinessFactor == undefined ? 1 : properties.glossinessFactor;\r\n\r\n if (properties.diffuseTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/diffuseTexture`, properties.diffuseTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Diffuse)`;\r\n babylonMaterial.albedoTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.specularGlossinessTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/specularGlossinessTexture`, properties.specularGlossinessTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Specular Glossiness)`;\r\n babylonMaterial.reflectivityTexture = texture;\r\n babylonMaterial.reflectivityTexture.hasAlpha = true;\r\n })\r\n );\r\n\r\n babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_pbrSpecularGlossiness(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_pbrSpecularGlossiness.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,IAAI,GAAG,qCAAqC,CAAC;AAEnD;;GAEG;AACH,MAAM,OAAO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;gBACxH,OAAO,CAAC,IAAI,GAAG,GAAG,eAAe,CAAC,IAAI,wBAAwB,CAAC;gBAC/D,eAAe,CAAC,mBAAmB,GAAG,OAAO,CAAC;gBAC9C,eAAe,CAAC,mBAAmB,CAAC,QAAQ,GAAG,IAAI,CAAC;YACxD,CAAC,CAAC,CACL,CAAC;YAEF,eAAe,CAAC,uCAAuC,GAAG,IAAI,CAAC;SAClE;QAED,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,mCAAmC,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { Color3 } from \"core/Maths/math.color\";\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 { IKHRMaterialsPbrSpecularGlossiness } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_pbrSpecularGlossiness\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)\r\n */\r\nexport class KHR_materials_pbrSpecularGlossiness 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 = 200;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @param loader\r\n * @hidden\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 /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param material\r\n * @param babylonMaterial\r\n * @hidden\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsPbrSpecularGlossiness>(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._loadSpecularGlossinessPropertiesAsync(extensionContext, material, extension, babylonMaterial));\r\n this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial);\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadSpecularGlossinessPropertiesAsync(context: string, material: IMaterial, properties: IKHRMaterialsPbrSpecularGlossiness, 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.metallic = null;\r\n babylonMaterial.roughness = null;\r\n\r\n if (properties.diffuseFactor) {\r\n babylonMaterial.albedoColor = Color3.FromArray(properties.diffuseFactor);\r\n babylonMaterial.alpha = properties.diffuseFactor[3];\r\n } else {\r\n babylonMaterial.albedoColor = Color3.White();\r\n }\r\n\r\n babylonMaterial.reflectivityColor = properties.specularFactor ? Color3.FromArray(properties.specularFactor) : Color3.White();\r\n babylonMaterial.microSurface = properties.glossinessFactor == undefined ? 1 : properties.glossinessFactor;\r\n\r\n if (properties.diffuseTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/diffuseTexture`, properties.diffuseTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Diffuse)`;\r\n babylonMaterial.albedoTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.specularGlossinessTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/specularGlossinessTexture`, properties.specularGlossinessTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Specular Glossiness)`;\r\n babylonMaterial.reflectivityTexture = texture;\r\n babylonMaterial.reflectivityTexture.hasAlpha = true;\r\n })\r\n );\r\n\r\n babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_pbrSpecularGlossiness(loader));\r\n"]}
@@ -1,17 +1,17 @@
1
1
  import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
2
  import { GLTFLoader } from "../glTFLoader.js";
3
3
  import { Color3 } from "@babylonjs/core/Maths/math.color.js";
4
- var NAME = "KHR_materials_sheen";
4
+ const NAME = "KHR_materials_sheen";
5
5
  /**
6
6
  * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
7
7
  * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
8
8
  */
9
- var KHR_materials_sheen = /** @class */ (function () {
9
+ export class KHR_materials_sheen {
10
10
  /**
11
11
  * @param loader
12
12
  * @hidden
13
13
  */
14
- function KHR_materials_sheen(loader) {
14
+ constructor(loader) {
15
15
  /**
16
16
  * The name of this extension.
17
17
  */
@@ -24,29 +24,28 @@ var KHR_materials_sheen = /** @class */ (function () {
24
24
  this.enabled = this._loader.isExtensionUsed(NAME);
25
25
  }
26
26
  /** @hidden */
27
- KHR_materials_sheen.prototype.dispose = function () {
27
+ dispose() {
28
28
  this._loader = null;
29
- };
29
+ }
30
30
  /**
31
31
  * @param context
32
32
  * @param material
33
33
  * @param babylonMaterial
34
34
  * @hidden
35
35
  */
36
- KHR_materials_sheen.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
37
- var _this = this;
38
- return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
39
- var promises = new Array();
40
- promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
41
- promises.push(_this._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial));
42
- return Promise.all(promises).then(function () { });
36
+ loadMaterialPropertiesAsync(context, material, babylonMaterial) {
37
+ return GLTFLoader.LoadExtensionAsync(context, material, this.name, (extensionContext, extension) => {
38
+ const promises = new Array();
39
+ promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
40
+ promises.push(this._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial));
41
+ return Promise.all(promises).then(() => { });
43
42
  });
44
- };
45
- KHR_materials_sheen.prototype._loadSheenPropertiesAsync = function (context, properties, babylonMaterial) {
43
+ }
44
+ _loadSheenPropertiesAsync(context, properties, babylonMaterial) {
46
45
  if (!(babylonMaterial instanceof PBRMaterial)) {
47
- throw new Error("".concat(context, ": Material type not supported"));
46
+ throw new Error(`${context}: Material type not supported`);
48
47
  }
49
- var promises = new Array();
48
+ const promises = new Array();
50
49
  babylonMaterial.sheen.isEnabled = true;
51
50
  babylonMaterial.sheen.intensity = 1;
52
51
  if (properties.sheenColorFactor != undefined) {
@@ -56,8 +55,8 @@ var KHR_materials_sheen = /** @class */ (function () {
56
55
  babylonMaterial.sheen.color = Color3.Black();
57
56
  }
58
57
  if (properties.sheenColorTexture) {
59
- promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenColorTexture"), properties.sheenColorTexture, function (texture) {
60
- texture.name = "".concat(babylonMaterial.name, " (Sheen Color)");
58
+ promises.push(this._loader.loadTextureInfoAsync(`${context}/sheenColorTexture`, properties.sheenColorTexture, (texture) => {
59
+ texture.name = `${babylonMaterial.name} (Sheen Color)`;
61
60
  babylonMaterial.sheen.texture = texture;
62
61
  }));
63
62
  }
@@ -69,17 +68,15 @@ var KHR_materials_sheen = /** @class */ (function () {
69
68
  }
70
69
  if (properties.sheenRoughnessTexture) {
71
70
  properties.sheenRoughnessTexture.nonColorData = true;
72
- promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenRoughnessTexture"), properties.sheenRoughnessTexture, function (texture) {
73
- texture.name = "".concat(babylonMaterial.name, " (Sheen Roughness)");
71
+ promises.push(this._loader.loadTextureInfoAsync(`${context}/sheenRoughnessTexture`, properties.sheenRoughnessTexture, (texture) => {
72
+ texture.name = `${babylonMaterial.name} (Sheen Roughness)`;
74
73
  babylonMaterial.sheen.textureRoughness = texture;
75
74
  }));
76
75
  }
77
76
  babylonMaterial.sheen.albedoScaling = true;
78
77
  babylonMaterial.sheen.useRoughnessFromMainTexture = false;
79
- return Promise.all(promises).then(function () { });
80
- };
81
- return KHR_materials_sheen;
82
- }());
83
- export { KHR_materials_sheen };
84
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_sheen(loader); });
78
+ return Promise.all(promises).then(() => { });
79
+ }
80
+ }
81
+ GLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_sheen(loader));
85
82
  //# sourceMappingURL=KHR_materials_sheen.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_sheen.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_sheen.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAG/C,IAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC;;;GAGG;AACH;IAkBI;;;OAGG;IACH,6BAAY,MAAkB;QArB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QASf,IAAI,CAAC,OAAO,GAAG,MAAM,CA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AAI,CAAC,cAAO,CAAC,CAAC,CAAC;IAChD,CAAC;IACL,0BAAC;AAAD,CAAC,AA7FD,IA6FC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAA/B,CAA+B,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\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 { IKHRMaterialsSheen } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_sheen\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)\r\n * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)\r\n */\r\nexport class KHR_materials_sheen 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 * @param loader\r\n * @hidden\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 /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param material\r\n * @param babylonMaterial\r\n * @hidden\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsSheen>(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._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadSheenPropertiesAsync(context: string, properties: IKHRMaterialsSheen, 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.sheen.isEnabled = true;\r\n babylonMaterial.sheen.intensity = 1;\r\n\r\n if (properties.sheenColorFactor != undefined) {\r\n babylonMaterial.sheen.color = Color3.FromArray(properties.sheenColorFactor);\r\n } else {\r\n babylonMaterial.sheen.color = Color3.Black();\r\n }\r\n\r\n if (properties.sheenColorTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/sheenColorTexture`, properties.sheenColorTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Sheen Color)`;\r\n babylonMaterial.sheen.texture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.sheenRoughnessFactor !== undefined) {\r\n babylonMaterial.sheen.roughness = properties.sheenRoughnessFactor;\r\n } else {\r\n babylonMaterial.sheen.roughness = 0;\r\n }\r\n\r\n if (properties.sheenRoughnessTexture) {\r\n (properties.sheenRoughnessTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/sheenRoughnessTexture`, properties.sheenRoughnessTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Sheen Roughness)`;\r\n babylonMaterial.sheen.textureRoughness = texture;\r\n })\r\n );\r\n }\r\n\r\n babylonMaterial.sheen.albedoScaling = true;\r\n babylonMaterial.sheen.useRoughnessFromMainTexture = false;\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_sheen(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_sheen.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_sheen.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAG/C,MAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAkB5B;;;OAGG;IACH,YAAY,MAAkB;QArB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QASf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACP,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACI,2BAA2B,CAAC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAC9F,OAAO,UAAU,CAAC,kBAAkB,CAAqB,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,EAAE;YACnH,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,yBAAyB,CAAC,gBAAgB,EAAE,SAAS,EAAE,eAAe,CA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CAAC,SAAS,GAAG,CAAC,CAAC;SACvC;QAED,IAAI,UAAU,CAAC,qBAAqB,EAAE;YACjC,UAAU,CAAC,qBAAsC,CAAC,YAAY,GAAG,IAAI,CAAC;YACvE,QAAQ,CAAC,IAAI,CACT,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,wBAAwB,EAAE,UAAU,CAAC,qBAAqB,EAAE,CAAC,OAAO,EAAE,EAAE;gBAChH,OAAO,CAAC,IAAI,GAAG,GAAG,eAAe,CAAC,IAAI,oBAAoB,CAAC;gBAC3D,eAAe,CAAC,KAAK,CAAC,gBAAgB,GAAG,OAAO,CAAC;YACrD,CAAC,CAAC,CACL,CAAC;SACL;QAED,eAAe,CAAC,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;QAC3C,eAAe,CAAC,KAAK,CAAC,2BAA2B,GAAG,KAAK,CAAC;QAE1D,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,mBAAmB,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\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 { IKHRMaterialsSheen } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_sheen\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)\r\n * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)\r\n */\r\nexport class KHR_materials_sheen 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 * @param loader\r\n * @hidden\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 /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param material\r\n * @param babylonMaterial\r\n * @hidden\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsSheen>(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._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadSheenPropertiesAsync(context: string, properties: IKHRMaterialsSheen, 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.sheen.isEnabled = true;\r\n babylonMaterial.sheen.intensity = 1;\r\n\r\n if (properties.sheenColorFactor != undefined) {\r\n babylonMaterial.sheen.color = Color3.FromArray(properties.sheenColorFactor);\r\n } else {\r\n babylonMaterial.sheen.color = Color3.Black();\r\n }\r\n\r\n if (properties.sheenColorTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/sheenColorTexture`, properties.sheenColorTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Sheen Color)`;\r\n babylonMaterial.sheen.texture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.sheenRoughnessFactor !== undefined) {\r\n babylonMaterial.sheen.roughness = properties.sheenRoughnessFactor;\r\n } else {\r\n babylonMaterial.sheen.roughness = 0;\r\n }\r\n\r\n if (properties.sheenRoughnessTexture) {\r\n (properties.sheenRoughnessTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/sheenRoughnessTexture`, properties.sheenRoughnessTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Sheen Roughness)`;\r\n babylonMaterial.sheen.textureRoughness = texture;\r\n })\r\n );\r\n }\r\n\r\n babylonMaterial.sheen.albedoScaling = true;\r\n babylonMaterial.sheen.useRoughnessFromMainTexture = false;\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_sheen(loader));\r\n"]}
@@ -1,16 +1,16 @@
1
1
  import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
2
  import { GLTFLoader } from "../glTFLoader.js";
3
3
  import { Color3 } from "@babylonjs/core/Maths/math.color.js";
4
- var NAME = "KHR_materials_specular";
4
+ const NAME = "KHR_materials_specular";
5
5
  /**
6
6
  * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular)
7
7
  */
8
- var KHR_materials_specular = /** @class */ (function () {
8
+ export class KHR_materials_specular {
9
9
  /**
10
10
  * @param loader
11
11
  * @hidden
12
12
  */
13
- function KHR_materials_specular(loader) {
13
+ constructor(loader) {
14
14
  /**
15
15
  * The name of this extension.
16
16
  */
@@ -23,29 +23,28 @@ var KHR_materials_specular = /** @class */ (function () {
23
23
  this.enabled = this._loader.isExtensionUsed(NAME);
24
24
  }
25
25
  /** @hidden */
26
- KHR_materials_specular.prototype.dispose = function () {
26
+ dispose() {
27
27
  this._loader = null;
28
- };
28
+ }
29
29
  /**
30
30
  * @param context
31
31
  * @param material
32
32
  * @param babylonMaterial
33
33
  * @hidden
34
34
  */
35
- KHR_materials_specular.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
36
- var _this = this;
37
- return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
38
- var promises = new Array();
39
- promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
40
- promises.push(_this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial));
41
- return Promise.all(promises).then(function () { });
35
+ loadMaterialPropertiesAsync(context, material, babylonMaterial) {
36
+ return GLTFLoader.LoadExtensionAsync(context, material, this.name, (extensionContext, extension) => {
37
+ const promises = new Array();
38
+ promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
39
+ promises.push(this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial));
40
+ return Promise.all(promises).then(() => { });
42
41
  });
43
- };
44
- KHR_materials_specular.prototype._loadSpecularPropertiesAsync = function (context, properties, babylonMaterial) {
42
+ }
43
+ _loadSpecularPropertiesAsync(context, properties, babylonMaterial) {
45
44
  if (!(babylonMaterial instanceof PBRMaterial)) {
46
- throw new Error("".concat(context, ": Material type not supported"));
45
+ throw new Error(`${context}: Material type not supported`);
47
46
  }
48
- var promises = new Array();
47
+ const promises = new Array();
49
48
  if (properties.specularFactor !== undefined) {
50
49
  babylonMaterial.metallicF0Factor = properties.specularFactor;
51
50
  }
@@ -54,22 +53,20 @@ var KHR_materials_specular = /** @class */ (function () {
54
53
  }
55
54
  if (properties.specularTexture) {
56
55
  properties.specularTexture.nonColorData = true;
57
- promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularTexture"), properties.specularTexture, function (texture) {
58
- texture.name = "".concat(babylonMaterial.name, " (Specular F0 Strength)");
56
+ promises.push(this._loader.loadTextureInfoAsync(`${context}/specularTexture`, properties.specularTexture, (texture) => {
57
+ texture.name = `${babylonMaterial.name} (Specular F0 Strength)`;
59
58
  babylonMaterial.metallicReflectanceTexture = texture;
60
59
  babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true;
61
60
  }));
62
61
  }
63
62
  if (properties.specularColorTexture) {
64
- promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularColorTexture"), properties.specularColorTexture, function (texture) {
65
- texture.name = "".concat(babylonMaterial.name, " (Specular F0 Color)");
63
+ promises.push(this._loader.loadTextureInfoAsync(`${context}/specularColorTexture`, properties.specularColorTexture, (texture) => {
64
+ texture.name = `${babylonMaterial.name} (Specular F0 Color)`;
66
65
  babylonMaterial.reflectanceTexture = texture;
67
66
  }));
68
67
  }
69
- return Promise.all(promises).then(function () { });
70
- };
71
- return KHR_materials_specular;
72
- }());
73
- export { KHR_materials_specular };
74
- GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_specular(loader); });
68
+ return Promise.all(promises).then(() => { });
69
+ }
70
+ }
71
+ GLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_specular(loader));
75
72
  //# sourceMappingURL=KHR_materials_specular.js.map