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:
[x] Figure out how to write the various data sources
[x] Get binary glTFs to work
[x] Rework the texture image index API to work with writing
[x] Add the missing material fields
[x] Add support for extensions
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.
This PR adds a
fastgltf::Exporter
object that can serialize afastgltf::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 ofComposer::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.