# Connect points with a mesh

**URL:** <https://forum.babylonjs.com/t/connect-points-with-a-mesh/23830>\
**Category:** Questions\
**Created:** [September 14, 2021, 3:07pm UTC](https://forum.babylonjs.com/t/connect-points-with-a-mesh/23830 "2021-09-14T15:07:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![CornelioD](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/corneliod/32/15799_2.png) [@CornelioD](https://forum.babylonjs.com/u/CornelioD)\
**Post date:** [September 14, 2021, 3:07pm UTC](https://forum.babylonjs.com/t/connect-points-with-a-mesh/23830/1 "2021-09-14T15:07:45Z")

</div>

Hi, I was looking for a way to create an editable mesh witch connect some points.  
So given a couple of objects, connect them via another mesh. I tried editing an existing polyhedron too.  
But it seems to have too many vertices… so maybe building every triangle is better?  
PG: [https://playground.babylonjs.com/#L8TP5D#1](https://playground.babylonjs.com/#L8TP5D#1)

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [September 14, 2021, 3:38pm UTC](https://forum.babylonjs.com/t/connect-points-with-a-mesh/23830/2 "2021-09-14T15:38:29Z")

</div>

The simplest is to create a custom polyhedra: [Creating Custom Polyhedra | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/mesh/creation/polyhedra/custom_poly)

Or you could create as you said your mesh manually:

> **[Create Custom Meshes From Scratch | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/mesh/creation/custom/custom)**
>
> Learn how to create custom meshes in Babylon.js.

---

<div class="post-metadata">

**Author:** ![msDestiny14](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/msdestiny14/32/9572_2.png) [@msDestiny14](https://forum.babylonjs.com/u/msDestiny14)\
**Post date:** [September 14, 2021, 9:44pm UTC](https://forum.babylonjs.com/t/connect-points-with-a-mesh/23830/3 "2021-09-14T21:44:52Z")

</div>

Do you want to be able to edit the vertices of the mesh once you create them, like dragging them around to change the shape of the mesh?

I can make a example for you 🙂

---

<div class="post-metadata">

**Author:** ![CornelioD](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/corneliod/32/15799_2.png) [@CornelioD](https://forum.babylonjs.com/u/CornelioD)\
**Post date:** [September 27, 2021, 12:37pm UTC](https://forum.babylonjs.com/t/connect-points-with-a-mesh/23830/4 "2021-09-27T12:37:38Z")

</div>

Yes, would be cool, I need a way to update them too! Thanks

---

<div class="post-metadata">

**Author:** ![DarraghBurke](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/darraghburke/32/10621_2.png) [@DarraghBurke](https://forum.babylonjs.com/u/DarraghBurke)\
**Post date:** [September 27, 2021, 8:16pm UTC](https://forum.babylonjs.com/t/connect-points-with-a-mesh/23830/5 "2021-09-27T20:16:46Z")

</div>

@msDestiny14 Just making sure you saw this 🙂 (I would also love to see this example)

---

<div class="post-metadata">

**Author:** ![msDestiny14](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/msdestiny14/32/9572_2.png) [@msDestiny14](https://forum.babylonjs.com/u/msDestiny14)\
**Post date:** [September 27, 2021, 8:28pm UTC](https://forum.babylonjs.com/t/connect-points-with-a-mesh/23830/6 "2021-09-27T20:28:52Z")

</div>

Yep. Thanks for the ping 😉 I’ll get something for you I can show real soon. 🙂

---

<div class="post-metadata">

**Author:** ![msDestiny14](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/msdestiny14/32/9572_2.png) [@msDestiny14](https://forum.babylonjs.com/u/msDestiny14)\
**Post date:** [September 28, 2021, 8:28pm UTC](https://forum.babylonjs.com/t/connect-points-with-a-mesh/23830/7 "2021-09-28T20:28:56Z")

</div>

Ok! Here is attempt #1 just so we can get the ball rolling a little bit.

[https://playground.babylonjs.com/#PBLS4Y#237](https://playground.babylonjs.com/#PBLS4Y#237)

Here is my version. I did similar to you where I created a primitive and attached boxes on all the vertices. Then I created gizmos and attached them to the boxes. Next I update each vertices each frame to match the gizmo’s position when I move it.

Note it still has the original problem of too many vertices. This is because each vertices is repeated multiple times depending on how many connecting points you have to it. The solution will be we must group those matching vertices so we’re only created one box per unique point. Then for each update match it to the corresponding duplicates. I try to come up with a way to best do this.

---

<div class="post-metadata">

**Author:** ![CornelioD](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/corneliod/32/15799_2.png) [@CornelioD](https://forum.babylonjs.com/u/CornelioD)\
**Post date:** [September 29, 2021, 9:15am UTC](https://forum.babylonjs.com/t/connect-points-with-a-mesh/23830/9 "2021-09-29T09:15:50Z")

</div>

Yep, I was trying to: [Babylon.js Playground](https://playground.babylonjs.com/#8QL4XQ)  
Seems like there is an ordering issue or something when updating…  
The idea was to create at attribute for every cube wich contains the index of vertex data  
and then when the cube moves, update the relative indexes

---

<div class="post-metadata">

**Author:** ![CornelioD](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/corneliod/32/15799_2.png) [@CornelioD](https://forum.babylonjs.com/u/CornelioD)\
**Post date:** [September 29, 2021, 7:13pm UTC](https://forum.babylonjs.com/t/connect-points-with-a-mesh/23830/10 "2021-09-29T19:13:36Z")

</div>

Yep, was a dumb error. Works: [https://playground.babylonjs.com/#8QL4XQ#2](https://playground.babylonjs.com/#8QL4XQ#2)
