Merging with @zz85's branch.

This commit is contained in:
Mr.doob
2011-11-11 18:58:54 +01:00
parent 9a375c4f39
commit 8730833a6a
2 changed files with 471 additions and 501 deletions
+463 -463
View File
File diff suppressed because it is too large Load Diff
+8 -38
View File
@@ -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
@@ -251,9 +238,11 @@ THREE.Curve.prototype.getTangent = function( t ) {
var pt1 = this.getPoint( t1 );
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;
// 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
@@ -371,17 +352,6 @@ THREE.QuadraticBezierCurve.prototype.getTangent = function( t ) {
// if segment is bezier
// 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;
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 */ ) {
this.points = points;
this.points = (points == undefined) ? [] : points;
};
@@ -710,7 +680,7 @@ THREE.SplineCurve3 = THREE.Curve.create(
function ( points /* array of Vector3 */) {
this.points = points;
this.points = (points == undefined) ? [] : points;
},