supereggbert / GLGE

A javascript webGL graphics library
http://glge.org
Other
394 stars 84 forks source link

Wavefront loader can't correctly locate mtl #40

Open erisdev opened 13 years ago

erisdev commented 13 years ago

I'm trying to load a wavefront model, model/steve.obj that references an mtl file in the same directory. When I try to load the model with steve.setSrc('model/steve.obj', location.href), I get this strange error that seems to point to a problem in the path munging.

Error loading Document: model//undefined/steve.mtl status 404

The obj file references it as simply steve.mtl, and I've traced the origin of the extra /undefined/ to GLGE.Wavefront.prototype.getAbsolutePath—I'm just not sure what to make of it. It might be worth the effort to refactor it to use a preexisting path parsing library that knows how to handle some of the edge cases that can come up.

erisdev commented 13 years ago

As a recommendation, js-uri seems to handle URIs pretty competently.

supereggbert commented 13 years ago

Thought I'd fixed the problem, I'll take another look. I've rewritten the function I'll do some testing to see if it works. If not I'll take a look at closer look at js-uri, it just seems a little bit overkill adding external dependency for path lookups.