|
@@ -4,12 +4,19 @@
|
|
|
*
|
|
|
* This file contains following classes:
|
|
|
*
|
|
|
+ * -- 2d classes --
|
|
|
* THREE.Curve
|
|
|
* THREE.LineCurve
|
|
|
* THREE.QuadraticBezierCurve
|
|
|
* THREE.CubicBezierCurve
|
|
|
* THREE.SplineCurve
|
|
|
* THREE.ArcCurve
|
|
|
+ *
|
|
|
+ * -- 3d classes --
|
|
|
+ * THREE.LineCurve3
|
|
|
+ * THREE.QuadraticBezierCurve3
|
|
|
+ * THREE.CubicBezierCurve3
|
|
|
+ * THREE.SplineCurve3
|
|
|
*
|
|
|
**/
|
|
|
|
|
@@ -660,3 +667,74 @@ THREE.QuadraticBezierCurve3 = THREE.Curve.create(
|
|
|
}
|
|
|
|
|
|
);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**************************************************************
|
|
|
+ * Cubic Bezier 3D curve
|
|
|
+ **************************************************************/
|
|
|
+
|
|
|
+THREE.CubicBezierCurve3 = THREE.Curve.create(
|
|
|
+
|
|
|
+ function ( v0, v1, v2, v3 ) {
|
|
|
+
|
|
|
+ this.v0 = v0;
|
|
|
+ this.v1 = v1;
|
|
|
+ this.v2 = v2;
|
|
|
+ this.v3 = v3;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ function ( t ) {
|
|
|
+
|
|
|
+ var tx, ty, tz;
|
|
|
+
|
|
|
+ tx = THREE.Shape.Utils.b3( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x );
|
|
|
+ ty = THREE.Shape.Utils.b3( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y );
|
|
|
+ tz = THREE.Shape.Utils.b3( t, this.v0.z, this.v1.z, this.v2.z, this.v3.z );
|
|
|
+
|
|
|
+ return new THREE.Vector3( tx, ty, tz );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**************************************************************
|
|
|
+ * Spline 3D curve
|
|
|
+ **************************************************************/
|
|
|
+
|
|
|
+
|
|
|
+THREE.SplineCurve3 = THREE.Curve.create(
|
|
|
+
|
|
|
+ function ( points /* array of Vector3 */) {
|
|
|
+
|
|
|
+ this.points = points;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ function ( t ) {
|
|
|
+
|
|
|
+ var v = new THREE.Vector3();
|
|
|
+ var c = [];
|
|
|
+ var points = this.points, point, intPoint, weight;
|
|
|
+ point = ( points.length - 1 ) * t;
|
|
|
+
|
|
|
+ intPoint = Math.floor( point );
|
|
|
+ weight = point - intPoint;
|
|
|
+
|
|
|
+ c[ 0 ] = intPoint == 0 ? intPoint : intPoint - 1;
|
|
|
+ c[ 1 ] = intPoint;
|
|
|
+ c[ 2 ] = intPoint > points.length - 2 ? intPoint : intPoint + 1;
|
|
|
+ c[ 3 ] = intPoint > points.length - 3 ? intPoint : intPoint + 2;
|
|
|
+
|
|
|
+ v.x = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].x, points[ c[ 1 ] ].x, points[ c[ 2 ] ].x, points[ c[ 3 ] ].x, weight );
|
|
|
+ v.y = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].y, points[ c[ 1 ] ].y, points[ c[ 2 ] ].y, points[ c[ 3 ] ].y, weight );
|
|
|
+ v.z = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].z, points[ c[ 1 ] ].z, points[ c[ 2 ] ].z, points[ c[ 3 ] ].z, weight );
|
|
|
+
|
|
|
+ return v;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+);
|