Skip to content

add colors to draw plotly mesh object #6829

Open
@ShawnLJW

Description

@ShawnLJW

Checklist

Proposed new feature or change

The colors of a triangle mesh is ignored by o3d.visualization.draw_plotly. We could consider implementing a similar behavior to get_point_object in get_mesh_object?

def get_mesh_object(geometry,):
    triangles = np.asarray(geometry.triangles)
    vertices = np.asarray(geometry.vertices)
    if geometry.has_vertex_colors():
        vertexcolor = np.asarray(geometry.vertex_colors)
    elif geometry.has_vertex_normals():
        vertexcolor = (0.5, 0.5, 0.5) + np.asarray(geometry.vertex_normals) * 0.5
    else:
        geometry.paint_uniform_color((0.6, 0.6, 0.6))
        vertexcolor = np.asarray(geometry.vertex_colors)
    mesh_3d = go.Mesh3d(x=vertices[:, 0],
                        y=vertices[:, 1],
                        z=vertices[:, 2],
                        i=triangles[:, 0],
                        j=triangles[:, 1],
                        k=triangles[:, 2],
                        vertexcolor=vertexcolor,
                        flatshading=True,
                        lighting=dict(ambient=0.18,
                                      diffuse=1,
                                      fresnel=0.1,
                                      specular=1,
                                      roughness=0.05,
                                      facenormalsepsilon=1e-15,
                                      vertexnormalsepsilon=1e-15),
                        lightposition=dict(x=100, y=200, z=0))
    return mesh_3d

References

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions