# Building a tube from array when returning to former point won't render the tube

**URL:** https://forum.babylonjs.com/t/building-a-tube-from-array-when-returning-to-former-point-wont-render-the-tube/1152
**Category:** Questions
**Created:** [February 3, 2019, 4:21am UTC](https://forum.babylonjs.com/t/building-a-tube-from-array-when-returning-to-former-point-wont-render-the-tube/1152 "2019-02-03T04:21:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rgalindox](https://avatars.discourse-cdn.com/v4/letter/r/6de8d8/32.png) [@rgalindox](https://forum.babylonjs.com/u/rgalindox)
#### Post date: [February 3, 2019, 4:21am UTC](https://forum.babylonjs.com/t/building-a-tube-from-array-when-returning-to-former-point-wont-render-the-tube/1152/1 "2019-02-03T04:21:15Z")

</div>

HI,

I’m creating a tube dynamically based on points from an array that is calculated on the fly finding a route, in some cases the point is repeated and the tube will return to a prior point as it finds a blocker, when this happens, the tube is not rendered after that point.

This is an example of an array that causes the behaviour, position 0 and 3 are repeated:

```
       var myPathTmp = [];
        myPathTmp[0] = new BABYLON.Vector3(2.273655652999878, 0.5, 1.9416018724441528);
        myPathTmp[1] = new BABYLON.Vector3(2.680851459503174, 0.5, 2.4170844554901123);
        myPathTmp[2] = new BABYLON.Vector3(2.273655652999878, 0.5, 1.9416018724441528);
        myPathTmp[3] = new BABYLON.Vector3(2.1215269565582275, 0.5, 2.6639657020568848);

```

tube = BABYLON.MeshBuilder.CreateTube(“tube”, {path: myPathTmp, radius: 0.02, sideOrientation: BABYLON.Mesh.DOUBLESIDE, updatable: true}, scene);  
tube.material = myMaterial;

This code won’t render the tube from array position 2 to 3.

If I remove the point myPathTmp[2]:  
var myPathTmp = [];  
myPathTmp[0] = new BABYLON.Vector3(2.273655652999878, 0.5, 1.9416018724441528);  
myPathTmp[1] = new BABYLON.Vector3(2.680851459503174, 0.5, 2.4170844554901123);  
myPathTmp[2] = new BABYLON.Vector3(2.1215269565582275, 0.5, 2.6639657020568848);

It renders the tube correctly. In this case Vector3 on position 1 is not repeated.

In my case the array is dynamically generated as it is finding a route.

Do you think this is a bug or a setting on the CreateTube that I need to set?

Thanks for your valuable help.

---

<div class="post-metadata">

### Author: ![jerome](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jerome/32/22_2.png) [@jerome](https://forum.babylonjs.com/u/jerome)
#### Post date: [February 3, 2019, 7:44am UTC](https://forum.babylonjs.com/t/building-a-tube-from-array-when-returning-to-former-point-wont-render-the-tube/1152/2 "2019-02-03T07:44:54Z")

</div>

The tube geometry is built upon the mathemical object Path3D : [Path3D - Babylon.js Documentation](https://doc.babylonjs.com/api/classes/babylon.path3d)

example : [Use Path3D - Babylon.js Documentation](https://doc.babylonjs.com/how_to/how_to_use_path3d)  
[Display Path3D Curve - Babylon.js Documentation](https://doc.babylonjs.com/snippets/path3d)

It’s probably not surprising that getting back on your path will generate some weird things in your tube…

---

<div class="post-metadata">

### Author: ![rgalindox](https://avatars.discourse-cdn.com/v4/letter/r/6de8d8/32.png) [@rgalindox](https://forum.babylonjs.com/u/rgalindox)
#### Post date: [February 4, 2019, 4:20pm UTC](https://forum.babylonjs.com/t/building-a-tube-from-array-when-returning-to-former-point-wont-render-the-tube/1152/3 "2019-02-04T16:20:21Z")

</div>

Thanks for the reply. If I use the line it renders it correctly. But line doesn’t have width parameter ☹
