# Tube does not show for some combination of points.

## Recommended Posts

I am facing a strange problem.  I am trying to draw tubes between points. The points are determined based on some mathematical logic. Strange thing is that for some combination of coordinated the tubes don't show up. Below is an example.

var path = [];
path.push(new BABYLON.Vector3(22, -3.1945000000000014, 0)) //point 1A
//path.push(new BABYLON.Vector3(22, -3.1944000000000017, 0)) //point 1B
path.push(new BABYLON.Vector3(22, 24.25, 0)) //point 2
var tube = BABYLON.Mesh.CreateTube("tube", path, .15, 16, null, 0, scene, false, BABYLON.Mesh.FRONTSIDE)

If I run the above code the tube will NOT show. But if i comment "point 1A" and uncomment "point 1B" then the line will show up. If you notice the difference between "point 1A" & "point 1B" is in value of "y". Its a very small difference. For some combination of points the tube totally disappears. For slightly higher or lower values of "y" it again shows up.

Another thing is the sequence.. If I add the "point 2" before "point  1B" then also the tube does not show.

a PG maybe ?

##### Share on other sites

http://www.babylonjs-playground.com/#1EVT9Z#2

Rem line 25, activate 26, tube appears.  *scratch scratch*

##### Share on other sites

http://www.babylonjs-playground.com/#1EVT9Z#3

Ok, it seems the problem is not related to the number of points in the tube path, but more to the way the underlying path3D is computed (probably the way the first normal and tangent are computed)

If you set y value other than -3.194 to the fist path point, it seems to work in your case.

I did a change in the path3D algorythm a month ago in order to simplify the code, but it seems to have imply this bug.

I need to check it when I will be back at work at the end of august. Sorry for the delay

##### Share on other sites

You don't get to code-play at home, Jeromino?  What's the story there?  (like it's any of MY beeswax)

Need a home puter?  I got a used VIC-20 here that I'm sure would run Knoppix.  Want me to mail it to you?

If it's your girl... demanding quality time... well... you're pretty much screwed, there.  I can't help with that.  I traded all my girlfriends... for 6 Western Digital 4tb external hard drives.  What a great deal!  heh

##### Share on other sites

The problem is that these positions are calculated dynamically. I am trying to build a 3 dimensional topology structure made of objects that are connected with tubes. This structure would be driven by a data file & hence it would be dynamic & can have different number & combination of objects with connections depending on what is there in the data file. So as you can understand the positions of the tubes (rather the position of the "to" & "from" points of the tube )  is not hard coded & is calculated at runtime. So hard coding is not a option.

So what you guys suggest me here? Is there some logic that I can use to avoid some specific "points" to create the "path" tube. Some logic that I would apply on the calculated values. If it does not pass then I use the nearest value & so on & so forth. Basically some logic to bypass this bug that is there. Otherwise, I am, kind of hitting a wall here.

##### Share on other sites

No, no, don't change anything please

The tube should work with any path. Actually there might be a problem in the path3D computation : a path3D object is created on the tube path parameter.

It used to work pretty well with the original implementation that I stressed heavily to test it. I guess the modification done recently in the path3D code brought this erratic behavior on limit cases : the tube path maybe collinear with one of the world axis, I don't really know.

I will investigate as soon as I will get back to work... the only place where I dig in BJS

##### Share on other sites

The problem is that these positions are calculated dynamically. I am trying to build a 3 dimensional topology structure made of objects that are connected with tubes. This structure would be driven by a data file & hence it would be dynamic & can have different number & combination of objects with connections depending on what is there in the data file. So as you can understand the positions of the tubes (rather the position of the "to" & "from" points of the tube )  is not hard coded & is calculated at runtime. So hard coding is not a option.

So what you guys suggest me here? Is there some logic that I can use to avoid some specific "points" to create the "path" tube. Some logic that I would apply on the calculated values. If it does not pass then I use the nearest value & so on & so forth. Basically some logic to bypass this bug that is there. Otherwise, I am, kind of hitting a wall here.

Simply use an older version of BJS while you are waiting for the fix.

See if this one works:

https://github.com/BabylonJS/Babylon.js/tree/c8400bee9880c4dc44a668c554e5dfeabd48c539/dist/preview%20release%20-%20alpha

##### Share on other sites

Ok.. Thanks for the replies... I will wait for the fix & in the meantime will check with an older version... If you can kindly post a reply on this post once fixed that will be great!... thanks...

##### Share on other sites

if your path has only two points, maybe could you use a Cylinder instead of a tube meantime ?

here are the last path3D commits :

https://github.com/BabylonJS/Babylon.js/commit/9b91bee3d693d692ebdcc9da83c898f1f52455d2

https://github.com/BabylonJS/Babylon.js/commit/c68262975a13ccce604a395ca653ebdf2ce7898b

I'll check at the end of august

##### Share on other sites

Thanks Jerome... Yes, I have tried with cylinder using this link (code from deltakosh)..

http://www.html5gamedevs.com/topic/9015-cylinder-between-two-points/

But it seems there is a problem with this code.

If I change the positions of the spheres then the cylinder would no longer connect

Like if i change this

whiteSphere.position = new BABYLON.Vector3(-20,0,0);

to

whiteSphere.position = new BABYLON.Vector3(-20,-20,0);

then then it will not work

##### Share on other sites

• 3 weeks later...

Ok

This should be fixed now.

The Path3D normals and binormals are computed in a point of the curve path from the tangent in this point and from an arbitrary vector chosen as non-collinear to this tangent.
If the tangent normalization is approximated, the choice of the arbitrary vector gave in in some limit cases something collinear with the tangent.

##### Share on other sites

merged. Thanks Jerome!

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.