frenchtoast747 / webgl-obj-loader

A simple OBJ model loader to help facilitate the learning of WebGL.
http://frenchtoast747.github.io/webgl-obj-loader/
MIT License
282 stars 59 forks source link

DownloadModels() use. #74

Open ClaudioPaterniti opened 4 years ago

ClaudioPaterniti commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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