@babylonjs/serializers 8.28.1 → 8.28.2
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.
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.d.ts +9 -1
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.js +192 -1
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +47 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat_anisotropy.d.ts +32 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat_anisotropy.js +231 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat_anisotropy.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat_color.d.ts +24 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat_color.js +101 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat_color.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat_darkening.d.ts +24 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat_darkening.js +70 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat_darkening.js.map +1 -0
- package/glTF/2.0/Extensions/{EXT_materials_diffuse_roughness.d.ts → KHR_materials_diffuse_roughness.d.ts} +3 -3
- package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js +78 -0
- package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.d.ts +1 -1
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +1 -1
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_iridescence.d.ts +1 -1
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js +1 -1
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.js +33 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.js +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/index.d.ts +4 -1
- package/glTF/2.0/Extensions/index.js +4 -1
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFExporter.d.ts +8 -1
- package/glTF/2.0/glTFExporter.js +17 -5
- package/glTF/2.0/glTFExporter.js.map +1 -1
- package/glTF/2.0/glTFExporterExtension.d.ts +1 -1
- package/glTF/2.0/glTFExporterExtension.js.map +1 -1
- package/glTF/2.0/glTFMaterialExporter.d.ts +9 -1
- package/glTF/2.0/glTFMaterialExporter.js +41 -15
- package/glTF/2.0/glTFMaterialExporter.js.map +1 -1
- package/package.json +3 -3
- package/glTF/2.0/Extensions/EXT_materials_diffuse_roughness.js +0 -61
- package/glTF/2.0/Extensions/EXT_materials_diffuse_roughness.js.map +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"KHR_materials_diffuse_roughness.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,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AI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,+BAA+B,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsDiffuseRoughness } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRBaseMaterial } from \"core/Materials/PBR/pbrBaseMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { OpenPBRMaterial } from \"core/Materials/PBR/openPbrMaterial\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nconst NAME = \"KHR_materials_diffuse_roughness\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_diffuse_roughness 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 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 const additionalTextures: BaseTexture[] = [];\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (babylonMaterial._baseDiffuseRoughness) {\r\n if (babylonMaterial._baseDiffuseRoughnessTexture) {\r\n additionalTextures.push(babylonMaterial._baseDiffuseRoughnessTexture);\r\n }\r\n return additionalTextures;\r\n }\r\n } else if (babylonMaterial instanceof OpenPBRMaterial) {\r\n if (babylonMaterial.baseDiffuseRoughness) {\r\n if (babylonMaterial.baseDiffuseRoughnessTexture) {\r\n additionalTextures.push(babylonMaterial.baseDiffuseRoughnessTexture);\r\n }\r\n return additionalTextures;\r\n }\r\n }\r\n\r\n return [];\r\n }\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 let diffuseRoughnessFactor: Nullable<number> = null;\r\n let diffuseRoughnessTexture: Nullable<BaseTexture> = null;\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n diffuseRoughnessFactor = babylonMaterial._baseDiffuseRoughness;\r\n diffuseRoughnessTexture = babylonMaterial._baseDiffuseRoughnessTexture;\r\n } else if (babylonMaterial instanceof OpenPBRMaterial) {\r\n diffuseRoughnessFactor = babylonMaterial.baseDiffuseRoughness;\r\n diffuseRoughnessTexture = babylonMaterial.baseDiffuseRoughnessTexture;\r\n }\r\n if (!diffuseRoughnessFactor) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n node.extensions = node.extensions || {};\r\n\r\n const diffuseRoughnessTextureInfo = this._exporter._materialExporter.getTextureInfo(diffuseRoughnessTexture);\r\n\r\n const diffuseRoughnessInfo: IKHRMaterialsDiffuseRoughness = {\r\n diffuseRoughnessFactor: diffuseRoughnessFactor,\r\n diffuseRoughnessTexture: diffuseRoughnessTextureInfo ?? undefined,\r\n };\r\n\r\n if (diffuseRoughnessInfo.diffuseRoughnessTexture !== null) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n node.extensions[NAME] = diffuseRoughnessInfo;\r\n\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_diffuse_roughness(exporter));\r\n"]}
|
@@ -27,7 +27,7 @@ export declare class KHR_materials_diffuse_transmission implements IGLTFExporter
|
|
27
27
|
* @param babylonMaterial corresponding babylon material
|
28
28
|
* @returns array of additional textures to export
|
29
29
|
*/
|
30
|
-
|
30
|
+
postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
|
31
31
|
private _isExtensionEnabled;
|
32
32
|
/**
|
33
33
|
* After exporting a material
|
@@ -50,7 +50,7 @@ export class KHR_materials_diffuse_transmission {
|
|
50
50
|
* @param babylonMaterial corresponding babylon material
|
51
51
|
* @returns array of additional textures to export
|
52
52
|
*/
|
53
|
-
|
53
|
+
async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
|
54
54
|
const additionalTextures = [];
|
55
55
|
if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {
|
56
56
|
const translucencyIntensityTexture = GetTranslucencyIntensityTexture(context, babylonMaterial);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_diffuse_transmission.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAG1C,MAAM,IAAI,GAAG,oCAAoC,CAAC;AAElD;;;GAGG;AACH,SAAS,+BAA+B,CAAC,OAAe,EAAE,eAA4B;IAClF,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC;IACxC,IAAI,OAAO,GAAG,IAAI,CAAC;IAEnB,gGAAgG;IAChG,IAAI,IAAI,CAAC,4BAA4B,EAAE,CAAC;QACpC,OAAO,GAAG,IAAI,CAAC,4BAA4B,CAAC;IAChD,CAAC;SAAM,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;QACnE,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC;IACpC,CAAC;IAED,IAAI,OAAO,IAAI,CAAC,IAAI,CA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C,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;gBACpK,MAAM,+BAA+B,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,wBAAwB,CAAC,IAAI,SAAS,CAAC;gBAEpI,MAAM,uBAAuB,GAAqC;oBAC9D,yBAAyB;oBACzB,0BAA0B;oBAC1B,8BAA8B;oBAC9B,+BAA+B;iBAClC,CAAC;gBAEF,IAAI,0BAA0B,IAAI,+BAA+B,EAAE,CAAC;oBAChE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;gBAC7D,CAAC;gBAED,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,uBAAuB,CAAC;YACpD,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,kCAAkC,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsDiffuseTransmission } 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 { Logger } from \"core/Misc/logger\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nconst NAME = \"KHR_materials_diffuse_transmission\";\r\n\r\n/**\r\n * Get the appropriate translucency intensity texture for the material.\r\n * @internal\r\n */\r\nfunction GetTranslucencyIntensityTexture(context: string, babylonMaterial: PBRMaterial): Nullable<BaseTexture> {\r\n const subs = babylonMaterial.subSurface;\r\n let texture = null;\r\n\r\n // Check if translucency intensity texture is available or can be derived from thickness texture\r\n if (subs.translucencyIntensityTexture) {\r\n texture = subs.translucencyIntensityTexture;\r\n } else if (subs.thicknessTexture && subs.useMaskFromThicknessTexture) {\r\n texture = subs.thicknessTexture;\r\n }\r\n\r\n if (texture && !subs.useGltfStyleTextures) {\r\n Logger.Warn(`${context}: Translucency intensity texture is not supported when useGltfStyleTextures = false. Ignoring for: ${babylonMaterial.name}`, 1);\r\n return null;\r\n }\r\n\r\n return texture;\r\n}\r\n\r\n/**\r\n * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)\r\n * !!! Experimental Extension Subject to Changes !!!\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_diffuse_transmission implements 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 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 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 postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[] {\r\n const additionalTextures: BaseTexture[] = [];\r\n\r\n if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n const translucencyIntensityTexture = GetTranslucencyIntensityTexture(context, babylonMaterial);\r\n if (translucencyIntensityTexture) {\r\n additionalTextures.push(translucencyIntensityTexture);\r\n }\r\n if (babylonMaterial.subSurface.translucencyColorTexture) {\r\n additionalTextures.push(babylonMaterial.subSurface.translucencyColorTexture);\r\n }\r\n return additionalTextures;\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 const subs = mat.subSurface;\r\n if (!subs.isTranslucencyEnabled) {\r\n return false;\r\n }\r\n\r\n return (\r\n !mat.unlit &&\r\n !subs.useAlbedoToTintTranslucency &&\r\n subs.useGltfStyleTextures &&\r\n subs.volumeIndexOfRefraction === 1 &&\r\n subs.minimumThickness === 0 &&\r\n subs.maximumThickness === 0\r\n );\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 that resolves with the updated node\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 subs = babylonMaterial.subSurface;\r\n const translucencyIntensityTexture = GetTranslucencyIntensityTexture(context, babylonMaterial);\r\n\r\n const diffuseTransmissionFactor = subs.translucencyIntensity == 0 ? undefined : subs.translucencyIntensity;\r\n const diffuseTransmissionTexture = this._exporter._materialExporter.getTextureInfo(translucencyIntensityTexture) ?? undefined;\r\n const diffuseTransmissionColorFactor = !subs.translucencyColor || subs.translucencyColor.equalsFloats(1.0, 1.0, 1.0) ? undefined : subs.translucencyColor.asArray();\r\n const diffuseTransmissionColorTexture = this._exporter._materialExporter.getTextureInfo(subs.translucencyColorTexture) ?? undefined;\r\n\r\n const diffuseTransmissionInfo: IKHRMaterialsDiffuseTransmission = {\r\n diffuseTransmissionFactor,\r\n diffuseTransmissionTexture,\r\n diffuseTransmissionColorFactor,\r\n diffuseTransmissionColorTexture,\r\n };\r\n\r\n if (diffuseTransmissionTexture || diffuseTransmissionColorTexture) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = diffuseTransmissionInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_diffuse_transmission(exporter));\r\n"]}
|
1
|
+
{"version":3,"file":"KHR_materials_diffuse_transmission.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAG1C,MAAM,IAAI,GAAG,oCAAoC,CAAC;AAElD;;;GAGG;AACH,SAAS,+BAA+B,CAAC,OAAe,EAAE,eAA4B;IAClF,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC;IACxC,IAAI,OAAO,GAAG,IAAI,CAAC;IAEnB,gGAAgG;IAChG,IAAI,IAAI,CAAC,4BAA4B,EAAE,CAAC;QACpC,OAAO,GAAG,IAAI,CAAC,4BAA4B,CAAC;IAChD,CAAC;SAAM,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;QACnE,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC;IACpC,CAAC;IAED,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,sGAAsG,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;QACvJ,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,OAAO,CAAC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BAAwB,CAAC,IAAI,SAAS,CAAC;gBAEpI,MAAM,uBAAuB,GAAqC;oBAC9D,yBAAyB;oBACzB,0BAA0B;oBAC1B,8BAA8B;oBAC9B,+BAA+B;iBAClC,CAAC;gBAEF,IAAI,0BAA0B,IAAI,+BAA+B,EAAE,CAAC;oBAChE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;gBAC7D,CAAC;gBAED,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,uBAAuB,CAAC;YACpD,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,kCAAkC,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsDiffuseTransmission } 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 { Logger } from \"core/Misc/logger\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nconst NAME = \"KHR_materials_diffuse_transmission\";\r\n\r\n/**\r\n * Get the appropriate translucency intensity texture for the material.\r\n * @internal\r\n */\r\nfunction GetTranslucencyIntensityTexture(context: string, babylonMaterial: PBRMaterial): Nullable<BaseTexture> {\r\n const subs = babylonMaterial.subSurface;\r\n let texture = null;\r\n\r\n // Check if translucency intensity texture is available or can be derived from thickness texture\r\n if (subs.translucencyIntensityTexture) {\r\n texture = subs.translucencyIntensityTexture;\r\n } else if (subs.thicknessTexture && subs.useMaskFromThicknessTexture) {\r\n texture = subs.thicknessTexture;\r\n }\r\n\r\n if (texture && !subs.useGltfStyleTextures) {\r\n Logger.Warn(`${context}: Translucency intensity texture is not supported when useGltfStyleTextures = false. Ignoring for: ${babylonMaterial.name}`, 1);\r\n return null;\r\n }\r\n\r\n return texture;\r\n}\r\n\r\n/**\r\n * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)\r\n * !!! Experimental Extension Subject to Changes !!!\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_diffuse_transmission implements 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 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 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 && this._isExtensionEnabled(babylonMaterial)) {\r\n const translucencyIntensityTexture = GetTranslucencyIntensityTexture(context, babylonMaterial);\r\n if (translucencyIntensityTexture) {\r\n additionalTextures.push(translucencyIntensityTexture);\r\n }\r\n if (babylonMaterial.subSurface.translucencyColorTexture) {\r\n additionalTextures.push(babylonMaterial.subSurface.translucencyColorTexture);\r\n }\r\n return additionalTextures;\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 const subs = mat.subSurface;\r\n if (!subs.isTranslucencyEnabled) {\r\n return false;\r\n }\r\n\r\n return (\r\n !mat.unlit &&\r\n !subs.useAlbedoToTintTranslucency &&\r\n subs.useGltfStyleTextures &&\r\n subs.volumeIndexOfRefraction === 1 &&\r\n subs.minimumThickness === 0 &&\r\n subs.maximumThickness === 0\r\n );\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 that resolves with the updated node\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 subs = babylonMaterial.subSurface;\r\n const translucencyIntensityTexture = GetTranslucencyIntensityTexture(context, babylonMaterial);\r\n\r\n const diffuseTransmissionFactor = subs.translucencyIntensity == 0 ? undefined : subs.translucencyIntensity;\r\n const diffuseTransmissionTexture = this._exporter._materialExporter.getTextureInfo(translucencyIntensityTexture) ?? undefined;\r\n const diffuseTransmissionColorFactor = !subs.translucencyColor || subs.translucencyColor.equalsFloats(1.0, 1.0, 1.0) ? undefined : subs.translucencyColor.asArray();\r\n const diffuseTransmissionColorTexture = this._exporter._materialExporter.getTextureInfo(subs.translucencyColorTexture) ?? undefined;\r\n\r\n const diffuseTransmissionInfo: IKHRMaterialsDiffuseTransmission = {\r\n diffuseTransmissionFactor,\r\n diffuseTransmissionTexture,\r\n diffuseTransmissionColorFactor,\r\n diffuseTransmissionColorTexture,\r\n };\r\n\r\n if (diffuseTransmissionTexture || diffuseTransmissionColorTexture) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = diffuseTransmissionInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_diffuse_transmission(exporter));\r\n"]}
|
@@ -19,6 +19,6 @@ export declare class KHR_materials_iridescence implements IGLTFExporterExtension
|
|
19
19
|
dispose(): void;
|
20
20
|
/** @internal */
|
21
21
|
get wasUsed(): boolean;
|
22
|
-
|
22
|
+
postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
|
23
23
|
postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
|
24
24
|
}
|
@@ -21,7 +21,7 @@ export class KHR_materials_iridescence {
|
|
21
21
|
get wasUsed() {
|
22
22
|
return this._wasUsed;
|
23
23
|
}
|
24
|
-
|
24
|
+
async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
|
25
25
|
const additionalTextures = [];
|
26
26
|
if (babylonMaterial instanceof PBRBaseMaterial) {
|
27
27
|
if (babylonMaterial.iridescence.isEnabled) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_iridescence.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAGrE,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAEzC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,yBAAyB;IAclC,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;IAEM,OAAO,KAAI,CAAC;IAEnB,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEM,
|
1
|
+
{"version":3,"file":"KHR_materials_iridescence.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAGrE,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAEzC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,yBAAyB;IAclC,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;IAEM,OAAO,KAAI,CAAC;IAEnB,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,yCAAyC,CAAE,OAAe,EAAE,IAAe,EAAE,eAAyB;QAC/G,MAAM,kBAAkB,GAAkB,EAAE,CAAC;QAC7C,IAAI,eAAe,YAAY,eAAe,EAAE,CAAC;YAC7C,IAAI,eAAe,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;gBACxC,IAAI,eAAe,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;oBACtC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;gBACjE,CAAC;gBACD,IAAI,eAAe,CAAC,WAAW,CAAC,gBAAgB,IAAI,eAAe,C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gBAEF,IAAI,eAAe,CAAC,kBAAkB,KAAK,IAAI,IAAI,eAAe,CAAC,2BAA2B,KAAK,IAAI,EAAE,CAAC;oBACtG,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;gBAC7D,CAAC;gBAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC;YAC5C,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,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsIridescence } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRBaseMaterial } from \"core/Materials/PBR/pbrBaseMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\nconst NAME = \"KHR_materials_iridescence\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_iridescence 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 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 const additionalTextures: BaseTexture[] = [];\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (babylonMaterial.iridescence.isEnabled) {\r\n if (babylonMaterial.iridescence.texture) {\r\n additionalTextures.push(babylonMaterial.iridescence.texture);\r\n }\r\n if (babylonMaterial.iridescence.thicknessTexture && babylonMaterial.iridescence.thicknessTexture !== babylonMaterial.iridescence.texture) {\r\n additionalTextures.push(babylonMaterial.iridescence.thicknessTexture);\r\n }\r\n return additionalTextures;\r\n }\r\n }\r\n\r\n return [];\r\n }\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 PBRBaseMaterial) {\r\n if (!babylonMaterial.iridescence.isEnabled) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n node.extensions = node.extensions || {};\r\n\r\n const iridescenceTextureInfo = this._exporter._materialExporter.getTextureInfo(babylonMaterial.iridescence.texture);\r\n const iridescenceThicknessTextureInfo = this._exporter._materialExporter.getTextureInfo(babylonMaterial.iridescence.thicknessTexture);\r\n\r\n const iridescenceInfo: IKHRMaterialsIridescence = {\r\n iridescenceFactor: babylonMaterial.iridescence.intensity,\r\n iridescenceIor: babylonMaterial.iridescence.indexOfRefraction,\r\n iridescenceThicknessMinimum: babylonMaterial.iridescence.minimumThickness,\r\n iridescenceThicknessMaximum: babylonMaterial.iridescence.maximumThickness,\r\n\r\n iridescenceTexture: iridescenceTextureInfo ?? undefined,\r\n iridescenceThicknessTexture: iridescenceThicknessTextureInfo ?? undefined,\r\n };\r\n\r\n if (iridescenceInfo.iridescenceTexture !== null || iridescenceInfo.iridescenceThicknessTexture !== null) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n node.extensions[NAME] = iridescenceInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_iridescence(exporter));\r\n"]}
|
@@ -19,6 +19,6 @@ export declare class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
|
|
19
19
|
dispose(): void;
|
20
20
|
/** @internal */
|
21
21
|
get wasUsed(): boolean;
|
22
|
-
|
22
|
+
postExportMaterialAdditionalTexturesAsync(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
|
23
23
|
postExportMaterialAsync(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
|
24
24
|
}
|
@@ -21,7 +21,7 @@ export class KHR_materials_sheen {
|
|
21
21
|
get wasUsed() {
|
22
22
|
return this._wasUsed;
|
23
23
|
}
|
24
|
-
|
24
|
+
async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
|
25
25
|
if (babylonMaterial instanceof PBRMaterial) {
|
26
26
|
if (babylonMaterial.sheen.isEnabled && babylonMaterial.sheen.texture) {
|
27
27
|
return [babylonMaterial.sheen.texture];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_sheen.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_sheen.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAG7D,MAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,mBAAmB;IAc5B,YAAY,QAAsB;QAblC,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;QAKrB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAEM,OAAO,KAAI,CAAC;IAEnB,gBAAgB;IAChB,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BAAiB,CAAC,cAAc,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC;gBAClI,CAAC;gBAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;YACtC,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,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, 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\";\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\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_sheen(exporter));\r\n"]}
|
@@ -27,7 +27,7 @@ export declare class KHR_materials_specular implements IGLTFExporterExtensionV2
|
|
27
27
|
* @param babylonMaterial corresponding babylon material
|
28
28
|
* @returns array of additional textures to export
|
29
29
|
*/
|
30
|
-
|
30
|
+
postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
|
31
31
|
private _isExtensionEnabled;
|
32
32
|
private _hasTexturesExtension;
|
33
33
|
/**
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { GLTFExporter } from "../glTFExporter.js";
|
2
2
|
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
3
|
+
import { OpenPBRMaterial } from "@babylonjs/core/Materials/PBR/openPbrMaterial.js";
|
3
4
|
const NAME = "KHR_materials_specular";
|
4
5
|
/**
|
5
6
|
* [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md)
|
@@ -29,7 +30,7 @@ export class KHR_materials_specular {
|
|
29
30
|
* @param babylonMaterial corresponding babylon material
|
30
31
|
* @returns array of additional textures to export
|
31
32
|
*/
|
32
|
-
|
33
|
+
async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
|
33
34
|
const additionalTextures = [];
|
34
35
|
if (babylonMaterial instanceof PBRMaterial) {
|
35
36
|
if (this._isExtensionEnabled(babylonMaterial)) {
|
@@ -66,6 +67,7 @@ export class KHR_materials_specular {
|
|
66
67
|
// eslint-disable-next-line no-restricted-syntax
|
67
68
|
postExportMaterialAsync(context, node, babylonMaterial) {
|
68
69
|
return new Promise((resolve) => {
|
70
|
+
var _a;
|
69
71
|
if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {
|
70
72
|
this._wasUsed = true;
|
71
73
|
node.extensions = node.extensions || {};
|
@@ -86,6 +88,36 @@ export class KHR_materials_specular {
|
|
86
88
|
}
|
87
89
|
node.extensions[NAME] = specularInfo;
|
88
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
|
+
}
|
89
121
|
resolve(node);
|
90
122
|
});
|
91
123
|
}
|
@@ -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,qDAAuC;AAG7D,MAAM,IAAI,GAAG,wBAAwB,CAAC;AAEtC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO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;oBAC3C,mBAAmB,EAAE,wBAAwB;oBAC7C,oBAAoB,EAAE,kBAAkB;iBAC3C,CAAC;gBAEF,IAAI,IAAI,CAAC,qBAAqB,CAAC,eAAe,CAAC,EAAE,CAAC;oBAC9C,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, IKHRMaterialsSpecular } 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\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 postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): 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 }\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":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAErE,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;I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,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, IKHRMaterialsSpecular, 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"]}
|
@@ -27,7 +27,7 @@ export declare class KHR_materials_transmission implements IGLTFExporterExtensio
|
|
27
27
|
* @param babylonMaterial corresponding babylon material
|
28
28
|
* @returns array of additional textures to export
|
29
29
|
*/
|
30
|
-
|
30
|
+
postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
|
31
31
|
private _isExtensionEnabled;
|
32
32
|
private _hasTexturesExtension;
|
33
33
|
/**
|
@@ -30,7 +30,7 @@ export class KHR_materials_transmission {
|
|
30
30
|
* @param babylonMaterial corresponding babylon material
|
31
31
|
* @returns array of additional textures to export
|
32
32
|
*/
|
33
|
-
|
33
|
+
async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
|
34
34
|
const additionalTextures = [];
|
35
35
|
if (babylonMaterial instanceof PBRMaterial) {
|
36
36
|
if (this._isExtensionEnabled(babylonMaterial)) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_transmission.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAE1C,MAAM,IAAI,GAAG,4BAA4B,CAAC;AAE1C;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,0BAA0B;IAcnC,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,
|
1
|
+
{"version":3,"file":"KHR_materials_transmission.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAE1C,MAAM,IAAI,GAAG,4BAA4B,CAAC;AAE1C;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,0BAA0B;IAcnC,YAAY,QAAsB;QAblC,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,G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EAAE,CAAC,IAAI,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsTransmission } 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 { Logger } from \"core/Misc/logger\";\r\n\r\nconst NAME = \"KHR_materials_transmission\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_transmission/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_transmission 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 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.subSurface.thicknessTexture) {\r\n additionalTextures.push(babylonMaterial.subSurface.thicknessTexture);\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 const subs = mat.subSurface;\r\n return (subs.isRefractionEnabled && subs.refractionIntensity != undefined && subs.refractionIntensity != 0) || this._hasTexturesExtension(mat);\r\n }\r\n\r\n private _hasTexturesExtension(mat: PBRMaterial): boolean {\r\n return mat.subSurface.refractionIntensityTexture != 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 true if successful\r\n */\r\n public async postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n\r\n const subSurface = babylonMaterial.subSurface;\r\n const transmissionFactor = subSurface.refractionIntensity === 0 ? undefined : subSurface.refractionIntensity;\r\n\r\n const volumeInfo: IKHRMaterialsTransmission = {\r\n transmissionFactor: transmissionFactor,\r\n };\r\n\r\n if (this._hasTexturesExtension(babylonMaterial)) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n if (subSurface.refractionIntensityTexture) {\r\n if (subSurface.useGltfStyleTextures) {\r\n const transmissionTexture = await this._exporter._materialExporter.exportTextureAsync(subSurface.refractionIntensityTexture);\r\n if (transmissionTexture) {\r\n volumeInfo.transmissionTexture = transmissionTexture;\r\n }\r\n } else {\r\n Logger.Warn(`${context}: Exporting a subsurface refraction intensity texture without \\`useGltfStyleTextures\\` is not supported`);\r\n }\r\n }\r\n\r\n node.extensions ||= {};\r\n node.extensions[NAME] = volumeInfo;\r\n }\r\n\r\n return node;\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_transmission(exporter));\r\n"]}
|
@@ -26,7 +26,7 @@ export declare class KHR_materials_volume implements IGLTFExporterExtensionV2 {
|
|
26
26
|
* @param babylonMaterial corresponding babylon material
|
27
27
|
* @returns array of additional textures to export
|
28
28
|
*/
|
29
|
-
|
29
|
+
postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
|
30
30
|
private _isExtensionEnabled;
|
31
31
|
private _hasTexturesExtension;
|
32
32
|
/**
|
@@ -29,7 +29,7 @@ export class KHR_materials_volume {
|
|
29
29
|
* @param babylonMaterial corresponding babylon material
|
30
30
|
* @returns array of additional textures to export
|
31
31
|
*/
|
32
|
-
|
32
|
+
async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
|
33
33
|
const additionalTextures = [];
|
34
34
|
if (babylonMaterial instanceof PBRMaterial) {
|
35
35
|
if (this._isExtensionEnabled(babylonMaterial)) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_volume.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_volume.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE/C,MAAM,IAAI,GAAG,sBAAsB,CAAC;AAEpC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,oBAAoB;IAc7B,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;IAEM,OAAO,KAAI,CAAC;IAEnB,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACI,
|
1
|
+
{"version":3,"file":"KHR_materials_volume.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_volume.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE/C,MAAM,IAAI,GAAG,sBAAsB,CAAC;AAEpC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,oBAAoB;IAc7B,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;IAEM,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,UAAU,CAAC,gBAAgB,EAAE,CAAC;oBAC9C,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;gBACzE,CAAC;gBACD,OAAO,kBAAkB,CAAC;YAC9B,CAAC;QACL,CAAC;QAED,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAEO,mBAAmB,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AAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,SAAS,CAAC;gBAC7G,MAAM,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,IAAI,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC;gBACxH,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;gBAE3G,MAAM,UAAU,GAAwB;oBACpC,eAAe,EAAE,eAAe;oBAChC,gBAAgB,EAAE,gBAAgB;oBAClC,mBAAmB,EAAE,mBAAmB;oBACxC,gBAAgB,EAAE,gBAAgB;iBACrC,CAAC;gBAEF,IAAI,IAAI,CAAC,qBAAqB,CAAC,eAAe,CAAC,EAAE,CAAC;oBAC9C,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;gBAC7D,CAAC;gBAED,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;YACvC,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,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsVolume } 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 { Color3 } from \"core/Maths/math.color\";\r\n\r\nconst NAME = \"KHR_materials_volume\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_volume 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 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 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.subSurface.thicknessTexture) {\r\n additionalTextures.push(babylonMaterial.subSurface.thicknessTexture);\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 const subs = mat.subSurface;\r\n // this extension requires either the KHR_materials_transmission or KHR_materials_diffuse_transmission extensions.\r\n if (!subs.isRefractionEnabled && !subs.isTranslucencyEnabled) {\r\n return false;\r\n }\r\n return (\r\n (subs.maximumThickness != undefined && subs.maximumThickness != 0) ||\r\n (subs.tintColorAtDistance != undefined && subs.tintColorAtDistance != Number.POSITIVE_INFINITY) ||\r\n (subs.tintColor != undefined && subs.tintColor != Color3.White()) ||\r\n this._hasTexturesExtension(mat)\r\n );\r\n }\r\n\r\n private _hasTexturesExtension(mat: PBRMaterial): boolean {\r\n return mat.subSurface.thicknessTexture != 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 that resolves with the updated node\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 subs = babylonMaterial.subSurface;\r\n const thicknessFactor = subs.maximumThickness == 0 ? undefined : subs.maximumThickness;\r\n const thicknessTexture = this._exporter._materialExporter.getTextureInfo(subs.thicknessTexture) ?? undefined;\r\n const attenuationDistance = subs.tintColorAtDistance == Number.POSITIVE_INFINITY ? undefined : subs.tintColorAtDistance;\r\n const attenuationColor = subs.tintColor.equalsFloats(1.0, 1.0, 1.0) ? undefined : subs.tintColor.asArray();\r\n\r\n const volumeInfo: IKHRMaterialsVolume = {\r\n thicknessFactor: thicknessFactor,\r\n thicknessTexture: thicknessTexture,\r\n attenuationDistance: attenuationDistance,\r\n attenuationColor: attenuationColor,\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 = node.extensions || {};\r\n node.extensions[NAME] = volumeInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_volume(exporter));\r\n"]}
|
@@ -3,6 +3,9 @@ export * from "./KHR_draco_mesh_compression.js";
|
|
3
3
|
export * from "./KHR_lights_punctual.js";
|
4
4
|
export * from "./KHR_materials_anisotropy.js";
|
5
5
|
export * from "./KHR_materials_clearcoat.js";
|
6
|
+
export * from "./KHR_materials_clearcoat_darkening.js";
|
7
|
+
export * from "./KHR_materials_clearcoat_color.js";
|
8
|
+
export * from "./KHR_materials_clearcoat_anisotropy.js";
|
6
9
|
export * from "./KHR_materials_diffuse_transmission.js";
|
7
10
|
export * from "./KHR_materials_dispersion.js";
|
8
11
|
export * from "./KHR_materials_emissive_strength.js";
|
@@ -13,7 +16,7 @@ export * from "./KHR_materials_specular.js";
|
|
13
16
|
export * from "./KHR_materials_transmission.js";
|
14
17
|
export * from "./KHR_materials_unlit.js";
|
15
18
|
export * from "./KHR_materials_volume.js";
|
16
|
-
export * from "./
|
19
|
+
export * from "./KHR_materials_diffuse_roughness.js";
|
17
20
|
export * from "./KHR_texture_transform.js";
|
18
21
|
export * from "./KHR_texture_basisu.js";
|
19
22
|
export * from "./EXT_texture_webp.js";
|
@@ -3,6 +3,9 @@ export * from "./KHR_draco_mesh_compression.js";
|
|
3
3
|
export * from "./KHR_lights_punctual.js";
|
4
4
|
export * from "./KHR_materials_anisotropy.js";
|
5
5
|
export * from "./KHR_materials_clearcoat.js";
|
6
|
+
export * from "./KHR_materials_clearcoat_darkening.js";
|
7
|
+
export * from "./KHR_materials_clearcoat_color.js";
|
8
|
+
export * from "./KHR_materials_clearcoat_anisotropy.js";
|
6
9
|
export * from "./KHR_materials_diffuse_transmission.js";
|
7
10
|
export * from "./KHR_materials_dispersion.js";
|
8
11
|
export * from "./KHR_materials_emissive_strength.js";
|
@@ -13,7 +16,7 @@ export * from "./KHR_materials_specular.js";
|
|
13
16
|
export * from "./KHR_materials_transmission.js";
|
14
17
|
export * from "./KHR_materials_unlit.js";
|
15
18
|
export * from "./KHR_materials_volume.js";
|
16
|
-
export * from "./
|
19
|
+
export * from "./KHR_materials_diffuse_roughness.js";
|
17
20
|
export * from "./KHR_texture_transform.js";
|
18
21
|
export * from "./KHR_texture_basisu.js";
|
19
22
|
export * from "./EXT_texture_webp.js";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_anisotropy\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_diffuse_transmission\";\r\nexport * from \"./KHR_materials_dispersion\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_anisotropy\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_clearcoat_darkening\";\r\nexport * from \"./KHR_materials_clearcoat_color\";\r\nexport * from \"./KHR_materials_clearcoat_anisotropy\";\r\nexport * from \"./KHR_materials_diffuse_transmission\";\r\nexport * from \"./KHR_materials_dispersion\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_materials_diffuse_roughness\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./EXT_texture_avif\";\r\n"]}
|
@@ -54,7 +54,14 @@ export declare class GLTFExporter {
|
|
54
54
|
private _ApplyExtensions;
|
55
55
|
_extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node, nodeMap: Map<Node, number>, convertToRightHanded: boolean): Promise<Nullable<INode>>;
|
56
56
|
_extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
|
57
|
-
|
57
|
+
/**
|
58
|
+
* Get additional textures for a material
|
59
|
+
* @param context The context when loading the asset
|
60
|
+
* @param material The glTF material
|
61
|
+
* @param babylonMaterial The Babylon.js material
|
62
|
+
* @returns List of additional textures
|
63
|
+
*/
|
64
|
+
_extensionsPostExportMaterialAdditionalTexturesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
|
58
65
|
_extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
|
59
66
|
_extensionsPostExportMeshPrimitive(primitive: IMeshPrimitive): void;
|
60
67
|
_extensionsPreGenerateBinaryAsync(): Promise<void>;
|
package/glTF/2.0/glTFExporter.js
CHANGED
@@ -26,6 +26,7 @@ import { Color3, Color4 } from "@babylonjs/core/Maths/math.color.js";
|
|
26
26
|
import { TargetCamera } from "@babylonjs/core/Cameras/targetCamera.js";
|
27
27
|
import { Epsilon } from "@babylonjs/core/Maths/math.constants.js";
|
28
28
|
import { DataWriter } from "./dataWriter.js";
|
29
|
+
import { OpenPBRMaterial } from "@babylonjs/core/Materials/PBR/openPbrMaterial.js";
|
29
30
|
class ExporterState {
|
30
31
|
constructor(convertToRightHanded, wasAddedByNoopNode) {
|
31
32
|
// Babylon indices array, start, count, offset, flip -> glTF accessor index
|
@@ -164,14 +165,22 @@ export class GLTFExporter {
|
|
164
165
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
165
166
|
return this._ApplyExtensions(material, (extension, node) => extension.postExportMaterialAsync && extension.postExportMaterialAsync(context, node, babylonMaterial));
|
166
167
|
}
|
167
|
-
|
168
|
+
/**
|
169
|
+
* Get additional textures for a material
|
170
|
+
* @param context The context when loading the asset
|
171
|
+
* @param material The glTF material
|
172
|
+
* @param babylonMaterial The Babylon.js material
|
173
|
+
* @returns List of additional textures
|
174
|
+
*/
|
175
|
+
async _extensionsPostExportMaterialAdditionalTexturesAsync(context, material, babylonMaterial) {
|
168
176
|
const output = [];
|
169
|
-
|
177
|
+
await Promise.all(GLTFExporter._ExtensionNames.map(async (name) => {
|
170
178
|
const extension = this._extensions[name];
|
171
|
-
if (extension.
|
172
|
-
|
179
|
+
if (extension.postExportMaterialAdditionalTexturesAsync) {
|
180
|
+
const textures = await extension.postExportMaterialAdditionalTexturesAsync(context, material, babylonMaterial);
|
181
|
+
output.push(...textures);
|
173
182
|
}
|
174
|
-
}
|
183
|
+
}));
|
175
184
|
return output;
|
176
185
|
}
|
177
186
|
_extensionsPostExportTextures(context, textureInfo, babylonTexture) {
|
@@ -1056,6 +1065,9 @@ export class GLTFExporter {
|
|
1056
1065
|
else if (babylonMaterial instanceof StandardMaterial) {
|
1057
1066
|
materialIndex = await this._materialExporter.exportStandardMaterialAsync(babylonMaterial, hasUVs);
|
1058
1067
|
}
|
1068
|
+
else if (babylonMaterial instanceof OpenPBRMaterial) {
|
1069
|
+
materialIndex = await this._materialExporter.exportOpenPBRMaterialAsync(babylonMaterial, hasUVs);
|
1070
|
+
}
|
1059
1071
|
else {
|
1060
1072
|
Logger.Warn(`Unsupported material '${babylonMaterial.name}' with type ${babylonMaterial.getClassName()}`);
|
1061
1073
|
return;
|