فهرست منبع

Removed useVertexNormals boolean from computeFaceNormals.
Bad things (and hard to debug) can happen that affect Ray.

Mr.doob 13 سال پیش
والد
کامیت
d196b36c51
2فایلهای تغییر یافته به همراه12 افزوده شده و 45 حذف شده
  1. 11 44
      src/core/Geometry.js
  2. 1 1
      src/extras/geometries/IcosahedronGeometry.js

+ 11 - 44
src/core/Geometry.js

@@ -100,64 +100,31 @@ THREE.Geometry.prototype = {
 
 	},
 
-	computeFaceNormals: function ( useVertexNormals ) {
+	computeFaceNormals: function () {
 
 		var n, nl, v, vl, vertex, f, fl, face, vA, vB, vC,
 		cb = new THREE.Vector3(), ab = new THREE.Vector3();
 
-		/*
-		for ( v = 0, vl = this.vertices.length; v < vl; v ++ ) {
-
-			vertex = this.vertices[ v ];
-			vertex.normal.set( 0, 0, 0 );
-
-		}
-		*/
-
 		for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
 
 			face = this.faces[ f ];
 
-			if ( useVertexNormals && face.vertexNormals.length  ) {
-
-				cb.set( 0, 0, 0 );
+			vA = this.vertices[ face.a ];
+			vB = this.vertices[ face.b ];
+			vC = this.vertices[ face.c ];
 
-				for ( n = 0, nl = face.vertexNormals.length; n < nl; n++ ) {
+			cb.sub( vC.position, vB.position );
+			ab.sub( vA.position, vB.position );
+			cb.crossSelf( ab );
 
-					cb.addSelf( face.vertexNormals[n] );
+			if ( !cb.isZero() ) {
 
-				}
-
-				cb.divideScalar( 3 );
-
-				if ( ! cb.isZero() ) {
-
-					cb.normalize();
-
-				}
-
-				face.normal.copy( cb );
-
-			} else {
-
-				vA = this.vertices[ face.a ];
-				vB = this.vertices[ face.b ];
-				vC = this.vertices[ face.c ];
-
-				cb.sub( vC.position, vB.position );
-				ab.sub( vA.position, vB.position );
-				cb.crossSelf( ab );
-
-				if ( !cb.isZero() ) {
-
-					cb.normalize();
-
-				}
-
-				face.normal.copy( cb );
+				cb.normalize();
 
 			}
 
+			face.normal.copy( cb );
+
 		}
 
 	},

+ 1 - 1
src/extras/geometries/IcosahedronGeometry.js

@@ -85,7 +85,7 @@ THREE.IcosahedronGeometry = function ( subdivisions ) {
 	scope.faceVertexUvs[ 0 ] = tempScope.faceVertexUvs[ 0 ];
 
 	this.computeCentroids();
-	this.computeFaceNormals( true );
+	this.computeFaceNormals();
 
 	function v( x, y, z ) {