diff --git a/src/renderers/webgl/WebGLAttributes.js b/src/renderers/webgl/WebGLAttributes.js index 6ff4e6ebad277d..fc52e617448d6f 100644 --- a/src/renderers/webgl/WebGLAttributes.js +++ b/src/renderers/webgl/WebGLAttributes.js @@ -8,6 +8,7 @@ function WebGLAttributes( gl, capabilities ) { const array = attribute.array; const usage = attribute.usage; + const size = array.byteLength; const buffer = gl.createBuffer(); @@ -76,7 +77,8 @@ function WebGLAttributes( gl, capabilities ) { buffer: buffer, type: type, bytesPerElement: array.BYTES_PER_ELEMENT, - version: attribute.version + version: attribute.version, + size: size }; } @@ -199,6 +201,12 @@ function WebGLAttributes( gl, capabilities ) { } else if ( data.version < attribute.version ) { + if ( data.size !== attribute.array.byteLength ) { + + throw new Error( 'THREE.WebGLAttributes: The size of the buffer attribute\'s array buffer does not match the original size. Resizing buffer attributes is not supported.' ); + + } + updateBuffer( data.buffer, attribute, bufferType ); data.version = attribute.version;