From 3ec919e9c487dba02fb3fe4122ecbc171f1dfd18 Mon Sep 17 00:00:00 2001 From: Tim Knip Date: Fri, 29 Sep 2017 20:16:55 +0200 Subject: [PATCH] better regexp for #109 --- lib/loadMtl.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/loadMtl.js b/lib/loadMtl.js index d57b8be..e65b9ed 100644 --- a/lib/loadMtl.js +++ b/lib/loadMtl.js @@ -205,7 +205,9 @@ loadMtl._createMaterial = function(materialOptions, options) { */ function parseMapOptions (texturePath, textureOptions) { - if (!/-(bm|t|s|o|blendu|blendv|boost|mm|texres|clamp|imfchan|type)\s+/.test(texturePath)) { + var re = /[\\\/]-(bm|t|s|o|blendu|blendv|boost|mm|texres|clamp|imfchan|type)/; + + if (!re.test(texturePath)) { return; } @@ -216,7 +218,7 @@ function parseMapOptions (texturePath, textureOptions) { var currPart = null; mapOptions.reduce(function (p, part) { - if (/-/.test(part)) { + if (re.test('/'+part)) { currPart = part; p[part] = []; } else if (currPart) { @@ -235,8 +237,9 @@ function loadMaterialTexture(material, name, texturePath, textureOptions, mtlDir return; } - var mapOptions = {}; - var newTexturePath = parseMapOptions(texturePath, mapOptions); + textureOptions = textureOptions || {}; + + var newTexturePath = parseMapOptions(texturePath, textureOptions); // TODO: handle texture options // NOTE: this might not be a good place to do this texturePath = newTexturePath ? newTexturePath : texturePath;