|
@@ -3131,6 +3131,8 @@
|
|
|
|
|
|
/**
|
|
|
* new Path3D(path, normal, raw)
|
|
|
+ * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
|
|
|
+ * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
|
|
|
* path : an array of Vector3, the curve axis of the Path3D
|
|
|
* normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
|
|
|
* raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
|
|
@@ -3143,26 +3145,49 @@
|
|
|
this._compute(firstNormal);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns the Path3D array of successive Vector3 designing its curve.
|
|
|
+ */
|
|
|
public getCurve(): Vector3[] {
|
|
|
return this._curve;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns an array populated with tangent vectors on each Path3D curve point.
|
|
|
+ */
|
|
|
public getTangents(): Vector3[] {
|
|
|
return this._tangents;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns an array populated with normal vectors on each Path3D curve point.
|
|
|
+ */
|
|
|
public getNormals(): Vector3[] {
|
|
|
return this._normals;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns an array populated with binormal vectors on each Path3D curve point.
|
|
|
+ */
|
|
|
public getBinormals(): Vector3[] {
|
|
|
return this._binormals;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns an array populated with distances (float) of the i-th point from the first curve point.
|
|
|
+ */
|
|
|
public getDistances(): number[] {
|
|
|
return this._distances;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Forces the Path3D tangent, normal, binormal and distance recomputation.
|
|
|
+ * Returns the same object updated.
|
|
|
+ */
|
|
|
public update(path: Vector3[], firstNormal?: Vector3): Path3D {
|
|
|
for (var p = 0; p < path.length; p++) {
|
|
|
this._curve[p].x = path[p].x;
|
|
@@ -3289,7 +3314,13 @@
|
|
|
private _points: Vector3[];
|
|
|
private _length: number = 0;
|
|
|
|
|
|
- // QuadraticBezier(origin_V3, control_V3, destination_V3, nbPoints)
|
|
|
+ /**
|
|
|
+ * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
|
|
|
+ * @param v0 (Vector3) the origin point of the Quadratic Bezier
|
|
|
+ * @param v1 (Vector3) the control point
|
|
|
+ * @param v2 (Vector3) the end point of the Quadratic Bezier
|
|
|
+ * @param nbPoints (integer) the wanted number of points in the curve
|
|
|
+ */
|
|
|
public static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3 {
|
|
|
nbPoints = nbPoints > 2 ? nbPoints : 3;
|
|
|
var bez = new Array<Vector3>();
|
|
@@ -3302,8 +3333,15 @@
|
|
|
}
|
|
|
return new Curve3(bez);
|
|
|
}
|
|
|
-
|
|
|
- // CubicBezier(origin_V3, control1_V3, control2_V3, destination_V3, nbPoints)
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
|
|
|
+ * @param v0 (Vector3) the origin point of the Cubic Bezier
|
|
|
+ * @param v1 (Vector3) the first control point
|
|
|
+ * @param v2 (Vector3) the second control point
|
|
|
+ * @param v3 (Vector3) the end point of the Cubic Bezier
|
|
|
+ * @param nbPoints (integer) the wanted number of points in the curve
|
|
|
+ */
|
|
|
public static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3 {
|
|
|
nbPoints = nbPoints > 3 ? nbPoints : 4;
|
|
|
var bez = new Array<Vector3>();
|
|
@@ -3317,7 +3355,14 @@
|
|
|
return new Curve3(bez);
|
|
|
}
|
|
|
|
|
|
- // HermiteSpline(origin_V3, originTangent_V3, destination_V3, destinationTangent_V3, nbPoints)
|
|
|
+ /**
|
|
|
+ * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
|
|
|
+ * @param p1 (Vector3) the origin point of the Hermite Spline
|
|
|
+ * @param t1 (Vector3) the tangent vector at the origin point
|
|
|
+ * @param p2 (Vector3) the end point of the Hermite Spline
|
|
|
+ * @param t2 (Vector3) the tangent vector at the end point
|
|
|
+ * @param nbPoints (integer) the wanted number of points in the curve
|
|
|
+ */
|
|
|
public static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3 {
|
|
|
var hermite = new Array<Vector3>();
|
|
|
var step = 1 / nbPoints;
|
|
@@ -3327,19 +3372,35 @@
|
|
|
return new Curve3(hermite);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
|
|
|
+ * A Curve3 is designed from a series of successive Vector3.
|
|
|
+ * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
|
|
|
+ */
|
|
|
constructor(points: Vector3[]) {
|
|
|
this._points = points;
|
|
|
this._length = this._computeLength(points);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns the Curve3 stored array of successive Vector3
|
|
|
+ */
|
|
|
public getPoints() {
|
|
|
return this._points;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns the computed length (float) of the curve.
|
|
|
+ */
|
|
|
public length() {
|
|
|
return this._length;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
|
|
|
+ * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
|
|
|
+ * curveA and curveB keep unchanged.
|
|
|
+ */
|
|
|
public continue(curve: Curve3): Curve3 {
|
|
|
var lastPoint = this._points[this._points.length - 1];
|
|
|
var continuedPoints = this._points.slice();
|