mirror of
https://github.com/CesiumGS/obj2gltf.git
synced 2024-11-23 08:34:14 -05:00
Merge pull request #219 from AnalyticalGraphicsInc/absolute-paths
Handle mtl and texture absolute paths
This commit is contained in:
commit
4df7c2a28d
@ -4,6 +4,7 @@ Change Log
|
||||
### 3.?.? ????-??-??
|
||||
|
||||
* Added back `inputUpAxis` and `outputUpAxis`. [#211](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/211)
|
||||
* Fixed handling of mtl and texture absolute paths. [#219](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/219)
|
||||
* Fixed specular image not being decoded when referenced by other textures. [#217](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/217)
|
||||
* Fixed parsing faces that reference non-existing attributes. [#218](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/218)
|
||||
|
||||
|
@ -89,7 +89,7 @@ function loadMtl(mtlPath, options) {
|
||||
texturePath = texturePath.split(/\s+/).pop();
|
||||
}
|
||||
texturePath = texturePath.replace(/\\/g, '/');
|
||||
return path.normalize(path.join(mtlDirectory, texturePath));
|
||||
return path.normalize(path.resolve(mtlDirectory, texturePath));
|
||||
}
|
||||
|
||||
function parseLine(line) {
|
||||
|
@ -478,7 +478,7 @@ function finishLoading(nodes, mtlPaths, objPath, usesMaterials, options) {
|
||||
|
||||
function normalizeMtlPath(mtlPath, objDirectory) {
|
||||
mtlPath = mtlPath.replace(/\\/g, '/');
|
||||
return path.normalize(path.join(objDirectory, mtlPath));
|
||||
return path.normalize(path.resolve(objDirectory, mtlPath));
|
||||
}
|
||||
|
||||
function loadMtls(mtlPaths, objPath, options) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Blender v2.78 (sub 0) OBJ File: ''
|
||||
# www.blender.org
|
||||
mtllib box.mtl
|
||||
mtllib /box.mtl
|
||||
o Cube
|
||||
v -1.000000 -1.000000 1.000000
|
||||
v -1.000000 1.000000 1.000000
|
||||
|
@ -10,4 +10,4 @@ Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd cesium.png
|
||||
map_Kd /cesium.png
|
||||
|
@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
const Cesium = require('cesium');
|
||||
const path = require('path');
|
||||
|
||||
const loadObj = require('../../lib/loadObj');
|
||||
const obj2gltf = require('../../lib/obj2gltf');
|
||||
@ -354,6 +355,7 @@ describe('loadObj', () => {
|
||||
const data = await loadObj(objMissingMtllibPath, options);
|
||||
expect(data.materials.length).toBe(0);
|
||||
expect(spy.calls.argsFor(0)[0].indexOf('ENOENT') >= 0).toBe(true);
|
||||
expect(spy.calls.argsFor(0)[0].indexOf(path.resolve('/box.mtl')) >= 0).toBe(true);
|
||||
expect(spy.calls.argsFor(1)[0].indexOf('Attempting to read the material file from within the obj directory instead.') >= 0).toBe(true);
|
||||
expect(spy.calls.argsFor(2)[0].indexOf('ENOENT') >= 0).toBe(true);
|
||||
expect(spy.calls.argsFor(3)[0].indexOf('Could not read material file') >= 0).toBe(true);
|
||||
@ -431,6 +433,7 @@ describe('loadObj', () => {
|
||||
const baseColorTexture = data.materials[0].pbrMetallicRoughness.baseColorTexture;
|
||||
expect(baseColorTexture).toBeUndefined();
|
||||
expect(spy.calls.argsFor(0)[0].indexOf('ENOENT') >= 0).toBe(true);
|
||||
expect(spy.calls.argsFor(0)[0].indexOf(path.resolve('/cesium.png')) >= 0).toBe(true);
|
||||
expect(spy.calls.argsFor(1)[0].indexOf('Attempting to read the texture file from within the obj directory instead.') >= 0).toBe(true);
|
||||
expect(spy.calls.argsFor(2)[0].indexOf('ENOENT') >= 0).toBe(true);
|
||||
expect(spy.calls.argsFor(3)[0].indexOf('Could not read texture file') >= 0).toBe(true);
|
||||
|
Loading…
Reference in New Issue
Block a user