Draw movable segment?

Hello i want to draw real 3D segment when i move in mouse in engine i want that considere my segment is real 3D object and i don’t want that this segment is screen interface

this is my code :
import sys
from direct.showbase.ShowBase import ShowBase
from pandac.PandaModules import *
from direct.directtools.DirectGeometry import LineNodePath

class Application(ShowBase):

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

        ls = LineSegs()
        ls.setThickness(10)

        # segment
        ls.setColor(1.0, 0.0, 0.0, 1.0)
        ls.moveTo(0.0, 0.0, 0.0)
        ls.drawTo(1.0, 0.0, 0.0)

        node = ls.create()
        render2d.attachNewNode(node)

Application().run()

how detach segment to screen ?

Attach the node to render instead of render2d if you want to attach the node to the 3D scene and not the screen.