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

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

Open
nauman-tintash opened this issue Apr 2, 2018 · 5 comments
Open

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

nauman-tintash opened this issue Apr 2, 2018 · 5 comments

Comments

@nauman-tintash
Copy link

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 nauman-tintash changed the title No texture maps are set if there is not .mtl file. No texture maps are set if there is no .mtl file. Apr 2, 2018
@nauman-tintash nauman-tintash changed the title No texture maps are set if there is no .mtl file. Set texture maps even if there is no .mtl file. Apr 2, 2018
@lilleyse
Copy link
Contributor

lilleyse commented Apr 2, 2018

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.

@nauman-tintash
Copy link
Author

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.

@lilleyse
Copy link
Contributor

lilleyse commented Apr 3, 2018

@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
Copy link
Contributor

lilleyse commented Apr 3, 2018

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

@yosun
Copy link

yosun commented Jun 29, 2024

any updates on this fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants