Jump to content

[Solved] Mesh Follow Curve


Snouto
 Share

Recommended Posts

Hi

I'm experimenting with Babylon and currently I'm trying to get a mesh (box) to follow a curve I've created. This part I've managed by borrowing various examples, but what i'd like to do now is make sure the box is always "facing" the direction of movement as it goes along the path. I've tried a few techniques I've found here and elsewhere but I seem to be having trouble making it work.

Here's "my" code:

http://www.babylonjs-playground.com/#5KA114#11

It's based on an example by @celian-garcia because I was planning on using TweenMax for this and some other animations I have in mind.

Once I can get the above working I will then parent a camera to the box and use this as a fly-by-wire animation for my final scene.

 

Would appreciate any help.


Cheers

Link to comment
Share on other sites

After more study of your code I do not think there is any relationship between the position at tween.time(i) and p so position and orientation do not match 

tween.time(i); //jumps to the appropriate time in the tween, causing position.x and position.y to be updated accordingly.

var orientation = new BABYLON.Vector3.RotationFromAxis(normals[p], binormals[p], tangents[p]);

You need something like

var rotationTween = TweenLite.to(rotation, quantity, {?????????}); and a rotationTween.time(i); as well as tween.time(i);


 

 

Link to comment
Share on other sites

hey @SinhNQ thanks so much for this, a very nice update you've made there. Actually I couldn't get your version to run but I took the changes you made and put them in to mine and it looks great! I just now have to figure out how to make sure the camera - once parented to the box - looks in the correct direction and I'm just about there. Many thanks!

Latest version

Link to comment
Share on other sites

Not quite right, loses tracking on tight bend. You can see the camera is following a box through the tube.

https://www.babylonjs-playground.com/#5KA114#23

Also by adding an s to http:// ensures everyone can load your file "https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"

                                                                                                                             ^

Link to comment
Share on other sites

  • Snouto changed the title to [Solved] Mesh Follow Curve

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...