autodesk-forks / USD

Universal Scene Description
http://www.openusd.org
Other
136 stars 22 forks source link

Feat: allow dropping of USD/USDZ files on page to load them #5

Closed hybridherbst closed 2 years ago

hybridherbst commented 2 years ago

Description of Change(s)

Allows to quickly preview USDZ files and test the capabilities of the web port by dropping files onto the page.

Note that this is a DRAFT: the one piece that's still missing is unloading the existing file. Right now, each dragged file will be added to the scene.

hybridherbst commented 2 years ago

@kaischroeder I looked into this a bit more and while I can hack around and unlink the file plus stop rendering, it's not ideal - I think there's a missing method in the RenderDelegateInterface to clean up, e.g. to remove the meshes it has added into the three scene from the scene again.

It also seems that there's no scene hierarchy preserved from the USDZ right now in the ThreeJsRenderDelegate, it just adds everything as root-level meshes. I think it would be better to (Step 1) parent everything under one named Group (UsdStage?), and (Step 2) preserving the USD hierarchy would be great for future use.

(There's actually a little // FIXME comment in there) window.scene.add(this._mesh); // FIXME

hybridherbst commented 2 years ago

I changed a couple of things and can now properly unload models by

I also added automatic camera framing when loading models, which makes navigation a lot easier. I think this is a proper PR now and not just a draft, works pretty well on my end - you can test on https://prefrontalcortex.github.io/USD/usd_for_web_demos/test.html

kaischroeder commented 2 years ago

This has been merged as #6