|
@@ -37,7 +37,7 @@ THREE.CylinderBufferGeometry = function ( radiusTop, radiusBottom, height, radia
|
|
|
|
|
|
// buffers
|
|
// buffers
|
|
|
|
|
|
- var indices = new THREE.BufferAttribute( new ( indexCount > 65535 ? Uint32Array : Uint16Array )( indexCount ) , 1 );
|
|
|
|
|
|
+ var indices = new THREE.BufferAttribute( new ( indexCount > 65535 ? Uint32Array : Uint16Array )( indexCount ), 1 );
|
|
var vertices = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
|
|
var vertices = 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 uvs = new THREE.BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
|
|
@@ -50,19 +50,10 @@ THREE.CylinderBufferGeometry = function ( radiusTop, radiusBottom, height, radia
|
|
|
|
|
|
generateTorso();
|
|
generateTorso();
|
|
|
|
|
|
- if( openEnded === false ) {
|
|
|
|
|
|
+ if ( openEnded === false ) {
|
|
|
|
|
|
- if( radiusTop > 0 ) {
|
|
|
|
-
|
|
|
|
- generateCap( true );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if( radiusBottom > 0 ) {
|
|
|
|
-
|
|
|
|
- generateCap( false );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ if ( radiusTop > 0 ) generateCap( true );
|
|
|
|
+ if ( radiusBottom > 0 ) generateCap( false );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -137,7 +128,7 @@ THREE.CylinderBufferGeometry = function ( radiusTop, radiusBottom, height, radia
|
|
normal.copy( vertex );
|
|
normal.copy( vertex );
|
|
|
|
|
|
// handle special case if radiusTop/radiusBottom is zero
|
|
// handle special case if radiusTop/radiusBottom is zero
|
|
- if( ( radiusTop === 0 && y === 0 ) || ( radiusBottom === 0 && y === heightSegments ) ) {
|
|
|
|
|
|
+ if ( ( radiusTop === 0 && y === 0 ) || ( radiusBottom === 0 && y === heightSegments ) ) {
|
|
|
|
|
|
normal.x = Math.sin( u * thetaLength + thetaStart );
|
|
normal.x = Math.sin( u * thetaLength + thetaStart );
|
|
normal.z = Math.cos( u * thetaLength + thetaStart );
|
|
normal.z = Math.cos( u * thetaLength + thetaStart );
|
|
@@ -176,14 +167,14 @@ THREE.CylinderBufferGeometry = function ( radiusTop, radiusBottom, height, radia
|
|
var i4 = indexArray[ y ][ x + 1 ];
|
|
var i4 = indexArray[ y ][ x + 1 ];
|
|
|
|
|
|
// face one
|
|
// face one
|
|
- indices.setX( indexOffset, i1 ); indexOffset++;
|
|
|
|
- indices.setX( indexOffset, i2 ); indexOffset++;
|
|
|
|
- indices.setX( indexOffset, i4 ); indexOffset++;
|
|
|
|
|
|
+ indices.setX( indexOffset, i1 ); indexOffset ++;
|
|
|
|
+ indices.setX( indexOffset, i2 ); indexOffset ++;
|
|
|
|
+ indices.setX( indexOffset, i4 ); indexOffset ++;
|
|
|
|
|
|
// face two
|
|
// face two
|
|
- indices.setX( indexOffset, i2 ); indexOffset++;
|
|
|
|
- indices.setX( indexOffset, i3 ); indexOffset++;
|
|
|
|
- indices.setX( indexOffset, i4 ); indexOffset++;
|
|
|
|
|
|
+ indices.setX( indexOffset, i2 ); indexOffset ++;
|
|
|
|
+ indices.setX( indexOffset, i3 ); indexOffset ++;
|
|
|
|
+ indices.setX( indexOffset, i4 ); indexOffset ++;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -216,7 +207,7 @@ THREE.CylinderBufferGeometry = function ( radiusTop, radiusBottom, height, radia
|
|
normals.setXYZ( index, 0, sign, 0 );
|
|
normals.setXYZ( index, 0, sign, 0 );
|
|
|
|
|
|
// uv
|
|
// uv
|
|
- if( top === true ) {
|
|
|
|
|
|
+ if ( top === true ) {
|
|
|
|
|
|
uv.x = x / radialSegments;
|
|
uv.x = x / radialSegments;
|
|
uv.y = 0;
|
|
uv.y = 0;
|
|
@@ -231,7 +222,7 @@ THREE.CylinderBufferGeometry = function ( radiusTop, radiusBottom, height, radia
|
|
uvs.setXY( index, uv.x, uv.y );
|
|
uvs.setXY( index, uv.x, uv.y );
|
|
|
|
|
|
// increase index
|
|
// increase index
|
|
- index++;
|
|
|
|
|
|
+ index ++;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -268,19 +259,19 @@ THREE.CylinderBufferGeometry = function ( radiusTop, radiusBottom, height, radia
|
|
var c = centerIndexStart + x;
|
|
var c = centerIndexStart + x;
|
|
var i = centerIndexEnd + x;
|
|
var i = centerIndexEnd + x;
|
|
|
|
|
|
- if( top === true ) {
|
|
|
|
|
|
+ if ( top === true ) {
|
|
|
|
|
|
// face top
|
|
// face top
|
|
- indices.setX( indexOffset, i ); indexOffset++;
|
|
|
|
- indices.setX( indexOffset, i + 1 ); indexOffset++;
|
|
|
|
- indices.setX( indexOffset, c ); indexOffset++;
|
|
|
|
|
|
+ indices.setX( indexOffset, i ); indexOffset ++;
|
|
|
|
+ indices.setX( indexOffset, i + 1 ); indexOffset ++;
|
|
|
|
+ indices.setX( indexOffset, c ); indexOffset ++;
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
// face bottom
|
|
// face bottom
|
|
- indices.setX( indexOffset, i + 1); indexOffset++;
|
|
|
|
- indices.setX( indexOffset, i ); indexOffset++;
|
|
|
|
- indices.setX( indexOffset, c ); indexOffset++;
|
|
|
|
|
|
+ indices.setX( indexOffset, i + 1 ); indexOffset ++;
|
|
|
|
+ indices.setX( indexOffset, i ); indexOffset ++;
|
|
|
|
+ indices.setX( indexOffset, c ); indexOffset ++;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|