Browse Source

Uninterleave sphere geo

Ben Adams 10 years ago
parent
commit
e6372ea389
1 changed files with 5 additions and 5 deletions
  1. 5 5
      src/extras/geometries/SphereBufferGeometry.js

+ 5 - 5
src/extras/geometries/SphereBufferGeometry.js

@@ -30,14 +30,14 @@ THREE.SphereBufferGeometry = function ( radius, widthSegments, heightSegments, p
 	thetaStart = thetaStart !== undefined ? thetaStart : 0;
 	thetaStart = thetaStart !== undefined ? thetaStart : 0;
 	thetaLength = thetaLength !== undefined ? thetaLength : Math.PI;
 	thetaLength = thetaLength !== undefined ? thetaLength : Math.PI;
 
 
-	var stride = ( 3 + 3 + 2 );
-	var vertexBuffer = new THREE.InterleavedBuffer( new Float32Array( ( ( widthSegments + 1 ) * ( heightSegments + 1 ) ) * stride ), stride );
+	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 uvs = new THREE.BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
 
 
-	var positions = new THREE.InterleavedBufferAttribute( vertexBuffer, 3, 0 );
 	this.addAttribute( 'position', positions );
 	this.addAttribute( 'position', positions );
-	var normals = new THREE.InterleavedBufferAttribute( vertexBuffer, 3, 3 );
 	this.addAttribute( 'normal', normals );
 	this.addAttribute( 'normal', normals );
-	var uvs = new THREE.InterleavedBufferAttribute( vertexBuffer, 2, 6 );
 	this.addAttribute( 'uv', uvs );
 	this.addAttribute( 'uv', uvs );
 
 
 	var x, y, u, v, px, py, pz, index = 0, vertices = [], normal = new THREE.Vector3();
 	var x, y, u, v, px, py, pz, index = 0, vertices = [], normal = new THREE.Vector3();