From cdcc530b0ecffe9f0de2ba1c92bf0a01019c6d78 Mon Sep 17 00:00:00 2001 From: Mikael Emtinger Date: Tue, 10 May 2011 14:44:27 +0200 Subject: [PATCH] Removed bugs related to custom attributes and buffers. Removed bug related to attributes.position --- src/renderers/WebGLRenderer.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 2a92b2d1..e0ace233 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -2217,8 +2217,7 @@ THREE.WebGLRenderer = function ( parameters ) { var attributes = material.program.attributes; - _gl.enableVertexAttribArray( attributes.position ); - + if ( attributes.position >= 0 ) _gl.enableVertexAttribArray( attributes.position ); if ( attributes.color >= 0 ) _gl.enableVertexAttribArray( attributes.color ); if ( attributes.normal >= 0 ) _gl.enableVertexAttribArray( attributes.normal ); if ( attributes.tangent >= 0 ) _gl.enableVertexAttribArray( attributes.tangent ); @@ -2234,13 +2233,18 @@ THREE.WebGLRenderer = function ( parameters ) { } - for ( a in material.attributes ) { - - if( attributes[ a ] >= 0 ) _gl.enableVertexAttribArray( attributes[ a ] ); - + if ( material.attributes ) { + + for ( a in material.attributes ) { + + if( attributes[ a ] !== undefined && attributes[ a ] >= 0 ) _gl.enableVertexAttribArray( attributes[ a ] ); + + } + } + if ( material.morphTargets ) { material.numSupportedMorphTargets = 0; @@ -2509,12 +2513,16 @@ THREE.WebGLRenderer = function ( parameters ) { for( a in material.attributes ) { - if( attributes[ a ] >= 0 ) { + if( attributes[ a ] !== undefined && attributes[ a ] >= 0 ) { attribute = material.attributes[ a ]; - _gl.bindBuffer( _gl.ARRAY_BUFFER, attribute.buffer ); - _gl.vertexAttribPointer( attributes[ a ], attribute.size, _gl.FLOAT, false, 0, 0 ); + if( attribute.buffer ) { + + _gl.bindBuffer( _gl.ARRAY_BUFFER, attribute.buffer ); + _gl.vertexAttribPointer( attributes[ a ], attribute.size, _gl.FLOAT, false, 0, 0 ); + + } }