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

GLTF save errors with invalid buffer #49

Closed xackery closed 2 years ago

xackery commented 2 years ago

https://github.com/qmuntal/gltf/blob/58807b50227bd15975e015ce2c4242efa3db9568/example_test.go#L17

If you change last line to:

 if err := gltf.Save(doc, "./example.gltf"); err != nil {
        panic(err)
    }

You get

panic: gltf: Invalid buffer.uri value '' [recovered]
    panic: gltf: Invalid buffer.uri value ''

seems glb and gltf aren't treated same? any tips to resolve the above?

qmuntal commented 2 years ago

Can you check if you are facing the same problem as in #45?

xackery commented 2 years ago

Can you check if you are facing the same problem as in #45?

Yep, adding:

for _, buff := range doc.Buffers {
        buff.EmbeddedResource()
    }

fixed it. It may be worthwhile adding this to the README as a note, it isn't obvious. Thanks!