I’m experimenting with MeshCat for my project involving pointclouds and meshes. I wanted to place several pointclouds in the visualizer with different colors. I loaded them from .ply files (only vertices, without faces).
If I place the mesh with: setobject!(vis[:hbunny],PointCloud(vertices(half_b)))
it works fine, and has black color. Then I tried with the Colors.jl
package and the only method that didn’t throw an error was the following: setobject(vis[:hbunny],PointCloud(vertices(half_b),fill(convert(RGB{Float32},parse(Colorant,"darkred"))),length(vertices(half_b)))))
Converting to Float32
seems compulsory, because if I try the following command:
setobject!(vis[:rotbunny],PointCloud(vertices(half_b),fill(parse(Colorant,"darkred"),length(vertices(half_b)))))
I get the following error:
MethodError: no method matching js_array_type(::Type{FixedPointNumbers.Normed{UInt8,8}})
Closest candidates are:
js_array_type(!Matched::Type{Float32}) at C:\Users\Pista\.julia\packages\MeshCat\rjDJh\src\lowering.jl:115
js_array_type(!Matched::Type{UInt32}) at C:\Users\Pista\.julia\packages\MeshCat\rjDJh\src\lowering.jl:116
I see that MeshCat
only accepts the Float32
and UInt32
types, so my main question is that, is there an easier way to generate the colors for the a pointcloud? (The Color
package with the color_names
dictionary would be convenient.)
And another question came to my mind: is there way to change the size of the points in the MeshCat
viewer?