mirror of
https://github.com/wahyd4/three.js.git
synced 2026-08-09 04:56:01 +10:00
Removed useVertexNormals boolean from computeFaceNormals.
Bad things (and hard to debug) can happen that affect Ray.
This commit is contained in:
+11
-44
@@ -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 ) {
|
||||
vA = this.vertices[ face.a ];
|
||||
vB = this.vertices[ face.b ];
|
||||
vC = this.vertices[ face.c ];
|
||||
|
||||
cb.set( 0, 0, 0 );
|
||||
cb.sub( vC.position, vB.position );
|
||||
ab.sub( vA.position, vB.position );
|
||||
cb.crossSelf( ab );
|
||||
|
||||
for ( n = 0, nl = face.vertexNormals.length; n < nl; n++ ) {
|
||||
if ( !cb.isZero() ) {
|
||||
|
||||
cb.addSelf( face.vertexNormals[n] );
|
||||
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user