|
@@ -21,7 +21,7 @@ THREE.SphereBufferGeometry = function ( radius, widthSegments, heightSegments, p
|
|
|
|
|
|
radius = radius || 50;
|
|
|
|
|
|
- widthSegments = Math.max( 2, Math.floor( widthSegments ) || 8 );
|
|
|
+ widthSegments = Math.max( 3, Math.floor( widthSegments ) || 8 );
|
|
|
heightSegments = Math.max( 2, Math.floor( heightSegments ) || 6 );
|
|
|
|
|
|
phiStart = phiStart !== undefined ? phiStart : 0;
|
|
@@ -30,10 +30,12 @@ THREE.SphereBufferGeometry = function ( radius, widthSegments, heightSegments, p
|
|
|
thetaStart = thetaStart !== undefined ? thetaStart : 0;
|
|
|
thetaLength = thetaLength !== undefined ? thetaLength : Math.PI;
|
|
|
|
|
|
+ var thetaEnd = thetaStart + thetaLength;
|
|
|
+
|
|
|
var vertexCount = ( ( widthSegments + 1 ) * ( heightSegments + 1 ) );
|
|
|
|
|
|
var positions = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
|
|
|
- var normals = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3);
|
|
|
+ var normals = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
|
|
|
var uvs = new THREE.BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
|
|
|
|
|
|
var index = 0, vertices = [], normal = new THREE.Vector3();
|
|
@@ -60,7 +62,7 @@ THREE.SphereBufferGeometry = function ( radius, widthSegments, heightSegments, p
|
|
|
|
|
|
verticesRow.push( index );
|
|
|
|
|
|
- index++;
|
|
|
+ index ++;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -74,13 +76,13 @@ THREE.SphereBufferGeometry = function ( radius, widthSegments, heightSegments, p
|
|
|
|
|
|
for ( var x = 0; x < widthSegments; x ++ ) {
|
|
|
|
|
|
- var v1 = vertices[ y ][ x + 1 ];
|
|
|
- var v2 = vertices[ y ][ x ];
|
|
|
- var v3 = vertices[ y + 1 ][ x ];
|
|
|
+ var v1 = vertices[ y ][ x + 1 ];
|
|
|
+ var v2 = vertices[ y ][ x ];
|
|
|
+ var v3 = vertices[ y + 1 ][ x ];
|
|
|
var v4 = vertices[ y + 1 ][ x + 1 ];
|
|
|
|
|
|
- if ( y !== 0 ) indices.push( v1, v2, v4 );
|
|
|
- if ( y !== heightSegments - 1 ) indices.push( v2, v3, v4 );
|
|
|
+ if ( y !== 0 || thetaStart > 0 ) indices.push( v1, v2, v4 );
|
|
|
+ if ( y !== heightSegments - 1 || thetaEnd < Math.PI ) indices.push( v2, v3, v4 );
|
|
|
|
|
|
}
|
|
|
|