mrdoob/three.js — pull request #3734 by erich666 (2013-08-09 15:35:41+00:00)
Title: New OrbitControls.js, fixing pan, adding touch support, and more

(Submitting against "dev" - it'll work for sure this time, Rocky. Old attempt is [here](https://github.com/mrdoob/three.js/pull/3733).)

This new version of OrbitControls does the following:
- Properly pans so that the object stays with the mouse pointer, including orthographic cameras.
- Adds touch support for tablets and smartphones.
- Adds a "target" parameter so that this control can be used as a drop-in replacement for TrackballControls.
- Properly accesses document (Greggman's changes).
- Adds in-code documentation.

It's battle-tested, as the code has been used [by thousands of students](http://bit.ly/ericity).

Original pull request: https://github.com/mrdoob/three.js/pull/3353

Previous discussion: https://github.com/mrdoob/three.js/issues/3346#issuecomment-21154258

Folded in Greggman's pull request: https://github.com/mrdoob/three.js/pull/3374

My apologies for not knowing how to update my previous pull request - git and github are non-obvious to us beginners. Anyway, this pull request integrates the two previous pull requests, https://github.com/mrdoob/three.js/pull/3353 and https://github.com/mrdoob/three.js/pull/3374.

I have tested against all the examples that currently use OrbitControls - the new code works about the same. The arrow keys are a bit different, as this new code (properly) makes the arrows work with respect to the screen, not the size of the environment.

Where you'll see the difference is in using OrbitControls as a replacement for TrackballControls is in examples such as webgl_materials_lightmap.html or webgl_morphtargets_md2.html. The mouse pointer stays closely tied to the object when panning when using my new control. The old control is unreliable; the new one properly uses the screen's relationship to the world to control panning.