jerome Posted May 6, 2015 Share Posted May 6, 2015 Added methog length() to curve3 : returns the total length of the curveAdded the Hermite Spline curve to the curve3 collection.var hermite = BABYLON.Curve3.CreateHermiteSpline(p1, t1, p2, t2, nbPoints);p1 : initial pointt1 : initial tangent vectorp2 : final pointt2 : final tangent vector This curve is based on the internal BJS Vector3.Hermite.It is very useful to smoothly continue or close other curves by using their first and last segments as Hermite tangents.example : smoothly closing two concatened cubic bezier curves// two concatened cubic Beziervar cubicA = BABYLON.Curve3.CreateCubicBezier(vA0, vA1, vA2, vA3, 50);var cubicB = BABYLON.Curve3.CreateCubicBezier(vB0, vB1, vB2, vB3, 50);var continued = cubicA.continue(cubicB);// initial Hermite values from continued first and last segmentsvar t = continued.length() / 2; // tangent scale factorvar points = continued.getPoints();var p1 = points[points.length - 1]; // last continued point = first hermite pointvar t1 = (p1.subtract(points[points.length - 2])).scale(t); // last segment scaled = hermite tangent t1var p2 = points[0]; // first continued point = last hermite pointvar t2 = (points[1].subtract(p2)).scale(t); // first segment scaled = hermite tangent t2var hermite = BABYLON.Curve3.CreateHermiteSpline(p1, t1, p2, t2, 50);continued = continued.continue(hermite);// finally drawing a smooth closed curvevar closedCurve = BABYLON.Mesh.CreateLines("closed", continued.getPoints(), scene);PR pending Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 6, 2015 Share Posted May 6, 2015 Validated Quote Link to comment Share on other sites More sharing options...
jerome Posted May 6, 2015 Author Share Posted May 6, 2015 cinq iou doc very soon 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.