# Selected line by mouse

**URL:** <https://forum.babylonjs.com/t/selected-line-by-mouse/13104>\
**Category:** Questions\
**Tags:** material\
**Created:** [August 4, 2020, 8:10am UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104 "2020-08-04T08:10:13Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 4, 2020, 8:10am UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/1 "2020-08-04T08:10:13Z")

</div>

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](https://playground.babylonjs.com/#FRJX06#28)

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

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 4, 2020, 9:42am UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/2 "2020-08-04T09:42:04Z")

</div>

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

[https://playground.babylonjs.com/#NGICN5#1](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).

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 4, 2020, 6:47pm UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/3 "2020-08-04T18:47:51Z")

</div>

> [@Evgeni\_Popov](#):
>
> [https://playground.babylonjs.com/#NGICN5#1](https://playground.babylonjs.com/#NGICN5#1)

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.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 4, 2020, 8:10pm UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/4 "2020-08-04T20:10:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 4, 2020, 8:21pm UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/5 "2020-08-04T20:21:51Z")

</div>

Thank you so much, 🙏 🙏 🙏

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 5, 2020, 8:04pm UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/6 "2020-08-05T20:04:36Z")

</div>

> [@Evgeni\_Popov](#):
>
> [https://playground.babylonjs.com/#NGICN5#1](https://playground.babylonjs.com/#NGICN5#1)

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:

> **[Babylon.js Playground](https://playground.babylonjs.com/#NGICN5%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 5, 2020, 9:21pm UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/7 "2020-08-05T21:21:50Z")

</div>

I think you should use tubes instead of cylinders:

[https://doc.babylonjs.com/how\_to/parametric\_shapes#tube](https://doc.babylonjs.com/how_to/parametric_shapes#tube)

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 6, 2020, 9:46am UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/8 "2020-08-06T09:46:28Z")

</div>

> [@Evgeni\_Popov](#):
>
> [https://doc.babylonjs.com/how\_to/parametric\_shapes#tube](https://doc.babylonjs.com/how_to/parametric_shapes#tube)

Thank you so much 🙏

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

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 6, 2020, 10:18am UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/9 "2020-08-06T10:18:32Z")

</div>

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

[https://playground.babylonjs.com/#NGICN5#3](https://playground.babylonjs.com/#NGICN5#3)

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 6, 2020, 11:58am UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/10 "2020-08-06T11:58:04Z")

</div>

> [@Evgeni\_Popov](#):
>
> [https://playground.babylonjs.com/#NGICN5#3](https://playground.babylonjs.com/#NGICN5#3)

thank you so much 🙏, 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,

> **[Babylon.js Playground](https://playground.babylonjs.com/#NGICN5%235)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 6, 2020, 6:03pm UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/11 "2020-08-06T18:03:48Z")

</div>

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

and how can I eliminate extra line?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 7, 2020, 8:05am UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/12 "2020-08-07T08:05:43Z")

</div>

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

[https://playground.babylonjs.com/#NGICN5#7](https://playground.babylonjs.com/#NGICN5#7)

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 7, 2020, 10:52am UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/13 "2020-08-07T10:52:02Z")

</div>

> [@Evgeni\_Popov](#):
>
> [https://playground.babylonjs.com/#NGICN5#7](https://playground.babylonjs.com/#NGICN5#7)

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.

> **[Babylon.js Playground](https://playground.babylonjs.com/#NGICN5%239)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 7, 2020, 12:04pm UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/14 "2020-08-07T12:04:27Z")

</div>

Because the mesh itself is at (0,0,0):  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/9/9b8daf411d89f525be62574db7601a13a4988108.png)

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:

```javascript
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](https://www.babylonjs-playground.com/#NGICN5#10)

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 7, 2020, 7:36pm UTC](https://forum.babylonjs.com/t/selected-line-by-mouse/13104/15 "2020-08-07T19:36:25Z")

</div>

> [@Evgeni\_Popov](#):
>
> [https://www.babylonjs-playground.com/#NGICN5#10](https://www.babylonjs-playground.com/#NGICN5#10)

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