|
@@ -83,17 +83,16 @@ function CubicPoly() {
|
|
|
var tmp = new Vector3();
|
|
|
var px = new CubicPoly(), py = new CubicPoly(), pz = new CubicPoly();
|
|
|
|
|
|
-function CatmullRomCurve3( points ) {
|
|
|
+function CatmullRomCurve3( points, closed, curveType, tension ) {
|
|
|
|
|
|
Curve.call( this );
|
|
|
|
|
|
this.type = 'CatmullRomCurve3';
|
|
|
|
|
|
- if ( points.length < 2 ) console.warn( 'THREE.CatmullRomCurve3: Points array needs at least two entries.' );
|
|
|
-
|
|
|
this.points = points || [];
|
|
|
- this.closed = false;
|
|
|
- this.curveType = 'centripetal';
|
|
|
+ this.closed = closed || false;
|
|
|
+ this.curveType = curveType || 'centripetal';
|
|
|
+ this.tension = tension || 0.5;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -172,10 +171,9 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
|
|
} else if ( this.curveType === 'catmullrom' ) {
|
|
|
|
|
|
- var tension = this.tension !== undefined ? this.tension : 0.5;
|
|
|
- px.initCatmullRom( p0.x, p1.x, p2.x, p3.x, tension );
|
|
|
- py.initCatmullRom( p0.y, p1.y, p2.y, p3.y, tension );
|
|
|
- pz.initCatmullRom( p0.z, p1.z, p2.z, p3.z, tension );
|
|
|
+ px.initCatmullRom( p0.x, p1.x, p2.x, p3.x, this.tension );
|
|
|
+ py.initCatmullRom( p0.y, p1.y, p2.y, p3.y, this.tension );
|
|
|
+ pz.initCatmullRom( p0.z, p1.z, p2.z, p3.z, this.tension );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -189,5 +187,27 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
|
|
};
|
|
|
|
|
|
+CatmullRomCurve3.prototype.copy = function ( source ) {
|
|
|
+
|
|
|
+ Curve.prototype.copy.call( this, source );
|
|
|
+
|
|
|
+ this.points = [];
|
|
|
+
|
|
|
+ for ( var i = 0, l = source.points.length; i < l; i ++ ) {
|
|
|
+
|
|
|
+ var point = source.points[ i ];
|
|
|
+
|
|
|
+ this.points.push( point.clone() );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this.closed = source.closed;
|
|
|
+ this.curveType = source.curveType;
|
|
|
+ this.tension = source.tension;
|
|
|
+
|
|
|
+ return this;
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
export { CatmullRomCurve3 };
|