在jupyter笔记本中可视化网格、点云和其他几何图形
threevis的Python项目详细描述
三视
python库,用于在jupyter笔记本中可视化网格、点云和其他几何图形
安装
pip install threevis
示例
快速网格检查
importthreevisimportopenmeshasomm=om.read_trimesh('examples/models/bunny.obj')threevis.display_openmesh(m)
自定义渲染
importthreevisimportopenmeshasomimportnumpyasnp# Load Meshm=om.read_trimesh('mouse.obj')# Create Contextctx=threevis.Context(width=640,height=480)# Get vertices and faces from the meshvertices=m.points()faces=m.face_vertex_indices()# We don't have normals, calculate themnormals=threevis.calculateFaceNormals(m.points(),m.face_vertex_indices())# Choose a random color for each facecolors=threevis.FaceAttribute(np.random.rand(len(faces),3))# Draw the mesh with flat shadingctx.draw_faces(vertices,faces,normals=normals,colors=colors,shading='flat')# Draw edges on top with random colorsctx.draw_edges(vertices,m.ev_indices(),colors=threevis.FaceAttribute(np.random.rand(len(m.ev_indices()),3)),linewidth=3)# Calculate data to display normals as edgesnormal_vis_verts,normal_vis_edges=threevis.calculateNormalEdges(vertices,faces,normals,length=0.05)# Draw the normals inctx.draw_edges(normal_vis_verts,normal_vis_edges,colors=colors)# Draw a point for each vertexctx.draw_vertices(vertices,point_size=4,colors='red')# Finally display itctx.display()
开发设置
- 安装依赖项
- 克隆存储库
pip install -e .
依赖关系
- pythreejs>;=1.0.0