mrdoob/three.js — pull request #4151 by jasongrout (2013-11-27 02:40:34+00:00)
Title: Fix mouse tracking bug when dom element is scrolled to a different position

When using getBoundingClientRect, the returned coordinates are relative to the viewport. If the page is then scrolled and we have a dom element that is not the document, the top and left offsets are out of date, thus the rotation calculations are off (sometimes by a lot).

In this fix, we instead do all calculations relative to the document (not the viewport) by adjusting the screen.left and screen.top variables with the scroll offset and using pageX/pageY instead of clientX/clientY for the click coordinates.