Open Conchylicultor opened 3 years ago
Duplicate of #946.
Point cloud visualization is working for me on Jupyter (rendered through VSCode on a remote machine), but the points are nearly impossible to see with the default white background because they are colored white.
Default result:
Modified result:
And here's the modification to color the cloud black:
import numpy as np
import trimesh
print(trimesh.__version__)
v = np.random.random((1000,3))
p = trimesh.points.PointCloud(v, colors=np.tile(np.array([0, 0, 0, 1]), (len(v), 1)))
s = trimesh.Scene()
s.add_geometry(trimesh.creation.axis())
s.add_geometry(p)
s.show()
I encountered the same problem:
from IPython.display import display
pc = trimesh.points.PointCloud(vertices=self.tensor)
display(pc.show())
In a notebook, the point cloud does not appear.
Thanks to @playertr, I was able to visualize the points albeit at an unworkable size.
I took a look at how the scene is bundled into a THREE.js compatible binary and came to the conclusion that a proper fix would not be very straightforward due to how materials are handled in the export to GLTF. Properties like size
and sizeAttenuation
do not seem available to the default PBRMaterial
class used by trimesh.
Thus, I relied on a workaround of visualizing the points as spheres:
import trimesh
import numpy as np
def points_to_spheres(points, radius=1):
"""
Convert points into spheres for notebook-friendly display
"""
return [
trimesh.primitives.Sphere(radius=radius, center=pt) for pt in points
]
# Similar example as above
v = np.random.random((1000,3))
p = points_to_spheres(v, radius=0.01)
s = trimesh.Scene()
s.add_geometry(trimesh.creation.axis())
s.add_geometry(p)
s.show()
Of course, this can be a one-liner instead of a function and you may still want to tweak things like color.
Result:
Reproduction instruction: https://colab.research.google.com/drive/1XU6z7ni3bTjoCU-LUxbpekGcCzYFEeiI?authuser=1#scrollTo=BFRvA_GLVcS4
The above code works well locally, but on colab/jupyter, only a black screen is displayed instead of the scene. Is there a workaround ?
(side question): Is there a way to customize the display of the points in addition of the color (e.g. size, square shape,...) ?