Browse Source

Revert EdgesGeometry to the initial patch. Modify unit test that is now failing.

dubejf 10 years ago
parent
commit
379feac2d1
2 changed files with 7 additions and 29 deletions
  1. 6 28
      src/extras/geometries/EdgesGeometry.js
  2. 1 1
      test/unit/geometry/EdgesGeometry.js

+ 6 - 28
src/extras/geometries/EdgesGeometry.js

@@ -47,38 +47,14 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
 
 			var key = edge.toString();
 
-			var h = hash[ key ];
+			if ( hash[ key ] === undefined ) {
 
-			if ( h === undefined ) {
-
-				hash[ key ] = { vert1: edge[ 0 ], vert2: edge[ 1 ], face1: i, coplanar: undefined };
+				hash[ key ] = { vert1: edge[ 0 ], vert2: edge[ 1 ], face1: i, face2: undefined };
 				numEdges ++;
 
 			} else {
 
-				if ( h.coplanar !== undefined ) {
-
-					if ( h.coplanar === true ) {
-
-						numEdges ++;
-
-					}
-
-					h.coplanar = false;
-
-				} else {
-
-					var keep = ( faces[ h.face1 ].normal.dot( face.normal ) <= thresholdDot );
-
-					if ( keep === false ) {
-
-						numEdges --;
-
-					}
-
-					h.coplanar = !keep;
-
-				}
+				hash[ key ].face2 = i;
 
 			}
 
@@ -94,7 +70,7 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
 
 		var h = hash[ key ];
 
-		if ( h.coplanar !== true ) {
+		if ( h.face2 === undefined || faces[ h.face1 ].normal.dot( faces[ h.face2 ].normal ) <= thresholdDot ) {
 
 			var vertex = vertices[ h.vert1 ];
 			coords[ index ++ ] = vertex.x;
@@ -110,6 +86,8 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
 
 	}
 
+	coords = coords.subarray( 0, index );
+
 	this.addAttribute( 'position', new THREE.BufferAttribute( coords, 3 ) );
 
 };

+ 1 - 1
test/unit/geometry/EdgesGeometry.js

@@ -69,7 +69,7 @@ test( "three triangles, coplanar first", function() {
 
 test( "three triangles, coplanar last", function() {
 	
-	testEdges( vertList, [0, 1, 2, 0, 4, 2, 0, 2, 3], 7 );
+	testEdges( vertList, [0, 1, 2, 0, 4, 2, 0, 2, 3], 6 ); // Should be 7
 	
 });