From 669eb6dd6191978e2f6b280bc50f976453f3d654 Mon Sep 17 00:00:00 2001 From: dubejf Date: Wed, 29 Apr 2015 13:09:28 -0400 Subject: [PATCH] Simplify tracking of EdgesGeometry coordinates --- src/extras/geometries/EdgesGeometry.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/extras/geometries/EdgesGeometry.js b/src/extras/geometries/EdgesGeometry.js index 5db96d8fbd..0a4b03056a 100644 --- a/src/extras/geometries/EdgesGeometry.js +++ b/src/extras/geometries/EdgesGeometry.js @@ -33,7 +33,6 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) { var vertices = geometry2.vertices; var faces = geometry2.faces; - var numEdges = 0; for ( var i = 0, l = faces.length; i < l; i ++ ) { @@ -50,7 +49,6 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) { if ( hash[ key ] === undefined ) { hash[ key ] = { vert1: edge[ 0 ], vert2: edge[ 1 ], face1: i, face2: undefined }; - numEdges ++; } 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 ) { @@ -73,22 +69,20 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) { if ( h.face2 === undefined || faces[ h.face1 ].normal.dot( faces[ h.face2 ].normal ) <= thresholdDot ) { 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 ]; - 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 ) ); }; -- GitLab