Skip to content

How do you use loaders? #273

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

Open
aliddell opened this issue May 31, 2019 · 5 comments
Open

How do you use loaders? #273

aliddell opened this issue May 31, 2019 · 5 comments

Comments

@aliddell
Copy link

aliddell commented May 31, 2019

Forgive the maybe-dumb question, but I'm new to both pythreejs and threejs in general.

I'm actually interested in the OBJLoader, but this is not included out of the box*, so I'll start with the FileLoader. It's not clear from the docs how to use it. Even looking over the Python source has me puzzled, since all the loaders look the same. I guess they wrap the JS in some way, so I would think it would be straightforward to do something like

from pythreejs import *

def onload_callback(*args, **kwargs):
    # do some stuff here

fl = FileLoader()
fl.load("/path/to/file", onLoad=onload_callback)

but there doesn't seem to be a load function. How do I use any of these loaders? grepping on "Loader" in the examples/ directory turns up nothing.

* it's in the examples directory, so I'm not sure why it couldn't be -- in any case I'd be willing to help implement it in pythreejs if I could understand how to use loaders in this library

@vidartf
Copy link
Member

vidartf commented Jun 2, 2019

There hasn't been any work to implement loaders yet, mostly as I've been unsure how to best source file/urls correctly to the JS-side (file loaders would have to download the file via contents api). If somebody wants to put some time in here, that would be very appreciated. I can help with mentoring of the current source code (helping find the right place to put code, which patterns to use, etc.).

In terms of the loaders, please note that several of them have been deprecated in favor of the GLTF loader (OpenGL Transfer Format), so we might come a long way by adding support for this.

@aliddell
Copy link
Author

aliddell commented Jun 3, 2019

Okay. As I said, I'm mostly interested in the OBJ loader (which piggybacks off the FileLoader, but so does the GLTF loader), so I'd be willing to help make progress there.

I did the naive thing and added OBJLoader as a class to export in three-class-config.js with the relative path pointing to the examples/loaders directory, and when that failed I just moved the OBJLoader file to the src/loaders folder and adjusted the path accordingly. That worked, in the sense that I got a class file that looked like every other loader class file. The point of this is that your autogen scripts are mysterious to me and I could use an overview of how they work, as well as a general orientation around just how the functionality written in JS is exposed in Python. If you'd like to send me an email (see my profile) we can discuss further.

@aliddell aliddell closed this as completed Jun 3, 2019
@vidartf vidartf reopened this Jun 4, 2019
@rkalyanapurdue
Copy link

I would like to be able to use the OBJLoader as well. Any progress/pointers on how to go about implementing this?

@aliddell
Copy link
Author

@rkalyanapurdue I ended up porting the OBJLoader to Python myself, and then I discovered PyWavefront. Two issues I ran into with PyWavefront:

  1. AFAICT you can't parse a response body directly, but you have to download a file to disk and then parse it;
  2. I wasn't able to get the mesh looking the same as I had seen with the OBJLoader on the same file.

@rkalyanapurdue
Copy link

Thanks @aliddell . I briefly looked at PyWavefront and Pyglet (for the viz.) but it seemed like Pyglet requires an X Server/display (unless I've understood wrong) which doesn't really work for our use case since the notebook server is running on a cloud VM.

@vidartf vidartf mentioned this issue Apr 3, 2020
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

No branches or pull requests

3 participants