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

DownloadModels() use. #74

Open
ClaudioPaterniti opened this issue Feb 7, 2020 · 3 comments
Open

DownloadModels() use. #74

ClaudioPaterniti opened this issue Feb 7, 2020 · 3 comments

Comments

@ClaudioPaterniti
Copy link

ClaudioPaterniti commented Feb 7, 2020

I'm trying to use the downloadModels() function like this:

OBJ.downloadModels([{
        obj: 'model/test.obj',
        mtl: true 
    }]).then(function(result){console.log("success")}, function(err){console.log("error")});

The files are actually successfully requested to the server but nothing is ever printed to the console.
What am I doing wrong?

@frenchtoast747
Copy link
Owner

frenchtoast747 commented Feb 7, 2020

I pasted the following into requirebin and it worked:

const OBJ = require('webgl-obj-loader');


// chaining promise approach
OBJ.downloadModels([{
  obj: 'http://frenchtoast747.github.io/webgl-obj-loader/models/suzanne.obj',
  mtl: true 
}])
.then((data) => console.log("success:", data))
.catch((e) => console.error("Failure:", e));

// resolved/rejected in the same `.then()`
OBJ.downloadModels([{
  obj: 'http://frenchtoast747.github.io/webgl-obj-loader/models/suzanne.obj',
  mtl: true 
}])
.then(
  function(data) { console.log("success:", data) }, 
  function(e) { console.error("Failure:", e) }
); 

In the console:
image

I apologize, I'd link to a working snippet, but RequireBin is not letting me save the snippet at the moment.

I would expect you to see something in the console with the code you've pasted above. The only thing that looks odd to me is the URL model/test.obj, you may want to use absolute paths instead.

@ClaudioPaterniti
Copy link
Author

I was using the minimized version webgl-obj-loader.min.js and could not make it work, I tried with the full version and it actually printed success with the same code I was using before. I don't know much about javascript but I guess there is something wrong with the minimization, maybe some name conflict.

@frenchtoast747
Copy link
Owner

Thanks for the details! I will look into this more.

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

2 participants