We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

drawing a line between two moving 3d objects?

Home Forums General Questions drawing a line between two moving 3d objects?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #74885
    xeon
    Customer

    I have a situation where I need to draw a line between two objects. Both objects are draggable by the user and I need a line that is drawn between the two objects to stay connected.

    I have tried placing html objects over each of my objects and trying to draw lines using the draw line puzzle…but thats just doesnt work well as the lines just dart off the screen.

    I have tried to use the following but am having issues with erasing the previous line and updating to the new line.

    Anyone have any suggestions or thoughts on whay I may be doing wrong?

    let p1x = VARS[‘point1_X’];
    let p1y = VARS[‘point1_Y’];
    let p1z = VARS[‘point1_Z’];
    let p2x = VARS[‘point2_X’];
    let p2y = VARS[‘point2_Y’]
    let p2z = VARS[‘point2_Z’];
    let Xmdt = (p1x+p2x)/2;
    let Ymdt = (p1y+p2y)/2;

    const material = new v3d.LineBasicMaterial({ color: 0x0000ff });

    const points = [];
    points.push(new v3d.Vector3(p2x, 0, p2y));
    points.push(new v3d.Vector3(Xmdt, 0, Ymdt));
    points.push(new v3d.Vector3(p1x, 0, p1y));

    const geometry = new v3d.BufferGeometry().setFromPoints(points);

    const line = new v3d.Line(geometry, material);

    line.geometry.attributes.position.needsUpdate = true;

    app.scene.add(line);

    Xeon
    Route 66 Digital
    Interactive Solutions - https://www.r66d.com
    Tutorials - https://www.xeons3dlab.com

    #74887
    xeon
    Customer

    I should clarify… this can be done using just 3D objects including a 3D object for the line. I am trying to see if a line (HTML) can be drawn between two moving 3D objects.

    Xeon
    Route 66 Digital
    Interactive Solutions - https://www.r66d.com
    Tutorials - https://www.xeons3dlab.com

    #74890
    kdv
    Participant

    I need a line that is drawn between the two objects to stay connected.

    smth like this https://v3d.net/a4k?

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #74893
    xeon
    Customer

    Yes.

    Xeon
    Route 66 Digital
    Interactive Solutions - https://www.r66d.com
    Tutorials - https://www.xeons3dlab.com

    #74902
    kdv
    Participant

    In your case you don’t need to draw a new line every move. Just draw the line between objects once and then update its geometry according to the objects current position.

    https://v3d.net/10ff

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.