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

This commit is contained in:
zz85
2011-09-28 17:20:37 +08:00
parent f43d6a3cd1
commit 3e8c66f6e1
+35 -19
View File
@@ -498,8 +498,8 @@ THREE.Geometry.prototype = {
// should shared edge be included?
// 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 );
addToMap( vfMap, hash, i );
@@ -518,24 +518,40 @@ THREE.Geometry.prototype = {
}
// 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 ] );
//
// }
//
// }
}