Browse Source

Simplify tracking of EdgesGeometry coordinates

dubejf 10 years ago
parent
commit
669eb6dd61
1 changed files with 8 additions and 14 deletions
  1. 8 14
      src/extras/geometries/EdgesGeometry.js

+ 8 - 14
src/extras/geometries/EdgesGeometry.js

@@ -33,7 +33,6 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
 
 
 	var vertices = geometry2.vertices;
 	var vertices = geometry2.vertices;
 	var faces = geometry2.faces;
 	var faces = geometry2.faces;
-	var numEdges = 0;
 
 
 	for ( var i = 0, l = faces.length; i < l; i ++ ) {
 	for ( var i = 0, l = faces.length; i < l; i ++ ) {
 
 
@@ -50,7 +49,6 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
 			if ( hash[ key ] === undefined ) {
 			if ( hash[ key ] === undefined ) {
 
 
 				hash[ key ] = { vert1: edge[ 0 ], vert2: edge[ 1 ], face1: i, face2: undefined };
 				hash[ key ] = { vert1: edge[ 0 ], vert2: edge[ 1 ], face1: i, face2: undefined };
-				numEdges ++;
 
 
 			} else {
 			} else {
 
 
@@ -62,9 +60,7 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
 
 
 	}
 	}
 
 
-	var coords = new Float32Array( numEdges * 2 * 3 );
-
-	var index = 0;
+	var coords = [];
 
 
 	for ( var key in hash ) {
 	for ( var key in hash ) {
 
 
@@ -73,22 +69,20 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
 		if ( h.face2 === undefined || faces[ h.face1 ].normal.dot( faces[ h.face2 ].normal ) <= thresholdDot ) {
 		if ( h.face2 === undefined || faces[ h.face1 ].normal.dot( faces[ h.face2 ].normal ) <= thresholdDot ) {
 
 
 			var vertex = vertices[ h.vert1 ];
 			var vertex = vertices[ h.vert1 ];
-			coords[ index ++ ] = vertex.x;
-			coords[ index ++ ] = vertex.y;
-			coords[ index ++ ] = vertex.z;
+			coords.push( vertex.x );
+			coords.push( vertex.y );
+			coords.push( vertex.z );
 
 
 			vertex = vertices[ h.vert2 ];
 			vertex = vertices[ h.vert2 ];
-			coords[ index ++ ] = vertex.x;
-			coords[ index ++ ] = vertex.y;
-			coords[ index ++ ] = vertex.z;
+			coords.push( vertex.x );
+			coords.push( vertex.y );
+			coords.push( vertex.z );
 
 
 		}
 		}
 
 
 	}
 	}
 
 
-	coords = coords.subarray( 0, index );
-
-	this.addAttribute( 'position', new THREE.BufferAttribute( coords, 3 ) );
+	this.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( coords ), 3 ) );
 
 
 };
 };