From b99d243f4d88acc1c9c893490a03aa3d5ca11974 Mon Sep 17 00:00:00 2001 From: Chetan Date: Fri, 6 Oct 2023 10:13:00 +0800 Subject: [PATCH 1/2] Remove double quotes in the mtl and texture paths so that the file can be read properly --- lib/loadMtl.js | 2 ++ lib/loadObj.js | 2 ++ package.json | 6 +++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/loadMtl.js b/lib/loadMtl.js index 90da39d..25b285f 100644 --- a/lib/loadMtl.js +++ b/lib/loadMtl.js @@ -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)/; diff --git a/lib/loadObj.js b/lib/loadObj.js index cf41ad2..a48e8a0 100644 --- a/lib/loadObj.js +++ b/lib/loadObj.js @@ -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; diff --git a/package.json b/package.json index 84e7b99..c67c40a 100644 --- a/package.json +++ b/package.json @@ -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)": [ @@ -72,4 +72,4 @@ "bin": { "obj2gltf": "./bin/obj2gltf.js" } -} \ No newline at end of file +} From a7e996f0e8ed9456e1f135ba68d47993535e51a2 Mon Sep 17 00:00:00 2001 From: Chetan Date: Sun, 8 Oct 2023 10:51:48 +0800 Subject: [PATCH 2/2] Update Changes.md to reflect the change whereby filepaths are now stripped of their double quotes --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 7d3862f..14b3676 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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