Browse Source

fixed Geometry.js so computeEdgeFaces() writes face indices to edges

zz85 14 years ago
parent
commit
3e8c66f6e1
1 changed files with 35 additions and 19 deletions
  1. 35 19
      src/core/Geometry.js

+ 35 - 19
src/core/Geometry.js

@@ -498,8 +498,8 @@ THREE.Geometry.prototype = {
 				// should shared edge be included?
 				// should shared edge be included?
 				// comment out if not
 				// comment out if not
 
 
-				hash = edge_hash( face.b, face.d ); 
-				addToMap( vfMap, hash, i );
+				// hash = edge_hash( face.b, face.d ); 
+				// addToMap( vfMap, hash, i );
 
 
 				hash = edge_hash( face.a, face.b );
 				hash = edge_hash( face.a, face.b );
 				addToMap( vfMap, hash, i );
 				addToMap( vfMap, hash, i );
@@ -518,24 +518,40 @@ THREE.Geometry.prototype = {
 		}
 		}
 
 
 		// extract faces
 		// extract faces
-
-		for( i = 0, il = this.edges.length; i < il; i ++ ) {
-
-			edge = this.edges[ i ];
-
-			v1 = edge.vertexIndices[ 0 ];
-			v2 = edge.vertexIndices[ 1 ];
-
-			edge.faceIndices = vfMap[ edge_hash( v1, v2 ) ].array;
-
-			for( j = 0; j < edge.faceIndices.length; j ++ ) {
-
-				faceIndex = edge.faceIndices[ j ];
-				edge.faces.push( this.faces[ faceIndex ] );
-
-			}
-
+		
+	
+		this.vfMap = vfMap;
+		
+		var numOfEdges = 0;
+		for (i in vfMap) {
+			numOfEdges++;
+			
+			edge = vfMap[i];
+			this.edges.push(edge.array);
+			
 		}
 		}
+		
+		//console.log('vfMap', vfMap, 'this.edges',this.edges, 'numOfEdges', numOfEdges);
+
+		// Not sure what the below does.
+		
+		// for( i = 0, il = this.edges.length; i < il; i ++ ) {
+		// 
+		// 	edge = this.edges[ i ];
+		// 
+		// 	v1 = edge.vertexIndices[ 0 ];
+		// 	v2 = edge.vertexIndices[ 1 ];
+		// 
+		// 	edge.faceIndices = vfMap[ edge_hash( v1, v2 ) ].array;
+		// 
+		// 	for( j = 0; j < edge.faceIndices.length; j ++ ) {
+		// 
+		// 		faceIndex = edge.faceIndices[ j ];
+		// 		edge.faces.push( this.faces[ faceIndex ] );
+		// 
+		// 	}
+		// 
+		// }
 
 
 	}
 	}