Browse Source

BufferGeometry: Added count back to attribute.

Mr.doob 11 years ago
parent
commit
496f9ddd31
2 changed files with 13 additions and 27 deletions
  1. 6 20
      src/core/BufferGeometry.js
  2. 7 7
      src/renderers/WebGLRenderer.js

+ 6 - 20
src/core/BufferGeometry.js

@@ -21,29 +21,15 @@ THREE.BufferGeometry.prototype = {
 
 	constructor: THREE.BufferGeometry,
 
-	addAttribute: function ( name, array, itemSize ) {
+	addAttribute: function ( name, array, itemSize, count ) {
 
-		if ( arguments.length === 4 ) {
+		this.attributes[ name ] = {
 
-			console.warn( 'DEPRECATED: BufferGeometry.addAttribute() now accepts only 3 arguments ( name, array, itemSize )' );
+			array: array,
+			itemSize: itemSize,
+			count: count !== undefined ? count : array.length
 
-			this.attributes[ arguments[ 0 ] ] = {
-
-				array: new arguments[ 1 ]( arguments[ 2 ] * arguments[ 3 ] ),
-				itemSize: arguments[ 3 ]
-
-			};
-
-		} else {
-
-			this.attributes[ name ] = {
-
-				array: array,
-				itemSize: itemSize
-
-			};
-
-		}
+		};
 
 	},
 

+ 7 - 7
src/renderers/WebGLRenderer.js

@@ -2662,11 +2662,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				// render non-indexed triangles
 
-				_gl.drawArrays( _gl.TRIANGLES, 0, position.array.length / 3 );
+				_gl.drawArrays( _gl.TRIANGLES, 0, position.count / 3 );
 
 				_this.info.render.calls ++;
-				_this.info.render.vertices += position.array.length / 3;
-				_this.info.render.faces += position.array.length / 3 / 3;
+				_this.info.render.vertices += position.count / 3;
+				_this.info.render.faces += position.count / 9;
 
 			}
 
@@ -2684,10 +2684,10 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			// render particles
 
-			_gl.drawArrays( _gl.POINTS, 0, position.array.length / 3 );
+			_gl.drawArrays( _gl.POINTS, 0, position.count / 3 );
 
 			_this.info.render.calls ++;
-			_this.info.render.points += position.array.length / 3;
+			_this.info.render.points += position.count / 3;
 
 		} else if ( object instanceof THREE.Line ) {
 
@@ -2773,10 +2773,10 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				var position = geometryAttributes[ "position" ];
 
-				_gl.drawArrays( primitives, 0, position.array.length / 3 );
+				_gl.drawArrays( primitives, 0, position.count / 3 );
 
 				_this.info.render.calls ++;
-				_this.info.render.points += position.array.length;
+				_this.info.render.points += position.count / 3;
 
 			}