zz85 пре 13 година
родитељ
комит
8bebe3e184
1 измењених фајлова са 18 додато и 19 уклоњено
  1. 18 19
      src/extras/core/Path.js

+ 18 - 19
src/extras/core/Path.js

@@ -42,7 +42,9 @@ THREE.Path.prototype.fromPoints = function ( vectors ) {
 
 
 	this.moveTo( vectors[ 0 ].x, vectors[ 0 ].y );
 	this.moveTo( vectors[ 0 ].x, vectors[ 0 ].y );
 
 
-	for ( var v = 1, vlen = vectors.length; v < vlen; v ++ ) {
+	var v, vlen = vectors.length;
+
+	for ( v = 1; v < vlen; v++ ) {
 
 
 		this.lineTo( vectors[ v ].x, vectors[ v ].y );
 		this.lineTo( vectors[ v ].x, vectors[ v ].y );
 
 
@@ -121,9 +123,7 @@ THREE.Path.prototype.splineThru = function( pts /*Array of Vector*/ ) {
 
 
 	var x0 = lastargs[ lastargs.length - 2 ];
 	var x0 = lastargs[ lastargs.length - 2 ];
 	var y0 = lastargs[ lastargs.length - 1 ];
 	var y0 = lastargs[ lastargs.length - 1 ];
-
-	// ---
-
+//---
 	var npts = [ new THREE.Vector2( x0, y0 ) ];
 	var npts = [ new THREE.Vector2( x0, y0 ) ];
 	Array.prototype.push.apply( npts, pts );
 	Array.prototype.push.apply( npts, pts );
 
 
@@ -155,7 +155,7 @@ THREE.Path.prototype.arc = function ( aX, aY, aRadius,
 
 
 THREE.Path.prototype.getSpacedPoints = function ( divisions, closedPath ) {
 THREE.Path.prototype.getSpacedPoints = function ( divisions, closedPath ) {
 
 
-	if ( ! divisions ) divisions = 40;
+	if ( !divisions ) divisions = 40;
 
 
 	var points = [];
 	var points = [];
 
 
@@ -332,12 +332,13 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 			var deltaAngle = aEndAngle - aStartAngle;
 			var deltaAngle = aEndAngle - aStartAngle;
 			var angle;
 			var angle;
 			var tdivisions = divisions * 2;
 			var tdivisions = divisions * 2;
+			var t;
 
 
 			for ( j = 1; j <= tdivisions; j ++ ) {
 			for ( j = 1; j <= tdivisions; j ++ ) {
 
 
 				t = j / tdivisions;
 				t = j / tdivisions;
 
 
-				if ( ! aClockwise ) {
+				if ( !aClockwise ) {
 
 
 					t = 1 - t;
 					t = 1 - t;
 
 
@@ -506,17 +507,6 @@ THREE.Path.prototype.debug = function( canvas ) {
 
 
 	var p, points = this.getPoints();
 	var p, points = this.getPoints();
 
 
-	//var theta = -90 /180 * Math.PI;
-	//var p, points = this.transform( 0.866, - 0.866,0, 0.500 , 0.50,-50 );
-
-	//0.866, - 0.866,0, 0.500 , 0.50,-50
-
-	// Math.cos(theta),Math.sin(theta),100,
-	// Math.cos(theta),-Math.sin(theta),-50
-
-	// translate, scale, rotation
-
-
 	for ( i = 0, il = points.length; i < il; i ++ ) {
 	for ( i = 0, il = points.length; i < il; i ++ ) {
 
 
 		p = points[ i ];
 		p = points[ i ];
@@ -566,15 +556,24 @@ THREE.Path.prototype.toShapes = function() {
 
 
 	}
 	}
 
 
-	//console.log(subPaths);
+	// console.log(subPaths);
 
 
 	if ( subPaths.length == 0 ) return [];
 	if ( subPaths.length == 0 ) return [];
 
 
 	var holesFirst = !THREE.Shape.Utils.isClockWise( subPaths[ 0 ].getPoints() );
 	var holesFirst = !THREE.Shape.Utils.isClockWise( subPaths[ 0 ].getPoints() );
+	if ( subPaths.length == 1) {
+		tmpPath = subPaths[0];
+		tmpShape = new THREE.Shape();
+		tmpShape.actions = tmpPath.actions;
+		tmpShape.curves = tmpPath.curves;
+		return tmpShape;
+	};
 
 
 	var tmpPath, tmpShape, shapes = [];
 	var tmpPath, tmpShape, shapes = [];
 
 
-	//console.log("Holes first", holesFirst);
+	// console.log("Holes first", holesFirst);
+	
+	
 
 
 	if ( holesFirst ) {
 	if ( holesFirst ) {