Browse Source

THREE.Shape.Utils.triangulateShape: Performance of removeHoles improved if there are several hundred holes

Juergen Ahting 11 years ago
parent
commit
04cd4ef926
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/extras/core/Shape.js

+ 4 - 1
src/extras/core/Shape.js

@@ -377,6 +377,7 @@ THREE.Shape.Utils = {
 
 			}
 
+			var minShapeIndex = 0;
 			var counter = indepHoles.length * 2;
 			while ( indepHoles.length > 0 ) {
 				counter --;
@@ -387,7 +388,7 @@ THREE.Shape.Utils = {
 
 				// search for shape-vertex and hole-vertex,
 				// which can be connected without intersections
-				for ( shapeIndex = 0; shapeIndex < shape.length; shapeIndex++ ) {
+				for ( shapeIndex = minShapeIndex; shapeIndex < shape.length; shapeIndex++ ) {
 
 					shapePt = shape[ shapeIndex ];
 					holeIndex	= -1;
@@ -417,6 +418,8 @@ THREE.Shape.Utils = {
 
 							shape = tmpShape1.concat( tmpHole1 ).concat( tmpHole2 ).concat( tmpShape2 );
 
+							minShapeIndex = shapeIndex;
+
 							// Debug only, to show the selected cuts
 							// glob_CutLines.push( [ shapePt, holePt ] );