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

Consistent API for the loader classes #1084

Closed
DocLabyrinth opened this issue Jan 12, 2012 · 6 comments
Closed

Consistent API for the loader classes #1084

DocLabyrinth opened this issue Jan 12, 2012 · 6 comments

Comments

@DocLabyrinth
Copy link

I have been working on integrating THREE.js with Crafty (https://github.com/louisstow/Crafty) to take advantage of the entity/component system. Crafty has a single function for loading in different assets which gives the option for passing progress and error callbacks. Although the loaders use a progress callback internally, each of them throws an error on failure and doesn't allow the caller to set a progress callback. Is it possible to make a consistent API for the loaders which allows tracking of success, progress and failure by the caller, and makes it easier to use them interchangeably?
It seems like separating the XHR functions and the code which actually parses the loaded data might be a good idea, since the XHR code is similar across most of the classes. If the API separated the functionality of creating geometry, animations etc from already loaded data it would be easier to integrate the loaders into other projects which already handle the XHR side of things.

@mrdoob
Copy link
Owner

mrdoob commented Jan 12, 2012

Agreed. Loaders need some love on progress/error reporting.

@zz85
Copy link
Contributor

zz85 commented Feb 18, 2012

would you suggest an api like

loader.onProgress = function(p) {};
loader.onSuccess = function(p) {};
loader.onFail = function(p) {};

or pass them all into a constructor like in jquery .ajax(), eg.
loader.handle(success, fail, progress)
?

@mrdoob
Copy link
Owner

mrdoob commented Feb 18, 2012

@mrdoob
Copy link
Owner

mrdoob commented Feb 18, 2012

But I think I'll change it so it uses EventTarget.js instead (already added it to TrackballControls.js recently).

@zz85
Copy link
Contributor

zz85 commented Feb 18, 2012

I see, didn't notice the recent changes :)

@mrdoob
Copy link
Owner

mrdoob commented Apr 17, 2012

#1751

@mrdoob mrdoob closed this as completed Apr 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants