Lines between clicked spheres and right click to stop the function

Hello Everybody! Sorry for my English!

In an old post there was this thread that gave me everything I need:
https://forum.babylonjs.com/t/pg-examples-on-creating-lines-on-click/16473/4

I would like to add that pressing the right button (when nothing is clicked or pick) exits the function.
A thing like that:





if(e.button === 2) {
if(pickResult.hit==false) {
“”“Exit Function “””
}
}
} // End onPointerUp
return scene;
}

Sorry but i’m newbie!

Hi @Vince456 and welcome to the forum!
I think just calling return; will work in your case.

No. like this:

if(e.button === 2) {
if(pickResult.hit==false) {
return;
}
}
} // End onPointerUp
return scene;
}

don’t work.

Because " return; " is still inside “onPointerUp” .

THANKS

Can you share a playground?

This is the first time that I share. I hope it work.

https://playground.babylonjs.com/#JWETXJ#17

if(e.button === 2) {
if(pickResult.hit==false) {
return;
}
}

DON’T WORK

THANKS

Yes, sharing works.
I’m not following what you want to achieve, sorry. Can you be more explicit?

I have created an html page with an html button and a div canvas.

When I push the html button the function (in .JS file) is activated for the lines between objects.

With the left button I connect the spheres with a line. And it’s ok.

Now,

I would like the function to STOP working with the right click (clicking where there is nothing).
So that I can activate other functions with the left button.

I basically don’t want the “LINES function” to stay active forever.

Thanks for your time.

If I understand correctly, you want to remove all the lines when right clicking somewhere that it not over a mesh ?

No. When right clicking somewhere that it not over a mesh, I want no longer to be able to make lines between meshes. I’don’t want to remove the lines but only exit function.

  1. push html button—> Active Function -enabled for lines with left button - OK
    2- draw lines between mesh - OK
    3- right clich where no over a mesh and exit function - not enabled for lines - KO

You can have a boolean allowMakeLines that is true by default, and when the over-nothing click happen, set it to false.
Then, check the boolean is true before

Something like that - https://playground.babylonjs.com/#JWETXJ#19

2 Likes

Or like that - https://playground.babylonjs.com/#JWETXJ#20

2 Likes

You guys are great

thanks you

2 Likes