浏览代码

Merging with @zz85's branch.

Mr.doob 13 年之前
父节点
当前提交
8730833a6a
共有 2 个文件被更改,包括 457 次插入487 次删除
  1. 449 449
      build/Three.js
  2. 8 38
      src/extras/core/Curve.js

文件差异内容过多而无法显示
+ 449 - 449
build/Three.js


+ 8 - 38
src/extras/core/Curve.js

@@ -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;
 
 	},
 

部分文件因为文件数量过多而无法显示