Draw 3D lines with mouse

You can use this class to draw lines in 3D .

https://docs.panda3d.org/1.10/python/reference/panda3d.core.LineSegs

from panda3d.core import LineSegs, NodePath
from direct.showbase.ShowBase import ShowBase


class MyApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

        lines = LineSegs()
        lines.move_to(0, 0, 0)
        lines.draw_to(3, 3, 2)
        lines.draw_to(3, 3, 4)
        lines.set_thickness(4)

        np = NodePath(lines.create())
        np.reparent_to(render)

app = MyApp()
app.run()

To determine the position of a click in 3D space, you can use this approach.

1 Like