def set_vertex_colors(mesh: trimesh.Trimesh, colors): vector_func = np.vectorize(max_to_white, otypes=[np.uint8], signature="(n)->(4)") mesh.visual = trimesh.visual.ColorVisuals(mesh, None, vector_func(colors))
def store_mesh(path, mesh: trimesh.Trimesh): mesh.export(path, "glb") mesh.visual = trimesh.visual.ColorVisuals(mesh, None, (0,0,0))