spnda / fastgltf

A modern C++17 glTF 2.0 library focused on speed, correctness, and usability
https://fastgltf.readthedocs.io/v0.8.x/
MIT License
301 stars 44 forks source link

Add: glTF Exporter #33

Closed spnda closed 9 months ago

spnda commented 1 year ago

This PR adds a fastgltf::Exporter object that can serialize a fastgltf::Asset into either a JSON or a binary blob (GLB). fastgltf::FileExporter builds upon this object by also automatically writing all of the relevant data to disk.

TODO list:

I'm opening this PR to keep track of the work and to have other people take their look before I push this into the main branch of the repository.

I also thought of a functional API for writing glTFs that would guarantee data safety while writing in various ways. That could, however, also be achieved by calling the validate function at the start of Composer::writeGLTF to guarantee the data is valid. Having the user properly figure out data relations from the glTF spec could still be tedious, where a functional API would be much more intuitive to use, as data relations would be much more apparent from the code itself. I will see if this additional API is necessary in the future.