Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove double quotes in the mtl and texture paths #297

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### 3.2.0 - 2023-??-??

- Added `doubleSidedMaterial` option to force materials to be rendered double sided. [#294](https://github.com/CesiumGS/obj2gltf/pull/294)
- Strip file paths of any enclosing double-quotes to allow the mtl/texture files to be properly parsed [#297](https://github.com/CesiumGS/obj2gltf/pull/297)

### 3.1.6 - 2023-02-10

Expand Down
2 changes: 2 additions & 0 deletions lib/loadMtl.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ function loadMtl(mtlPath, options) {
}

function normalizeTexturePath(texturePath, mtlDirectory) {
//Remove double quotes around the texture file if it exists
texturePath = texturePath.replace(/^"(.+)"$/, "$1");
// Removes texture options from texture name
// Assumes no spaces in texture name
const re = /-(bm|t|s|o|blendu|blendv|boost|mm|texres|clamp|imfchan|type)/;
Expand Down
2 changes: 2 additions & 0 deletions lib/loadObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ function loadObj(objPath, options) {
function getMtlPaths(mtllibLine) {
// Handle paths with spaces. E.g. mtllib my material file.mtl
const mtlPaths = [];
//Remove double quotes around the mtl file if it exists
mtllibLine = mtllibLine.replace(/^"(.+)"$/, "$1");
const splits = mtllibLine.split(" ");
const length = splits.length;
let startIndex = 0;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
"jasmine": "^5.0.0",
"jasmine-spec-reporter": "^7.0.0",
"jsdoc": "^4.0.0",
"lint-staged": "^14.0.1",
"nyc": "^15.1.0",
"prettier": "3.0.3",
"lint-staged": "^14.0.1"
"prettier": "3.0.3"
},
"lint-staged": {
"*.(js|ts)": [
Expand All @@ -72,4 +72,4 @@
"bin": {
"obj2gltf": "./bin/obj2gltf.js"
}
}
}