|
@@ -560,7 +560,7 @@ var KHR_lights_punctual = /** @class */ (function () {
|
|
|
}
|
|
|
parentNode.extensions[NAME] = lightReference;
|
|
|
// Do not export the original node
|
|
|
- resolve(undefined);
|
|
|
+ resolve(null);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -3793,7 +3793,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Utility methods for working with glTF material conversion properties. This class should only be used internally
|
|
|
* @hidden
|
|
@@ -3835,10 +3834,7 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]) {
|
|
|
promises.push(this._convertStandardMaterialAsync(babylonMaterial, mimeType, hasTextureCoords));
|
|
|
}
|
|
|
- else if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]) {
|
|
|
- promises.push(this._convertPBRMetallicRoughnessMaterialAsync(babylonMaterial, mimeType, hasTextureCoords));
|
|
|
- }
|
|
|
- else if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]) {
|
|
|
+ else if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]) {
|
|
|
promises.push(this._convertPBRMaterialAsync(babylonMaterial, mimeType, hasTextureCoords));
|
|
|
}
|
|
|
else {
|
|
@@ -4469,21 +4465,26 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
*/
|
|
|
_GLTFMaterialExporter.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords) {
|
|
|
var promises = [];
|
|
|
+ var baseColor = babylonPBRMaterial.albedoColor || babylonPBRMaterial.baseColor;
|
|
|
+ var metallic = babylonPBRMaterial.metallic || babylonPBRMaterial.metallic;
|
|
|
+ var roughness = babylonPBRMaterial.roughness || babylonPBRMaterial.roughness;
|
|
|
var metallicRoughness = {
|
|
|
- baseColor: babylonPBRMaterial.albedoColor,
|
|
|
- metallic: babylonPBRMaterial.metallic,
|
|
|
- roughness: babylonPBRMaterial.roughness
|
|
|
+ baseColor: baseColor,
|
|
|
+ metallic: metallic,
|
|
|
+ roughness: roughness
|
|
|
};
|
|
|
if (hasTextureCoords) {
|
|
|
- if (babylonPBRMaterial.albedoTexture) {
|
|
|
+ var albedoTexture = babylonPBRMaterial.albedoTexture || babylonPBRMaterial.baseTexture;
|
|
|
+ if (albedoTexture) {
|
|
|
promises.push(this._exportTextureAsync(babylonPBRMaterial.albedoTexture, mimeType).then(function (glTFTexture) {
|
|
|
if (glTFTexture) {
|
|
|
glTFPbrMetallicRoughness.baseColorTexture = glTFTexture;
|
|
|
}
|
|
|
}));
|
|
|
}
|
|
|
- if (babylonPBRMaterial.metallicTexture) {
|
|
|
- promises.push(this._exportTextureAsync(babylonPBRMaterial.metallicTexture, mimeType).then(function (glTFTexture) {
|
|
|
+ var metallicTexture = babylonPBRMaterial.metallicTexture || babylonPBRMaterial.metallicRoughnessTexture;
|
|
|
+ if (metallicTexture) {
|
|
|
+ promises.push(this._exportTextureAsync(metallicTexture, mimeType).then(function (glTFTexture) {
|
|
|
if (glTFTexture) {
|
|
|
glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFTexture;
|
|
|
}
|
|
@@ -4604,30 +4605,36 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
return Promise.resolve().then(function () {
|
|
|
var samplers = _this._exporter._samplers;
|
|
|
var textures = _this._exporter._textures;
|
|
|
+ var diffuseColor = babylonPBRMaterial.albedoColor || babylonPBRMaterial.diffuseColor || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
|
|
|
+ var specularColor = babylonPBRMaterial.reflectivityColor || babylonPBRMaterial.specularColor || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
|
|
|
+ var glossiness = babylonPBRMaterial.microSurface || babylonPBRMaterial.glossiness || 1;
|
|
|
var specGloss = {
|
|
|
- diffuseColor: babylonPBRMaterial.albedoColor || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White(),
|
|
|
- specularColor: babylonPBRMaterial.reflectivityColor || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White(),
|
|
|
- glossiness: babylonPBRMaterial.microSurface || 1,
|
|
|
+ diffuseColor: diffuseColor,
|
|
|
+ specularColor: specularColor,
|
|
|
+ glossiness: glossiness,
|
|
|
};
|
|
|
var samplerIndex = null;
|
|
|
- var sampler = _this._getGLTFTextureSampler(babylonPBRMaterial.albedoTexture);
|
|
|
+ var albedoTexture = babylonPBRMaterial.albedoTexture || babylonPBRMaterial.diffuseTexture;
|
|
|
+ var reflectivityTexture = babylonPBRMaterial.reflectivityTexture || babylonPBRMaterial.specularGlossinessTexture;
|
|
|
+ var sampler = _this._getGLTFTextureSampler(albedoTexture);
|
|
|
if (sampler.magFilter != null && sampler.minFilter != null && sampler.wrapS != null && sampler.wrapT != null) {
|
|
|
samplers.push(sampler);
|
|
|
samplerIndex = samplers.length - 1;
|
|
|
}
|
|
|
- if (babylonPBRMaterial.reflectivityTexture && !babylonPBRMaterial.useMicroSurfaceFromReflectivityMapAlpha) {
|
|
|
+ var useMicrosurfaceFromReflectivityMapAlpha = babylonPBRMaterial.useMicroSurfaceFromReflectivityMapAlpha || babylonPBRMaterial.useMicroSurfaceFromReflectivityMapAlpha;
|
|
|
+ if (reflectivityTexture && !useMicrosurfaceFromReflectivityMapAlpha) {
|
|
|
return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported");
|
|
|
}
|
|
|
- if ((babylonPBRMaterial.albedoTexture || babylonPBRMaterial.reflectivityTexture) && hasTextureCoords) {
|
|
|
- return _this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(babylonPBRMaterial.albedoTexture, babylonPBRMaterial.reflectivityTexture, specGloss, mimeType).then(function (metallicRoughnessFactors) {
|
|
|
+ if ((albedoTexture || reflectivityTexture) && hasTextureCoords) {
|
|
|
+ return _this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(albedoTexture, reflectivityTexture, specGloss, mimeType).then(function (metallicRoughnessFactors) {
|
|
|
if (metallicRoughnessFactors.baseColorTextureBase64) {
|
|
|
- var glTFBaseColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.baseColorTextureBase64, "bjsBaseColorTexture_" + (textures.length) + ".png", mimeType, babylonPBRMaterial.albedoTexture ? babylonPBRMaterial.albedoTexture.coordinatesIndex : null, samplerIndex);
|
|
|
+ var glTFBaseColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.baseColorTextureBase64, "bjsBaseColorTexture_" + (textures.length) + ".png", mimeType, albedoTexture ? albedoTexture.coordinatesIndex : null, samplerIndex);
|
|
|
if (glTFBaseColorTexture) {
|
|
|
glTFPbrMetallicRoughness.baseColorTexture = glTFBaseColorTexture;
|
|
|
}
|
|
|
}
|
|
|
if (metallicRoughnessFactors.metallicRoughnessTextureBase64) {
|
|
|
- var glTFMRColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + (textures.length) + ".png", mimeType, babylonPBRMaterial.reflectivityTexture ? babylonPBRMaterial.reflectivityTexture.coordinatesIndex : null, samplerIndex);
|
|
|
+ var glTFMRColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + (textures.length) + ".png", mimeType, reflectivityTexture ? reflectivityTexture.coordinatesIndex : null, samplerIndex);
|
|
|
if (glTFMRColorTexture) {
|
|
|
glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFMRColorTexture;
|
|
|
}
|
|
@@ -4641,8 +4648,8 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
});
|
|
|
};
|
|
|
/**
|
|
|
- * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
|
|
|
- * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
|
|
|
+ * Converts a Babylon PBR Base Material to a glTF Material
|
|
|
+ * @param babylonPBRMaterial BJS PBR Base Material
|
|
|
* @param mimeType mime type to use for the textures
|
|
|
* @param images array of glTF image interfaces
|
|
|
* @param textures array of glTF texture interfaces
|
|
@@ -4658,12 +4665,14 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
};
|
|
|
var useMetallicRoughness = babylonPBRMaterial.isMetallicWorkflow();
|
|
|
if (useMetallicRoughness) {
|
|
|
- if (babylonPBRMaterial.albedoColor) {
|
|
|
+ var albedoColor = babylonPBRMaterial.albedoColor || babylonPBRMaterial.diffuseColor || babylonPBRMaterial.baseColor;
|
|
|
+ var alpha = babylonPBRMaterial.alpha;
|
|
|
+ if (albedoColor) {
|
|
|
glTFPbrMetallicRoughness.baseColorFactor = [
|
|
|
- babylonPBRMaterial.albedoColor.r,
|
|
|
- babylonPBRMaterial.albedoColor.g,
|
|
|
- babylonPBRMaterial.albedoColor.b,
|
|
|
- babylonPBRMaterial.alpha
|
|
|
+ albedoColor.r,
|
|
|
+ albedoColor.g,
|
|
|
+ albedoColor.b,
|
|
|
+ alpha
|
|
|
];
|
|
|
}
|
|
|
return this._convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(function (metallicRoughness) {
|
|
@@ -4697,40 +4706,44 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
glTFPbrMetallicRoughness.roughnessFactor = metallicRoughness.roughness;
|
|
|
}
|
|
|
if (babylonPBRMaterial.backFaceCulling != null && !babylonPBRMaterial.backFaceCulling) {
|
|
|
- if (!babylonPBRMaterial.twoSidedLighting) {
|
|
|
+ if (!(babylonPBRMaterial.twoSidedLighting || babylonPBRMaterial.doubleSided)) {
|
|
|
babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Tools"].Warn(babylonPBRMaterial.name + ": Back-face culling enabled and two-sided lighting disabled is not supported in glTF.");
|
|
|
}
|
|
|
glTFMaterial.doubleSided = true;
|
|
|
}
|
|
|
if (hasTextureCoords) {
|
|
|
- if (babylonPBRMaterial.bumpTexture) {
|
|
|
- var promise = this._exportTextureAsync(babylonPBRMaterial.bumpTexture, mimeType).then(function (glTFTexture) {
|
|
|
+ var bumpTexture_1 = babylonPBRMaterial.bumpTexture || babylonPBRMaterial.normalTexture;
|
|
|
+ if (bumpTexture_1) {
|
|
|
+ var promise = this._exportTextureAsync(bumpTexture_1, mimeType).then(function (glTFTexture) {
|
|
|
if (glTFTexture) {
|
|
|
glTFMaterial.normalTexture = glTFTexture;
|
|
|
- if (babylonPBRMaterial.bumpTexture.level !== 1) {
|
|
|
- glTFMaterial.normalTexture.scale = babylonPBRMaterial.bumpTexture.level;
|
|
|
+ if (bumpTexture_1.level !== 1) {
|
|
|
+ glTFMaterial.normalTexture.scale = bumpTexture_1.level;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
promises.push(promise);
|
|
|
}
|
|
|
- if (babylonPBRMaterial.ambientTexture) {
|
|
|
- var promise = this._exportTextureAsync(babylonPBRMaterial.ambientTexture, mimeType).then(function (glTFTexture) {
|
|
|
+ var ambientTexture = babylonPBRMaterial.ambientTexture || babylonPBRMaterial.occlusionTexture;
|
|
|
+ if (ambientTexture) {
|
|
|
+ var promise = this._exportTextureAsync(ambientTexture, mimeType).then(function (glTFTexture) {
|
|
|
if (glTFTexture) {
|
|
|
var occlusionTexture = {
|
|
|
index: glTFTexture.index,
|
|
|
texCoord: glTFTexture.texCoord
|
|
|
};
|
|
|
glTFMaterial.occlusionTexture = occlusionTexture;
|
|
|
- if (babylonPBRMaterial.ambientTextureStrength) {
|
|
|
- occlusionTexture.strength = babylonPBRMaterial.ambientTextureStrength;
|
|
|
+ var ambientTextureStrength = babylonPBRMaterial.ambientTextureStrength || babylonPBRMaterial.occlusionStrength;
|
|
|
+ if (ambientTextureStrength) {
|
|
|
+ occlusionTexture.strength = ambientTextureStrength;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
promises.push(promise);
|
|
|
}
|
|
|
- if (babylonPBRMaterial.emissiveTexture) {
|
|
|
- var promise = this._exportTextureAsync(babylonPBRMaterial.emissiveTexture, mimeType).then(function (glTFTexture) {
|
|
|
+ var emissiveTexture = babylonPBRMaterial.emissiveTexture || babylonPBRMaterial.emissiveTexture;
|
|
|
+ if (emissiveTexture) {
|
|
|
+ var promise = this._exportTextureAsync(emissiveTexture, mimeType).then(function (glTFTexture) {
|
|
|
if (glTFTexture) {
|
|
|
glTFMaterial.emissiveTexture = glTFTexture;
|
|
|
}
|
|
@@ -4738,8 +4751,9 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
|
promises.push(promise);
|
|
|
}
|
|
|
}
|
|
|
- if (!_GLTFMaterialExporter.FuzzyEquals(babylonPBRMaterial.emissiveColor, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black(), _GLTFMaterialExporter._Epsilon)) {
|
|
|
- glTFMaterial.emissiveFactor = babylonPBRMaterial.emissiveColor.asArray();
|
|
|
+ var emissiveColor = babylonPBRMaterial.emissiveColor || babylonPBRMaterial.emissiveColor;
|
|
|
+ if (!_GLTFMaterialExporter.FuzzyEquals(emissiveColor, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black(), _GLTFMaterialExporter._Epsilon)) {
|
|
|
+ glTFMaterial.emissiveFactor = emissiveColor.asArray();
|
|
|
}
|
|
|
glTFMaterial.pbrMetallicRoughness = glTFPbrMetallicRoughness;
|
|
|
materials.push(glTFMaterial);
|