webgl-obj-loader icon indicating copy to clipboard operation
webgl-obj-loader copied to clipboard

DownloadModels() use.

Open ClaudioPaterniti opened this issue 6 years ago • 3 comments

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?

ClaudioPaterniti avatar Feb 07 '20 12:02 ClaudioPaterniti

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.

frenchtoast747 avatar Feb 07 '20 20:02 frenchtoast747

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.

ClaudioPaterniti avatar Feb 08 '20 17:02 ClaudioPaterniti

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

frenchtoast747 avatar Feb 09 '20 05:02 frenchtoast747