Browse Source

fix cylinder normals

Mugen87 9 years ago
parent
commit
4c0b857145
1 changed files with 9 additions and 0 deletions
  1. 9 0
      src/extras/geometries/CylinderBufferGeometry.js

+ 9 - 0
src/extras/geometries/CylinderBufferGeometry.js

@@ -135,6 +135,15 @@ THREE.CylinderBufferGeometry = function ( radiusTop, radiusBottom, height, radia
 
 
 				// normal
 				// normal
 				normal.copy( vertex );
 				normal.copy( vertex );
+
+				// handle special case if radiusTop/radiusBottom is zero
+				if( ( radiusTop === 0  && y === 0 ) || ( radiusBottom === 0  && y === heightSegments ) ) {
+
+					normal.x = Math.sin( u * thetaLength + thetaStart );
+					normal.z = Math.cos( u * thetaLength + thetaStart );
+
+				}
+
 				normal.setY( Math.sqrt( normal.x * normal.x + normal.z * normal.z ) * tanTheta ).normalize();
 				normal.setY( Math.sqrt( normal.x * normal.x + normal.z * normal.z ) * tanTheta ).normalize();
 				normals.setXYZ( index, normal.x, normal.y, normal.z );
 				normals.setXYZ( index, normal.x, normal.y, normal.z );