mmatl / pyrender

Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes.
http://pyrender.readthedocs.io/
MIT License
1.31k stars 226 forks source link

duckmesh = Mesh.from_trimesh(list(duck.geometry.values())[0]) AttributeError: 'Trimesh' object has no attribute 'geometry' #208

Open lucasjinreal opened 2 years ago

lucasjinreal commented 2 years ago

duckmesh = Mesh.from_trimesh(list(duck.geometry.values())[0]) AttributeError: 'Trimesh' object has no attribute 'geometry'

Auratons commented 2 years ago

If there is only one element in the ply file (I can only imagine it's like that since I have no idea what your duck is), trimesh.load returns Trimesh instance. With more elements it should return Scene instance instead. Scene has geometries instance variable as expected. Quick fix (pyrender.Scene.from_trimesh_scene iterates over geometries inside, so for loadedMesh being Trimesh it fails the same as your code):

loadedMesh = trimesh.load(plyPath)
if isinstance(loadedMesh, trimesh.Trimesh):
    trimeshScene = trimesh.Scene()
    trimeshScene.add_geometry(loadedMesh)
else:
    trimeshScene = loaded_mesh
scene = pyrender.Scene.from_trimesh_scene(trimeshScene)