sleepyraccoon / jsc3d

Automatically exported from code.google.com/p/jsc3d
0 stars 0 forks source link

Not loading textures from mtl (and FIX!) #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When modifying an mtl file in an editor (windows/notepad) possibly an \r 
character is inserted. The jsc3d/ObjLoader does not remove the '\r' and thus 
not load the textures.

Just use the replace function to remove the '/r': 

// GOTO 
JSC3D.ObjLoader.prototype.parseMtl = function(data) {
    var mtls = {};
    var curMtlName = '';

        data = data.replace(/(\r)/gm,"");   //<------ ADD THIS

Original issue reported on code.google.com by jimve...@gmail.com on 17 Apr 2013 at 9:18

GoogleCodeExporter commented 9 years ago
Thanks for reporting this! Since String.split() also accepts a regular 
expression as the separator, I adopted a slightly different method to solve 
this problem:

var lines = data.split('\n'); 
            =>
var lines = data.split(/\r?\n/);

And now it works fine for manually edited obj/stl files.  Thanks again!

Original comment by Humu2...@gmail.com on 1 May 2013 at 1:21