CesiumGS / cesium-native

Apache License 2.0
438 stars 215 forks source link

Minimal example for meshopt compression extension #935

Closed Mnzs1701 closed 3 months ago

Mnzs1701 commented 3 months ago

I am trying to create a gltf with buffers compressed using mesh optimizer compression extension, however I am unable to understand how to compress the actual buffers. Does cesium native provide functionality to compress the buffer or only to add a compressed buffer? In the case of reading gltf, it appears to have the ability to decompress a buffer, however in the case of writing a gltf I cannot find a way to compress the raw buffer into meshoptimized form. At the moment I am able to add the extension into the buffer as below:

CesiumGltf::ExtensionBufferExtMeshoptCompression& extension = buffer.addExtension<CesiumGltf::ExtensionBufferExtMeshoptCompression>();

And add the extension into the model itself:

model.addExtensionUsed(CesiumGltf::ExtensionBufferExtMeshoptCompression::ExtensionName);

but these end up with the extensions written into gltf without any actual buffer written. Any minimal example of compressing a buffer and writing it would be great.

kring commented 3 months ago

cesium-native doesn't currently have any support for compressing with meshopt. You would need to use the meshopt library directly to create the correct glTF buffers.