|
@@ -147,20 +147,7 @@ THREE.Curve.prototype.getUtoTmapping = function ( u, distance ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- // // TODO Should do binary search + sub division + interpolation when needed
|
|
|
|
- // time = Date.now();
|
|
|
|
- // while ( i < il ) {
|
|
|
|
- //
|
|
|
|
- // i++;
|
|
|
|
- //
|
|
|
|
- // if ( targetArcLength < arcLengths[ i ] ) break;
|
|
|
|
- //
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // i--;
|
|
|
|
- // console.log('o' , i, Date.now()- time);
|
|
|
|
-
|
|
|
|
- var time = Date.now();
|
|
|
|
|
|
+ //var time = Date.now();
|
|
|
|
|
|
// binary search for the index with largest value smaller than target u distance
|
|
// binary search for the index with largest value smaller than target u distance
|
|
|
|
|
|
@@ -251,9 +238,11 @@ THREE.Curve.prototype.getTangent = function( t ) {
|
|
var pt1 = this.getPoint( t1 );
|
|
var pt1 = this.getPoint( t1 );
|
|
var pt2 = this.getPoint( t2 );
|
|
var pt2 = this.getPoint( t2 );
|
|
|
|
|
|
- var vec = new THREE.Vector2();
|
|
|
|
- vec.sub( pt2, pt1 );
|
|
|
|
- return vec.unit();
|
|
|
|
|
|
+ // var vec = new THREE.Vector2();
|
|
|
|
+ // vec.sub( pt2, pt1 );
|
|
|
|
+
|
|
|
|
+ var vec = pt1.clone().subSelf(pt2);
|
|
|
|
+ return vec.normalize();
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -296,14 +285,6 @@ THREE.LineCurve.prototype.getPoint = function ( t ) {
|
|
|
|
|
|
return point;
|
|
return point;
|
|
|
|
|
|
- // var dx = this.x2 - this.x1;
|
|
|
|
- // var dy = this.y2 - this.y1;
|
|
|
|
- //
|
|
|
|
- // var tx = this.x1 + dx * t;
|
|
|
|
- // var ty = this.y1 + dy * t;
|
|
|
|
- //
|
|
|
|
- // return new THREE.Vector2( tx, ty );
|
|
|
|
-
|
|
|
|
};
|
|
};
|
|
|
|
|
|
// Line curve is linear, so we can overwrite default getPointAt
|
|
// Line curve is linear, so we can overwrite default getPointAt
|
|
@@ -371,17 +352,6 @@ THREE.QuadraticBezierCurve.prototype.getTangent = function( t ) {
|
|
// if segment is bezier
|
|
// if segment is bezier
|
|
// perform subdivisions
|
|
// perform subdivisions
|
|
|
|
|
|
- // var x0, y0, x1, y1, x2, y2;
|
|
|
|
-
|
|
|
|
- // x0 = this.actions[ 0 ].args[ 0 ];
|
|
|
|
- // y0 = this.actions[ 0 ].args[ 1 ];
|
|
|
|
- //
|
|
|
|
- // x1 = this.actions[ 1 ].args[ 0 ];
|
|
|
|
- // y1 = this.actions[ 1 ].args[ 1 ];
|
|
|
|
- //
|
|
|
|
- // x2 = this.actions[ 1 ].args[ 2 ];
|
|
|
|
- // y2 = this.actions[ 1 ].args[ 3 ];
|
|
|
|
-
|
|
|
|
var tx, ty;
|
|
var tx, ty;
|
|
|
|
|
|
tx = THREE.Curve.Utils.tangentQuadraticBezier( t, this.v0.x, this.v1.x, this.v2.x );
|
|
tx = THREE.Curve.Utils.tangentQuadraticBezier( t, this.v0.x, this.v1.x, this.v2.x );
|
|
@@ -458,7 +428,7 @@ THREE.CubicBezierCurve.prototype.getTangent = function( t ) {
|
|
|
|
|
|
THREE.SplineCurve = function ( points /* array of Vector2 */ ) {
|
|
THREE.SplineCurve = function ( points /* array of Vector2 */ ) {
|
|
|
|
|
|
- this.points = points;
|
|
|
|
|
|
+ this.points = (points == undefined) ? [] : points;
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -710,7 +680,7 @@ THREE.SplineCurve3 = THREE.Curve.create(
|
|
|
|
|
|
function ( points /* array of Vector3 */) {
|
|
function ( points /* array of Vector3 */) {
|
|
|
|
|
|
- this.points = points;
|
|
|
|
|
|
+ this.points = (points == undefined) ? [] : points;
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|