diff --git a/SharedProjects/Babylon2GLTF/GLTFExporter.Texture.cs b/SharedProjects/Babylon2GLTF/GLTFExporter.Texture.cs index c5ba05ab..5598b8ca 100644 --- a/SharedProjects/Babylon2GLTF/GLTFExporter.Texture.cs +++ b/SharedProjects/Babylon2GLTF/GLTFExporter.Texture.cs @@ -177,7 +177,7 @@ private GLTFTextureInfo ExportTexture(BabylonTexture babylonTexture, GLTF gltf, if (!string.IsNullOrWhiteSpace(exportParameters.textureFolder)) { textureUri = PathUtilities.GetRelativePath( exportParameters.outputPath,exportParameters.textureFolder); - textureUri = Path.Combine(textureUri, ImageName); + textureUri = PathUtilities.IsLocalRootPath(textureUri) ? ImageName : Path.Combine(textureUri, ImageName); } gltfImage = new GLTFImage { @@ -266,7 +266,6 @@ private GLTFTextureInfo ExportTexture(BabylonTexture babylonTexture, GLTF gltf, if (CheckIfImageIsRegistered(textureID)) { var textureComponent = GetRegisteredTexture(textureID); - return textureComponent; } @@ -278,6 +277,7 @@ private GLTFTextureInfo ExportTexture(BabylonTexture babylonTexture, GLTF gltf, } } + private string TextureTransformID(GLTFTextureInfo gltfTextureInfo) { if (gltfTextureInfo.extensions == null || !gltfTextureInfo.extensions.ContainsKey(KHR_texture_transform)) diff --git a/SharedProjects/Utilities/PathUtilities.cs b/SharedProjects/Utilities/PathUtilities.cs index 9e254e36..f3a20206 100644 --- a/SharedProjects/Utilities/PathUtilities.cs +++ b/SharedProjects/Utilities/PathUtilities.cs @@ -6,6 +6,9 @@ namespace Utilities { static class PathUtilities { + public static string LocalDir = "."; + public static string LocalDirPath = $"{LocalDir}{Path.DirectorySeparatorChar}"; + public static string AltLocalDirPath = $"{LocalDir}{Path.AltDirectorySeparatorChar}"; /// /// Creates a relative path from one file or folder to another. Input paths that are directories should have a trailing slash. @@ -66,6 +69,8 @@ public static string VerifyLegalFileName(string fileName) return r.Replace(fileName, "_"); //source: https://stackoverflow.com/a/146162/301388 } + + public static bool IsLocalRootPath(string path) => string.IsNullOrEmpty(path) || path.CompareTo(AltLocalDirPath) == 0 || path.CompareTo(LocalDirPath) == 0 || path.CompareTo(LocalDir) == 0; }