Open Tzanker opened 2 years ago
Had the same issue. I think there is a bug in this line, it's indented too deeply. Linking mesh to material should not depend on UV, at least not in the case of PBR material. Unindented that line and resolved the export problem.
Hey, is this still happening on the latest versions? This should be unit tested and I just quickly ran
e = trimesh.load('models/fuze.obj')
e.export('~/Downloads/textest.glb')
Which loaded fine on https://gltf-viewer.donmccurdy.com/
If it's not working unit testable examples super welcome!
Hi, my use case is that I load STL files, add material and export it as GLB. Here is runable minimal example (attached the input file):
import trimesh
import trimesh.visual
m = trimesh.load('example.stl')
m.visual = trimesh.visual.TextureVisuals(
material=trimesh.visual.material.PBRMaterial(
baseColorFactor=trimesh.visual.random_color()
)
)
m.show()
m.export("example.glb")
The shown object has color, however after exporting the material/color is lost. I must use PBR material because the software reading my output only handles that. example.stl.zip
the "fix" is presented here: https://github.com/mikedh/trimesh/pull/1895
sphere.visual.material = primary_color_material
# material will *not* export without uv coordinates to gltf
# as GLTF requires TEXCOORD_0 be defined if there is a material
sphere.visual.uv = g.np.zeros((len(sphere.vertices), 2))
maybe it should give some kind of warning on saving a scene as gltf with materials and empty uv. This used to just work before 1895
Had the same issue. I think there is a bug in this line, it's indented too deeply. Linking mesh to material should not depend on UV, at least not in the case of PBR material. Unindented that line and resolved the export problem.
Hi,
I am trying to save a textured OBJ file as a GLB. The texturing imports fine, i can see it using mesh.show(), but when i export as a GLB no texture appears on the model. I saw another similar issue that makes it seem as if this has been implemented but it doesnt seem to be working here.
Thanks so much!!
mesh.show():
After export:
![image](https://user-images.githubusercontent.com/47015099/126837429-b6ebe2d1-1e5c-410d-9e0c-45980517f738.png)