glTFast icon indicating copy to clipboard operation
glTFast copied to clipboard

Under Android platform, the gltf model that loads local files will have the wrong path.

Open han-tianyu opened this issue 1 year ago • 2 comments

[new Uri(uri, ".")] in UriHelper.GetBaseUri(Uri uri) cannot process files in the jar:file:// path, and an error message is displayed. It is recommended to change GetBaseUri(Uri uri) to public static Uri GetBaseUri(Uri uri) { return GetParentUri(uri, 1); } and public static Uri GetParentUri(Uri uri, int level) { if (uri == null) return null; string[] segments = uri.Segments; string uriString = uri.Scheme + ":"; if (!string.IsNullOrEmpty(uri.Host)) { uriString += "//" + uri.Host; } if (segments.Length >= level) { string parentDirectory = String.Join("", segments, 0, segments.Length - level).Replace("//", "/"); uriString += parentDirectory; } return new Uri(uriString, UriKind.RelativeOrAbsolute); }

han-tianyu avatar Jan 16 '24 07:01 han-tianyu

I couldn't confirm that UriHelper.GetBaseUri does not work with jar:file:// style URIs:

// This works:
Assert.AreEqual(new Uri("jar:file:///dir/sub/"), UriHelper.GetBaseUri(new Uri("jar:file:///dir/sub/file.gltf")));

Closing this now. Feel free to provide a failing test (ideally in UriHelperTest.cs) and re-open the issue.

atteneder avatar Aug 09 '24 12:08 atteneder

I was able to reproduce the issue. It's the combination of double-schema (jar:file:) and a (escaped) unicode character that causes problems. Since the double-schema is used on Android only, it only surfaced there.

atteneder avatar Sep 06 '24 15:09 atteneder

fixed in 6.9.0.

atteneder avatar Dec 11 '24 10:12 atteneder