From 84bb3ff09d3b515df2e8b23da0e20d9705ba9108 Mon Sep 17 00:00:00 2001 From: wsw0108 Date: Wed, 16 Oct 2024 13:30:16 +0800 Subject: [PATCH 1/2] Fix: add missing mimetype image/webp --- include/fastgltf/types.hpp | 4 ++++ src/fastgltf.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/include/fastgltf/types.hpp b/include/fastgltf/types.hpp index 4879057d7..6be746942 100644 --- a/include/fastgltf/types.hpp +++ b/include/fastgltf/types.hpp @@ -210,6 +210,7 @@ namespace fastgltf { DDS = 4, GltfBuffer = 5, OctetStream = 6, + WEBP = 7, }; FASTGLTF_EXPORT enum class AnimationInterpolation : std::uint8_t { @@ -458,6 +459,7 @@ namespace fastgltf { constexpr std::string_view mimeTypeDds = "image/vnd-ms.dds"; constexpr std::string_view mimeTypeGltfBuffer = "application/gltf-buffer"; constexpr std::string_view mimeTypeOctetStream = "application/octet-stream"; + constexpr std::string_view mimeTypeWebp = "image/webp"; constexpr std::string_view getMimeTypeString(MimeType mimeType) noexcept { switch (mimeType) { @@ -473,6 +475,8 @@ namespace fastgltf { return mimeTypeGltfBuffer; case MimeType::OctetStream: return mimeTypeOctetStream; + case MimeType::WEBP: + return mimeTypeWebp; default: return ""; } diff --git a/src/fastgltf.cpp b/src/fastgltf.cpp index 179336562..f96c52b60 100644 --- a/src/fastgltf.cpp +++ b/src/fastgltf.cpp @@ -799,6 +799,9 @@ fg::MimeType fg::Parser::getMimeTypeFromString(std::string_view mime) { case force_consteval: { return MimeType::OctetStream; } + case force_consteval: { + return MimeType::WEBP; + } default: { return MimeType::None; } From 6a9dc9aa475723d248d7a1df6f5234bac2a953a6 Mon Sep 17 00:00:00 2001 From: wsw0108 Date: Wed, 16 Oct 2024 13:37:22 +0800 Subject: [PATCH 2/2] Fix type of clearcoat.clearcoatNormalTexture --- include/fastgltf/types.hpp | 2 +- src/fastgltf.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/fastgltf/types.hpp b/include/fastgltf/types.hpp index 6be746942..cd08df70f 100644 --- a/include/fastgltf/types.hpp +++ b/include/fastgltf/types.hpp @@ -1929,7 +1929,7 @@ namespace fastgltf { Optional clearcoatTexture; num clearcoatRoughnessFactor = 0.0f; Optional clearcoatRoughnessTexture; - Optional clearcoatNormalTexture; + Optional clearcoatNormalTexture; }; FASTGLTF_EXPORT struct MaterialSheen { diff --git a/src/fastgltf.cpp b/src/fastgltf.cpp index f96c52b60..d8971611a 100644 --- a/src/fastgltf.cpp +++ b/src/fastgltf.cpp @@ -2637,9 +2637,9 @@ fg::Error fg::Parser::parseMaterialExtensions(simdjson::dom::object &object, fas return error; } - TextureInfo clearcoatNormalTexture; + NormalTextureInfo clearcoatNormalTexture; if (auto error = parseTextureInfo(clearcoatObject, "clearcoatNormalTexture", - &clearcoatNormalTexture, config.extensions); error == + &clearcoatNormalTexture, config.extensions, TextureInfoType::NormalTexture); error == Error::None) { clearcoat->clearcoatNormalTexture = std::move(clearcoatNormalTexture); } else if (error != Error::MissingField) { @@ -4738,7 +4738,7 @@ void fg::Exporter::writeMaterials(const Asset& asset, std::string& json) { if (it->clearcoat->clearcoatNormalTexture.has_value()) { if (json.back() != '{') json += ','; json += "\"clearcoatNormalTexture\":"; - writeTextureInfo(json, &it->clearcoat->clearcoatNormalTexture.value()); + writeTextureInfo(json, &it->clearcoat->clearcoatNormalTexture.value(), TextureInfoType::NormalTexture); } json += '}'; }