Răsfoiți Sursa

Merge pull request #16457 from WestLangley/dev-sphere_geo

SphereGeometry: correctly handle uvs for a sphere sector
Mr.doob 6 ani în urmă
părinte
comite
d80e106de2
1 a modificat fișierele cu 12 adăugiri și 2 ștergeri
  1. 12 2
      src/geometries/SphereGeometry.js

+ 12 - 2
src/geometries/SphereGeometry.js

@@ -64,7 +64,7 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
 	thetaStart = thetaStart !== undefined ? thetaStart : 0;
 	thetaLength = thetaLength !== undefined ? thetaLength : Math.PI;
 
-	var thetaEnd = thetaStart + thetaLength;
+	var thetaEnd = Math.min( thetaStart + thetaLength, Math.PI );
 
 	var ix, iy;
 
@@ -91,7 +91,17 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
 
 		// special case for the poles
 
-		var uOffset = ( iy == 0 ) ? 0.5 / widthSegments : ( ( iy == heightSegments ) ? - 0.5 / widthSegments : 0 );
+		var uOffset = 0;
+
+		if ( iy == 0 && thetaStart == 0 ) {
+
+			uOffset = 0.5 / widthSegments;
+
+		} else if ( iy == heightSegments && thetaEnd == Math.PI ) {
+
+			uOffset = - 0.5 / widthSegments;
+
+		}
 
 		for ( ix = 0; ix <= widthSegments; ix ++ ) {