@babylonjs/serializers 9.13.0 → 9.14.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
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_fuzz.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_fuzz.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAA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AC,CAAC;gBAC7D,CAAC;gBAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;YACrC,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,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import { type IMaterial, type IKHRMaterialsFuzz } from \"babylonjs-gltf2interface\";\r\nimport { type IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport { type Material } from \"core/Materials/material\";\r\nimport { OpenPBRMaterial } from \"core/Materials/PBR/openpbrMaterial\";\r\nimport { MergeTexturesAsync, CreateRGBAConfiguration, CreateTextureInput, CreateConstantInput } from \"core/Materials/Textures/textureMerger\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { type InternalTexture } from \"core/Materials/Textures/internalTexture\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\n\r\nconst NAME = \"KHR_materials_fuzz\";\r\n\r\n/**\r\n * Generate a unique ID for the merged coat textures based on the internal texture data.\r\n * This is used for caching merged textures.\r\n * @param babylonMaterial Source OpenPBR material\r\n * @returns A unique ID string for the merged coat textures\r\n * @internal\r\n */\r\nfunction GetFuzzColorTextureId(babylonMaterial: OpenPBRMaterial): string {\r\n const fuzzColorTexture: Nullable<BaseTexture> = babylonMaterial.fuzzColorTexture;\r\n const fuzzColorId = fuzzColorTexture && fuzzColorTexture.getInternalTexture() ? fuzzColorTexture!.getInternalTexture()!.uniqueId : \"NoFuzzColor\";\r\n const fuzzRoughnessTexture: Nullable<BaseTexture> = babylonMaterial.fuzzRoughnessTexture;\r\n const fuzzRoughnessId = fuzzRoughnessTexture && fuzzRoughnessTexture.getInternalTexture() ? fuzzRoughnessTexture!.getInternalTexture()!.uniqueId : \"NoFuzzRoughness\";\r\n return `FuzzColor_${fuzzColorId}_FuzzRoughness_${fuzzRoughnessId}`;\r\n}\r\n\r\n/**\r\n * Using the coat weight and coat roughness textures, create a merged internal texture that can be used\r\n * for multiple textures (with potentially different transforms) on export.\r\n * @param babylonMaterial The source OpenPBR material\r\n * @returns A new, internal texture with the coat weight in the red channel and coat roughness in the green channel\r\n * @internal\r\n */\r\nasync function CreateMergedFuzzInternalTexture(babylonMaterial: OpenPBRMaterial): Promise<Nullable<InternalTexture>> {\r\n const scene = babylonMaterial.getScene();\r\n const fuzzColorTexture: Nullable<BaseTexture> = babylonMaterial.fuzzColorTexture;\r\n const fuzzRoughnessTexture: Nullable<BaseTexture> = babylonMaterial.fuzzRoughnessTexture;\r\n // If we don't have any textures, we don't need to generate anything.\r\n if (!(fuzzColorTexture || fuzzRoughnessTexture)) {\r\n return null;\r\n }\r\n\r\n const texture = await MergeTexturesAsync(\r\n \"FuzzTexture\",\r\n CreateRGBAConfiguration(\r\n fuzzColorTexture ? CreateTextureInput(fuzzColorTexture, 0) : CreateConstantInput(1.0), // fuzz color from red channel\r\n fuzzColorTexture ? CreateTextureInput(fuzzColorTexture, 1) : CreateConstantInput(1.0), // fuzz color from green channel\r\n fuzzColorTexture ? CreateTextureInput(fuzzColorTexture, 2) : CreateConstantInput(1.0), // fuzz color from blue channel\r\n // fuzz roughness goes in the alpha channel but may come from red or alpha channels in the source\r\n fuzzRoughnessTexture ? CreateTextureInput(fuzzRoughnessTexture, babylonMaterial._useFuzzRoughnessFromTextureAlpha ? 3 : 0) : CreateConstantInput(1.0)\r\n ),\r\n scene\r\n );\r\n\r\n return texture.getInternalTexture();\r\n}\r\n\r\n/**\r\n * Creates a temporary texture based on the source texture.\r\n * @param internalTexture The source internal texture\r\n * @param sourceTexture The source of the new texture's name, and sampler info\r\n * @returns The new texture\r\n */\r\nfunction CreateTempTexture(internalTexture: InternalTexture, sourceTexture: BaseTexture): Texture {\r\n const tempTexture = new Texture(sourceTexture.name, sourceTexture.getScene());\r\n tempTexture._texture = internalTexture;\r\n tempTexture.coordinatesIndex = sourceTexture.coordinatesIndex;\r\n if (sourceTexture instanceof Texture) {\r\n tempTexture.uOffset = sourceTexture.uOffset;\r\n tempTexture.vOffset = sourceTexture.vOffset;\r\n tempTexture.uScale = sourceTexture.uScale;\r\n tempTexture.vScale = sourceTexture.vScale;\r\n tempTexture.wAng = sourceTexture.wAng;\r\n }\r\n tempTexture.wrapU = sourceTexture.wrapU;\r\n tempTexture.wrapV = sourceTexture.wrapV;\r\n return tempTexture;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_fuzz 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 /**\r\n * Cache that holds temporary merged textures created during export\r\n */\r\n private _mergedTexturesMap: Record<string, BaseTexture> = {};\r\n\r\n /**\r\n * Cache that holds internal textures of merged textures created during export\r\n */\r\n private _cachedInternalTexturesMap: Record<string, InternalTexture> = {};\r\n\r\n public dispose() {\r\n for (const key of Object.keys(this._mergedTexturesMap)) {\r\n const texture = this._mergedTexturesMap[key];\r\n texture.dispose();\r\n }\r\n this._mergedTexturesMap = {};\r\n for (const key of Object.keys(this._cachedInternalTexturesMap)) {\r\n const internalTexture = this._cachedInternalTexturesMap[key];\r\n internalTexture.dispose();\r\n }\r\n this._cachedInternalTexturesMap = {};\r\n }\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 OpenPBRMaterial) {\r\n const additionalTextures: BaseTexture[] = [];\r\n if (babylonMaterial.fuzzWeight > 0.0) {\r\n if (babylonMaterial.fuzzWeightTexture) {\r\n additionalTextures.push(babylonMaterial.fuzzWeightTexture);\r\n }\r\n let fuzzTexturesNeedMerge = false;\r\n if (babylonMaterial.fuzzRoughnessTexture) {\r\n if (babylonMaterial._useFuzzRoughnessFromTextureAlpha) {\r\n additionalTextures.push(babylonMaterial.fuzzRoughnessTexture);\r\n } else {\r\n fuzzTexturesNeedMerge = true;\r\n }\r\n }\r\n if (babylonMaterial.fuzzColorTexture && !fuzzTexturesNeedMerge) {\r\n additionalTextures.push(babylonMaterial.fuzzColorTexture);\r\n }\r\n if (fuzzTexturesNeedMerge) {\r\n const texId = GetFuzzColorTextureId(babylonMaterial);\r\n if (!this._cachedInternalTexturesMap[texId]) {\r\n const mergedInternalTexture = await CreateMergedFuzzInternalTexture(babylonMaterial);\r\n if (mergedInternalTexture) {\r\n this._cachedInternalTexturesMap[texId] = mergedInternalTexture;\r\n }\r\n }\r\n if (this._cachedInternalTexturesMap[texId]) {\r\n if (babylonMaterial.fuzzColorTexture) {\r\n this._mergedTexturesMap[babylonMaterial.fuzzColorTexture.uniqueId] = CreateTempTexture(\r\n this._cachedInternalTexturesMap[texId],\r\n babylonMaterial.fuzzColorTexture\r\n );\r\n additionalTextures.push(this._mergedTexturesMap[babylonMaterial.fuzzColorTexture.uniqueId]);\r\n }\r\n if (babylonMaterial.fuzzRoughnessTexture) {\r\n this._mergedTexturesMap[babylonMaterial.fuzzRoughnessTexture.uniqueId] = CreateTempTexture(\r\n this._cachedInternalTexturesMap[texId],\r\n babylonMaterial.fuzzRoughnessTexture\r\n );\r\n additionalTextures.push(this._mergedTexturesMap[babylonMaterial.fuzzRoughnessTexture.uniqueId]);\r\n }\r\n }\r\n }\r\n }\r\n return additionalTextures;\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 OpenPBRMaterial) {\r\n if (babylonMaterial.fuzzWeight == 0.0) {\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 fuzzInfo: IKHRMaterialsFuzz = {\r\n fuzzFactor: babylonMaterial.fuzzWeight,\r\n fuzzColorFactor: babylonMaterial.fuzzColor.asArray(),\r\n fuzzRoughnessFactor: babylonMaterial.fuzzRoughness,\r\n };\r\n\r\n if (babylonMaterial.fuzzWeightTexture) {\r\n fuzzInfo.fuzzTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.fuzzWeightTexture) ?? undefined;\r\n }\r\n\r\n let fuzzColorTexture: Nullable<BaseTexture>;\r\n if (babylonMaterial.fuzzColorTexture) {\r\n if (this._mergedTexturesMap[babylonMaterial.fuzzColorTexture.uniqueId]) {\r\n fuzzColorTexture = this._mergedTexturesMap[babylonMaterial.fuzzColorTexture.uniqueId];\r\n } else {\r\n fuzzColorTexture = babylonMaterial.fuzzColorTexture;\r\n }\r\n fuzzInfo.fuzzColorTexture = this._exporter._materialExporter.getTextureInfo(fuzzColorTexture) ?? undefined;\r\n }\r\n\r\n let fuzzRoughnessTexture: Nullable<BaseTexture>;\r\n if (babylonMaterial.fuzzRoughnessTexture) {\r\n if (this._mergedTexturesMap[babylonMaterial.fuzzRoughnessTexture.uniqueId]) {\r\n fuzzRoughnessTexture = this._mergedTexturesMap[babylonMaterial.fuzzRoughnessTexture.uniqueId];\r\n } else {\r\n fuzzRoughnessTexture = babylonMaterial.fuzzRoughnessTexture;\r\n }\r\n fuzzInfo.fuzzRoughnessTexture = this._exporter._materialExporter.getTextureInfo(fuzzRoughnessTexture) ?? undefined;\r\n }\r\n\r\n if (fuzzInfo.fuzzColorTexture !== null || fuzzInfo.fuzzRoughnessTexture !== null) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n node.extensions[NAME] = fuzzInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_fuzz(exporter));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_fuzz.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_fuzz.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,2BAA2B,CAAC;AAE1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,0BAA0B,EAAE,CAAC","sourcesContent":["/**\r\n * Re-exports the pure implementation and applies the runtime registration side effect.\r\n * Import \"./KHR_materials_fuzz.pure\" for tree-shakeable, side-effect-free usage.\r\n */\r\nexport * from \"./KHR_materials_fuzz.pure\";\r\n\r\nimport { RegisterKHR_materials_fuzz } from \"./KHR_materials_fuzz.pure\";\r\nRegisterKHR_materials_fuzz();\r\n"]}
@@ -0,0 +1,37 @@
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_fuzz implements IGLTFExporterExtensionV2 {
10
+ /** Name of this extension */
11
+ readonly name = "KHR_materials_fuzz";
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
+ /**
20
+ * Cache that holds temporary merged textures created during export
21
+ */
22
+ private _mergedTexturesMap;
23
+ /**
24
+ * Cache that holds internal textures of merged textures created during export
25
+ */
26
+ private _cachedInternalTexturesMap;
27
+ dispose(): void;
28
+ /** @internal */
29
+ get wasUsed(): boolean;
30
+ postExportMaterialAdditionalTexturesAsync(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
31
+ postExportMaterialAsync(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
32
+ }
33
+ /**
34
+ * Registers the KHR_materials_fuzz glTF serializer extension with the {@link GLTFExporter}.
35
+ * Safe to call multiple times; only the first call has an effect.
36
+ */
37
+ export declare function RegisterKHR_materials_fuzz(): void;
@@ -0,0 +1,206 @@
1
+ import { GLTFExporter } from "../glTFExporter.js";
2
+ import { OpenPBRMaterial } from "@babylonjs/core/Materials/PBR/openpbrMaterial.pure.js";
3
+ import { MergeTexturesAsync, CreateRGBAConfiguration, CreateTextureInput, CreateConstantInput } from "@babylonjs/core/Materials/Textures/textureMerger.js";
4
+ import { Texture } from "@babylonjs/core/Materials/Textures/texture.pure.js";
5
+ const NAME = "KHR_materials_fuzz";
6
+ /**
7
+ * Generate a unique ID for the merged coat textures based on the internal texture data.
8
+ * This is used for caching merged textures.
9
+ * @param babylonMaterial Source OpenPBR material
10
+ * @returns A unique ID string for the merged coat textures
11
+ * @internal
12
+ */
13
+ function GetFuzzColorTextureId(babylonMaterial) {
14
+ const fuzzColorTexture = babylonMaterial.fuzzColorTexture;
15
+ const fuzzColorId = fuzzColorTexture && fuzzColorTexture.getInternalTexture() ? fuzzColorTexture.getInternalTexture().uniqueId : "NoFuzzColor";
16
+ const fuzzRoughnessTexture = babylonMaterial.fuzzRoughnessTexture;
17
+ const fuzzRoughnessId = fuzzRoughnessTexture && fuzzRoughnessTexture.getInternalTexture() ? fuzzRoughnessTexture.getInternalTexture().uniqueId : "NoFuzzRoughness";
18
+ return `FuzzColor_${fuzzColorId}_FuzzRoughness_${fuzzRoughnessId}`;
19
+ }
20
+ /**
21
+ * Using the coat weight and coat roughness textures, create a merged internal texture that can be used
22
+ * for multiple textures (with potentially different transforms) on export.
23
+ * @param babylonMaterial The source OpenPBR material
24
+ * @returns A new, internal texture with the coat weight in the red channel and coat roughness in the green channel
25
+ * @internal
26
+ */
27
+ async function CreateMergedFuzzInternalTexture(babylonMaterial) {
28
+ const scene = babylonMaterial.getScene();
29
+ const fuzzColorTexture = babylonMaterial.fuzzColorTexture;
30
+ const fuzzRoughnessTexture = babylonMaterial.fuzzRoughnessTexture;
31
+ // If we don't have any textures, we don't need to generate anything.
32
+ if (!(fuzzColorTexture || fuzzRoughnessTexture)) {
33
+ return null;
34
+ }
35
+ const texture = await MergeTexturesAsync("FuzzTexture", CreateRGBAConfiguration(fuzzColorTexture ? CreateTextureInput(fuzzColorTexture, 0) : CreateConstantInput(1.0), // fuzz color from red channel
36
+ fuzzColorTexture ? CreateTextureInput(fuzzColorTexture, 1) : CreateConstantInput(1.0), // fuzz color from green channel
37
+ fuzzColorTexture ? CreateTextureInput(fuzzColorTexture, 2) : CreateConstantInput(1.0), // fuzz color from blue channel
38
+ // fuzz roughness goes in the alpha channel but may come from red or alpha channels in the source
39
+ fuzzRoughnessTexture ? CreateTextureInput(fuzzRoughnessTexture, babylonMaterial._useFuzzRoughnessFromTextureAlpha ? 3 : 0) : CreateConstantInput(1.0)), scene);
40
+ return texture.getInternalTexture();
41
+ }
42
+ /**
43
+ * Creates a temporary texture based on the source texture.
44
+ * @param internalTexture The source internal texture
45
+ * @param sourceTexture The source of the new texture's name, and sampler info
46
+ * @returns The new texture
47
+ */
48
+ function CreateTempTexture(internalTexture, sourceTexture) {
49
+ const tempTexture = new Texture(sourceTexture.name, sourceTexture.getScene());
50
+ tempTexture._texture = internalTexture;
51
+ tempTexture.coordinatesIndex = sourceTexture.coordinatesIndex;
52
+ if (sourceTexture instanceof Texture) {
53
+ tempTexture.uOffset = sourceTexture.uOffset;
54
+ tempTexture.vOffset = sourceTexture.vOffset;
55
+ tempTexture.uScale = sourceTexture.uScale;
56
+ tempTexture.vScale = sourceTexture.vScale;
57
+ tempTexture.wAng = sourceTexture.wAng;
58
+ }
59
+ tempTexture.wrapU = sourceTexture.wrapU;
60
+ tempTexture.wrapV = sourceTexture.wrapV;
61
+ return tempTexture;
62
+ }
63
+ /**
64
+ * @internal
65
+ */
66
+ // eslint-disable-next-line @typescript-eslint/naming-convention
67
+ export class KHR_materials_fuzz {
68
+ constructor(exporter) {
69
+ /** Name of this extension */
70
+ this.name = NAME;
71
+ /** Defines whether this extension is enabled */
72
+ this.enabled = true;
73
+ /** Defines whether this extension is required */
74
+ this.required = false;
75
+ this._wasUsed = false;
76
+ /**
77
+ * Cache that holds temporary merged textures created during export
78
+ */
79
+ this._mergedTexturesMap = {};
80
+ /**
81
+ * Cache that holds internal textures of merged textures created during export
82
+ */
83
+ this._cachedInternalTexturesMap = {};
84
+ this._exporter = exporter;
85
+ }
86
+ dispose() {
87
+ for (const key of Object.keys(this._mergedTexturesMap)) {
88
+ const texture = this._mergedTexturesMap[key];
89
+ texture.dispose();
90
+ }
91
+ this._mergedTexturesMap = {};
92
+ for (const key of Object.keys(this._cachedInternalTexturesMap)) {
93
+ const internalTexture = this._cachedInternalTexturesMap[key];
94
+ internalTexture.dispose();
95
+ }
96
+ this._cachedInternalTexturesMap = {};
97
+ }
98
+ /** @internal */
99
+ get wasUsed() {
100
+ return this._wasUsed;
101
+ }
102
+ async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
103
+ if (babylonMaterial instanceof OpenPBRMaterial) {
104
+ const additionalTextures = [];
105
+ if (babylonMaterial.fuzzWeight > 0.0) {
106
+ if (babylonMaterial.fuzzWeightTexture) {
107
+ additionalTextures.push(babylonMaterial.fuzzWeightTexture);
108
+ }
109
+ let fuzzTexturesNeedMerge = false;
110
+ if (babylonMaterial.fuzzRoughnessTexture) {
111
+ if (babylonMaterial._useFuzzRoughnessFromTextureAlpha) {
112
+ additionalTextures.push(babylonMaterial.fuzzRoughnessTexture);
113
+ }
114
+ else {
115
+ fuzzTexturesNeedMerge = true;
116
+ }
117
+ }
118
+ if (babylonMaterial.fuzzColorTexture && !fuzzTexturesNeedMerge) {
119
+ additionalTextures.push(babylonMaterial.fuzzColorTexture);
120
+ }
121
+ if (fuzzTexturesNeedMerge) {
122
+ const texId = GetFuzzColorTextureId(babylonMaterial);
123
+ if (!this._cachedInternalTexturesMap[texId]) {
124
+ const mergedInternalTexture = await CreateMergedFuzzInternalTexture(babylonMaterial);
125
+ if (mergedInternalTexture) {
126
+ this._cachedInternalTexturesMap[texId] = mergedInternalTexture;
127
+ }
128
+ }
129
+ if (this._cachedInternalTexturesMap[texId]) {
130
+ if (babylonMaterial.fuzzColorTexture) {
131
+ this._mergedTexturesMap[babylonMaterial.fuzzColorTexture.uniqueId] = CreateTempTexture(this._cachedInternalTexturesMap[texId], babylonMaterial.fuzzColorTexture);
132
+ additionalTextures.push(this._mergedTexturesMap[babylonMaterial.fuzzColorTexture.uniqueId]);
133
+ }
134
+ if (babylonMaterial.fuzzRoughnessTexture) {
135
+ this._mergedTexturesMap[babylonMaterial.fuzzRoughnessTexture.uniqueId] = CreateTempTexture(this._cachedInternalTexturesMap[texId], babylonMaterial.fuzzRoughnessTexture);
136
+ additionalTextures.push(this._mergedTexturesMap[babylonMaterial.fuzzRoughnessTexture.uniqueId]);
137
+ }
138
+ }
139
+ }
140
+ }
141
+ return additionalTextures;
142
+ }
143
+ return [];
144
+ }
145
+ async postExportMaterialAsync(context, node, babylonMaterial) {
146
+ return await new Promise((resolve) => {
147
+ if (babylonMaterial instanceof OpenPBRMaterial) {
148
+ if (babylonMaterial.fuzzWeight == 0.0) {
149
+ resolve(node);
150
+ return;
151
+ }
152
+ this._wasUsed = true;
153
+ if (node.extensions == null) {
154
+ node.extensions = {};
155
+ }
156
+ const fuzzInfo = {
157
+ fuzzFactor: babylonMaterial.fuzzWeight,
158
+ fuzzColorFactor: babylonMaterial.fuzzColor.asArray(),
159
+ fuzzRoughnessFactor: babylonMaterial.fuzzRoughness,
160
+ };
161
+ if (babylonMaterial.fuzzWeightTexture) {
162
+ fuzzInfo.fuzzTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.fuzzWeightTexture) ?? undefined;
163
+ }
164
+ let fuzzColorTexture;
165
+ if (babylonMaterial.fuzzColorTexture) {
166
+ if (this._mergedTexturesMap[babylonMaterial.fuzzColorTexture.uniqueId]) {
167
+ fuzzColorTexture = this._mergedTexturesMap[babylonMaterial.fuzzColorTexture.uniqueId];
168
+ }
169
+ else {
170
+ fuzzColorTexture = babylonMaterial.fuzzColorTexture;
171
+ }
172
+ fuzzInfo.fuzzColorTexture = this._exporter._materialExporter.getTextureInfo(fuzzColorTexture) ?? undefined;
173
+ }
174
+ let fuzzRoughnessTexture;
175
+ if (babylonMaterial.fuzzRoughnessTexture) {
176
+ if (this._mergedTexturesMap[babylonMaterial.fuzzRoughnessTexture.uniqueId]) {
177
+ fuzzRoughnessTexture = this._mergedTexturesMap[babylonMaterial.fuzzRoughnessTexture.uniqueId];
178
+ }
179
+ else {
180
+ fuzzRoughnessTexture = babylonMaterial.fuzzRoughnessTexture;
181
+ }
182
+ fuzzInfo.fuzzRoughnessTexture = this._exporter._materialExporter.getTextureInfo(fuzzRoughnessTexture) ?? undefined;
183
+ }
184
+ if (fuzzInfo.fuzzColorTexture !== null || fuzzInfo.fuzzRoughnessTexture !== null) {
185
+ this._exporter._materialNeedsUVsSet.add(babylonMaterial);
186
+ }
187
+ node.extensions[NAME] = fuzzInfo;
188
+ }
189
+ resolve(node);
190
+ });
191
+ }
192
+ }
193
+ let _Registered = false;
194
+ /**
195
+ * Registers the KHR_materials_fuzz glTF serializer extension with the {@link GLTFExporter}.
196
+ * Safe to call multiple times; only the first call has an effect.
197
+ */
198
+ // eslint-disable-next-line @typescript-eslint/naming-convention
199
+ export function RegisterKHR_materials_fuzz() {
200
+ if (_Registered) {
201
+ return;
202
+ }
203
+ _Registered = true;
204
+ GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_fuzz(exporter));
205
+ }
206
+ //# sourceMappingURL=KHR_materials_fuzz.pure.js.map
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AAQ,CAAC,oBAAoB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,cAAc,CAAC,oBAAoB,CAAC,IAAI,SAAS,CAAC;gBACvH,CAAC;gBAED,IAAI,QAAQ,CAAC,gBAAgB,KAAK,IAAI,IAAI,QAAQ,CAAC,oBAAoB,KAAK,IAAI,EAAE,CAAC;oBAC/E,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;gBAC7D,CAAC;gBAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;YACrC,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,0BAA0B;IACtC,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,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzF,CAAC","sourcesContent":["import { type IMaterial, type IKHRMaterialsFuzz } from \"babylonjs-gltf2interface\";\r\nimport { type IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport { type Material } from \"core/Materials/material\";\r\nimport { OpenPBRMaterial } from \"core/Materials/PBR/openpbrMaterial.pure\";\r\nimport { MergeTexturesAsync, CreateRGBAConfiguration, CreateTextureInput, CreateConstantInput } from \"core/Materials/Textures/textureMerger\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { type InternalTexture } from \"core/Materials/Textures/internalTexture\";\r\nimport { Texture } from \"core/Materials/Textures/texture.pure\";\r\n\r\nconst NAME = \"KHR_materials_fuzz\";\r\n\r\n/**\r\n * Generate a unique ID for the merged coat textures based on the internal texture data.\r\n * This is used for caching merged textures.\r\n * @param babylonMaterial Source OpenPBR material\r\n * @returns A unique ID string for the merged coat textures\r\n * @internal\r\n */\r\nfunction GetFuzzColorTextureId(babylonMaterial: OpenPBRMaterial): string {\r\n const fuzzColorTexture: Nullable<BaseTexture> = babylonMaterial.fuzzColorTexture;\r\n const fuzzColorId = fuzzColorTexture && fuzzColorTexture.getInternalTexture() ? fuzzColorTexture!.getInternalTexture()!.uniqueId : \"NoFuzzColor\";\r\n const fuzzRoughnessTexture: Nullable<BaseTexture> = babylonMaterial.fuzzRoughnessTexture;\r\n const fuzzRoughnessId = fuzzRoughnessTexture && fuzzRoughnessTexture.getInternalTexture() ? fuzzRoughnessTexture!.getInternalTexture()!.uniqueId : \"NoFuzzRoughness\";\r\n return `FuzzColor_${fuzzColorId}_FuzzRoughness_${fuzzRoughnessId}`;\r\n}\r\n\r\n/**\r\n * Using the coat weight and coat roughness textures, create a merged internal texture that can be used\r\n * for multiple textures (with potentially different transforms) on export.\r\n * @param babylonMaterial The source OpenPBR material\r\n * @returns A new, internal texture with the coat weight in the red channel and coat roughness in the green channel\r\n * @internal\r\n */\r\nasync function CreateMergedFuzzInternalTexture(babylonMaterial: OpenPBRMaterial): Promise<Nullable<InternalTexture>> {\r\n const scene = babylonMaterial.getScene();\r\n const fuzzColorTexture: Nullable<BaseTexture> = babylonMaterial.fuzzColorTexture;\r\n const fuzzRoughnessTexture: Nullable<BaseTexture> = babylonMaterial.fuzzRoughnessTexture;\r\n // If we don't have any textures, we don't need to generate anything.\r\n if (!(fuzzColorTexture || fuzzRoughnessTexture)) {\r\n return null;\r\n }\r\n\r\n const texture = await MergeTexturesAsync(\r\n \"FuzzTexture\",\r\n CreateRGBAConfiguration(\r\n fuzzColorTexture ? CreateTextureInput(fuzzColorTexture, 0) : CreateConstantInput(1.0), // fuzz color from red channel\r\n fuzzColorTexture ? CreateTextureInput(fuzzColorTexture, 1) : CreateConstantInput(1.0), // fuzz color from green channel\r\n fuzzColorTexture ? CreateTextureInput(fuzzColorTexture, 2) : CreateConstantInput(1.0), // fuzz color from blue channel\r\n // fuzz roughness goes in the alpha channel but may come from red or alpha channels in the source\r\n fuzzRoughnessTexture ? CreateTextureInput(fuzzRoughnessTexture, babylonMaterial._useFuzzRoughnessFromTextureAlpha ? 3 : 0) : CreateConstantInput(1.0)\r\n ),\r\n scene\r\n );\r\n\r\n return texture.getInternalTexture();\r\n}\r\n\r\n/**\r\n * Creates a temporary texture based on the source texture.\r\n * @param internalTexture The source internal texture\r\n * @param sourceTexture The source of the new texture's name, and sampler info\r\n * @returns The new texture\r\n */\r\nfunction CreateTempTexture(internalTexture: InternalTexture, sourceTexture: BaseTexture): Texture {\r\n const tempTexture = new Texture(sourceTexture.name, sourceTexture.getScene());\r\n tempTexture._texture = internalTexture;\r\n tempTexture.coordinatesIndex = sourceTexture.coordinatesIndex;\r\n if (sourceTexture instanceof Texture) {\r\n tempTexture.uOffset = sourceTexture.uOffset;\r\n tempTexture.vOffset = sourceTexture.vOffset;\r\n tempTexture.uScale = sourceTexture.uScale;\r\n tempTexture.vScale = sourceTexture.vScale;\r\n tempTexture.wAng = sourceTexture.wAng;\r\n }\r\n tempTexture.wrapU = sourceTexture.wrapU;\r\n tempTexture.wrapV = sourceTexture.wrapV;\r\n return tempTexture;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_fuzz 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 /**\r\n * Cache that holds temporary merged textures created during export\r\n */\r\n private _mergedTexturesMap: Record<string, BaseTexture> = {};\r\n\r\n /**\r\n * Cache that holds internal textures of merged textures created during export\r\n */\r\n private _cachedInternalTexturesMap: Record<string, InternalTexture> = {};\r\n\r\n public dispose() {\r\n for (const key of Object.keys(this._mergedTexturesMap)) {\r\n const texture = this._mergedTexturesMap[key];\r\n texture.dispose();\r\n }\r\n this._mergedTexturesMap = {};\r\n for (const key of Object.keys(this._cachedInternalTexturesMap)) {\r\n const internalTexture = this._cachedInternalTexturesMap[key];\r\n internalTexture.dispose();\r\n }\r\n this._cachedInternalTexturesMap = {};\r\n }\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 OpenPBRMaterial) {\r\n const additionalTextures: BaseTexture[] = [];\r\n if (babylonMaterial.fuzzWeight > 0.0) {\r\n if (babylonMaterial.fuzzWeightTexture) {\r\n additionalTextures.push(babylonMaterial.fuzzWeightTexture);\r\n }\r\n let fuzzTexturesNeedMerge = false;\r\n if (babylonMaterial.fuzzRoughnessTexture) {\r\n if (babylonMaterial._useFuzzRoughnessFromTextureAlpha) {\r\n additionalTextures.push(babylonMaterial.fuzzRoughnessTexture);\r\n } else {\r\n fuzzTexturesNeedMerge = true;\r\n }\r\n }\r\n if (babylonMaterial.fuzzColorTexture && !fuzzTexturesNeedMerge) {\r\n additionalTextures.push(babylonMaterial.fuzzColorTexture);\r\n }\r\n if (fuzzTexturesNeedMerge) {\r\n const texId = GetFuzzColorTextureId(babylonMaterial);\r\n if (!this._cachedInternalTexturesMap[texId]) {\r\n const mergedInternalTexture = await CreateMergedFuzzInternalTexture(babylonMaterial);\r\n if (mergedInternalTexture) {\r\n this._cachedInternalTexturesMap[texId] = mergedInternalTexture;\r\n }\r\n }\r\n if (this._cachedInternalTexturesMap[texId]) {\r\n if (babylonMaterial.fuzzColorTexture) {\r\n this._mergedTexturesMap[babylonMaterial.fuzzColorTexture.uniqueId] = CreateTempTexture(\r\n this._cachedInternalTexturesMap[texId],\r\n babylonMaterial.fuzzColorTexture\r\n );\r\n additionalTextures.push(this._mergedTexturesMap[babylonMaterial.fuzzColorTexture.uniqueId]);\r\n }\r\n if (babylonMaterial.fuzzRoughnessTexture) {\r\n this._mergedTexturesMap[babylonMaterial.fuzzRoughnessTexture.uniqueId] = CreateTempTexture(\r\n this._cachedInternalTexturesMap[texId],\r\n babylonMaterial.fuzzRoughnessTexture\r\n );\r\n additionalTextures.push(this._mergedTexturesMap[babylonMaterial.fuzzRoughnessTexture.uniqueId]);\r\n }\r\n }\r\n }\r\n }\r\n return additionalTextures;\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 OpenPBRMaterial) {\r\n if (babylonMaterial.fuzzWeight == 0.0) {\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 fuzzInfo: IKHRMaterialsFuzz = {\r\n fuzzFactor: babylonMaterial.fuzzWeight,\r\n fuzzColorFactor: babylonMaterial.fuzzColor.asArray(),\r\n fuzzRoughnessFactor: babylonMaterial.fuzzRoughness,\r\n };\r\n\r\n if (babylonMaterial.fuzzWeightTexture) {\r\n fuzzInfo.fuzzTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.fuzzWeightTexture) ?? undefined;\r\n }\r\n\r\n let fuzzColorTexture: Nullable<BaseTexture>;\r\n if (babylonMaterial.fuzzColorTexture) {\r\n if (this._mergedTexturesMap[babylonMaterial.fuzzColorTexture.uniqueId]) {\r\n fuzzColorTexture = this._mergedTexturesMap[babylonMaterial.fuzzColorTexture.uniqueId];\r\n } else {\r\n fuzzColorTexture = babylonMaterial.fuzzColorTexture;\r\n }\r\n fuzzInfo.fuzzColorTexture = this._exporter._materialExporter.getTextureInfo(fuzzColorTexture) ?? undefined;\r\n }\r\n\r\n let fuzzRoughnessTexture: Nullable<BaseTexture>;\r\n if (babylonMaterial.fuzzRoughnessTexture) {\r\n if (this._mergedTexturesMap[babylonMaterial.fuzzRoughnessTexture.uniqueId]) {\r\n fuzzRoughnessTexture = this._mergedTexturesMap[babylonMaterial.fuzzRoughnessTexture.uniqueId];\r\n } else {\r\n fuzzRoughnessTexture = babylonMaterial.fuzzRoughnessTexture;\r\n }\r\n fuzzInfo.fuzzRoughnessTexture = this._exporter._materialExporter.getTextureInfo(fuzzRoughnessTexture) ?? undefined;\r\n }\r\n\r\n if (fuzzInfo.fuzzColorTexture !== null || fuzzInfo.fuzzRoughnessTexture !== null) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n node.extensions[NAME] = fuzzInfo;\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_fuzz 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_fuzz(): 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_fuzz(exporter));\r\n}\r\n"]}
@@ -1,29 +1,5 @@
1
- import { type IMaterial } from "babylonjs-gltf2interface";
2
- import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
3
- import { type Material } from "@babylonjs/core/Materials/material.js";
4
1
  /**
5
- * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md)
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./KHR_materials_ior.pure" for tree-shakeable, side-effect-free usage.
6
4
  */
7
- export declare class KHR_materials_ior implements IGLTFExporterExtensionV2 {
8
- /** Name of this extension */
9
- readonly name = "KHR_materials_ior";
10
- /** Defines whether this extension is enabled */
11
- enabled: boolean;
12
- /** Defines whether this extension is required */
13
- required: boolean;
14
- private _wasUsed;
15
- constructor();
16
- /** Dispose */
17
- dispose(): void;
18
- /** @internal */
19
- get wasUsed(): boolean;
20
- private _isExtensionEnabled;
21
- /**
22
- * After exporting a material
23
- * @param context GLTF context of the material
24
- * @param node exported GLTF node
25
- * @param babylonMaterial corresponding babylon material
26
- * @returns promise, resolves with the material
27
- */
28
- postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
29
- }
5
+ export * from "./KHR_materials_ior.pure.js";
@@ -1,70 +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_ior";
5
1
  /**
6
- * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md)
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./KHR_materials_ior.pure" for tree-shakeable, side-effect-free usage.
7
4
  */
8
- // eslint-disable-next-line @typescript-eslint/naming-convention
9
- export class KHR_materials_ior {
10
- constructor() {
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
- }
19
- /** Dispose */
20
- dispose() { }
21
- /** @internal */
22
- get wasUsed() {
23
- return this._wasUsed;
24
- }
25
- _isExtensionEnabled(mat) {
26
- // This extension must not be used on a material that also uses KHR_materials_unlit
27
- if (mat.unlit) {
28
- return false;
29
- }
30
- if (mat instanceof OpenPBRMaterial) {
31
- return mat.specularIor != 1.5; // 1.5 is normative default value.
32
- }
33
- else if (mat instanceof PBRMaterial) {
34
- return mat.indexOfRefraction != undefined && mat.indexOfRefraction != 1.5; // 1.5 is normative default value.
35
- }
36
- return false;
37
- }
38
- /**
39
- * After exporting a material
40
- * @param context GLTF context of the material
41
- * @param node exported GLTF node
42
- * @param babylonMaterial corresponding babylon material
43
- * @returns promise, resolves with the material
44
- */
45
- // eslint-disable-next-line no-restricted-syntax
46
- postExportMaterialAsync(context, node, babylonMaterial) {
47
- return new Promise((resolve) => {
48
- if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {
49
- this._wasUsed = true;
50
- const iorInfo = {
51
- ior: babylonMaterial.indexOfRefraction,
52
- };
53
- node.extensions = node.extensions || {};
54
- node.extensions[NAME] = iorInfo;
55
- }
56
- else if (babylonMaterial instanceof OpenPBRMaterial && this._isExtensionEnabled(babylonMaterial)) {
57
- this._wasUsed = true;
58
- const iorInfo = {
59
- ior: babylonMaterial.specularIor,
60
- };
61
- node.extensions = node.extensions || {};
62
- node.extensions[NAME] = iorInfo;
63
- }
64
- resolve(node);
65
- });
66
- }
67
- }
68
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
69
- GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_ior());
5
+ export * from "./KHR_materials_ior.pure.js";
6
+ import { RegisterKHR_materials_ior } from "./KHR_materials_ior.pure.js";
7
+ RegisterKHR_materials_ior();
70
8
  //# sourceMappingURL=KHR_materials_ior.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_ior.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_ior.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC;;GAEG;AACH,gEAAgE;AAChE,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;YACpC,CAAC;iBAAM,IAAI,eAAe,YAAY,eAAe,IAAI,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,EAAE,CAAC;gBACjG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACrB,MAAM,OAAO,GAAqB;oBAC9B,GAAG,EAAE,eAAe,CAAC,WAAW;iBACnC,CAAC;gBACF,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;YACpC,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,6DAA6D;AAC7D,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC","sourcesContent":["import { type IMaterial, type IKHRMaterialsIor } 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 { OpenPBRMaterial } from \"core/Materials/PBR/openpbrMaterial\";\r\n\r\nconst NAME = \"KHR_materials_ior\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_ior 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 constructor() {}\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 private _isExtensionEnabled(mat: PBRMaterial | OpenPBRMaterial): 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 if (mat instanceof OpenPBRMaterial) {\r\n return mat.specularIor != 1.5; // 1.5 is normative default value.\r\n } else if (mat instanceof PBRMaterial) {\r\n return mat.indexOfRefraction != undefined && mat.indexOfRefraction != 1.5; // 1.5 is normative default value.\r\n }\r\n return false;\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 const iorInfo: IKHRMaterialsIor = {\r\n ior: babylonMaterial.indexOfRefraction,\r\n };\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = iorInfo;\r\n } else if (babylonMaterial instanceof OpenPBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n const iorInfo: IKHRMaterialsIor = {\r\n ior: babylonMaterial.specularIor,\r\n };\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = iorInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_ior());\r\n"]}
1
+ {"version":3,"file":"KHR_materials_ior.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_ior.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,0BAA0B,CAAC;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,yBAAyB,EAAE,CAAC","sourcesContent":["/**\r\n * Re-exports the pure implementation and applies the runtime registration side effect.\r\n * Import \"./KHR_materials_ior.pure\" for tree-shakeable, side-effect-free usage.\r\n */\r\nexport * from \"./KHR_materials_ior.pure\";\r\n\r\nimport { RegisterKHR_materials_ior } from \"./KHR_materials_ior.pure\";\r\nRegisterKHR_materials_ior();\r\n"]}
@@ -0,0 +1,34 @@
1
+ import { type IMaterial } from "babylonjs-gltf2interface";
2
+ import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
3
+ import { type Material } from "@babylonjs/core/Materials/material.js";
4
+ /**
5
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md)
6
+ */
7
+ export declare class KHR_materials_ior implements IGLTFExporterExtensionV2 {
8
+ /** Name of this extension */
9
+ readonly name = "KHR_materials_ior";
10
+ /** Defines whether this extension is enabled */
11
+ enabled: boolean;
12
+ /** Defines whether this extension is required */
13
+ required: boolean;
14
+ private _wasUsed;
15
+ constructor();
16
+ /** Dispose */
17
+ dispose(): void;
18
+ /** @internal */
19
+ get wasUsed(): boolean;
20
+ private _isExtensionEnabled;
21
+ /**
22
+ * After exporting a material
23
+ * @param context GLTF context of the material
24
+ * @param node exported GLTF node
25
+ * @param babylonMaterial corresponding babylon material
26
+ * @returns promise, resolves with the material
27
+ */
28
+ postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
29
+ }
30
+ /**
31
+ * Registers the KHR_materials_ior glTF serializer extension with the {@link GLTFExporter}.
32
+ * Safe to call multiple times; only the first call has an effect.
33
+ */
34
+ export declare function RegisterKHR_materials_ior(): void;
@@ -0,0 +1,81 @@
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_ior";
5
+ /**
6
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md)
7
+ */
8
+ // eslint-disable-next-line @typescript-eslint/naming-convention
9
+ export class KHR_materials_ior {
10
+ constructor() {
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
+ }
19
+ /** Dispose */
20
+ dispose() { }
21
+ /** @internal */
22
+ get wasUsed() {
23
+ return this._wasUsed;
24
+ }
25
+ _isExtensionEnabled(mat) {
26
+ // This extension must not be used on a material that also uses KHR_materials_unlit
27
+ if (mat.unlit) {
28
+ return false;
29
+ }
30
+ if (mat instanceof OpenPBRMaterial) {
31
+ return mat.specularIor != 1.5; // 1.5 is normative default value.
32
+ }
33
+ else if (mat instanceof PBRMaterial) {
34
+ return mat.indexOfRefraction != undefined && mat.indexOfRefraction != 1.5; // 1.5 is normative default value.
35
+ }
36
+ return false;
37
+ }
38
+ /**
39
+ * After exporting a material
40
+ * @param context GLTF context of the material
41
+ * @param node exported GLTF node
42
+ * @param babylonMaterial corresponding babylon material
43
+ * @returns promise, resolves with the material
44
+ */
45
+ // eslint-disable-next-line no-restricted-syntax
46
+ postExportMaterialAsync(context, node, babylonMaterial) {
47
+ return new Promise((resolve) => {
48
+ if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {
49
+ this._wasUsed = true;
50
+ const iorInfo = {
51
+ ior: babylonMaterial.indexOfRefraction,
52
+ };
53
+ node.extensions = node.extensions || {};
54
+ node.extensions[NAME] = iorInfo;
55
+ }
56
+ else if (babylonMaterial instanceof OpenPBRMaterial && this._isExtensionEnabled(babylonMaterial)) {
57
+ this._wasUsed = true;
58
+ const iorInfo = {
59
+ ior: babylonMaterial.specularIor,
60
+ };
61
+ node.extensions = node.extensions || {};
62
+ node.extensions[NAME] = iorInfo;
63
+ }
64
+ resolve(node);
65
+ });
66
+ }
67
+ }
68
+ let _Registered = false;
69
+ /**
70
+ * Registers the KHR_materials_ior glTF serializer extension with the {@link GLTFExporter}.
71
+ * Safe to call multiple times; only the first call has an effect.
72
+ */
73
+ // eslint-disable-next-line @typescript-eslint/naming-convention
74
+ export function RegisterKHR_materials_ior() {
75
+ if (_Registered) {
76
+ return;
77
+ }
78
+ _Registered = true;
79
+ GLTFExporter.RegisterExtension(NAME, () => new KHR_materials_ior());
80
+ }
81
+ //# sourceMappingURL=KHR_materials_ior.pure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_materials_ior.pure.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_ior.pure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE1E,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,iBAAiB;IAY1B;QAXA,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAEhB,aAAQ,GAAG,KAAK,CAAC;IAEV,CAAC;IAEhB,cAAc;IACP,OAAO,KAAI,CAAC;IAEnB,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEO,mBAAmB,CAAC,GAAkC;QAC1D,mFAAmF;QACnF,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YACZ,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,IAAI,GAAG,YAAY,eAAe,EAAE,CAAC;Y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H,gEAAgE;AAChE,MAAM,UAAU,yBAAyB;IACrC,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC;AACxE,CAAC","sourcesContent":["import { type IMaterial, type IKHRMaterialsIor } 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 { OpenPBRMaterial } from \"core/Materials/PBR/openpbrMaterial.pure\";\r\n\r\nconst NAME = \"KHR_materials_ior\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_ior 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 constructor() {}\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 private _isExtensionEnabled(mat: PBRMaterial | OpenPBRMaterial): 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 if (mat instanceof OpenPBRMaterial) {\r\n return mat.specularIor != 1.5; // 1.5 is normative default value.\r\n } else if (mat instanceof PBRMaterial) {\r\n return mat.indexOfRefraction != undefined && mat.indexOfRefraction != 1.5; // 1.5 is normative default value.\r\n }\r\n return false;\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 const iorInfo: IKHRMaterialsIor = {\r\n ior: babylonMaterial.indexOfRefraction,\r\n };\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = iorInfo;\r\n } else if (babylonMaterial instanceof OpenPBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n const iorInfo: IKHRMaterialsIor = {\r\n ior: babylonMaterial.specularIor,\r\n };\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = iorInfo;\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_ior 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_ior(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n GLTFExporter.RegisterExtension(NAME, () => new KHR_materials_ior());\r\n}\r\n"]}
@@ -1,24 +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
- * @internal
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./KHR_materials_iridescence.pure" for tree-shakeable, side-effect-free usage.
8
4
  */
9
- export declare class KHR_materials_iridescence implements IGLTFExporterExtensionV2 {
10
- /** Name of this extension */
11
- readonly name = "KHR_materials_iridescence";
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(): 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
- }
5
+ export * from "./KHR_materials_iridescence.pure.js";