Stick mesh to a line


I have to build a massive structure with alu profiles and i think it would be great if i could first build the structure with lines between points and after “stick” my mesh profiles on the lines.

here’s a playground to explain

I can’t find the rotation vector of the line to align my profile to it.

Is there a function to “stick” the mesh to the line.


Let me take a look.

1 Like

It can be done by computing the quaternion that transform a direction unit vector by another.

Babylon.js Playground (

I baked the transform instead of multiplying quaternion. It’s easier for explanation.
line 87, I compute the normalized line direction.
line 92, I compute the quaternion that transform the mesh direction (change this value if you don’t want to bake vertices) to the line direction.
That’s it :slight_smile:


Thanks very much.

I didn’t know the .bakeCurrentTransformIntoVertices() method and it’s really useful to reset all transformations and keep the geometry.

1 Like