With Greggman's changes

Folded in this code
https://github.com/greggman/three.js/commit/fde9f9917d6d8381f06bf22cdff766029d1761be
Also added documentation.