Fix texture options ending up in texture filename #109

This happens when in `*.mtl` a relative texture path does not have a
`./` prefix.
eg: map_bump -bm 0.1 foo.jpg
This commit is contained in:
Tim Knip 2017-10-02 01:50:45 +02:00
parent 3cff129933
commit 3e41cdc7f6
1 changed files with 29 additions and 20 deletions

View File

@ -211,6 +211,15 @@ function parseMapOptions (texturePath, textureOptions) {
return;
}
if (re.test('/'+path.basename(texturePath))) {
// options ended up in filename, eg: map_bump -bm 0.1 foo.jpg
// assume no spaces in texture filename
var parts = path.basename(texturePath).split(/\s+/);
var texture = parts.pop();
// handle options below
texturePath = path.join(path.dirname(texturePath), parts.join(' '), texture);
}
var pathParts = texturePath.split(/[\\\/]/);
if (pathParts.length && pathParts.length > 2) {