BabylonJS: Curve3 Cheat Sheet

Quadratic Bezier Curve

Syntax

var bezier = BABYLON.Curve3.CreateQuadraticBezier(origin, control, destination, nb_of_points);

Parameters

Below are parameters related to the Quadratic Bezier Curve:

  • Origin − The origin point for the curve.
  • Control − Control points for the curve.
  • Destination − Destination point.
  • Noofpoints − Points in the array.

Cubic Bezeir Curve

Syntax

var bezier3 = BABYLON.Curve3.CreateCubicBezier(origin, control1, control2, destination, nb_of_points)

Parameters

Below are parameters related to the Cubic Bezier Curve:

  • Origin − Origin point.
  • control1 − The first control point in vector form.
  • control2 − The second control point in vector form.
  • Destination − Destination point in vector form.
  • no_of_points − The number of points in array form.

HermiteSpline Curve

Syntax

var hermite = BABYLON.Curve3.CreateHermiteSpline(p1, t1, p2, t2, nbPoints);

Parameters

Below are parameters related to the Hermite Spline Curve :

  • p1 − The origin point for the curve.
  • t1 − The origin tangent vector point.
  • p2 − Destination point.
  • t2 − Destination tangent vector.
  • NbPoints − The array of points for the final curve.

Catmull-Rom Spline Curve

Syntax

var nbPoints = 20;   // the number of points between each Vector3 control points
var points = [vec1, vec2, ..., vecN];  // an array of Vector3 the curve must pass through : the control points
var catmullRom = BABYLON.Curve3.CreateCatmullRomSpline(points, nbPoints);

Parameters

Below are parameters related to the Catmull-Rom Spline Curve:

  • Points − An array of Vector3, the curve must pass through the control points.
  • NbPoints − The number of points between each Vector3 control points.
var path = catmullRom.getPoints(); // getPoints() returns an array of successive Vector3.
var l = catmullRom.length(); // method returns the curve length.

Leave a Reply

Your email address will not be published. Required fields are marked *