Jump to content

[Solved] 3D spline through its control points (e.g. BABYLON.Curve3.CreateCatmullRom)


Adrian3D
 Share

Recommended Posts

Hello Babylon.js Community,

I am trying to create a smooth 3D spline that goes through its control points.

I was reading through the Curve3 tutorial and started a playground attempt: http://www.babylonjs-playground.com/#1GXSPK#1

My guess is that I have to create the spline step-by-step somehow with the BABYLON.Curve3.continue() function!?!
Maybe I also miss a very simple approach to reach my goal?

Wishfull thinking:
Three.js offers exactly the spline I am looking for:

Would something like this be of interest for the Curve3 class in general, e.g.
var oMyNoBrainerCurve3 = new BABYLON.Curve3.CreateCatmullRom( Vector3[] );

Anyone can give me a hand? Any help is appreciated.

 

Link to comment
Share on other sites

you're right, this spline is not implemented for now in the Curve3 helpers. I could do it for you the next weeks, when I get some free time.

Meanwhile, you can always build your own with the integrated math function : 

http://doc.babylonjs.com/classes/2.5/vector3#static-catmullrom-value1-value2-value3-value4-amount-rarr-vector3-classes-2-5-vector3-

 code : https://github.com/BabylonJS/Babylon.js/blob/master/src/Math/babylon.math.ts#L1507

Link to comment
Share on other sites

PRed : https://github.com/BabylonJS/Babylon.js/pull/1791

Thanks to @BitOfGold whose PG helped me to code it quickly

As the title says ...

var points = [vec1, vec2, vec2, ... vecN]; // the points the curve must pass through
var nbPoints = 20; 
BABYLON.Curve3.CreateCatmullRomSpline(points, nbPoints);

documentation coming soon ...

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.

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