From 0dab85553a9dc934932db4114e9da442445c90a0 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 7 Jun 2022 15:29:00 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E8=AD=A6=E5=91=8A=20`Texture=20image=20MIM?= =?UTF-8?q?E=20type=20`{textureInfo.DataMimeType}`=20is=20not=20supported.?= =?UTF-8?q?`=20=E3=81=AE=E9=98=B2=E6=AD=A2=E3=80=82=20image.uri=20?= =?UTF-8?q?=E3=81=8B=E3=82=89=20mime=20=E3=82=92=E6=B1=BA=E5=AE=9A?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit glb のときは mime を省略不可。 > a reference to a bufferView; in that case mimeType MUST be defined. --- Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs index 899c6bde7..e61058ce3 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs @@ -333,6 +333,21 @@ namespace UniGLTF return result; } + static string GuessMimeFromUri(string uri) + { + if (string.IsNullOrEmpty(uri)) + { + return null; + } + var ext = System.IO.Path.GetExtension(uri).ToLower(); + switch (ext) + { + case ".png": return "image/png"; + case ".jpg": return "image/jpeg"; + default: return null; + } + } + public (NativeArray binary, string mimeType)? GetBytesFromImage(int imageIndex) { if (imageIndex < 0 || imageIndex >= GLTF.images.Count) return default; @@ -340,11 +355,13 @@ namespace UniGLTF var image = GLTF.images[imageIndex]; if (string.IsNullOrEmpty(image.uri)) { + // use bufferView(glb) return (GetBytesFromBufferView(image.bufferView), image.mimeType); } else { - return (GetBytesFromUri(image.uri), image.mimeType); + // use uri(gltf) + return (GetBytesFromUri(image.uri), image.mimeType ?? GuessMimeFromUri(image.uri)); } } From 2e3cba22471e062ea6b8ce134a3d187d7b0c0adb Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 8 Jun 2022 16:23:09 +0900 Subject: [PATCH 2/2] fix ToLowerInvariant. add `.jpeg` --- Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs index e61058ce3..3a7527e96 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs @@ -339,12 +339,16 @@ namespace UniGLTF { return null; } - var ext = System.IO.Path.GetExtension(uri).ToLower(); + var ext = System.IO.Path.GetExtension(uri).ToLowerInvariant(); switch (ext) { - case ".png": return "image/png"; - case ".jpg": return "image/jpeg"; - default: return null; + case ".png": + return "image/png"; + case ".jpg": + case ".jpeg": + return "image/jpeg"; + default: + return null; } }