Răsfoiți Sursa

Merge pull request #16043 from WestLangley/dev-sphere_geometry

Prevent UV shearing near the poles in sphere geometries
Mr.doob 6 ani în urmă
părinte
comite
bdb77d1ed5
1 a modificat fișierele cu 6 adăugiri și 2 ștergeri
  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;
 
+		// special case for the poles
+
+		var uOffset = ( iy == 0 ) ? 0.5 / widthSegments : ( ( iy == heightSegments ) ? - 0.5 / widthSegments : 0 );
+
 		for ( ix = 0; ix <= widthSegments; ix ++ ) {
 
 			var u = ix / widthSegments;
@@ -103,12 +107,12 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
 
 			// normal
 
-			normal.set( vertex.x, vertex.y, vertex.z ).normalize();
+			normal.copy( vertex ).normalize();
 			normals.push( normal.x, normal.y, normal.z );
 
 			// uv
 
-			uvs.push( u, 1 - v );
+			uvs.push( u + uOffset, 1 - v );
 
 			verticesRow.push( index ++ );