Procházet zdrojové kódy

Merge pull request #16043 from WestLangley/dev-sphere_geometry

Prevent UV shearing near the poles in sphere geometries
Mr.doob před 6 roky
rodič
revize
bdb77d1ed5
1 změnil soubory, kde provedl 6 přidání a 2 odebrání
  1. 6 2
      src/geometries/SphereGeometry.js

+ 6 - 2
src/geometries/SphereGeometry.js

@@ -89,6 +89,10 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
 
 
 		var v = iy / heightSegments;
 		var v = iy / heightSegments;
 
 
+		// special case for the poles
+
+		var uOffset = ( iy == 0 ) ? 0.5 / widthSegments : ( ( iy == heightSegments ) ? - 0.5 / widthSegments : 0 );
+
 		for ( ix = 0; ix <= widthSegments; ix ++ ) {
 		for ( ix = 0; ix <= widthSegments; ix ++ ) {
 
 
 			var u = ix / widthSegments;
 			var u = ix / widthSegments;
@@ -103,12 +107,12 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
 
 
 			// normal
 			// normal
 
 
-			normal.set( vertex.x, vertex.y, vertex.z ).normalize();
+			normal.copy( vertex ).normalize();
 			normals.push( normal.x, normal.y, normal.z );
 			normals.push( normal.x, normal.y, normal.z );
 
 
 			// uv
 			// uv
 
 
-			uvs.push( u, 1 - v );
+			uvs.push( u + uOffset, 1 - v );
 
 
 			verticesRow.push( index ++ );
 			verticesRow.push( index ++ );