Two opposite center points of tube

Hi, I got a problem with the tube mesh. I need to find two opposite center points of the pipe. My goal is to add a position and rotation gizmo and on ‘onDragEndObservable’ calculate updated edges. This tube is always straight. It seems to be easy but I don’t know how to do that.

Playground:

1 Like

Hi,
I’m not sure what you want to achieve. First, the tube is not straight on its axis from the start in this PG. I assume you want to create a pivot on each side of the (length?) of the tube and attach the gizmo to this end. Is that what you are looking for? Does it have to be dynamic, extrapolated from whatever the length of a tube object is and attach to each end, so the gizmo would make the tube rotate (or position) from the pivot set on either edge of the tube?

No, I want to add one gizmo to the center of that tube (as it is right now). And on ‘onDragEndObservable’ recalculate edges (at the beginning edges are in the “path” array).

When you say ‘recalculate’, do you mean ‘capture/get’ the values?

Yes, exactly. My bad. I mean get positions of two new edges.

OK, starting to understand. But you would get only the one vector point position and rotation that is in the center of the tube, located at each end of the tube, correct?

Yes, in other words, I want to get a new ‘path’ array of the updated tube.

Right. I think this is clear now. To be honest I’m not sure what would be the best method so I’m gonna call a couple of people in to quickly help you solve this. Stay tuned…

Edit: @carolhmj and @Cedric , may be you Guys can quickly help out with this (faster than I can)?, Thx a lot,

Edit2: Well, thinking of it a little, I believe the initial path/extrusion of the tube should probably not be rotated on the Y axis to make things easier while testing. Then, probably the vector3 point for the extrusion/path should be variables. Next, we could capture this variable vector3 point’s position. But again, I’m not sure this is the (best) method.

Hi! Let’s say you used the gizmo to drag the mesh 1 unit on the X axis, so, a (1,0,0) translation. If you apply the same translation to the path points, then you have the updated path. The same logic follows for the other transformations.

Thanks, that solution is ok for positionGizmo, but what with rotatonGizmo? How can I rotate Vector3 (I mean vectors from the original path)?

Did you figure it out? I’m still not sure what your issue is. Look at this updated PG where I added a ‘beforeRender’ function with a console log. When you rotate or position the mesh with the gizmo, you can get your updated values for all. What exactly is your issue with ‘rotation’?

I’m still not sure to understand.
Do you want to generate a tube from 1 end to another and have a position gizmo on 1 end and a rotation gizmo on the other.
And when the position gizmo is dragged, recompute a tube mesh?

Hello @Tomasz_Zieba just checking in, are you still having issues?