rdeits / MeshCat.jl

WebGL-based 3D visualizer in Julia
MIT License
233 stars 42 forks source link

Simple line and arrows #217

Closed ga72kud closed 2 years ago

ga72kud commented 2 years ago

Hi, thank you for the excellent package. Is there a simple and fast solution for visualizing a line and arrows (should I use polygon of geometry basics?)? I want to visualize a point cloud and compute the nearest neighbor graph. 3dimensional Line, in the documentation, is a 2dim line mentioned

ga72kud commented 2 years ago

Seems like to have use shaft = Cylinder(zero(Point{3, Float64}), Point(0.0, 0.0, 10.0), 0.1) setobject!(vis, shaft)

ferrolho commented 2 years ago

Hi @ga72kud,

For simple line segments, you can use something like this:

function show_path(vis::Visualizer, points::Matrix{Float64})
    points = collect(eachcol(points))
    material = LineBasicMaterial(color=colorant"yellow", linewidth=2.0)
    setobject!(vis["path"], Object(PointCloud(points), material, "Line"))
    nothing
end

For arrows, see this https://github.com/JuliaRobotics/RigidBodyDynamics.jl/issues/589#issuecomment-943176446.