qmuntal / gltf

Go library for encoding glTF 2.0 files
https://www.khronos.org/gltf/
BSD 2-Clause "Simplified" License
241 stars 32 forks source link

Added SetJSONIndent to Encoder #57

Closed xackery closed 2 years ago

xackery commented 2 years ago

This pretty prints encoded gltf, e.g.

{"buffers":[{"uri":"data:application/octet-stream;base64

turns to

{
    "buffers": [
        {
            "uri": "data:application/octet-stream;base64

just by setting e.g.

enc := gltf.NewEncoder(w)
enc.AsBinary = false
enc.SetIndent("", "\t") // <-- this line
err = enc.Encode(doc)
qmuntal commented 2 years ago

Can you add a test which roundtrips (encode-> decode -> compare) an indented gltf just to be sure that it does not break anything?

xackery commented 2 years ago

Can you add a test which roundtrips (encode-> decode -> compare) an indented gltf just to be sure that it does not break anything?

I added additional tests inside encode_test that at least cover the new code, I am unsure if you want even more testing? From what I can tell, encode testing is exclusive to encode_test, but I basically do encode/decode/compare with this new commit ... Let me know if this satisfies your ask