obj2gltf icon indicating copy to clipboard operation
obj2gltf copied to clipboard

Set texture maps even if there is no .mtl file.

Open nauman-tintash opened this issue 6 years ago • 5 comments

If there is no .mtl file with the OBJ, then no texture is set even if we pass individual texture maps as command line params. There should be a feature to add the texture maps (diffuse, normal, etc) to the model directly through params even if there is no material file present.

nauman-tintash avatar Apr 02 '18 19:04 nauman-tintash

Thanks @nauman-tintash, this is the intended behavior of the command line flags at the bottom of the list but there seems to be a bug where they are getting ignored in certain cases. I should have a fix soon.

lilleyse avatar Apr 02 '18 19:04 lilleyse

Thanks @lilleyse for letting me know. If you have any clues on why these flags might be getting ignored that you can share, that'd be really helpful. I intend to look at the bug myself as well and would love to contribute.

nauman-tintash avatar Apr 02 '18 19:04 nauman-tintash

@nauman-tintash awesome!

The problem is the flags are only being considered if loadMtl is called, and that only happens when the obj has an mtl file.

The fix is a bit messier than I was hoping, but one approach is to fix how default materials are handled.

In loadObj there is a function assignDefaultMaterial which usually bails early if there were no materials, but instead it should call loadMtl.getDefaultMaterial and assign that material to each primitive.

loadMtl.getDefaultMaterial will need to be refactored to load the overriding textures. As a result it will need to return a promise, which means assignDefaultMaterial will need to return a promise as well.

Finally createGltf#getMaterial can be changed to no longer check for default materials.

lilleyse avatar Apr 03 '18 17:04 lilleyse

Also - if you do plan on contributing make sure to send in a CLA

lilleyse avatar Apr 03 '18 18:04 lilleyse