Set mesh rotation depending on 2 position vectors

Recommended Posts

I try something pretty easy (I think) but I cant make it work.

The want that the faces are aligned in their direction between two world space Vector3.

The position on the screenshot is not correct but that's not the problem. :) 

I tried it with lookAt for the mesh and also played a bit around with RotationFromAxis from this example


But its always not correct rotated, correct would it be when they are aligned along the edge between the two vertices where currently the feces are placed.

Any suggestions?

Bildschirmfoto 2017-11-19 um 14.26.47.png

Share this post

Link to post
Share on other sites

:)  Hi guys. 

This issue is related-to the old cylinderBetweenPoints() function that is laying around in some playgrounds.  Xtender wants the fence-section to start at END of previous fence-section run, and go to some "next fence-section start position".  He is having a difficult time determining the Y-rotation needed to accomplish that.  (not uncommon)

He needs fenceSectionBetweenPoints()  :)  Each fence section might need a gizmo/invisible-parent... as a central rotating/positioning device.  It also might be wise to set the fence-section pivotPoint/origin... to the start-point (left-edge?) of the fence-section.  Not sure... still thinking.  :)

A playground search for 'vend' will find all those playgrounds.  One of them is here:  https://www.babylonjs-playground.com/#1MQTOG#0

Hope this helps (and clarifies).

Share this post

Link to post
Share on other sites


I had a purrrdy, fancy, fence thing going... but... too artsy... couldn't beat Adam to the draw.  Mine wasn't going to use picked points... just an array of fence post points. 

If each fence section has a set width (and it does), then... hmm.  Needs thinkin'.  I want to make an irregular-shaped circle of fencing, just to experiment.  Adam will beat me to that, too... but I always learn stuff from his code.  (He's a friggin' genius.  So is Jerome.  I am among BIG guns, here.)  :) Anyway, so far...


Too slow. Not finished.  :)  Darned Adam... he's got a FAST draw.  No outlaw challenge can gun him down in the streets.  heh

Later, we'll attach 2 physics hingeJoints between each fence section in the "circle", and create the first BJS physics-active bulldozer track.  :/

Share this post

Link to post
Share on other sites

Hi XT.  Oh sure, now we have MORE hell.  :D  (Wingnut trying comedy, there, XT... ignore at-will)

Let me predict:  You want all vertical fence-boards... to remain perfectly vertical, even when section is running up/down a hill?  Cross-boards can be angled up/down, but not verticals?  Thoughts?

Share this post

Link to post
Share on other sites

Just ignore that the are fences. Imagen that they are just 3d "Lines" and I would like to place it between 2 V3 . The Position and Scaling is the easy part. its just the rotation thing.

But I thing I come a bit closer, looks like my artist mad some failures in the model export. when i make the mesh lookAt the targer position its nearly perfect. only that its pointing in the complete opposite direction.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.