Closed neilrackett closed 1 year ago
There are complexities in generating a BVH and storing in glTF which are outlined in #367, unfortunately. The serialized format is fairly simple, though, so implementing this at the app level should be straight forward - whether it be a file, database entry, browser cache storage, etc.
But either way I don't think JSON is an optimal format for storing the binary data required by the serialized format (file size, parse time). It would be best to save separate files or create a binary format to save the file to disk.
Thanks for the quick response - I'll investigate what we might be able to implement at app level as an alternative and let you know if we come up with anything useful!
Sounds good -- I'll close this for now!
So, if you're looking to cache BVH and have just stumbled across this thread:
localForage.setItem("my-bvh", MeshBVH.serialize(bvh))
to save and geometry.boundsTree = MeshBVH.deserialize(await localForage.getItem("my-bvh"), geometry)
to load
Calculating BVH for a large model can take a very long time.
While it's currently possible to
serialize
BVH data into a format that can easily be transferred between workers and the main thread, it cannot easily be serialized into a format that can be exported as JSON, imported anddeserialize
d later.It would be great if you could do this:
Possibly also useful as part of CLI tool suggestion (#367)?