From 84615fe345ff850e446f3306ef1b0a9ee7ef0db4 Mon Sep 17 00:00:00 2001 From: WestLangley Date: Wed, 24 Apr 2013 21:36:04 -0400 Subject: [PATCH] Corrected face normal calculation in PolyhedronGeometry --- src/extras/geometries/PolyhedronGeometry.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/extras/geometries/PolyhedronGeometry.js b/src/extras/geometries/PolyhedronGeometry.js index 6b437f8266..a8ee08177a 100644 --- a/src/extras/geometries/PolyhedronGeometry.js +++ b/src/extras/geometries/PolyhedronGeometry.js @@ -63,11 +63,6 @@ THREE.PolyhedronGeometry = function ( vertices, faces, radius, detail ) { } - // Merge vertices - - this.mergeVertices(); - - // Apply radius for ( var i = 0, l = this.vertices.length; i < l; i ++ ) { @@ -77,6 +72,17 @@ THREE.PolyhedronGeometry = function ( vertices, faces, radius, detail ) { } + // Merge vertices + + this.mergeVertices(); + + this.computeCentroids(); + + this.computeFaceNormals(); + + this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius ); + + // Project vector onto sphere's surface function prepare( vector ) { @@ -101,7 +107,6 @@ THREE.PolyhedronGeometry = function ( vertices, faces, radius, detail ) { var face = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] ); face.centroid.add( v1 ).add( v2 ).add( v3 ).divideScalar( 3 ); - face.normal.copy( face.centroid ).normalize(); that.faces.push( face ); var azi = azimuth( face.centroid ); @@ -213,9 +218,6 @@ THREE.PolyhedronGeometry = function ( vertices, faces, radius, detail ) { } - this.computeCentroids(); - - this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius ); }; -- GitLab