pyrender icon indicating copy to clipboard operation
pyrender copied to clipboard

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

Open lucasjinreal opened this issue 3 years ago • 1 comments

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

lucasjinreal avatar Jan 07 '22 16:01 lucasjinreal

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)

Auratons avatar Jan 16 '22 14:01 Auratons