Skip to content

Commit

Permalink
fix(mesh): use automatic UVs shape when mesh has not material
Browse files Browse the repository at this point in the history
UVs are all (0.5, 0.5). Limitation of trimesh.
  • Loading branch information
Olaf Haag committed Jan 3, 2024
1 parent ce9556a commit 9c16e8c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/readyplayerme/meshops/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ def read_gltf(filename: str | Path) -> Mesh:
raise OSError(msg) from error
# Convert the loaded trimesh into a Mesh object for abstraction.
try:
# trimesh doesn't load UVs if there's no material.
uvs = loaded.visual.uv # Fails if it has ColorVisuals instead of TextureVisuals.
except AttributeError:
uvs = None
if isinstance(loaded.visual, trimesh.visual.color.ColorVisuals):
uvs = loaded.visual.to_texture().uv # Sets the shape of UVs, but values are all 0.5.
else:
uvs = None
try:
material = Material.from_trimesh_material(loaded.visual.material)
except AttributeError:
Expand Down

0 comments on commit 9c16e8c

Please sign in to comment.