Selected line by mouse

Hello Everyone

I’m trying to selected each line in my code with the help of mouse pointer, but I couldn’t find what is my mistake to select them. this is my PG:
https://playground.babylonjs.com/#FRJX06#28

Is it possible to help me to find a way to select each line?

You should push numbers as coordinates in the line array, not strings:

https://playground.babylonjs.com/#NGICN5#1

Also, visibility does not work for line meshes, you should use the alpha property of the colors instead to change the opacity (see PG).

1 Like

Hi @Evgeni_Popov, Thank you so much, you are wonderful, but is it possible to select each line separately?
I need to select them separately to show each line details.

In this case you will have to create different line systems, one for each line.

Thank you so much, :pray: :pray: :pray:

Hi @Evgeni_Popov,
sorry for taking your precious time, I have changed lineSystem to createCylinder method to build lines, but the problem is the points and also the degrees, i want to know is it possible to locate each cylinder between every two points of lines? I mean by default the points located on the center of cylinder, but how can modify them to locate the X,Y and Z at the top of the cylinder, and how can I rotate them to create the line with the help of cylinders:
https://playground.babylonjs.com/#NGICN5#2

I think you should use tubes instead of cylinders:

https://doc.babylonjs.com/how_to/parametric_shapes#tube

1 Like

Thank you so much :pray:

but I want something to select each line separately, the tube is like createLineSystem, and I can’t select each tube separately.

You can use tubes to have the correct orientation for the lines:

https://playground.babylonjs.com/#NGICN5#3

1 Like

thank you so much :pray:, I am so sorry for my many questions.
but the ID is not always change every 3 points, I try to do this but I got an error,
https://playground.babylonjs.com/#NGICN5#5

I mean for example if I add another point for “ID” = “0” then the tubes is like this:
https://playground.babylonjs.com/#NGICN5#6

and how can I eliminate extra line?

You can reuse the lines.filter(...) code you used previously:

https://playground.babylonjs.com/#NGICN5#7

1 Like

I cannot thank you enough for helping me. many thanks for your assistance.
I have just another question, why when I wanted to get the location of each tube , I can’t get the actual location, the location for all of them are 0,0,0.

https://playground.babylonjs.com/#NGICN5#9

Because the mesh itself is at (0,0,0):
image

As the name of the mesh is the FID of your structure, you can get the x/y/z of the first vertex of the tube path by doing:

const entry = lines.filter((entry) => entry.FID === selectedMesh.name)[0];
labelPos.text = entry.X + ", " + entry.Y + ", " + entry.Z;

https://www.babylonjs-playground.com/#NGICN5#10

1 Like

it’s great. I have learnt so much, thanks to you. Thanks a lot

1 Like