@babylonjs/serializers 5.1.0 → 5.4.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.
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +21 -0
- package/glTF/2.0/Extensions/KHR_materials_ior.js +53 -0
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_iridescence.d.ts +24 -0
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js +75 -0
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +26 -0
- package/glTF/2.0/Extensions/KHR_materials_specular.js +86 -0
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +26 -0
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +77 -0
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +26 -0
- package/glTF/2.0/Extensions/KHR_materials_volume.js +89 -0
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -0
- package/glTF/2.0/Extensions/index.d.ts +5 -0
- package/glTF/2.0/Extensions/index.js +5 -0
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFMaterialExporter.d.ts +0 -8
- package/glTF/2.0/glTFMaterialExporter.js +2 -78
- package/glTF/2.0/glTFMaterialExporter.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { _Exporter } from "../glTFExporter.js";
|
|
2
|
+
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
|
3
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
|
4
|
+
var NAME = "KHR_materials_volume";
|
|
5
|
+
/**
|
|
6
|
+
* [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md)
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
9
|
+
var KHR_materials_volume = /** @class */ (function () {
|
|
10
|
+
function KHR_materials_volume(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
|
+
KHR_materials_volume.prototype.dispose = function () { };
|
|
21
|
+
Object.defineProperty(KHR_materials_volume.prototype, "wasUsed", {
|
|
22
|
+
/** @hidden */
|
|
23
|
+
get: function () {
|
|
24
|
+
return this._wasUsed;
|
|
25
|
+
},
|
|
26
|
+
enumerable: false,
|
|
27
|
+
configurable: true
|
|
28
|
+
});
|
|
29
|
+
KHR_materials_volume.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) {
|
|
30
|
+
var additionalTextures = [];
|
|
31
|
+
if (babylonMaterial instanceof PBRMaterial) {
|
|
32
|
+
if (this._isExtensionEnabled(babylonMaterial)) {
|
|
33
|
+
if (babylonMaterial.subSurface.thicknessTexture) {
|
|
34
|
+
additionalTextures.push(babylonMaterial.subSurface.thicknessTexture);
|
|
35
|
+
}
|
|
36
|
+
return additionalTextures;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return additionalTextures;
|
|
40
|
+
};
|
|
41
|
+
KHR_materials_volume.prototype._isExtensionEnabled = function (mat) {
|
|
42
|
+
// This extension must not be used on a material that also uses KHR_materials_unlit
|
|
43
|
+
if (mat.unlit) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
var subs = mat.subSurface;
|
|
47
|
+
// this extension requires either the KHR_materials_transmission or KHR_materials_translucency extensions.
|
|
48
|
+
if (!subs.isRefractionEnabled && !subs.isTranslucencyEnabled) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return ((subs.maximumThickness != undefined && subs.maximumThickness != 0) ||
|
|
52
|
+
(subs.tintColorAtDistance != undefined && subs.tintColorAtDistance != Number.POSITIVE_INFINITY) ||
|
|
53
|
+
(subs.tintColor != undefined && subs.tintColor != Color3.White()) ||
|
|
54
|
+
this._hasTexturesExtension(mat));
|
|
55
|
+
};
|
|
56
|
+
KHR_materials_volume.prototype._hasTexturesExtension = function (mat) {
|
|
57
|
+
return mat.subSurface.thicknessTexture != null;
|
|
58
|
+
};
|
|
59
|
+
KHR_materials_volume.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) {
|
|
60
|
+
var _this = this;
|
|
61
|
+
return new Promise(function (resolve) {
|
|
62
|
+
var _a;
|
|
63
|
+
if (babylonMaterial instanceof PBRMaterial && _this._isExtensionEnabled(babylonMaterial)) {
|
|
64
|
+
_this._wasUsed = true;
|
|
65
|
+
var subs = babylonMaterial.subSurface;
|
|
66
|
+
var thicknessFactor = subs.maximumThickness == 0 ? undefined : subs.maximumThickness;
|
|
67
|
+
var thicknessTexture = (_a = _this._exporter._glTFMaterialExporter._getTextureInfo(subs.thicknessTexture)) !== null && _a !== void 0 ? _a : undefined;
|
|
68
|
+
var attenuationDistance = subs.tintColorAtDistance == Number.POSITIVE_INFINITY ? undefined : subs.tintColorAtDistance;
|
|
69
|
+
var attenuationColor = subs.tintColor.equalsFloats(1.0, 1.0, 1.0) ? undefined : subs.tintColor.asArray();
|
|
70
|
+
var volumeInfo = {
|
|
71
|
+
thicknessFactor: thicknessFactor,
|
|
72
|
+
thicknessTexture: thicknessTexture,
|
|
73
|
+
attenuationDistance: attenuationDistance,
|
|
74
|
+
attenuationColor: attenuationColor,
|
|
75
|
+
hasTextures: function () {
|
|
76
|
+
return _this._hasTexturesExtension(babylonMaterial);
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
node.extensions = node.extensions || {};
|
|
80
|
+
node.extensions[NAME] = volumeInfo;
|
|
81
|
+
}
|
|
82
|
+
resolve(node);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
return KHR_materials_volume;
|
|
86
|
+
}());
|
|
87
|
+
export { KHR_materials_volume };
|
|
88
|
+
_Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_volume(exporter); });
|
|
89
|
+
//# sourceMappingURL=KHR_materials_volume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KHR_materials_volume.js","sourceRoot":"","sources":["../../../../../../../lts/serializers/generated/glTF/2.0/Extensions/KHR_materials_volume.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAE/C,IAAM,IAAI,GAAG,sBAAsB,CAAC;AAEpC;;GAEG;AACH,gEAAgE;AAChE;IAcI,8BAAY,QAAmB;QAb/B,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,sCAAO,GAAd,cAAkB,CAAC;IAGnB,sBAAW,yCAAO;QADlB,cAAc;aACd;YACI,OAAO,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;;;OAAA;IAEM,mEAAoC,GAA3C,UAA6C,OAAe,EAAE,IAAe,EAAE,eAAyB;QACpG,IAAM,kBAAkB,GAAkB,EAAE,CAAC;QAE7C,IAAI,eAAe,YAAY,WAAW,EAAE;YACxC,IAAI,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,EAAE;gBA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AAkC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsVolume } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } 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: _Exporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @hidden */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\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.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_translucency 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 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._glTFMaterialExporter._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 hasTextures: () => {\r\n return this._hasTexturesExtension(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\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_volume(exporter));\r\n"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export * from "./KHR_texture_transform";
|
|
2
2
|
export * from "./KHR_lights_punctual";
|
|
3
3
|
export * from "./KHR_materials_clearcoat";
|
|
4
|
+
export * from "./KHR_materials_iridescence";
|
|
4
5
|
export * from "./KHR_materials_sheen";
|
|
5
6
|
export * from "./KHR_materials_unlit";
|
|
7
|
+
export * from "./KHR_materials_ior";
|
|
8
|
+
export * from "./KHR_materials_specular";
|
|
9
|
+
export * from "./KHR_materials_volume";
|
|
10
|
+
export * from "./KHR_materials_transmission";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export * from "./KHR_texture_transform.js";
|
|
2
2
|
export * from "./KHR_lights_punctual.js";
|
|
3
3
|
export * from "./KHR_materials_clearcoat.js";
|
|
4
|
+
export * from "./KHR_materials_iridescence.js";
|
|
4
5
|
export * from "./KHR_materials_sheen.js";
|
|
5
6
|
export * from "./KHR_materials_unlit.js";
|
|
7
|
+
export * from "./KHR_materials_ior.js";
|
|
8
|
+
export * from "./KHR_materials_specular.js";
|
|
9
|
+
export * from "./KHR_materials_volume.js";
|
|
10
|
+
export * from "./KHR_materials_transmission.js";
|
|
6
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../lts/serializers/generated/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC","sourcesContent":["export * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_unlit\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../lts/serializers/generated/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC","sourcesContent":["export * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_materials_transmission\";\r\n"]}
|
|
@@ -6,7 +6,6 @@ import type { _Exporter } from "./glTFExporter";
|
|
|
6
6
|
declare type Material = import("@babylonjs/core/Materials/material.js").Material;
|
|
7
7
|
declare type StandardMaterial = import("@babylonjs/core/Materials/standardMaterial.js").StandardMaterial;
|
|
8
8
|
declare type PBRBaseMaterial = import("@babylonjs/core/Materials/PBR/pbrBaseMaterial.js").PBRBaseMaterial;
|
|
9
|
-
declare type PBRMetallicRoughnessMaterial = import("@babylonjs/core/Materials/PBR/pbrMetallicRoughnessMaterial.js").PBRMetallicRoughnessMaterial;
|
|
10
9
|
/**
|
|
11
10
|
* Utility methods for working with glTF material conversion properties. This class should only be used internally
|
|
12
11
|
* @hidden
|
|
@@ -88,13 +87,6 @@ export declare class _GLTFMaterialExporter {
|
|
|
88
87
|
*/
|
|
89
88
|
_convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
|
|
90
89
|
private _finishMaterial;
|
|
91
|
-
/**
|
|
92
|
-
* Converts a Babylon PBR Metallic Roughness Material to a glTF Material
|
|
93
|
-
* @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
|
|
94
|
-
* @param mimeType mime type to use for the textures
|
|
95
|
-
* @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
|
|
96
|
-
*/
|
|
97
|
-
_convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
|
|
98
90
|
/**
|
|
99
91
|
* Converts an image typed array buffer to a base64 image
|
|
100
92
|
* @param buffer typed array buffer
|
|
@@ -205,7 +205,7 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
205
205
|
var glTFMaterial = { name: babylonStandardMaterial.name };
|
|
206
206
|
if (babylonStandardMaterial.backFaceCulling != null && !babylonStandardMaterial.backFaceCulling) {
|
|
207
207
|
if (!babylonStandardMaterial.twoSidedLighting) {
|
|
208
|
-
Tools.Warn(babylonStandardMaterial.name + ": Back-face culling
|
|
208
|
+
Tools.Warn(babylonStandardMaterial.name + ": Back-face culling disabled and two-sided lighting disabled is not supported in glTF.");
|
|
209
209
|
}
|
|
210
210
|
glTFMaterial.doubleSided = true;
|
|
211
211
|
}
|
|
@@ -288,82 +288,6 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
288
288
|
});
|
|
289
289
|
});
|
|
290
290
|
};
|
|
291
|
-
/**
|
|
292
|
-
* Converts a Babylon PBR Metallic Roughness Material to a glTF Material
|
|
293
|
-
* @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
|
|
294
|
-
* @param mimeType mime type to use for the textures
|
|
295
|
-
* @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
|
|
296
|
-
*/
|
|
297
|
-
_GLTFMaterialExporter.prototype._convertPBRMetallicRoughnessMaterialAsync = function (babylonPBRMetalRoughMaterial, mimeType, hasTextureCoords) {
|
|
298
|
-
var materialMap = this._exporter._materialMap;
|
|
299
|
-
var materials = this._exporter._materials;
|
|
300
|
-
var promises = [];
|
|
301
|
-
var glTFPbrMetallicRoughness = {};
|
|
302
|
-
if (babylonPBRMetalRoughMaterial.baseColor) {
|
|
303
|
-
glTFPbrMetallicRoughness.baseColorFactor = [
|
|
304
|
-
babylonPBRMetalRoughMaterial.baseColor.r,
|
|
305
|
-
babylonPBRMetalRoughMaterial.baseColor.g,
|
|
306
|
-
babylonPBRMetalRoughMaterial.baseColor.b,
|
|
307
|
-
babylonPBRMetalRoughMaterial.alpha,
|
|
308
|
-
];
|
|
309
|
-
}
|
|
310
|
-
if (babylonPBRMetalRoughMaterial.metallic != null && babylonPBRMetalRoughMaterial.metallic !== 1) {
|
|
311
|
-
glTFPbrMetallicRoughness.metallicFactor = babylonPBRMetalRoughMaterial.metallic;
|
|
312
|
-
}
|
|
313
|
-
if (babylonPBRMetalRoughMaterial.roughness != null && babylonPBRMetalRoughMaterial.roughness !== 1) {
|
|
314
|
-
glTFPbrMetallicRoughness.roughnessFactor = babylonPBRMetalRoughMaterial.roughness;
|
|
315
|
-
}
|
|
316
|
-
var glTFMaterial = {
|
|
317
|
-
name: babylonPBRMetalRoughMaterial.name,
|
|
318
|
-
};
|
|
319
|
-
if (babylonPBRMetalRoughMaterial.doubleSided) {
|
|
320
|
-
glTFMaterial.doubleSided = babylonPBRMetalRoughMaterial.doubleSided;
|
|
321
|
-
}
|
|
322
|
-
_GLTFMaterialExporter._SetAlphaMode(glTFMaterial, babylonPBRMetalRoughMaterial);
|
|
323
|
-
if (hasTextureCoords) {
|
|
324
|
-
if (babylonPBRMetalRoughMaterial.baseTexture != null) {
|
|
325
|
-
promises.push(this._exportTextureAsync(babylonPBRMetalRoughMaterial.baseTexture, mimeType).then(function (glTFTexture) {
|
|
326
|
-
if (glTFTexture) {
|
|
327
|
-
glTFPbrMetallicRoughness.baseColorTexture = glTFTexture;
|
|
328
|
-
}
|
|
329
|
-
}));
|
|
330
|
-
}
|
|
331
|
-
if (babylonPBRMetalRoughMaterial.normalTexture) {
|
|
332
|
-
promises.push(this._exportTextureAsync(babylonPBRMetalRoughMaterial.normalTexture, mimeType).then(function (glTFTexture) {
|
|
333
|
-
if (glTFTexture) {
|
|
334
|
-
glTFMaterial.normalTexture = glTFTexture;
|
|
335
|
-
if (babylonPBRMetalRoughMaterial.normalTexture.level !== 1) {
|
|
336
|
-
glTFMaterial.normalTexture.scale = babylonPBRMetalRoughMaterial.normalTexture.level;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}));
|
|
340
|
-
}
|
|
341
|
-
if (babylonPBRMetalRoughMaterial.occlusionTexture) {
|
|
342
|
-
promises.push(this._exportTextureAsync(babylonPBRMetalRoughMaterial.occlusionTexture, mimeType).then(function (glTFTexture) {
|
|
343
|
-
if (glTFTexture) {
|
|
344
|
-
glTFMaterial.occlusionTexture = glTFTexture;
|
|
345
|
-
if (babylonPBRMetalRoughMaterial.occlusionStrength != null) {
|
|
346
|
-
glTFMaterial.occlusionTexture.strength = babylonPBRMetalRoughMaterial.occlusionStrength;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}));
|
|
350
|
-
}
|
|
351
|
-
if (babylonPBRMetalRoughMaterial.emissiveTexture) {
|
|
352
|
-
promises.push(this._exportTextureAsync(babylonPBRMetalRoughMaterial.emissiveTexture, mimeType).then(function (glTFTexture) {
|
|
353
|
-
if (glTFTexture) {
|
|
354
|
-
glTFMaterial.emissiveTexture = glTFTexture;
|
|
355
|
-
}
|
|
356
|
-
}));
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
if (_GLTFMaterialExporter._FuzzyEquals(babylonPBRMetalRoughMaterial.emissiveColor, Color3.Black(), _GLTFMaterialExporter._Epsilon)) {
|
|
360
|
-
glTFMaterial.emissiveFactor = babylonPBRMetalRoughMaterial.emissiveColor.asArray();
|
|
361
|
-
}
|
|
362
|
-
glTFMaterial.pbrMetallicRoughness = glTFPbrMetallicRoughness;
|
|
363
|
-
materials.push(glTFMaterial);
|
|
364
|
-
materialMap[babylonPBRMetalRoughMaterial.uniqueId] = materials.length - 1;
|
|
365
|
-
return this._finishMaterial(promises, glTFMaterial, babylonPBRMetalRoughMaterial, mimeType);
|
|
366
|
-
};
|
|
367
291
|
/**
|
|
368
292
|
* Converts an image typed array buffer to a base64 image
|
|
369
293
|
* @param buffer typed array buffer
|
|
@@ -892,7 +816,7 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
892
816
|
}
|
|
893
817
|
if (babylonPBRMaterial.backFaceCulling != null && !babylonPBRMaterial.backFaceCulling) {
|
|
894
818
|
if (!babylonPBRMaterial._twoSidedLighting) {
|
|
895
|
-
Tools.Warn(babylonPBRMaterial.name + ": Back-face culling
|
|
819
|
+
Tools.Warn(babylonPBRMaterial.name + ": Back-face culling disabled and two-sided lighting disabled is not supported in glTF.");
|
|
896
820
|
}
|
|
897
821
|
glTFMaterial.doubleSided = true;
|
|
898
822
|
}
|