gltf icon indicating copy to clipboard operation
gltf copied to clipboard

How to edit contents of gltf?

Open Makogan opened this issue 2 years ago • 1 comments

I need to apply a linear transformation to the gltf data. i know the amth that I need to do, but I am not sure how to use the crate to modify it.

For example say I want to scale down all inverse bind matrices, The way the library is implemented seems to allow you to peek into the ibm data through, e.g.:

        for ibm_accessor in skin.inverse_bind_matrices()
        {
            println!("Accessor #{}", ibm_accessor.index());
            println!("offset: {}", ibm_accessor.offset());
            println!("count: {}", ibm_accessor.count());
            println!("data_type: {:?}", ibm_accessor.data_type());
            println!("dimensions: {:?}", ibm_accessor.dimensions());

            let source = ibm_accessor.view().unwrap().buffer().source();
        }

But this is read only. I cannot write bytes back into the buffer, how would I go about it?

Makogan avatar Jul 18 '22 21:07 Makogan

Regretfully, the only way right now is to modify the underlying JSON. https://docs.rs/gltf/latest/gltf/struct.Document.html#method.into_json

alteous avatar Apr 03 '23 12:04 alteous