mrdoob/three.js — pull request #5041 by wwwtyro (2014-07-09 02:34:58+00:00)
Title: Allow optional use of bufferSubData in setDirectBuffers

Demo: http://tyrovr.com/lab/three.js/bufferSubData/ (see the "animate" function for how it's used: http://tyrovr.com/lab/three.js/bufferSubData/main.js)

User can add an array of ranges of an attribute array to update, instead of sending the entire buffer to the GPU if they are only updating a fraction of it e.g.,

```javascript
geometry.attributes.position.array.set( [ 0,0,0, 1,0,0, 0,1,0 ] );
// ... render
geometry.attributes.position.array[0] = -1;
geometry.attributes.position.updateElements = [ [ 0, 1 ] ]; // [ start of range, end of range + 1 ]
geometry.attributes.position.needsUpdate = true;
// ... render, position.array[ 0 ] is sent to GPU
```

If ```updateElements``` is an empty array or not an Array, the whole array is copied, per usual.

In the demo above, I get a reduction from 96% to 12% of time spent in setDirectBuffers when using bufferSubData.

Thanks for looking!