better regexp for #109

This commit is contained in:
Tim Knip 2017-09-29 20:16:55 +02:00
parent ac756bed05
commit 3ec919e9c4
1 changed files with 7 additions and 4 deletions

View File

@ -205,7 +205,9 @@ loadMtl._createMaterial = function(materialOptions, options) {
*/ */
function parseMapOptions (texturePath, textureOptions) { 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; return;
} }
@ -216,7 +218,7 @@ function parseMapOptions (texturePath, textureOptions) {
var currPart = null; var currPart = null;
mapOptions.reduce(function (p, part) { mapOptions.reduce(function (p, part) {
if (/-/.test(part)) { if (re.test('/'+part)) {
currPart = part; currPart = part;
p[part] = []; p[part] = [];
} else if (currPart) { } else if (currPart) {
@ -235,8 +237,9 @@ function loadMaterialTexture(material, name, texturePath, textureOptions, mtlDir
return; return;
} }
var mapOptions = {}; textureOptions = textureOptions || {};
var newTexturePath = parseMapOptions(texturePath, mapOptions);
var newTexturePath = parseMapOptions(texturePath, textureOptions);
// TODO: handle texture options // TODO: handle texture options
// NOTE: this might not be a good place to do this // NOTE: this might not be a good place to do this
texturePath = newTexturePath ? newTexturePath : texturePath; texturePath = newTexturePath ? newTexturePath : texturePath;