|
|
@@ -76,6 +76,10 @@ class SphereGeometry extends BufferGeometry {
|
|
|
const verticesRow = [];
|
|
|
|
|
|
const v = iy / heightSegments;
|
|
|
+ const theta = thetaStart + v * thetaLength;
|
|
|
+
|
|
|
+ const y = radius * Math.cos( theta );
|
|
|
+ const ringRadius = Math.sqrt( radius * radius - y * y );
|
|
|
|
|
|
// special case for the poles
|
|
|
|
|
|
@@ -94,12 +98,13 @@ class SphereGeometry extends BufferGeometry {
|
|
|
for ( let ix = 0; ix <= widthSegments; ix ++ ) {
|
|
|
|
|
|
const u = ix / widthSegments;
|
|
|
+ const phi = phiStart + u * phiLength;
|
|
|
|
|
|
// vertex
|
|
|
|
|
|
- vertex.x = - radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
|
|
|
- vertex.y = radius * Math.cos( thetaStart + v * thetaLength );
|
|
|
- vertex.z = radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
|
|
|
+ vertex.x = - ringRadius * Math.cos( phi );
|
|
|
+ vertex.y = y;
|
|
|
+ vertex.z = ringRadius * Math.sin( phi );
|
|
|
|
|
|
vertices.push( vertex.x, vertex.y, vertex.z );
|
|
|
|