glTFast icon indicating copy to clipboard operation
glTFast copied to clipboard

Add support for loading a glTF from an arbitrary stream

Open sandr01d opened this issue 1 year ago • 1 comments

I've mostly kept the existing implementation of GltfImport.LoadFile(), but modified it to support any kind of stream (as long as the stream is readable). While loading from a file stream does probably cover most use cases, being able to load from any kind of stream does offer some benefints, e.g. when loading a glTF from a MemoryStream that is already in memory. My personal use case is loading a glTF from a zip archive's DeflateStream directly without having to decrompress the entire file first. There is a slight downside with this new implementation: the parsing of the JSON string can not be cancelled. A override of StreamReader.ReadToEndAsync() that takes a cancellation token exists in .NET 7, but I guess it will take a while until Unity catches up with that. That being said, I think that shouldn't be an issue, as glTFast parses JSON very fast and we can still cancel before starting to parse binary data.

sandr01d avatar Sep 07 '23 12:09 sandr01d

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Sep 07 '23 12:09 CLAassistant