Skip to content

Commit d80e106

Browse files
authored
Merge pull request #16457 from WestLangley/dev-sphere_geo
SphereGeometry: correctly handle uvs for a sphere sector
2 parents 18f79c9 + d15efbd commit d80e106

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/geometries/SphereGeometry.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
6464
thetaStart = thetaStart !== undefined ? thetaStart : 0;
6565
thetaLength = thetaLength !== undefined ? thetaLength : Math.PI;
6666

67-
var thetaEnd = thetaStart + thetaLength;
67+
var thetaEnd = Math.min( thetaStart + thetaLength, Math.PI );
6868

6969
var ix, iy;
7070

@@ -91,7 +91,17 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
9191

9292
// special case for the poles
9393

94-
var uOffset = ( iy == 0 ) ? 0.5 / widthSegments : ( ( iy == heightSegments ) ? - 0.5 / widthSegments : 0 );
94+
var uOffset = 0;
95+
96+
if ( iy == 0 && thetaStart == 0 ) {
97+
98+
uOffset = 0.5 / widthSegments;
99+
100+
} else if ( iy == heightSegments && thetaEnd == Math.PI ) {
101+
102+
uOffset = - 0.5 / widthSegments;
103+
104+
}
95105

96106
for ( ix = 0; ix <= widthSegments; ix ++ ) {
97107

0 commit comments

Comments
 (0)