BallCompass is a 3D compass application.
Please note: Apples iOS 4 introduced a bug preventing BallCompass from working properly. Soon to be released iOS 4.1 solves this problem, restoring previous functionality.
The orientation of the compass ball is based on gravity and the magnetic field surrounding the phone. It is similar in behavior to the fluid filled ball compasses available for car dashboards.
On devices with a built-in compass, like the iPhone 3GS, the compass is a real-time active ball compass.
For older model phones, GPS location information updates the display based on the current direction of travel. (It will take a few seconds of traveling to detect the present course.)