@babylonjs/serializers 8.34.0 → 8.35.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 (31) hide show
  1. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js +11 -5
  2. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -1
  3. package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +8 -0
  4. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +136 -13
  5. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  6. package/glTF/2.0/Extensions/{KHR_materials_clearcoat_darkening.d.ts → KHR_materials_coat.d.ts} +10 -2
  7. package/glTF/2.0/Extensions/KHR_materials_coat.js +383 -0
  8. package/glTF/2.0/Extensions/KHR_materials_coat.js.map +1 -0
  9. package/glTF/2.0/Extensions/{KHR_materials_clearcoat_color.d.ts → KHR_materials_fuzz.d.ts} +13 -5
  10. package/glTF/2.0/Extensions/KHR_materials_fuzz.js +194 -0
  11. package/glTF/2.0/Extensions/KHR_materials_fuzz.js.map +1 -0
  12. package/glTF/2.0/Extensions/index.d.ts +2 -4
  13. package/glTF/2.0/Extensions/index.js +2 -4
  14. package/glTF/2.0/Extensions/index.js.map +1 -1
  15. package/glTF/2.0/glTFExporter.d.ts +2 -5
  16. package/glTF/2.0/glTFExporter.js +1 -1
  17. package/glTF/2.0/glTFExporter.js.map +1 -1
  18. package/glTF/2.0/glTFMaterialExporter.d.ts +1 -3
  19. package/glTF/2.0/glTFMaterialExporter.js +40 -31
  20. package/glTF/2.0/glTFMaterialExporter.js.map +1 -1
  21. package/package.json +3 -3
  22. package/glTF/2.0/Extensions/KHR_materials_clearcoat_anisotropy.d.ts +0 -32
  23. package/glTF/2.0/Extensions/KHR_materials_clearcoat_anisotropy.js +0 -152
  24. package/glTF/2.0/Extensions/KHR_materials_clearcoat_anisotropy.js.map +0 -1
  25. package/glTF/2.0/Extensions/KHR_materials_clearcoat_color.js +0 -101
  26. package/glTF/2.0/Extensions/KHR_materials_clearcoat_color.js.map +0 -1
  27. package/glTF/2.0/Extensions/KHR_materials_clearcoat_darkening.js +0 -70
  28. package/glTF/2.0/Extensions/KHR_materials_clearcoat_darkening.js.map +0 -1
  29. package/glTF/2.0/Extensions/KHR_materials_clearcoat_ior.d.ts +0 -26
  30. package/glTF/2.0/Extensions/KHR_materials_clearcoat_ior.js +0 -60
  31. package/glTF/2.0/Extensions/KHR_materials_clearcoat_ior.js.map +0 -1
@@ -1,152 +0,0 @@
1
- import { GLTFExporter } from "../glTFExporter.js";
2
- import { OpenPBRMaterial } from "@babylonjs/core/Materials/PBR/openpbrMaterial.js";
3
- import { MergeTexturesAsync, CreateRGBAConfiguration, CreateTextureInput, CreateConstantInput } from "@babylonjs/core/Materials/Textures/textureMerger.js";
4
- const NAME = "KHR_materials_clearcoat_anisotropy";
5
- // Convert OpenPBR anisotropy values to glTF-compatible values
6
- function OpenpbrAnisotropyStrengthToGltf(baseRoughness, anisotropy) {
7
- const baseAlpha = baseRoughness * baseRoughness;
8
- const roughnessT = baseAlpha * Math.sqrt(2.0 / (1.0 + (1 - anisotropy) * (1 - anisotropy)));
9
- const roughnessB = (1 - anisotropy) * roughnessT;
10
- const newBaseRoughness = Math.sqrt(roughnessB);
11
- const newAnisotropyStrength = Math.min(Math.sqrt((roughnessT - baseAlpha) / Math.max(1.0 - baseAlpha, 0.0001)), 1.0);
12
- return { newBaseRoughness, newAnisotropyStrength };
13
- }
14
- function GetAnisoTextureId(babylonMaterial) {
15
- const anisoStrengthTexture = babylonMaterial.coatRoughnessAnisotropyTexture;
16
- const tangentTexture = babylonMaterial.geometryCoatTangentTexture;
17
- const strengthId = anisoStrengthTexture && anisoStrengthTexture.getInternalTexture() ? anisoStrengthTexture.getInternalTexture().uniqueId : "NoStrength";
18
- const tangentId = tangentTexture && tangentTexture.getInternalTexture() ? tangentTexture.getInternalTexture().uniqueId : "NoTangent";
19
- return `${strengthId}_${tangentId}`;
20
- }
21
- // In your postExportMaterialAsync method:
22
- async function CreateMergedAnisotropyTexture(babylonMaterial) {
23
- const scene = babylonMaterial.getScene();
24
- const anisoStrengthTexture = babylonMaterial.coatRoughnessAnisotropyTexture;
25
- const tangentTexture = babylonMaterial.geometryCoatTangentTexture;
26
- // If we don't have any textures, we don't need to generate anything.
27
- if (!(anisoStrengthTexture || tangentTexture)) {
28
- return null;
29
- }
30
- return await MergeTexturesAsync("AnisotropyTexture", CreateRGBAConfiguration(tangentTexture ? CreateTextureInput(tangentTexture, 0) : CreateConstantInput(1.0), // tangent x from red channel
31
- tangentTexture ? CreateTextureInput(tangentTexture, 1) : CreateConstantInput(0.0), // tangent y from green channel
32
- anisoStrengthTexture ? CreateTextureInput(anisoStrengthTexture, 0) : CreateConstantInput(1.0) // Anisotropy from red channel
33
- ), scene);
34
- }
35
- /**
36
- * @internal
37
- */
38
- // eslint-disable-next-line @typescript-eslint/naming-convention
39
- export class KHR_materials_clearcoat_anisotropy {
40
- constructor(exporter) {
41
- /** Name of this extension */
42
- this.name = NAME;
43
- /** Defines whether this extension is enabled */
44
- this.enabled = true;
45
- /** Defines whether this extension is required */
46
- this.required = false;
47
- this._wasUsed = false;
48
- this._anisoTexturesMap = {};
49
- this._exporter = exporter;
50
- }
51
- dispose() { }
52
- /** @internal */
53
- get wasUsed() {
54
- return this._wasUsed;
55
- }
56
- /**
57
- * After exporting a material, deal with the additional textures
58
- * @param context GLTF context of the material
59
- * @param node exported GLTF node
60
- * @param babylonMaterial corresponding babylon material
61
- * @returns array of additional textures to export
62
- */
63
- async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
64
- const additionalTextures = [];
65
- if (babylonMaterial instanceof OpenPBRMaterial) {
66
- if (babylonMaterial.coatRoughnessAnisotropy > 0) {
67
- const texId = GetAnisoTextureId(babylonMaterial);
68
- if (this._anisoTexturesMap[texId]) {
69
- additionalTextures.push(this._anisoTexturesMap[texId]);
70
- }
71
- else {
72
- const anisoTexture = await CreateMergedAnisotropyTexture(babylonMaterial);
73
- if (anisoTexture) {
74
- additionalTextures.push(anisoTexture);
75
- this._anisoTexturesMap[texId] = anisoTexture;
76
- }
77
- }
78
- return additionalTextures;
79
- }
80
- }
81
- return [];
82
- }
83
- // eslint-disable-next-line no-restricted-syntax
84
- postExportMaterialAsync(context, node, babylonMaterial) {
85
- return new Promise((resolve) => {
86
- var _a;
87
- if (babylonMaterial instanceof OpenPBRMaterial) {
88
- if (babylonMaterial.coatRoughnessAnisotropy > 0) {
89
- // This material must have the clearcoat extension already before
90
- // we can add the clearcoat anisotropy sub-extension
91
- node.extensions = node.extensions || {};
92
- const parentExt = node.extensions ? node.extensions["KHR_materials_clearcoat"] : null;
93
- if (!parentExt) {
94
- return resolve(node);
95
- }
96
- this._wasUsed = true;
97
- // Check if we can convert from OpenPBR anisotropy to glTF anisotropy
98
- // Conversion involves both specular roughness and anisotropic roughness changes so,
99
- // if there are textures for either, we can't reliably convert due to there potentially
100
- // being different mappings between the textures.
101
- const roughnessTexture = babylonMaterial.coatRoughnessTexture;
102
- const mergedAnisoTexture = this._anisoTexturesMap[babylonMaterial.id];
103
- // If no textures are being used, we'll always output glTF-style anisotropy.
104
- // If using OpenPBR anisotropy, convert the constants. Otherwise, just export what we have.
105
- if (!roughnessTexture && !mergedAnisoTexture) {
106
- // Convert constants
107
- let newBaseRoughness = babylonMaterial.coatRoughness;
108
- let newAnisotropyStrength = babylonMaterial.coatRoughnessAnisotropy;
109
- if (!babylonMaterial._useGltfStyleAnisotropy) {
110
- const newParams = OpenpbrAnisotropyStrengthToGltf(babylonMaterial.coatRoughness, babylonMaterial.coatRoughnessAnisotropy);
111
- newBaseRoughness = newParams.newBaseRoughness;
112
- newAnisotropyStrength = newParams.newAnisotropyStrength;
113
- }
114
- if (node.pbrMetallicRoughness) {
115
- node.pbrMetallicRoughness.roughnessFactor = newBaseRoughness;
116
- }
117
- const anisotropyInfo = {
118
- clearcoatAnisotropyStrength: newAnisotropyStrength,
119
- clearcoatAnisotropyRotation: babylonMaterial.geometryCoatTangentAngle + Math.PI * 0.5,
120
- clearcoatAnisotropyTexture: undefined,
121
- };
122
- parentExt.extensions = parentExt.extensions || {};
123
- parentExt.extensions[NAME] = anisotropyInfo;
124
- return resolve(node);
125
- }
126
- const mergedAnisoTextureInfo = mergedAnisoTexture ? this._exporter._materialExporter.getTextureInfo(mergedAnisoTexture) : null;
127
- const anisotropyInfo = {
128
- clearcoatAnisotropyStrength: babylonMaterial.coatRoughnessAnisotropy,
129
- clearcoatAnisotropyRotation: babylonMaterial.geometryCoatTangentAngle,
130
- clearcoatAnisotropyTexture: mergedAnisoTextureInfo ? mergedAnisoTextureInfo : undefined,
131
- extensions: {},
132
- };
133
- if (!babylonMaterial._useGltfStyleAnisotropy) {
134
- anisotropyInfo.extensions["EXT_materials_anisotropy_openpbr"] = {
135
- openPbrAnisotropyEnabled: true,
136
- };
137
- (_a = this._exporter._glTF).extensionsUsed || (_a.extensionsUsed = []);
138
- if (this._exporter._glTF.extensionsUsed.indexOf("EXT_materials_anisotropy_openpbr") === -1) {
139
- this._exporter._glTF.extensionsUsed.push("EXT_materials_anisotropy_openpbr");
140
- }
141
- }
142
- this._exporter._materialNeedsUVsSet.add(babylonMaterial);
143
- parentExt.extensions = parentExt.extensions || {};
144
- parentExt.extensions[NAME] = anisotropyInfo;
145
- }
146
- }
147
- resolve(node);
148
- });
149
- }
150
- }
151
- GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat_anisotropy(exporter), 105);
152
- //# sourceMappingURL=KHR_materials_clearcoat_anisotropy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"KHR_materials_clearcoat_anisotropy.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat_anisotropy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAErE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YACL,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,EAAE,GAAG,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsClearcoatAnisotropy } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { OpenPBRMaterial } from \"core/Materials/PBR/openpbrMaterial\";\r\nimport type { ProceduralTexture } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { MergeTexturesAsync, CreateRGBAConfiguration, CreateTextureInput, CreateConstantInput } from \"core/Materials/Textures/textureMerger\";\r\n\r\nconst NAME = \"KHR_materials_clearcoat_anisotropy\";\r\n\r\n// Convert OpenPBR anisotropy values to glTF-compatible values\r\nfunction OpenpbrAnisotropyStrengthToGltf(baseRoughness: number, anisotropy: number) {\r\n const baseAlpha = baseRoughness * baseRoughness;\r\n const roughnessT = baseAlpha * Math.sqrt(2.0 / (1.0 + (1 - anisotropy) * (1 - anisotropy)));\r\n const roughnessB = (1 - anisotropy) * roughnessT;\r\n const newBaseRoughness = Math.sqrt(roughnessB);\r\n const newAnisotropyStrength = Math.min(Math.sqrt((roughnessT - baseAlpha) / Math.max(1.0 - baseAlpha, 0.0001)), 1.0);\r\n\r\n return { newBaseRoughness, newAnisotropyStrength };\r\n}\r\n\r\nfunction GetAnisoTextureId(babylonMaterial: OpenPBRMaterial): string {\r\n const anisoStrengthTexture: Nullable<BaseTexture> = babylonMaterial.coatRoughnessAnisotropyTexture;\r\n const tangentTexture = babylonMaterial.geometryCoatTangentTexture;\r\n const strengthId = anisoStrengthTexture && anisoStrengthTexture.getInternalTexture() ? anisoStrengthTexture!.getInternalTexture()!.uniqueId : \"NoStrength\";\r\n const tangentId = tangentTexture && tangentTexture.getInternalTexture() ? tangentTexture!.getInternalTexture()!.uniqueId : \"NoTangent\";\r\n return `${strengthId}_${tangentId}`;\r\n}\r\n\r\n// In your postExportMaterialAsync method:\r\nasync function CreateMergedAnisotropyTexture(babylonMaterial: OpenPBRMaterial): Promise<Nullable<ProceduralTexture>> {\r\n const scene = babylonMaterial.getScene();\r\n\r\n const anisoStrengthTexture: Nullable<BaseTexture> = babylonMaterial.coatRoughnessAnisotropyTexture;\r\n const tangentTexture = babylonMaterial.geometryCoatTangentTexture;\r\n\r\n // If we don't have any textures, we don't need to generate anything.\r\n if (!(anisoStrengthTexture || tangentTexture)) {\r\n return null;\r\n }\r\n\r\n return await MergeTexturesAsync(\r\n \"AnisotropyTexture\",\r\n CreateRGBAConfiguration(\r\n tangentTexture ? CreateTextureInput(tangentTexture, 0) : CreateConstantInput(1.0), // tangent x from red channel\r\n tangentTexture ? CreateTextureInput(tangentTexture, 1) : CreateConstantInput(0.0), // tangent y from green channel\r\n anisoStrengthTexture ? CreateTextureInput(anisoStrengthTexture, 0) : CreateConstantInput(1.0) // Anisotropy from red channel\r\n ),\r\n scene\r\n );\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_clearcoat_anisotropy 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 private _anisoTexturesMap: Record<string, ProceduralTexture> = {};\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 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 if (babylonMaterial instanceof OpenPBRMaterial) {\r\n if (babylonMaterial.coatRoughnessAnisotropy > 0) {\r\n const texId = GetAnisoTextureId(babylonMaterial);\r\n if (this._anisoTexturesMap[texId]) {\r\n additionalTextures.push(this._anisoTexturesMap[texId]);\r\n } else {\r\n const anisoTexture = await CreateMergedAnisotropyTexture(babylonMaterial);\r\n if (anisoTexture) {\r\n additionalTextures.push(anisoTexture);\r\n this._anisoTexturesMap[texId] = anisoTexture;\r\n }\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 OpenPBRMaterial) {\r\n if (babylonMaterial.coatRoughnessAnisotropy > 0) {\r\n // This material must have the clearcoat extension already before\r\n // we can add the clearcoat anisotropy sub-extension\r\n node.extensions = node.extensions || {};\r\n const parentExt = node.extensions ? node.extensions[\"KHR_materials_clearcoat\"] : null;\r\n if (!parentExt) {\r\n return resolve(node);\r\n }\r\n this._wasUsed = true;\r\n\r\n // Check if we can convert from OpenPBR anisotropy to glTF anisotropy\r\n // Conversion involves both specular roughness and anisotropic roughness changes so,\r\n // if there are textures for either, we can't reliably convert due to there potentially\r\n // being different mappings between the textures.\r\n const roughnessTexture: Nullable<BaseTexture> = babylonMaterial.coatRoughnessTexture;\r\n const mergedAnisoTexture = this._anisoTexturesMap[babylonMaterial.id];\r\n\r\n // If no textures are being used, we'll always output glTF-style anisotropy.\r\n // If using OpenPBR anisotropy, convert the constants. Otherwise, just export what we have.\r\n if (!roughnessTexture && !mergedAnisoTexture) {\r\n // Convert constants\r\n let newBaseRoughness = babylonMaterial.coatRoughness;\r\n let newAnisotropyStrength = babylonMaterial.coatRoughnessAnisotropy;\r\n if (!babylonMaterial._useGltfStyleAnisotropy) {\r\n const newParams = OpenpbrAnisotropyStrengthToGltf(babylonMaterial.coatRoughness, babylonMaterial.coatRoughnessAnisotropy);\r\n newBaseRoughness = newParams.newBaseRoughness;\r\n newAnisotropyStrength = newParams.newAnisotropyStrength;\r\n }\r\n if (node.pbrMetallicRoughness) {\r\n node.pbrMetallicRoughness.roughnessFactor = newBaseRoughness;\r\n }\r\n const anisotropyInfo: IKHRMaterialsClearcoatAnisotropy = {\r\n clearcoatAnisotropyStrength: newAnisotropyStrength,\r\n clearcoatAnisotropyRotation: babylonMaterial.geometryCoatTangentAngle + Math.PI * 0.5,\r\n clearcoatAnisotropyTexture: undefined,\r\n };\r\n parentExt.extensions = parentExt.extensions || {};\r\n parentExt.extensions[NAME] = anisotropyInfo;\r\n return resolve(node);\r\n }\r\n\r\n const mergedAnisoTextureInfo = mergedAnisoTexture ? this._exporter._materialExporter.getTextureInfo(mergedAnisoTexture) : null;\r\n\r\n const anisotropyInfo: IKHRMaterialsClearcoatAnisotropy = {\r\n clearcoatAnisotropyStrength: babylonMaterial.coatRoughnessAnisotropy,\r\n clearcoatAnisotropyRotation: babylonMaterial.geometryCoatTangentAngle,\r\n clearcoatAnisotropyTexture: mergedAnisoTextureInfo ? mergedAnisoTextureInfo : undefined,\r\n extensions: {},\r\n };\r\n\r\n if (!babylonMaterial._useGltfStyleAnisotropy) {\r\n anisotropyInfo.extensions![\"EXT_materials_anisotropy_openpbr\"] = {\r\n openPbrAnisotropyEnabled: true,\r\n };\r\n this._exporter._glTF.extensionsUsed ||= [];\r\n if (this._exporter._glTF.extensionsUsed.indexOf(\"EXT_materials_anisotropy_openpbr\") === -1) {\r\n this._exporter._glTF.extensionsUsed.push(\"EXT_materials_anisotropy_openpbr\");\r\n }\r\n }\r\n\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n\r\n parentExt.extensions = parentExt.extensions || {};\r\n parentExt.extensions[NAME] = anisotropyInfo;\r\n }\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat_anisotropy(exporter), 105);\r\n"]}
@@ -1,101 +0,0 @@
1
- import { GLTFExporter } from "../glTFExporter.js";
2
- import { PBRBaseMaterial } from "@babylonjs/core/Materials/PBR/pbrBaseMaterial.js";
3
- import { OpenPBRMaterial } from "@babylonjs/core/Materials/PBR/openpbrMaterial.js";
4
- const NAME = "KHR_materials_clearcoat_color";
5
- /**
6
- * @internal
7
- */
8
- // eslint-disable-next-line @typescript-eslint/naming-convention
9
- export class KHR_materials_clearcoat_color {
10
- constructor(exporter) {
11
- /** Name of this extension */
12
- this.name = NAME;
13
- /** Defines whether this extension is enabled */
14
- this.enabled = true;
15
- /** Defines whether this extension is required */
16
- this.required = false;
17
- this._wasUsed = false;
18
- this._exporter = exporter;
19
- }
20
- dispose() { }
21
- /** @internal */
22
- get wasUsed() {
23
- return this._wasUsed;
24
- }
25
- async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
26
- const additionalTextures = [];
27
- if (babylonMaterial instanceof PBRBaseMaterial) {
28
- if (babylonMaterial.clearCoat.isEnabled) {
29
- if (babylonMaterial.clearCoat.tintTexture) {
30
- additionalTextures.push(babylonMaterial.clearCoat.tintTexture);
31
- }
32
- return additionalTextures;
33
- }
34
- }
35
- else if (babylonMaterial instanceof OpenPBRMaterial) {
36
- if (babylonMaterial.coatWeight > 0) {
37
- if (babylonMaterial.coatColorTexture) {
38
- additionalTextures.push(babylonMaterial.coatColorTexture);
39
- }
40
- return additionalTextures;
41
- }
42
- }
43
- return [];
44
- }
45
- // eslint-disable-next-line no-restricted-syntax
46
- postExportMaterialAsync(context, node, babylonMaterial) {
47
- return new Promise((resolve) => {
48
- if (babylonMaterial instanceof PBRBaseMaterial) {
49
- if (!babylonMaterial.clearCoat.isEnabled) {
50
- resolve(node);
51
- return;
52
- }
53
- this._wasUsed = true;
54
- // This material must have the clearcoat extension already before
55
- // we can add the clearcoat color sub-extension
56
- const parentExt = node.extensions ? node.extensions["KHR_materials_clearcoat"] : null;
57
- if (!parentExt) {
58
- resolve(node);
59
- return;
60
- }
61
- const coatColorTextureInfo = this._exporter._materialExporter.getTextureInfo(babylonMaterial.clearCoat.tintTexture);
62
- const clearCoatInfo = {
63
- clearcoatColorFactor: babylonMaterial.clearCoat.tintColor.asArray(),
64
- clearcoatColorTexture: coatColorTextureInfo ?? undefined,
65
- };
66
- if (clearCoatInfo.clearcoatColorTexture !== null) {
67
- this._exporter._materialNeedsUVsSet.add(babylonMaterial);
68
- }
69
- parentExt.extensions = parentExt.extensions || {};
70
- parentExt.extensions[NAME] = clearCoatInfo;
71
- }
72
- else if (babylonMaterial instanceof OpenPBRMaterial) {
73
- if (babylonMaterial.coatWeight == 0.0) {
74
- resolve(node);
75
- return;
76
- }
77
- this._wasUsed = true;
78
- // This material must have the clearcoat extension already before
79
- // we can add the clearcoat color sub-extension
80
- const parentExt = node.extensions ? node.extensions["KHR_materials_clearcoat"] : null;
81
- if (!parentExt) {
82
- resolve(node);
83
- return;
84
- }
85
- const coatColorTextureInfo = this._exporter._materialExporter.getTextureInfo(babylonMaterial.coatWeightTexture);
86
- const clearCoatInfo = {
87
- clearcoatColorFactor: babylonMaterial.coatColor.asArray(),
88
- clearcoatColorTexture: coatColorTextureInfo ?? undefined,
89
- };
90
- if (clearCoatInfo.clearcoatColorTexture !== null) {
91
- this._exporter._materialNeedsUVsSet.add(babylonMaterial);
92
- }
93
- parentExt.extensions = parentExt.extensions || {};
94
- parentExt.extensions[NAME] = clearCoatInfo;
95
- }
96
- resolve(node);
97
- });
98
- }
99
- }
100
- GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat_color(exporter), 105);
101
- //# sourceMappingURL=KHR_materials_clearcoat_color.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"KHR_materials_clearcoat_color.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat_color.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAGrE,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAErE,MAAM,IAAI,GAAG,+BAA+B,CAAC;AAE7C;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,6BAA6B;IActC,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,SAAS,CAAC,SAAS,EAAE,CAAC;gBACtC,IAAI,eAAe,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;oBACxC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;gBACnE,CAAC;gBACD,OAAO,kBAAkB,CAAC;YAC9B,CAAC;QACL,CAAC;aAAM,IAAI,eAAe,YAAY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,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,6BAA6B,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsClearcoatColor } 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\nimport { OpenPBRMaterial } from \"core/Materials/PBR/openpbrMaterial\";\r\n\r\nconst NAME = \"KHR_materials_clearcoat_color\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_clearcoat_color 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.clearCoat.isEnabled) {\r\n if (babylonMaterial.clearCoat.tintTexture) {\r\n additionalTextures.push(babylonMaterial.clearCoat.tintTexture);\r\n }\r\n return additionalTextures;\r\n }\r\n } else if (babylonMaterial instanceof OpenPBRMaterial) {\r\n if (babylonMaterial.coatWeight > 0) {\r\n if (babylonMaterial.coatColorTexture) {\r\n additionalTextures.push(babylonMaterial.coatColorTexture);\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.clearCoat.isEnabled) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n // This material must have the clearcoat extension already before\r\n // we can add the clearcoat color sub-extension\r\n const parentExt = node.extensions ? node.extensions[\"KHR_materials_clearcoat\"] : null;\r\n if (!parentExt) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n const coatColorTextureInfo = this._exporter._materialExporter.getTextureInfo(babylonMaterial.clearCoat.tintTexture);\r\n\r\n const clearCoatInfo: IKHRMaterialsClearcoatColor = {\r\n clearcoatColorFactor: babylonMaterial.clearCoat.tintColor.asArray(),\r\n clearcoatColorTexture: coatColorTextureInfo ?? undefined,\r\n };\r\n\r\n if (clearCoatInfo.clearcoatColorTexture !== null) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n parentExt.extensions = parentExt.extensions || {};\r\n parentExt.extensions[NAME] = clearCoatInfo;\r\n } else if (babylonMaterial instanceof OpenPBRMaterial) {\r\n if (babylonMaterial.coatWeight == 0.0) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n // This material must have the clearcoat extension already before\r\n // we can add the clearcoat color sub-extension\r\n const parentExt = node.extensions ? node.extensions[\"KHR_materials_clearcoat\"] : null;\r\n if (!parentExt) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n const coatColorTextureInfo = this._exporter._materialExporter.getTextureInfo(babylonMaterial.coatWeightTexture);\r\n const clearCoatInfo: IKHRMaterialsClearcoatColor = {\r\n clearcoatColorFactor: babylonMaterial.coatColor.asArray(),\r\n clearcoatColorTexture: coatColorTextureInfo ?? undefined,\r\n };\r\n\r\n if (clearCoatInfo.clearcoatColorTexture !== null) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n parentExt.extensions = parentExt.extensions || {};\r\n parentExt.extensions[NAME] = clearCoatInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat_color(exporter), 105);\r\n"]}
@@ -1,70 +0,0 @@
1
- import { GLTFExporter } from "../glTFExporter.js";
2
- import { OpenPBRMaterial } from "@babylonjs/core/Materials/PBR/openpbrMaterial.js";
3
- const NAME = "KHR_materials_clearcoat_darkening";
4
- /**
5
- * @internal
6
- */
7
- // eslint-disable-next-line @typescript-eslint/naming-convention
8
- export class KHR_materials_clearcoat_darkening {
9
- constructor(exporter) {
10
- /** Name of this extension */
11
- this.name = NAME;
12
- /** Defines whether this extension is enabled */
13
- this.enabled = true;
14
- /** Defines whether this extension is required */
15
- this.required = false;
16
- this._wasUsed = false;
17
- this._exporter = exporter;
18
- }
19
- dispose() { }
20
- /** @internal */
21
- get wasUsed() {
22
- return this._wasUsed;
23
- }
24
- async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
25
- const additionalTextures = [];
26
- if (babylonMaterial instanceof OpenPBRMaterial) {
27
- if (babylonMaterial.coatDarkening) {
28
- if (babylonMaterial.coatDarkeningTexture) {
29
- additionalTextures.push(babylonMaterial.coatDarkeningTexture);
30
- }
31
- return additionalTextures;
32
- }
33
- }
34
- return [];
35
- }
36
- // eslint-disable-next-line no-restricted-syntax
37
- postExportMaterialAsync(context, node, babylonMaterial) {
38
- return new Promise((resolve) => {
39
- let coatDarkeningFactor = null;
40
- let coatDarkeningTexture = null;
41
- if (babylonMaterial instanceof OpenPBRMaterial) {
42
- coatDarkeningFactor = babylonMaterial.coatDarkening;
43
- coatDarkeningTexture = babylonMaterial.coatDarkeningTexture;
44
- }
45
- if (coatDarkeningFactor === null || (coatDarkeningFactor === 1.0 && coatDarkeningTexture === null)) {
46
- return resolve(node);
47
- }
48
- // This material must have the clearcoat extension already before
49
- // we can add the clearcoat darkening sub-extension
50
- const parentExt = node.extensions ? node.extensions["KHR_materials_clearcoat"] : null;
51
- if (!parentExt) {
52
- return resolve(node);
53
- }
54
- this._wasUsed = true;
55
- const coatDarkeningTextureInfo = this._exporter._materialExporter.getTextureInfo(coatDarkeningTexture);
56
- const coatDarkeningInfo = {
57
- clearcoatDarkeningFactor: coatDarkeningFactor,
58
- clearcoatDarkeningTexture: coatDarkeningTextureInfo ?? undefined,
59
- };
60
- if (coatDarkeningInfo.clearcoatDarkeningTexture !== null) {
61
- this._exporter._materialNeedsUVsSet.add(babylonMaterial);
62
- }
63
- parentExt.extensions = parentExt.extensions || {};
64
- parentExt.extensions[NAME] = coatDarkeningInfo;
65
- return resolve(node);
66
- });
67
- }
68
- }
69
- GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat_darkening(exporter), 105);
70
- //# sourceMappingURL=KHR_materials_clearcoat_darkening.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"KHR_materials_clearcoat_darkening.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat_darkening.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAGrE,MAAM,IAAI,GAAG,mCAAmC,CAAC;AAEjD;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,iCAAiC;IAc1C,YAAY,QAAsB;QAblC,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CA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,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACtF,IAAI,CAAC,SAAS,EAAE,CAAC;gBACb,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;YAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YAErB,MAAM,wBAAwB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;YAEvG,MAAM,iBAAiB,GAAoC;gBACvD,wBAAwB,EAAE,mBAAmB;gBAC7C,yBAAyB,EAAE,wBAAwB,IAAI,SAAS;aACnE,CAAC;YAEF,IAAI,iBAAiB,CAAC,yBAAyB,KAAK,IAAI,EAAE,CAAC;gBACvD,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;YAC7D,CAAC;YAED,SAAS,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,IAAI,EAAE,CAAC;YAClD,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC;YAE/C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,iCAAiC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsClearcoatDarkening } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\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_clearcoat_darkening\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_clearcoat_darkening 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 OpenPBRMaterial) {\r\n if (babylonMaterial.coatDarkening) {\r\n if (babylonMaterial.coatDarkeningTexture) {\r\n additionalTextures.push(babylonMaterial.coatDarkeningTexture);\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 coatDarkeningFactor: Nullable<number> = null;\r\n let coatDarkeningTexture: Nullable<BaseTexture> = null;\r\n if (babylonMaterial instanceof OpenPBRMaterial) {\r\n coatDarkeningFactor = babylonMaterial.coatDarkening;\r\n coatDarkeningTexture = babylonMaterial.coatDarkeningTexture;\r\n }\r\n if (coatDarkeningFactor === null || (coatDarkeningFactor === 1.0 && coatDarkeningTexture === null)) {\r\n return resolve(node);\r\n }\r\n\r\n // This material must have the clearcoat extension already before\r\n // we can add the clearcoat darkening sub-extension\r\n const parentExt = node.extensions ? node.extensions[\"KHR_materials_clearcoat\"] : null;\r\n if (!parentExt) {\r\n return resolve(node);\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n const coatDarkeningTextureInfo = this._exporter._materialExporter.getTextureInfo(coatDarkeningTexture);\r\n\r\n const coatDarkeningInfo: IKHRMaterialsClearcoatDarkening = {\r\n clearcoatDarkeningFactor: coatDarkeningFactor,\r\n clearcoatDarkeningTexture: coatDarkeningTextureInfo ?? undefined,\r\n };\r\n\r\n if (coatDarkeningInfo.clearcoatDarkeningTexture !== null) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n parentExt.extensions = parentExt.extensions || {};\r\n parentExt.extensions[NAME] = coatDarkeningInfo;\r\n\r\n return resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat_darkening(exporter), 105);\r\n"]}
@@ -1,26 +0,0 @@
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
- /**
6
- * @internal
7
- */
8
- export declare class KHR_materials_clearcoat_ior implements IGLTFExporterExtensionV2 {
9
- /** Name of this extension */
10
- readonly name = "KHR_materials_clearcoat_ior";
11
- /** Defines whether this extension is enabled */
12
- enabled: boolean;
13
- /** Defines whether this extension is required */
14
- required: boolean;
15
- private _exporter;
16
- private _wasUsed;
17
- /**
18
- * @param exporter The glTF exporter
19
- */
20
- constructor(exporter: GLTFExporter);
21
- /** @internal */
22
- dispose(): void;
23
- /** @internal */
24
- get wasUsed(): boolean;
25
- postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
26
- }
@@ -1,60 +0,0 @@
1
- import { GLTFExporter } from "../glTFExporter.js";
2
- import { OpenPBRMaterial } from "@babylonjs/core/Materials/PBR/openpbrMaterial.js";
3
- import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
4
- const NAME = "KHR_materials_clearcoat_ior";
5
- /**
6
- * @internal
7
- */
8
- // eslint-disable-next-line @typescript-eslint/naming-convention
9
- export class KHR_materials_clearcoat_ior {
10
- /**
11
- * @param exporter The glTF exporter
12
- */
13
- constructor(exporter) {
14
- /** Name of this extension */
15
- this.name = NAME;
16
- /** Defines whether this extension is enabled */
17
- this.enabled = true;
18
- /** Defines whether this extension is required */
19
- this.required = false;
20
- this._wasUsed = false;
21
- this._exporter = exporter;
22
- }
23
- /** @internal */
24
- dispose() { }
25
- /** @internal */
26
- get wasUsed() {
27
- return this._wasUsed;
28
- }
29
- // eslint-disable-next-line no-restricted-syntax
30
- postExportMaterialAsync(context, node, babylonMaterial) {
31
- return new Promise((resolve) => {
32
- let coatIor = null;
33
- if (babylonMaterial instanceof OpenPBRMaterial) {
34
- coatIor = babylonMaterial.coatIor;
35
- }
36
- else if (babylonMaterial instanceof PBRMaterial) {
37
- coatIor = babylonMaterial.clearCoat.indexOfRefraction;
38
- }
39
- if (coatIor === null || coatIor === 1.5) {
40
- return resolve(node);
41
- }
42
- // This material must have the clearcoat extension already before
43
- // we can add the clearcoat IOR sub-extension
44
- const parentExt = node.extensions ? node.extensions["KHR_materials_clearcoat"] : null;
45
- if (!parentExt) {
46
- return resolve(node);
47
- }
48
- this._wasUsed = true;
49
- const coatIorInfo = {
50
- clearcoatIor: coatIor,
51
- };
52
- this._exporter;
53
- parentExt.extensions = parentExt.extensions || {};
54
- parentExt.extensions[NAME] = coatIorInfo;
55
- return resolve(node);
56
- });
57
- }
58
- }
59
- GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat_ior(exporter), 105);
60
- //# sourceMappingURL=KHR_materials_clearcoat_ior.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"KHR_materials_clearcoat_ior.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat_ior.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,yDAA2C;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,CAAC;YACzB,CAAC;YAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YAErB,MAAM,WAAW,GAA8B;gBAC3C,YAAY,EAAE,OAAO;aACxB,CAAC;YAEF,IAAI,CAAC,SAAS,CAAC;YAEf,SAAS,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,IAAI,EAAE,CAAC;YAClD,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;YAEzC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,2BAA2B,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsClearcoatIor } 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 { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nconst NAME = \"KHR_materials_clearcoat_ior\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_clearcoat_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 _exporter: GLTFExporter;\r\n\r\n private _wasUsed = false;\r\n\r\n /**\r\n * @param exporter The glTF exporter\r\n */\r\n constructor(exporter: GLTFExporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n /** @internal */\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 // 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 coatIor: Nullable<number> = null;\r\n if (babylonMaterial instanceof OpenPBRMaterial) {\r\n coatIor = babylonMaterial.coatIor;\r\n } else if (babylonMaterial instanceof PBRMaterial) {\r\n coatIor = babylonMaterial.clearCoat.indexOfRefraction;\r\n }\r\n if (coatIor === null || coatIor === 1.5) {\r\n return resolve(node);\r\n }\r\n\r\n // This material must have the clearcoat extension already before\r\n // we can add the clearcoat IOR sub-extension\r\n const parentExt = node.extensions ? node.extensions[\"KHR_materials_clearcoat\"] : null;\r\n if (!parentExt) {\r\n return resolve(node);\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n const coatIorInfo: IKHRMaterialsClearcoatIor = {\r\n clearcoatIor: coatIor,\r\n };\r\n\r\n this._exporter;\r\n\r\n parentExt.extensions = parentExt.extensions || {};\r\n parentExt.extensions[NAME] = coatIorInfo;\r\n\r\n return resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat_ior(exporter), 105);\r\n"]}