@babylonjs/serializers 9.13.0 → 9.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/3MF/core/model/pure.d.ts +8 -0
  2. package/3MF/core/model/pure.js +9 -0
  3. package/3MF/core/model/pure.js.map +1 -0
  4. package/3MF/core/pure.d.ts +3 -0
  5. package/3MF/core/pure.js +5 -0
  6. package/3MF/core/pure.js.map +1 -0
  7. package/3MF/core/xml/pure.d.ts +7 -0
  8. package/3MF/core/xml/pure.js +8 -0
  9. package/3MF/core/xml/pure.js.map +1 -0
  10. package/3MF/pure.d.ts +4 -0
  11. package/3MF/pure.js +6 -0
  12. package/3MF/pure.js.map +1 -0
  13. package/BVH/pure.d.ts +2 -0
  14. package/BVH/pure.js +3 -0
  15. package/BVH/pure.js.map +1 -0
  16. package/OBJ/pure.d.ts +2 -0
  17. package/OBJ/pure.js +3 -0
  18. package/OBJ/pure.js.map +1 -0
  19. package/USDZ/pure.d.ts +2 -0
  20. package/USDZ/pure.js +4 -0
  21. package/USDZ/pure.js.map +1 -0
  22. package/glTF/2.0/Extensions/EXT_lights_area.d.ts +3 -37
  23. package/glTF/2.0/Extensions/EXT_lights_area.js +5 -130
  24. package/glTF/2.0/Extensions/EXT_lights_area.js.map +1 -1
  25. package/glTF/2.0/Extensions/EXT_lights_area.pure.d.ts +44 -0
  26. package/glTF/2.0/Extensions/EXT_lights_area.pure.js +145 -0
  27. package/glTF/2.0/Extensions/EXT_lights_area.pure.js.map +1 -0
  28. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +4 -38
  29. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +6 -138
  30. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  31. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.pure.d.ts +44 -0
  32. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.pure.js +151 -0
  33. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.pure.js.map +1 -0
  34. package/glTF/2.0/Extensions/EXT_texture_avif.d.ts +3 -15
  35. package/glTF/2.0/Extensions/EXT_texture_avif.js +5 -38
  36. package/glTF/2.0/Extensions/EXT_texture_avif.js.map +1 -1
  37. package/glTF/2.0/Extensions/EXT_texture_avif.pure.d.ts +27 -0
  38. package/glTF/2.0/Extensions/EXT_texture_avif.pure.js +58 -0
  39. package/glTF/2.0/Extensions/EXT_texture_avif.pure.js.map +1 -0
  40. package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +3 -14
  41. package/glTF/2.0/Extensions/EXT_texture_webp.js +5 -37
  42. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
  43. package/glTF/2.0/Extensions/EXT_texture_webp.pure.d.ts +26 -0
  44. package/glTF/2.0/Extensions/EXT_texture_webp.pure.js +57 -0
  45. package/glTF/2.0/Extensions/EXT_texture_webp.pure.js.map +1 -0
  46. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +3 -30
  47. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +5 -128
  48. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  49. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.d.ts +37 -0
  50. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.js +143 -0
  51. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.js.map +1 -0
  52. package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +3 -37
  53. package/glTF/2.0/Extensions/KHR_lights_punctual.js +5 -142
  54. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  55. package/glTF/2.0/Extensions/KHR_lights_punctual.pure.d.ts +44 -0
  56. package/glTF/2.0/Extensions/KHR_lights_punctual.pure.js +157 -0
  57. package/glTF/2.0/Extensions/KHR_lights_punctual.pure.js.map +1 -0
  58. package/glTF/2.0/Extensions/KHR_materials_anisotropy.d.ts +3 -30
  59. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js +5 -177
  60. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -1
  61. package/glTF/2.0/Extensions/KHR_materials_anisotropy.pure.d.ts +37 -0
  62. package/glTF/2.0/Extensions/KHR_materials_anisotropy.pure.js +192 -0
  63. package/glTF/2.0/Extensions/KHR_materials_anisotropy.pure.js.map +1 -0
  64. package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +3 -30
  65. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +5 -251
  66. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  67. package/glTF/2.0/Extensions/KHR_materials_clearcoat.pure.d.ts +37 -0
  68. package/glTF/2.0/Extensions/KHR_materials_clearcoat.pure.js +266 -0
  69. package/glTF/2.0/Extensions/KHR_materials_clearcoat.pure.js.map +1 -0
  70. package/glTF/2.0/Extensions/KHR_materials_coat.d.ts +3 -30
  71. package/glTF/2.0/Extensions/KHR_materials_coat.js +5 -380
  72. package/glTF/2.0/Extensions/KHR_materials_coat.js.map +1 -1
  73. package/glTF/2.0/Extensions/KHR_materials_coat.pure.d.ts +37 -0
  74. package/glTF/2.0/Extensions/KHR_materials_coat.pure.js +395 -0
  75. package/glTF/2.0/Extensions/KHR_materials_coat.pure.js.map +1 -0
  76. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.d.ts +3 -22
  77. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js +5 -75
  78. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js.map +1 -1
  79. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.pure.d.ts +29 -0
  80. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.pure.js +90 -0
  81. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.pure.js.map +1 -0
  82. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.d.ts +3 -38
  83. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +5 -115
  84. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
  85. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.pure.d.ts +45 -0
  86. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.pure.js +130 -0
  87. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.pure.js.map +1 -0
  88. package/glTF/2.0/Extensions/KHR_materials_dispersion.d.ts +3 -29
  89. package/glTF/2.0/Extensions/KHR_materials_dispersion.js +5 -60
  90. package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
  91. package/glTF/2.0/Extensions/KHR_materials_dispersion.pure.d.ts +36 -0
  92. package/glTF/2.0/Extensions/KHR_materials_dispersion.pure.js +75 -0
  93. package/glTF/2.0/Extensions/KHR_materials_dispersion.pure.js.map +1 -0
  94. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +3 -25
  95. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +5 -54
  96. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
  97. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.pure.d.ts +32 -0
  98. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.pure.js +69 -0
  99. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.pure.js.map +1 -0
  100. package/glTF/2.0/Extensions/KHR_materials_fuzz.d.ts +3 -30
  101. package/glTF/2.0/Extensions/KHR_materials_fuzz.js +5 -191
  102. package/glTF/2.0/Extensions/KHR_materials_fuzz.js.map +1 -1
  103. package/glTF/2.0/Extensions/KHR_materials_fuzz.pure.d.ts +37 -0
  104. package/glTF/2.0/Extensions/KHR_materials_fuzz.pure.js +206 -0
  105. package/glTF/2.0/Extensions/KHR_materials_fuzz.pure.js.map +1 -0
  106. package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +3 -27
  107. package/glTF/2.0/Extensions/KHR_materials_ior.js +5 -67
  108. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  109. package/glTF/2.0/Extensions/KHR_materials_ior.pure.d.ts +34 -0
  110. package/glTF/2.0/Extensions/KHR_materials_ior.pure.js +81 -0
  111. package/glTF/2.0/Extensions/KHR_materials_ior.pure.js.map +1 -0
  112. package/glTF/2.0/Extensions/KHR_materials_iridescence.d.ts +3 -22
  113. package/glTF/2.0/Extensions/KHR_materials_iridescence.js +5 -100
  114. package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
  115. package/glTF/2.0/Extensions/KHR_materials_iridescence.pure.d.ts +29 -0
  116. package/glTF/2.0/Extensions/KHR_materials_iridescence.pure.js +115 -0
  117. package/glTF/2.0/Extensions/KHR_materials_iridescence.pure.js.map +1 -0
  118. package/glTF/2.0/Extensions/KHR_materials_openpbr.d.ts +3 -25
  119. package/glTF/2.0/Extensions/KHR_materials_openpbr.js +5 -41
  120. package/glTF/2.0/Extensions/KHR_materials_openpbr.js.map +1 -1
  121. package/glTF/2.0/Extensions/KHR_materials_openpbr.pure.d.ts +32 -0
  122. package/glTF/2.0/Extensions/KHR_materials_openpbr.pure.js +56 -0
  123. package/glTF/2.0/Extensions/KHR_materials_openpbr.pure.js.map +1 -0
  124. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +3 -22
  125. package/glTF/2.0/Extensions/KHR_materials_sheen.js +5 -63
  126. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  127. package/glTF/2.0/Extensions/KHR_materials_sheen.pure.d.ts +29 -0
  128. package/glTF/2.0/Extensions/KHR_materials_sheen.pure.js +78 -0
  129. package/glTF/2.0/Extensions/KHR_materials_sheen.pure.js.map +1 -0
  130. package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +3 -39
  131. package/glTF/2.0/Extensions/KHR_materials_specular.js +5 -123
  132. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  133. package/glTF/2.0/Extensions/KHR_materials_specular.pure.d.ts +46 -0
  134. package/glTF/2.0/Extensions/KHR_materials_specular.pure.js +138 -0
  135. package/glTF/2.0/Extensions/KHR_materials_specular.pure.js.map +1 -0
  136. package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +3 -38
  137. package/glTF/2.0/Extensions/KHR_materials_transmission.js +5 -145
  138. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  139. package/glTF/2.0/Extensions/KHR_materials_transmission.pure.d.ts +45 -0
  140. package/glTF/2.0/Extensions/KHR_materials_transmission.pure.js +160 -0
  141. package/glTF/2.0/Extensions/KHR_materials_transmission.pure.js.map +1 -0
  142. package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +3 -18
  143. package/glTF/2.0/Extensions/KHR_materials_unlit.js +5 -43
  144. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  145. package/glTF/2.0/Extensions/KHR_materials_unlit.pure.d.ts +25 -0
  146. package/glTF/2.0/Extensions/KHR_materials_unlit.pure.js +58 -0
  147. package/glTF/2.0/Extensions/KHR_materials_unlit.pure.js.map +1 -0
  148. package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +3 -38
  149. package/glTF/2.0/Extensions/KHR_materials_volume.js +5 -169
  150. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  151. package/glTF/2.0/Extensions/KHR_materials_volume.pure.d.ts +45 -0
  152. package/glTF/2.0/Extensions/KHR_materials_volume.pure.js +184 -0
  153. package/glTF/2.0/Extensions/KHR_materials_volume.pure.js.map +1 -0
  154. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.d.ts +3 -38
  155. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js +5 -130
  156. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js.map +1 -1
  157. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.d.ts +45 -0
  158. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.js +145 -0
  159. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.js.map +1 -0
  160. package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +3 -14
  161. package/glTF/2.0/Extensions/KHR_texture_basisu.js +5 -37
  162. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
  163. package/glTF/2.0/Extensions/KHR_texture_basisu.pure.d.ts +26 -0
  164. package/glTF/2.0/Extensions/KHR_texture_basisu.pure.js +57 -0
  165. package/glTF/2.0/Extensions/KHR_texture_basisu.pure.js.map +1 -0
  166. package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +3 -19
  167. package/glTF/2.0/Extensions/KHR_texture_transform.js +5 -90
  168. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  169. package/glTF/2.0/Extensions/KHR_texture_transform.pure.d.ts +26 -0
  170. package/glTF/2.0/Extensions/KHR_texture_transform.pure.js +105 -0
  171. package/glTF/2.0/Extensions/KHR_texture_transform.pure.js.map +1 -0
  172. package/glTF/2.0/Extensions/pure.d.ts +26 -0
  173. package/glTF/2.0/Extensions/pure.js +27 -0
  174. package/glTF/2.0/Extensions/pure.js.map +1 -0
  175. package/glTF/2.0/pure.d.ts +5 -0
  176. package/glTF/2.0/pure.js +7 -0
  177. package/glTF/2.0/pure.js.map +1 -0
  178. package/glTF/pure.d.ts +3 -0
  179. package/glTF/pure.js +5 -0
  180. package/glTF/pure.js.map +1 -0
  181. package/package.json +30 -4
  182. package/pure.d.ts +7 -0
  183. package/pure.js +9 -0
  184. package/pure.js.map +1 -0
  185. package/stl/pure.d.ts +2 -0
  186. package/stl/pure.js +3 -0
  187. package/stl/pure.js.map +1 -0
@@ -0,0 +1,29 @@
1
+ import { type IMaterial } from "babylonjs-gltf2interface";
2
+ import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
3
+ import { GLTFExporter } from "../glTFExporter.js";
4
+ import { type Material } from "@babylonjs/core/Materials/material.js";
5
+ import { type BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
6
+ /**
7
+ * @internal
8
+ */
9
+ export declare class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
10
+ /** Name of this extension */
11
+ readonly name = "KHR_materials_sheen";
12
+ /** Defines whether this extension is enabled */
13
+ enabled: boolean;
14
+ /** Defines whether this extension is required */
15
+ required: boolean;
16
+ private _wasUsed;
17
+ private _exporter;
18
+ constructor(exporter: GLTFExporter);
19
+ dispose(): void;
20
+ /** @internal */
21
+ get wasUsed(): boolean;
22
+ postExportMaterialAdditionalTexturesAsync(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
23
+ postExportMaterialAsync(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
24
+ }
25
+ /**
26
+ * Registers the KHR_materials_sheen glTF serializer extension with the {@link GLTFExporter}.
27
+ * Safe to call multiple times; only the first call has an effect.
28
+ */
29
+ export declare function RegisterKHR_materials_sheen(): void;
@@ -0,0 +1,78 @@
1
+ import { GLTFExporter } from "../glTFExporter.js";
2
+ import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.pure.js";
3
+ const NAME = "KHR_materials_sheen";
4
+ /**
5
+ * @internal
6
+ */
7
+ // eslint-disable-next-line @typescript-eslint/naming-convention
8
+ export class KHR_materials_sheen {
9
+ constructor(exporter) {
10
+ /** Name of this extension */
11
+ this.name = NAME;
12
+ /** Defines whether this extension is enabled */
13
+ this.enabled = true;
14
+ /** Defines whether this extension is required */
15
+ this.required = false;
16
+ this._wasUsed = false;
17
+ this._exporter = exporter;
18
+ }
19
+ dispose() { }
20
+ /** @internal */
21
+ get wasUsed() {
22
+ return this._wasUsed;
23
+ }
24
+ async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
25
+ if (babylonMaterial instanceof PBRMaterial) {
26
+ if (babylonMaterial.sheen.isEnabled && babylonMaterial.sheen.texture) {
27
+ return [babylonMaterial.sheen.texture];
28
+ }
29
+ }
30
+ return [];
31
+ }
32
+ async postExportMaterialAsync(context, node, babylonMaterial) {
33
+ return await new Promise((resolve) => {
34
+ if (babylonMaterial instanceof PBRMaterial) {
35
+ if (!babylonMaterial.sheen.isEnabled) {
36
+ resolve(node);
37
+ return;
38
+ }
39
+ this._wasUsed = true;
40
+ if (node.extensions == null) {
41
+ node.extensions = {};
42
+ }
43
+ const sheenInfo = {
44
+ sheenColorFactor: babylonMaterial.sheen.color.asArray(),
45
+ sheenRoughnessFactor: babylonMaterial.sheen.roughness ?? 0,
46
+ };
47
+ if (sheenInfo.sheenColorTexture !== null || sheenInfo.sheenRoughnessTexture !== null) {
48
+ this._exporter._materialNeedsUVsSet.add(babylonMaterial);
49
+ }
50
+ if (babylonMaterial.sheen.texture) {
51
+ sheenInfo.sheenColorTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.sheen.texture) ?? undefined;
52
+ }
53
+ if (babylonMaterial.sheen.textureRoughness && !babylonMaterial.sheen.useRoughnessFromMainTexture) {
54
+ sheenInfo.sheenRoughnessTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.sheen.textureRoughness) ?? undefined;
55
+ }
56
+ else if (babylonMaterial.sheen.texture && babylonMaterial.sheen.useRoughnessFromMainTexture) {
57
+ sheenInfo.sheenRoughnessTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.sheen.texture) ?? undefined;
58
+ }
59
+ node.extensions[NAME] = sheenInfo;
60
+ }
61
+ resolve(node);
62
+ });
63
+ }
64
+ }
65
+ let _Registered = false;
66
+ /**
67
+ * Registers the KHR_materials_sheen glTF serializer extension with the {@link GLTFExporter}.
68
+ * Safe to call multiple times; only the first call has an effect.
69
+ */
70
+ // eslint-disable-next-line @typescript-eslint/naming-convention
71
+ export function RegisterKHR_materials_sheen() {
72
+ if (_Registered) {
73
+ return;
74
+ }
75
+ _Registered = true;
76
+ GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_sheen(exporter));
77
+ }
78
+ //# sourceMappingURL=KHR_materials_sheen.pure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_materials_sheen.pure.js","sourceRoot":"","sources":["../../../../../../dev/serializers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AC,IAAI,CAAC,GAAG,SAAS,CAAC;YACtC,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,gEAAgE;AAChE,MAAM,UAAU,2BAA2B;IACvC,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["import { type IMaterial, type IKHRMaterialsSheen } from \"babylonjs-gltf2interface\";\r\nimport { type IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport { type Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial.pure\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\nconst NAME = \"KHR_materials_sheen\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_sheen implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _wasUsed = false;\r\n\r\n private _exporter: GLTFExporter;\r\n\r\n constructor(exporter: GLTFExporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n public async postExportMaterialAdditionalTexturesAsync(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]> {\r\n if (babylonMaterial instanceof PBRMaterial) {\r\n if (babylonMaterial.sheen.isEnabled && babylonMaterial.sheen.texture) {\r\n return [babylonMaterial.sheen.texture];\r\n }\r\n }\r\n\r\n return [];\r\n }\r\n\r\n public async postExportMaterialAsync(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return await new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRMaterial) {\r\n if (!babylonMaterial.sheen.isEnabled) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n if (node.extensions == null) {\r\n node.extensions = {};\r\n }\r\n const sheenInfo: IKHRMaterialsSheen = {\r\n sheenColorFactor: babylonMaterial.sheen.color.asArray(),\r\n sheenRoughnessFactor: babylonMaterial.sheen.roughness ?? 0,\r\n };\r\n\r\n if (sheenInfo.sheenColorTexture !== null || sheenInfo.sheenRoughnessTexture !== null) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n if (babylonMaterial.sheen.texture) {\r\n sheenInfo.sheenColorTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.sheen.texture) ?? undefined;\r\n }\r\n\r\n if (babylonMaterial.sheen.textureRoughness && !babylonMaterial.sheen.useRoughnessFromMainTexture) {\r\n sheenInfo.sheenRoughnessTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.sheen.textureRoughness) ?? undefined;\r\n } else if (babylonMaterial.sheen.texture && babylonMaterial.sheen.useRoughnessFromMainTexture) {\r\n sheenInfo.sheenRoughnessTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.sheen.texture) ?? undefined;\r\n }\r\n\r\n node.extensions[NAME] = sheenInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Registers the KHR_materials_sheen glTF serializer extension with the {@link GLTFExporter}.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function RegisterKHR_materials_sheen(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_sheen(exporter));\r\n}\r\n"]}
@@ -1,41 +1,5 @@
1
- import { type IMaterial } from "babylonjs-gltf2interface";
2
- import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
3
- import { GLTFExporter } from "../glTFExporter.js";
4
- import { type Material } from "@babylonjs/core/Materials/material.js";
5
- import { type BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
6
1
  /**
7
- * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md)
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./KHR_materials_specular.pure" for tree-shakeable, side-effect-free usage.
8
4
  */
9
- export declare class KHR_materials_specular implements IGLTFExporterExtensionV2 {
10
- /** Name of this extension */
11
- readonly name = "KHR_materials_specular";
12
- /** Defines whether this extension is enabled */
13
- enabled: boolean;
14
- /** Defines whether this extension is required */
15
- required: boolean;
16
- private _exporter;
17
- private _wasUsed;
18
- constructor(exporter: GLTFExporter);
19
- /** Dispose */
20
- dispose(): void;
21
- /** @internal */
22
- get wasUsed(): boolean;
23
- /**
24
- * After exporting a material, deal with the additional textures
25
- * @param context GLTF context of the material
26
- * @param node exported GLTF node
27
- * @param babylonMaterial corresponding babylon material
28
- * @returns array of additional textures to export
29
- */
30
- postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
31
- private _isExtensionEnabled;
32
- private _hasTexturesExtension;
33
- /**
34
- * After exporting a material
35
- * @param context GLTF context of the material
36
- * @param node exported GLTF node
37
- * @param babylonMaterial corresponding babylon material
38
- * @returns promise, resolves with the material
39
- */
40
- postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
41
- }
5
+ export * from "./KHR_materials_specular.pure.js";
@@ -1,126 +1,8 @@
1
- import { GLTFExporter } from "../glTFExporter.js";
2
- import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
3
- import { OpenPBRMaterial } from "@babylonjs/core/Materials/PBR/openpbrMaterial.js";
4
- const NAME = "KHR_materials_specular";
5
1
  /**
6
- * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md)
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./KHR_materials_specular.pure" for tree-shakeable, side-effect-free usage.
7
4
  */
8
- // eslint-disable-next-line @typescript-eslint/naming-convention
9
- export class KHR_materials_specular {
10
- constructor(exporter) {
11
- /** Name of this extension */
12
- this.name = NAME;
13
- /** Defines whether this extension is enabled */
14
- this.enabled = true;
15
- /** Defines whether this extension is required */
16
- this.required = false;
17
- this._wasUsed = false;
18
- this._exporter = exporter;
19
- }
20
- /** Dispose */
21
- dispose() { }
22
- /** @internal */
23
- get wasUsed() {
24
- return this._wasUsed;
25
- }
26
- /**
27
- * After exporting a material, deal with the additional textures
28
- * @param context GLTF context of the material
29
- * @param node exported GLTF node
30
- * @param babylonMaterial corresponding babylon material
31
- * @returns array of additional textures to export
32
- */
33
- async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
34
- const additionalTextures = [];
35
- if (babylonMaterial instanceof PBRMaterial) {
36
- if (this._isExtensionEnabled(babylonMaterial)) {
37
- if (babylonMaterial.metallicReflectanceTexture) {
38
- additionalTextures.push(babylonMaterial.metallicReflectanceTexture);
39
- }
40
- if (babylonMaterial.reflectanceTexture) {
41
- additionalTextures.push(babylonMaterial.reflectanceTexture);
42
- }
43
- return additionalTextures;
44
- }
45
- }
46
- return additionalTextures;
47
- }
48
- _isExtensionEnabled(mat) {
49
- // This extension must not be used on a material that also uses KHR_materials_unlit
50
- if (mat.unlit) {
51
- return false;
52
- }
53
- return ((mat.metallicF0Factor != undefined && mat.metallicF0Factor != 1.0) ||
54
- (mat.metallicReflectanceColor != undefined && !mat.metallicReflectanceColor.equalsFloats(1.0, 1.0, 1.0)) ||
55
- this._hasTexturesExtension(mat));
56
- }
57
- _hasTexturesExtension(mat) {
58
- return mat.metallicReflectanceTexture != null || mat.reflectanceTexture != null;
59
- }
60
- /**
61
- * After exporting a material
62
- * @param context GLTF context of the material
63
- * @param node exported GLTF node
64
- * @param babylonMaterial corresponding babylon material
65
- * @returns promise, resolves with the material
66
- */
67
- // eslint-disable-next-line no-restricted-syntax
68
- postExportMaterialAsync(context, node, babylonMaterial) {
69
- return new Promise((resolve) => {
70
- var _a;
71
- if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {
72
- this._wasUsed = true;
73
- node.extensions = node.extensions || {};
74
- const metallicReflectanceTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.metallicReflectanceTexture) ?? undefined;
75
- const reflectanceTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.reflectanceTexture) ?? undefined;
76
- const metallicF0Factor = babylonMaterial.metallicF0Factor == 1.0 ? undefined : babylonMaterial.metallicF0Factor;
77
- const metallicReflectanceColor = babylonMaterial.metallicReflectanceColor.equalsFloats(1.0, 1.0, 1.0)
78
- ? undefined
79
- : babylonMaterial.metallicReflectanceColor.asArray();
80
- const specularInfo = {
81
- specularFactor: metallicF0Factor,
82
- specularTexture: metallicReflectanceTexture,
83
- specularColorFactor: metallicReflectanceColor,
84
- specularColorTexture: reflectanceTexture,
85
- };
86
- if (this._hasTexturesExtension(babylonMaterial)) {
87
- this._exporter._materialNeedsUVsSet.add(babylonMaterial);
88
- }
89
- node.extensions[NAME] = specularInfo;
90
- }
91
- else if (babylonMaterial instanceof OpenPBRMaterial) {
92
- node.extensions = node.extensions || {};
93
- const specularWeightTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.specularWeightTexture) ?? undefined;
94
- const specularColorTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.specularColorTexture) ?? undefined;
95
- const specularWeight = babylonMaterial.specularWeight == 1.0 ? undefined : babylonMaterial.specularWeight;
96
- const specularColor = babylonMaterial.specularColor.equalsFloats(1.0, 1.0, 1.0) ? undefined : babylonMaterial.specularColor.asArray();
97
- if (!specularColorTexture && !specularWeightTexture && specularWeight === undefined && specularColor === undefined) {
98
- return resolve(node);
99
- }
100
- this._wasUsed = true;
101
- const specularEdgeColorInfo = {
102
- specularEdgeColorEnabled: true,
103
- };
104
- const specularInfo = {
105
- specularFactor: specularWeight,
106
- specularTexture: specularWeightTexture,
107
- specularColorFactor: specularColor,
108
- specularColorTexture: specularColorTexture,
109
- extensions: {},
110
- };
111
- specularInfo.extensions["EXT_materials_specular_edge_color"] = specularEdgeColorInfo;
112
- (_a = this._exporter._glTF).extensionsUsed || (_a.extensionsUsed = []);
113
- if (this._exporter._glTF.extensionsUsed.indexOf("EXT_materials_specular_edge_color") === -1) {
114
- this._exporter._glTF.extensionsUsed.push("EXT_materials_specular_edge_color");
115
- }
116
- if (specularWeightTexture || specularColorTexture) {
117
- this._exporter._materialNeedsUVsSet.add(babylonMaterial);
118
- }
119
- node.extensions[NAME] = specularInfo;
120
- }
121
- resolve(node);
122
- });
123
- }
124
- }
125
- GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_specular(exporter));
5
+ export * from "./KHR_materials_specular.pure.js";
6
+ import { RegisterKHR_materials_specular } from "./KHR_materials_specular.pure.js";
7
+ RegisterKHR_materials_specular();
126
8
  //# sourceMappingURL=KHR_materials_specular.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_specular.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_specular.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,MAAM,IAAI,GAAG,wBAAwB,CAAC;AAEtC;;GAEG;AACH,gEAAgE;AAChE,MAAM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,wBAAwB,EAAE,IAAI;iBACjC,CAAC;gBAEF,MAAM,YAAY,GAA0B;oBACxC,cAAc,EAAE,cAAc;oBAC9B,eAAe,EAAE,qBAAqB;oBACtC,mBAAmB,EAAE,aAAa;oBAClC,oBAAoB,EAAE,oBAAoB;oBAC1C,UAAU,EAAE,EAAE;iBACjB,CAAC;gBAEF,YAAY,CAAC,UAAW,CAAC,mCAAmC,CAAC,GAAG,qBAAqB,CAAC;gBACtF,MAAA,IAAI,CAAC,SAAS,CAAC,KAAK,EAAC,cAAc,QAAd,cAAc,GAAK,EAAE,EAAC;gBAC3C,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,mCAAmC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;oBAC1F,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;gBAClF,CAAC;gBAED,IAAI,qBAAqB,IAAI,oBAAoB,EAAE,CAAC;oBAChD,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;gBAC7D,CAAC;gBAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;YACzC,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import { type IMaterial, type IKHRMaterialsSpecular, type IEXTMaterialsSpecularEdgeColor } from \"babylonjs-gltf2interface\";\r\nimport { type IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport { type Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { OpenPBRMaterial } from \"core/Materials/PBR/openpbrMaterial\";\r\n\r\nconst NAME = \"KHR_materials_specular\";\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 IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: GLTFExporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: GLTFExporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n /** Dispose */\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n /**\r\n * After exporting a material, deal with the additional textures\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns array of additional textures to export\r\n */\r\n public async postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]> {\r\n const additionalTextures: BaseTexture[] = [];\r\n\r\n if (babylonMaterial instanceof PBRMaterial) {\r\n if (this._isExtensionEnabled(babylonMaterial)) {\r\n if (babylonMaterial.metallicReflectanceTexture) {\r\n additionalTextures.push(babylonMaterial.metallicReflectanceTexture);\r\n }\r\n if (babylonMaterial.reflectanceTexture) {\r\n additionalTextures.push(babylonMaterial.reflectanceTexture);\r\n }\r\n return additionalTextures;\r\n }\r\n }\r\n\r\n return additionalTextures;\r\n }\r\n\r\n private _isExtensionEnabled(mat: PBRMaterial): boolean {\r\n // This extension must not be used on a material that also uses KHR_materials_unlit\r\n if (mat.unlit) {\r\n return false;\r\n }\r\n return (\r\n (mat.metallicF0Factor != undefined && mat.metallicF0Factor != 1.0) ||\r\n (mat.metallicReflectanceColor != undefined && !mat.metallicReflectanceColor.equalsFloats(1.0, 1.0, 1.0)) ||\r\n this._hasTexturesExtension(mat)\r\n );\r\n }\r\n\r\n private _hasTexturesExtension(mat: PBRMaterial): boolean {\r\n return mat.metallicReflectanceTexture != null || mat.reflectanceTexture != null;\r\n }\r\n\r\n /**\r\n * After exporting a material\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns promise, resolves with the material\r\n */\r\n // eslint-disable-next-line no-restricted-syntax\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n\r\n node.extensions = node.extensions || {};\r\n\r\n const metallicReflectanceTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.metallicReflectanceTexture) ?? undefined;\r\n const reflectanceTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.reflectanceTexture) ?? undefined;\r\n const metallicF0Factor = babylonMaterial.metallicF0Factor == 1.0 ? undefined : babylonMaterial.metallicF0Factor;\r\n const metallicReflectanceColor = babylonMaterial.metallicReflectanceColor.equalsFloats(1.0, 1.0, 1.0)\r\n ? undefined\r\n : babylonMaterial.metallicReflectanceColor.asArray();\r\n\r\n const specularInfo: IKHRMaterialsSpecular = {\r\n specularFactor: metallicF0Factor,\r\n specularTexture: metallicReflectanceTexture,\r\n specularColorFactor: metallicReflectanceColor,\r\n specularColorTexture: reflectanceTexture,\r\n };\r\n\r\n if (this._hasTexturesExtension(babylonMaterial)) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n node.extensions[NAME] = specularInfo;\r\n } else if (babylonMaterial instanceof OpenPBRMaterial) {\r\n node.extensions = node.extensions || {};\r\n\r\n const specularWeightTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.specularWeightTexture) ?? undefined;\r\n const specularColorTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.specularColorTexture) ?? undefined;\r\n const specularWeight = babylonMaterial.specularWeight == 1.0 ? undefined : babylonMaterial.specularWeight;\r\n const specularColor = babylonMaterial.specularColor.equalsFloats(1.0, 1.0, 1.0) ? undefined : babylonMaterial.specularColor.asArray();\r\n\r\n if (!specularColorTexture && !specularWeightTexture && specularWeight === undefined && specularColor === undefined) {\r\n return resolve(node);\r\n }\r\n this._wasUsed = true;\r\n\r\n const specularEdgeColorInfo: IEXTMaterialsSpecularEdgeColor = {\r\n specularEdgeColorEnabled: true,\r\n };\r\n\r\n const specularInfo: IKHRMaterialsSpecular = {\r\n specularFactor: specularWeight,\r\n specularTexture: specularWeightTexture,\r\n specularColorFactor: specularColor,\r\n specularColorTexture: specularColorTexture,\r\n extensions: {},\r\n };\r\n\r\n specularInfo.extensions![\"EXT_materials_specular_edge_color\"] = specularEdgeColorInfo;\r\n this._exporter._glTF.extensionsUsed ||= [];\r\n if (this._exporter._glTF.extensionsUsed.indexOf(\"EXT_materials_specular_edge_color\") === -1) {\r\n this._exporter._glTF.extensionsUsed.push(\"EXT_materials_specular_edge_color\");\r\n }\r\n\r\n if (specularWeightTexture || specularColorTexture) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n node.extensions[NAME] = specularInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_specular(exporter));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_specular.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_specular.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,+BAA+B,CAAC;AAE9C,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,8BAA8B,EAAE,CAAC","sourcesContent":["/**\r\n * Re-exports the pure implementation and applies the runtime registration side effect.\r\n * Import \"./KHR_materials_specular.pure\" for tree-shakeable, side-effect-free usage.\r\n */\r\nexport * from \"./KHR_materials_specular.pure\";\r\n\r\nimport { RegisterKHR_materials_specular } from \"./KHR_materials_specular.pure\";\r\nRegisterKHR_materials_specular();\r\n"]}
@@ -0,0 +1,46 @@
1
+ import { type IMaterial } from "babylonjs-gltf2interface";
2
+ import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
3
+ import { GLTFExporter } from "../glTFExporter.js";
4
+ import { type Material } from "@babylonjs/core/Materials/material.js";
5
+ import { type BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
6
+ /**
7
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md)
8
+ */
9
+ export declare class KHR_materials_specular implements IGLTFExporterExtensionV2 {
10
+ /** Name of this extension */
11
+ readonly name = "KHR_materials_specular";
12
+ /** Defines whether this extension is enabled */
13
+ enabled: boolean;
14
+ /** Defines whether this extension is required */
15
+ required: boolean;
16
+ private _exporter;
17
+ private _wasUsed;
18
+ constructor(exporter: GLTFExporter);
19
+ /** Dispose */
20
+ dispose(): void;
21
+ /** @internal */
22
+ get wasUsed(): boolean;
23
+ /**
24
+ * After exporting a material, deal with the additional textures
25
+ * @param context GLTF context of the material
26
+ * @param node exported GLTF node
27
+ * @param babylonMaterial corresponding babylon material
28
+ * @returns array of additional textures to export
29
+ */
30
+ postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
31
+ private _isExtensionEnabled;
32
+ private _hasTexturesExtension;
33
+ /**
34
+ * After exporting a material
35
+ * @param context GLTF context of the material
36
+ * @param node exported GLTF node
37
+ * @param babylonMaterial corresponding babylon material
38
+ * @returns promise, resolves with the material
39
+ */
40
+ postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
41
+ }
42
+ /**
43
+ * Registers the KHR_materials_specular glTF serializer extension with the {@link GLTFExporter}.
44
+ * Safe to call multiple times; only the first call has an effect.
45
+ */
46
+ export declare function RegisterKHR_materials_specular(): void;
@@ -0,0 +1,138 @@
1
+ import { GLTFExporter } from "../glTFExporter.js";
2
+ import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.pure.js";
3
+ import { OpenPBRMaterial } from "@babylonjs/core/Materials/PBR/openpbrMaterial.pure.js";
4
+ const NAME = "KHR_materials_specular";
5
+ /**
6
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md)
7
+ */
8
+ // eslint-disable-next-line @typescript-eslint/naming-convention
9
+ export class KHR_materials_specular {
10
+ constructor(exporter) {
11
+ /** Name of this extension */
12
+ this.name = NAME;
13
+ /** Defines whether this extension is enabled */
14
+ this.enabled = true;
15
+ /** Defines whether this extension is required */
16
+ this.required = false;
17
+ this._wasUsed = false;
18
+ this._exporter = exporter;
19
+ }
20
+ /** Dispose */
21
+ dispose() { }
22
+ /** @internal */
23
+ get wasUsed() {
24
+ return this._wasUsed;
25
+ }
26
+ /**
27
+ * After exporting a material, deal with the additional textures
28
+ * @param context GLTF context of the material
29
+ * @param node exported GLTF node
30
+ * @param babylonMaterial corresponding babylon material
31
+ * @returns array of additional textures to export
32
+ */
33
+ async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
34
+ const additionalTextures = [];
35
+ if (babylonMaterial instanceof PBRMaterial) {
36
+ if (this._isExtensionEnabled(babylonMaterial)) {
37
+ if (babylonMaterial.metallicReflectanceTexture) {
38
+ additionalTextures.push(babylonMaterial.metallicReflectanceTexture);
39
+ }
40
+ if (babylonMaterial.reflectanceTexture) {
41
+ additionalTextures.push(babylonMaterial.reflectanceTexture);
42
+ }
43
+ return additionalTextures;
44
+ }
45
+ }
46
+ return additionalTextures;
47
+ }
48
+ _isExtensionEnabled(mat) {
49
+ // This extension must not be used on a material that also uses KHR_materials_unlit
50
+ if (mat.unlit) {
51
+ return false;
52
+ }
53
+ return ((mat.metallicF0Factor != undefined && mat.metallicF0Factor != 1.0) ||
54
+ (mat.metallicReflectanceColor != undefined && !mat.metallicReflectanceColor.equalsFloats(1.0, 1.0, 1.0)) ||
55
+ this._hasTexturesExtension(mat));
56
+ }
57
+ _hasTexturesExtension(mat) {
58
+ return mat.metallicReflectanceTexture != null || mat.reflectanceTexture != null;
59
+ }
60
+ /**
61
+ * After exporting a material
62
+ * @param context GLTF context of the material
63
+ * @param node exported GLTF node
64
+ * @param babylonMaterial corresponding babylon material
65
+ * @returns promise, resolves with the material
66
+ */
67
+ // eslint-disable-next-line no-restricted-syntax
68
+ postExportMaterialAsync(context, node, babylonMaterial) {
69
+ return new Promise((resolve) => {
70
+ var _a;
71
+ if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {
72
+ this._wasUsed = true;
73
+ node.extensions = node.extensions || {};
74
+ const metallicReflectanceTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.metallicReflectanceTexture) ?? undefined;
75
+ const reflectanceTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.reflectanceTexture) ?? undefined;
76
+ const metallicF0Factor = babylonMaterial.metallicF0Factor == 1.0 ? undefined : babylonMaterial.metallicF0Factor;
77
+ const metallicReflectanceColor = babylonMaterial.metallicReflectanceColor.equalsFloats(1.0, 1.0, 1.0)
78
+ ? undefined
79
+ : babylonMaterial.metallicReflectanceColor.asArray();
80
+ const specularInfo = {
81
+ specularFactor: metallicF0Factor,
82
+ specularTexture: metallicReflectanceTexture,
83
+ specularColorFactor: metallicReflectanceColor,
84
+ specularColorTexture: reflectanceTexture,
85
+ };
86
+ if (this._hasTexturesExtension(babylonMaterial)) {
87
+ this._exporter._materialNeedsUVsSet.add(babylonMaterial);
88
+ }
89
+ node.extensions[NAME] = specularInfo;
90
+ }
91
+ else if (babylonMaterial instanceof OpenPBRMaterial) {
92
+ node.extensions = node.extensions || {};
93
+ const specularWeightTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.specularWeightTexture) ?? undefined;
94
+ const specularColorTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.specularColorTexture) ?? undefined;
95
+ const specularWeight = babylonMaterial.specularWeight == 1.0 ? undefined : babylonMaterial.specularWeight;
96
+ const specularColor = babylonMaterial.specularColor.equalsFloats(1.0, 1.0, 1.0) ? undefined : babylonMaterial.specularColor.asArray();
97
+ if (!specularColorTexture && !specularWeightTexture && specularWeight === undefined && specularColor === undefined) {
98
+ return resolve(node);
99
+ }
100
+ this._wasUsed = true;
101
+ const specularEdgeColorInfo = {
102
+ specularEdgeColorEnabled: true,
103
+ };
104
+ const specularInfo = {
105
+ specularFactor: specularWeight,
106
+ specularTexture: specularWeightTexture,
107
+ specularColorFactor: specularColor,
108
+ specularColorTexture: specularColorTexture,
109
+ extensions: {},
110
+ };
111
+ specularInfo.extensions["EXT_materials_specular_edge_color"] = specularEdgeColorInfo;
112
+ (_a = this._exporter._glTF).extensionsUsed || (_a.extensionsUsed = []);
113
+ if (this._exporter._glTF.extensionsUsed.indexOf("EXT_materials_specular_edge_color") === -1) {
114
+ this._exporter._glTF.extensionsUsed.push("EXT_materials_specular_edge_color");
115
+ }
116
+ if (specularWeightTexture || specularColorTexture) {
117
+ this._exporter._materialNeedsUVsSet.add(babylonMaterial);
118
+ }
119
+ node.extensions[NAME] = specularInfo;
120
+ }
121
+ resolve(node);
122
+ });
123
+ }
124
+ }
125
+ let _Registered = false;
126
+ /**
127
+ * Registers the KHR_materials_specular glTF serializer extension with the {@link GLTFExporter}.
128
+ * Safe to call multiple times; only the first call has an effect.
129
+ */
130
+ // eslint-disable-next-line @typescript-eslint/naming-convention
131
+ export function RegisterKHR_materials_specular() {
132
+ if (_Registered) {
133
+ return;
134
+ }
135
+ _Registered = true;
136
+ GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_specular(exporter));
137
+ }
138
+ //# sourceMappingURL=KHR_materials_specular.pure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_materials_specular.pure.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_specular.pure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE1E,MAAM,IAAI,GAAG,wBAAwB,CAAC;AAEtC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,sBAAsB;IAc/B,YAAY,QAAsB;QAblC,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAIhB,aAAQ,GAAG,KAAK,CAAC;QAGrB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAED,cAAc;IACP,OAAO,KAAI,CAAC;IAEnB,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,yCAAyC,CAAE,OAAe,EAAE,IAAe,EAAE,eAAyB;QAC/G,MAAM,kBAAkB,GAAkB,EAAE,CAAC;QAE7C,IAAI,eAAe,YAAY,WAAW,EAAE,CAAC;YACzC,IAAI,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,EAAE,CAAC;gBAC5C,IAAI,eAAe,CAAC,0BAA0B,EAAE,CAAC;oBAC7C,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,0BAA0B,CAAC,CAAC;gBACxE,CAAC;gBACD,IAAI,eAAe,CAAC,kBAAkB,EAAE,CAAC;oBACrC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;gBAChE,CAAC;gBACD,OA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CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,gEAAgE;AAChE,MAAM,UAAU,8BAA8B;IAC1C,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC7F,CAAC","sourcesContent":["import { type IMaterial, type IKHRMaterialsSpecular, type IEXTMaterialsSpecularEdgeColor } from \"babylonjs-gltf2interface\";\r\nimport { type IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport { type Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial.pure\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { OpenPBRMaterial } from \"core/Materials/PBR/openpbrMaterial.pure\";\r\n\r\nconst NAME = \"KHR_materials_specular\";\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 IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: GLTFExporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: GLTFExporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n /** Dispose */\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n /**\r\n * After exporting a material, deal with the additional textures\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns array of additional textures to export\r\n */\r\n public async postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]> {\r\n const additionalTextures: BaseTexture[] = [];\r\n\r\n if (babylonMaterial instanceof PBRMaterial) {\r\n if (this._isExtensionEnabled(babylonMaterial)) {\r\n if (babylonMaterial.metallicReflectanceTexture) {\r\n additionalTextures.push(babylonMaterial.metallicReflectanceTexture);\r\n }\r\n if (babylonMaterial.reflectanceTexture) {\r\n additionalTextures.push(babylonMaterial.reflectanceTexture);\r\n }\r\n return additionalTextures;\r\n }\r\n }\r\n\r\n return additionalTextures;\r\n }\r\n\r\n private _isExtensionEnabled(mat: PBRMaterial): boolean {\r\n // This extension must not be used on a material that also uses KHR_materials_unlit\r\n if (mat.unlit) {\r\n return false;\r\n }\r\n return (\r\n (mat.metallicF0Factor != undefined && mat.metallicF0Factor != 1.0) ||\r\n (mat.metallicReflectanceColor != undefined && !mat.metallicReflectanceColor.equalsFloats(1.0, 1.0, 1.0)) ||\r\n this._hasTexturesExtension(mat)\r\n );\r\n }\r\n\r\n private _hasTexturesExtension(mat: PBRMaterial): boolean {\r\n return mat.metallicReflectanceTexture != null || mat.reflectanceTexture != null;\r\n }\r\n\r\n /**\r\n * After exporting a material\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns promise, resolves with the material\r\n */\r\n // eslint-disable-next-line no-restricted-syntax\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n\r\n node.extensions = node.extensions || {};\r\n\r\n const metallicReflectanceTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.metallicReflectanceTexture) ?? undefined;\r\n const reflectanceTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.reflectanceTexture) ?? undefined;\r\n const metallicF0Factor = babylonMaterial.metallicF0Factor == 1.0 ? undefined : babylonMaterial.metallicF0Factor;\r\n const metallicReflectanceColor = babylonMaterial.metallicReflectanceColor.equalsFloats(1.0, 1.0, 1.0)\r\n ? undefined\r\n : babylonMaterial.metallicReflectanceColor.asArray();\r\n\r\n const specularInfo: IKHRMaterialsSpecular = {\r\n specularFactor: metallicF0Factor,\r\n specularTexture: metallicReflectanceTexture,\r\n specularColorFactor: metallicReflectanceColor,\r\n specularColorTexture: reflectanceTexture,\r\n };\r\n\r\n if (this._hasTexturesExtension(babylonMaterial)) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n node.extensions[NAME] = specularInfo;\r\n } else if (babylonMaterial instanceof OpenPBRMaterial) {\r\n node.extensions = node.extensions || {};\r\n\r\n const specularWeightTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.specularWeightTexture) ?? undefined;\r\n const specularColorTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.specularColorTexture) ?? undefined;\r\n const specularWeight = babylonMaterial.specularWeight == 1.0 ? undefined : babylonMaterial.specularWeight;\r\n const specularColor = babylonMaterial.specularColor.equalsFloats(1.0, 1.0, 1.0) ? undefined : babylonMaterial.specularColor.asArray();\r\n\r\n if (!specularColorTexture && !specularWeightTexture && specularWeight === undefined && specularColor === undefined) {\r\n return resolve(node);\r\n }\r\n this._wasUsed = true;\r\n\r\n const specularEdgeColorInfo: IEXTMaterialsSpecularEdgeColor = {\r\n specularEdgeColorEnabled: true,\r\n };\r\n\r\n const specularInfo: IKHRMaterialsSpecular = {\r\n specularFactor: specularWeight,\r\n specularTexture: specularWeightTexture,\r\n specularColorFactor: specularColor,\r\n specularColorTexture: specularColorTexture,\r\n extensions: {},\r\n };\r\n\r\n specularInfo.extensions![\"EXT_materials_specular_edge_color\"] = specularEdgeColorInfo;\r\n this._exporter._glTF.extensionsUsed ||= [];\r\n if (this._exporter._glTF.extensionsUsed.indexOf(\"EXT_materials_specular_edge_color\") === -1) {\r\n this._exporter._glTF.extensionsUsed.push(\"EXT_materials_specular_edge_color\");\r\n }\r\n\r\n if (specularWeightTexture || specularColorTexture) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n node.extensions[NAME] = specularInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Registers the KHR_materials_specular glTF serializer extension with the {@link GLTFExporter}.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function RegisterKHR_materials_specular(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_specular(exporter));\r\n}\r\n"]}
@@ -1,40 +1,5 @@
1
- import { type IMaterial } from "babylonjs-gltf2interface";
2
- import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
3
- import { GLTFExporter } from "../glTFExporter.js";
4
- import { type Material } from "@babylonjs/core/Materials/material.js";
5
- import { type BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
6
1
  /**
7
- * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./KHR_materials_transmission.pure" for tree-shakeable, side-effect-free usage.
8
4
  */
9
- export declare class KHR_materials_transmission implements IGLTFExporterExtensionV2 {
10
- /** Name of this extension */
11
- readonly name = "KHR_materials_transmission";
12
- /** Defines whether this extension is enabled */
13
- enabled: boolean;
14
- /** Defines whether this extension is required */
15
- required: boolean;
16
- private _exporter;
17
- private _wasUsed;
18
- constructor(exporter: GLTFExporter);
19
- /** Dispose */
20
- dispose(): void;
21
- /** @internal */
22
- get wasUsed(): boolean;
23
- /**
24
- * After exporting a material, deal with additional textures
25
- * @param context GLTF context of the material
26
- * @param node exported GLTF node
27
- * @param babylonMaterial corresponding babylon material
28
- * @returns array of additional textures to export
29
- */
30
- postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
31
- private _isExtensionEnabled;
32
- /**
33
- * After exporting a material
34
- * @param context GLTF context of the material
35
- * @param node exported GLTF node
36
- * @param babylonMaterial corresponding babylon material
37
- * @returns true if successful
38
- */
39
- postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
40
- }
5
+ export * from "./KHR_materials_transmission.pure.js";