Adrian3D Posted February 17, 2017 Share Posted February 17, 2017 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: https://threejs.org/docs/#Reference/Extras.Curves/CatmullRomCurve3 https://threejs.org/examples/#webgl_lines_splines 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. Quote Link to comment Share on other sites More sharing options...
jerome Posted February 17, 2017 Share Posted February 17, 2017 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 Quote Link to comment Share on other sites More sharing options...
BitOfGold Posted February 17, 2017 Share Posted February 17, 2017 http://www.babylonjs-playground.com/#1GXSPK#13 I need this for a camera-path control too, so it was on my task list (not in the first hundred tasks ) jerome 1 Quote Link to comment Share on other sites More sharing options...
Adrian3D Posted February 20, 2017 Author Share Posted February 20, 2017 @BitOfGold: This is awesome and exactly what I was looking for. Thank you so much. @jerome: I am not very familiar with pull and push requests nor TypeScript. But if you plan to add BABYLON.Curve3.CreateCatmullRom to the Curve3 class in future I will be happy to update the tutorial accordingly including the playground examples. Quote Link to comment Share on other sites More sharing options...
jerome Posted February 20, 2017 Share Posted February 20, 2017 I'm currently implementing it in the Curve3 object for the BJS core ;-) NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted February 20, 2017 Share Posted February 20, 2017 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 ... adam and The Leftover 2 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 21, 2017 Share Posted February 21, 2017 PG updated jerome 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted February 21, 2017 Share Posted February 21, 2017 Curve3.CreateCatmullRomSpline(points, nbPoints) is now in the core and documented : https://github.com/BabylonJS/Documentation/blob/master/content/tutorials/03_Advanced/How_to_use_Curve3.md Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.