Strip trailing whitespace from i3dm external content URL

This whitespace may be added to keep the size of an i3dm file 8 byte
aligned.
This commit is contained in:
Tim Moore 2024-06-27 19:16:49 +02:00
parent ef1438fa25
commit c6de588e14
1 changed files with 8 additions and 1 deletions

View File

@ -457,9 +457,16 @@ CesiumAsync::Future<ConvertedI3dm> convertI3dmContent(
repositionInstances(decodedInstances);
std::string baseUri;
if (header.gltfFormat == 0) {
// The spec says that the URL can be padded with ' ' (0x20) characters in
// order to make the size of the whole i3dm file 8-byte aligned.
auto rLastNotSpace =
std::find_if_not(gltfData.rbegin(), gltfData.rend(), [](auto&& b) {
return static_cast<int>(b) == ' ';
});
auto spaceDistance = gltfData.rend() - rLastNotSpace;
std::string gltfUri(
reinterpret_cast<const char*>(gltfData.data()),
gltfData.size());
spaceDistance);
baseUri = CesiumUtility::Uri::resolve(assetFetcher.baseUrl, gltfUri);
} else {
baseUri = assetFetcher.baseUrl;