Browse Source

Merge pull request #8308 from Mugen87/cylinder-fix

Fix normals in CylinderBufferGeometry
Mr.doob 9 years ago
parent
commit
506b34b6b7
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.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();
 				normals.setXYZ( index, normal.x, normal.y, normal.z );