mrdoob/three.js — pull request #5042 by wwwtyro (2014-07-09 04:19:40+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)

Edit: It's not clear from the text on the demo page, but bufferSubData is being called 1000x per frame when it is being used; bufferData once when it is being used.

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!