浏览代码

ShapeUtils: Moved addContour() and removeDupEndPts() out of triangulateShape(). See #12940.

Mr.doob 7 年之前
父节点
当前提交
166ba2f5e6
共有 1 个文件被更改,包括 22 次插入23 次删除
  1. 22 23
      src/extras/ShapeUtils.js

+ 22 - 23
src/extras/ShapeUtils.js

@@ -31,29 +31,6 @@ var ShapeUtils = {
 
 
 	triangulateShape: function ( contour, holes ) {
 	triangulateShape: function ( contour, holes ) {
 
 
-		function removeDupEndPts( points ) {
-
-			var l = points.length;
-
-			if ( l > 2 && points[ l - 1 ].equals( points[ 0 ] ) ) {
-
-				points.pop();
-
-			}
-
-		}
-
-		function addContour( vertices, contour ) {
-
-			for ( var i = 0; i < contour.length; i ++ ) {
-
-				vertices.push( contour[ i ].x );
-				vertices.push( contour[ i ].y );
-
-			}
-
-		}
-
 		var vertices = []; // flat array of vertices like [ x0,y0, x1,y1, x2,y2, ... ]
 		var vertices = []; // flat array of vertices like [ x0,y0, x1,y1, x2,y2, ... ]
 		var holeIndices = []; // array of hole indices
 		var holeIndices = []; // array of hole indices
 		var faces = []; // final array of vertex indices like [ [ a,b,d ], [ b,c,d ] ]
 		var faces = []; // final array of vertex indices like [ [ a,b,d ], [ b,c,d ] ]
@@ -92,5 +69,27 @@ var ShapeUtils = {
 
 
 };
 };
 
 
+function removeDupEndPts( points ) {
+
+	var l = points.length;
+
+	if ( l > 2 && points[ l - 1 ].equals( points[ 0 ] ) ) {
+
+		points.pop();
+
+	}
+
+}
+
+function addContour( vertices, contour ) {
+
+	for ( var i = 0; i < contour.length; i ++ ) {
+
+		vertices.push( contour[ i ].x );
+		vertices.push( contour[ i ].y );
+
+	}
+
+}
 
 
 export { ShapeUtils };
 export { ShapeUtils };