Browse Source

Merge branch 'auto-buffer-size' of git://github.com/tapio/three.js into dev

Mr.doob 12 years ago
parent
commit
26b36b38da

+ 4 - 8
examples/webgl_buffergeometry.html

@@ -84,23 +84,19 @@
 				geometry.attributes = {
 					index: {
 						itemSize: 1,
-						array: new Uint16Array( triangles * 3 ),
-						numItems: triangles * 3
+						array: new Uint16Array( triangles * 3 )
 					},
 					position: {
 						itemSize: 3,
-						array: new Float32Array( triangles * 3 * 3 ),
-						numItems: triangles * 3 * 3
+						array: new Float32Array( triangles * 3 * 3 )
 					},
 					normal: {
 						itemSize: 3,
-						array: new Float32Array( triangles * 3 * 3 ),
-						numItems: triangles * 3 * 3
+						array: new Float32Array( triangles * 3 * 3 )
 					},
 					color: {
 						itemSize: 3,
-						array: new Float32Array( triangles * 3 * 3 ),
-						numItems: triangles * 3 * 3
+						array: new Float32Array( triangles * 3 * 3 )
 					}
 				}
 

+ 2 - 5
examples/webgl_buffergeometry_custom_attributes_particles.html

@@ -143,18 +143,15 @@
 
 				position: {
 					itemSize: 3,
-					array: new Float32Array( particles * 3 ),
-					numItems: particles * 3
+					array: new Float32Array( particles * 3 )
 				},
 				customColor: {
 					itemSize: 3,
-					array: new Float32Array( particles * 3 ),
-					numItems: particles * 3
+					array: new Float32Array( particles * 3 )
 				},
 				size: {
 					itemSize: 1,
 					array: new Float32Array( particles ),
-					numItems: particles * 1,
 					dynamic: true
 				},
 

+ 2 - 4
examples/webgl_buffergeometry_lines.html

@@ -72,13 +72,11 @@
 				geometry.attributes = {
 					position: {
 						itemSize: 3,
-						array: new Float32Array(segments * 3),
-						numItems: segments * 3
+						array: new Float32Array(segments * 3)
 					},
 					color: {
 						itemSize: 3,
-						array: new Float32Array(segments * 3),
-						numItems: segments * 3
+						array: new Float32Array(segments * 3)
 					}
 				};
 

+ 2 - 4
examples/webgl_buffergeometry_particles.html

@@ -73,13 +73,11 @@
 
 					position: {
 						itemSize: 3,
-						array: new Float32Array( particles * 3 ),
-						numItems: particles * 3
+						array: new Float32Array( particles * 3 )
 					},
 					color: {
 						itemSize: 3,
-						array: new Float32Array( particles * 3 ),
-						numItems: particles * 3
+						array: new Float32Array( particles * 3 )
 					}
 
 				}

+ 2 - 4
src/core/BufferGeometry.js

@@ -187,8 +187,7 @@ THREE.BufferGeometry.prototype = {
 				this.attributes[ "normal" ] = {
 
 					itemSize: 3,
-					array: new Float32Array( nVertexElements ),
-					numItems: nVertexElements
+					array: new Float32Array( nVertexElements )
 
 				};
 
@@ -371,8 +370,7 @@ THREE.BufferGeometry.prototype = {
 			this.attributes[ "tangent" ] = {
 
 				itemSize: 4,
-				array: new Float32Array( nTangentElements ),
-				numItems: nTangentElements
+				array: new Float32Array( nTangentElements )
 
 			};
 

+ 6 - 0
src/renderers/WebGLRenderer.js

@@ -1070,6 +1070,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			attribute = geometry.attributes[ a ];
 
+			if ( attribute.numItems === undefined ) {
+
+				attribute.numItems = attribute.array.length;
+
+			}
+
 			attribute.buffer = _gl.createBuffer();
 
 			_gl.bindBuffer( type, attribute.buffer );

+ 6 - 0
src/renderers/WebGLRenderer2.js

@@ -462,6 +462,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			attribute = geometry.attributes[ a ];
 
+			if ( attribute.numItems === undefined ) {
+
+				attribute.numItems = attribute.array.length;
+
+			}
+
 			attribute.buffer = renderer.createBuffer();
 
 			if ( a === "index" ) {