petrbroz / svf-utils

Utilities for working with the SVF file format used by Autodesk Platform Services.
https://petrbroz.github.io/svf-utils/
MIT License
126 stars 54 forks source link

Need more detailed example for parseMeshes #25

Closed leefsmp closed 4 years ago

leefsmp commented 4 years ago

Hi Petr! I would be interested in determining the bounding box of a given Forge model without loading it in the viewer.

So my first question is am I correct that I would need to iterate all the meshes of the model and compute the union bbox myself? Or there is a global bbox data available directly?

Then my second is would you be able to provide a slightly more detailed example of using parseMeshes. I am not sure how I should get the buffer passed as input of parseMeshes. I've got a URN and a token, what should be the workflow to parse meshes of the whole model? Would be fantastic.

Thanks ;)

petrbroz commented 4 years ago

Hi Philippe :)

Regarding the first question, each model usually has the world bounds stored in its metadata:

Screen Shot 2020-09-14 at 9 42 20 AM

One thing I'm not sure about is whether it's guaranteed to always be there, so computing the bounds yourself from the fragment list data might be a safer choice.

Regarding the second question, as you can see in the SvfReader implementation, the parseMeshes function is used to process individual "geometry pack files" (0.pf, 1.pf, 2.pf, ...). The samples folder includes various usage examples. For example, you could take the remote-svf-to-gltf.js script and modify it by passing an existing token to the ModelDerivativeClient class instead of passing in client ID/secret. Or you can simply use the command-line tool available in this repository which can already accept FORGE_ACCESS_TOKEN as an env. variable.

leefsmp commented 4 years ago

Thanks.