提交 98b9c2fb 编写于 作者: R Ricardo Cabello

Merge pull request #6819 from WestLangley/dev-sphere

SphereBufferGeometry: Fixed missing faces in sphere sectors
......@@ -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 );
}
......
......@@ -22,7 +22,7 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar
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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册