Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: GLTF loading support #321

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

reductor
Copy link

@reductor reductor commented Apr 20, 2020

Initial WIP for #246

Remaining work

  • Cleanup code (remove dummy prints in example)
  • Make it work

GLTFAsset: {
relativePath: './textures/GLTFAsset',
properties: {
scene: new Types.ThreeType('Scene', {use_instancedict: true}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this always produce a scene? If so, maybe this should inherit Scene instead. It will simplify the logic a lot,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my use case it will, same with many others use cases I suspect, so could simplify it to inherit from that, and just name it GLTFScene which would simplify it to just support that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would be my recommendation.

Copy link
Author

@reductor reductor Apr 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately this also has some issues as children and other properties do not exist within python so do not have the required model id's or ipymodel

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need to interact/modify the loaded model in Python, you would probably need to implement the loader in Python. Otherwise you are likely to end up in an asynchronous mess where the Python code has to wait for the JS to do stuff and sync it back before being able to continue executing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I need to be able interact with the scene that is loaded, so I'm fine with having python wait for a model loading, after doing some more work I have identified a few more issues

  • createUninitializedChildren only works on InitializedThreeType parameters, for something being created in JS first this should ideally be all properties
  • createUninitializedChildren does not handle nested properties (and handling this also means handling the allow_single arrays)
  • (need to also verify impact) utils.createModel does not update the initPromise to include its additional setup for comms
  • Not all properties exist to be pushed from JS to python (e.g. _ref_geometry), so syncToModel fails because it can't use obj[propName] on these
  • (need to verify) Some nested traitlets appear to fail because the widget serialization is on the container not the instance

I've managed to use the mesh and parts that get loaded and pushed from this, however I've hit some very unusual issues where the data does not exist in python until I refresh the page.

Unfortunately I need to stop working on this for the time being, so anyone feel free to take over, I may return to it in a few weeks.

@kolibril13
Copy link

Hi there!
I wrote a threejs GLTF viewer for jupyter using anywidget that you can find here:
https://github.com/kolibril13/anywidget-3dviewer-GLTF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants