Jump to content

[Solved} + Rotation flipping when mesh on path


Recommended Posts


I'm animating vehicles on paths, and have no flipping until I get to a heart shape. The curve is less than others, yet I'm getting tons of flipping (gimble lock.) I've tried converting the animation to use quaternions, but no such luck. Here's the code I'm using for the animation:



      function heartFlight(vehicle) {
          vehicle.rotation.x = 0;
          vehicle.rotation.z = Math.PI / 4;
          vehicle.position.y = 0;
      const Heartpath = [
        new BABYLON.Vector3(0, -40, 100),
        new BABYLON.Vector3(-50, 20, 100),
        new BABYLON.Vector3(-25, 38, 100),
        new BABYLON.Vector3(0, 18, 100),
        new BABYLON.Vector3(25, 38, 100),
        new BABYLON.Vector3(50, 20, 100),
        new BABYLON.Vector3(0, -40, 99),
      const catmullRomH = BABYLON.Curve3.CreateCatmullRomSpline(
       //let catmullRomSplineH = BABYLON.Mesh.CreateLines("catmullRomH", catmullRomH.getPoints(), scene);
       //catmullRomSplineH.color = new BABYLON.Color3(1,0,0); 
      const path3d = new BABYLON.Path3D(catmullRomH.getPoints());
      const tangents = path3d.getTangents(); // array of tangents to the curve
      const normals = path3d.getNormals(); // array of normals to the curve
      const binormals = path3d.getBinormals(); // array of binormals to curve
      const speed = 20
      // const speed = 10
      const animationPosition = new BABYLON.Animation('animPos', 'position', speed, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
      const animationRotation = new BABYLON.Animation('animRot', 'rotation', speed, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
      const keysPosition = [];
      const keysRotation = [];
      for (let p = 0; p < catmullRomH.getPoints().length; p++) {
          frame: p,
          value: catmullRomH.getPoints()[p]

          frame: p,
          value: BABYLON.Vector3.RotationFromAxis(normals[p], binormals[p], tangents[p])


      vehicle.parent.animations = [

      flying = scene.beginAnimation(vehicle.parent, 0, 300, false);


If anyone can offer a solution to stop the constant flipping, I would be grateful. Every method I know doesn't want to work on this path.



Link to comment
Share on other sites


You are amazing in my opinion. I had switched the normals and binormals, but foolishly assumed that changing the order of the tangents would not have an extreme effect on the orientation behavior. This is a huge help to me, and I owe you one - and way beyond "one." You are a gentleman and very accomplished scholar. It's certainly a pleasure to have you as an integral part of our small (yet rapidly growing) community. I just hope I can assist you on the same level one day.

Please have a great weekend! 



Link to comment
Share on other sites

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.

×   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.


  • Recently Browsing   0 members

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