diff --git a/src/OBJFile.js b/src/OBJFile.js index f4c9e6e..b1faa56 100644 --- a/src/OBJFile.js +++ b/src/OBJFile.js @@ -28,7 +28,15 @@ class OBJFile { for (let i = 0; i < lines.length; i += 1) { const line = _stripComments(lines[i]); - const lineItems = line.replace(/\s+/g, ' ').trim().split(' '); + // splitting by blanks. For mtllib entry, balanced quote (single or double) around referreed file is stripped and file name having blanks is supported. + let lineItems; + let mtllibMatch = line.match(/^\s*(mtllib)\s+(['"]?)(.*?)\2\s*$/i); + + if (mtllibMatch) { + lineItems = [mtllibMatch[1].toLowerCase(), mtllibMatch[3]]; + } else { + lineItems = line.replace(/\s+/g, ' ').trim().split(' '); + } switch (lineItems[0].toLowerCase()) { case 'o': // Start A New Model