CesiumGS / cesium-native

Apache License 2.0
421 stars 212 forks source link

Unable to save Meshoptimizer compressed models as uncompressed glb models #785

Open xinghaoyujianni opened 9 months ago

xinghaoyujianni commented 9 months ago

I have the following code and the saved decompress.glb is not getting loaded!

GltfReader reader; GltfReaderResult result = reader.readGltf(readFile("C:\Users\EXT_meshopt_compression.glb")); Model& model = result.model.value();

CesiumGltfWriter::GltfWriter writer; CesiumGltfWriter::GltfWriterOptions options; options.binaryChunkByteAlignment = 4;

const std::vector readModelBuffer = model.buffers[0].cesium.data; CesiumGltfWriter::GltfWriterResult writeResult = writer.writeGlb(model, gsl::span(readModelBuffer), options); const std::vector& glbBytesDefaultPadding = writeResult.gltfBytes;

std::ofstream ofs("C:\Users\decompress.glb", std::ios::binary | std::ios::trunc | std::ios::out); ofs.write( (const char*)glbBytesDefaultPadding.data(), glbBytesDefaultPadding.size()); ofs.flush(); ofs.close();

csciguy8 commented 9 months ago

Can you do a little debugging on your end here? It's not clear the failures you are seeing or what line is failing?

It's ok if you discover a bug in the cesium-native code, and want to share an example problem that reproduces it.

But in this case, it's not clear whether the problem is in cesium-native, or your test setup.

j9liu commented 7 months ago

Hey @xinghaoyujianni,

Are you still experiencing this issue? If so, can you provide more details? In particular, it's not clear what you mean by the "glb is not getting loaded".

Otherwise, if this is no longer relevant, or if we don't receive a response, I'll close this issue.