Examples » ArcBall Camera new in 2020.06

Intuitive camera control with smooth navigation.

Image

Implementation of Ken Shoemake's arcball camera with a smooth navigation feature. Using arcball, the camera control is more accurate and consistent. See also the Mouse Interaction example for an alternative approach.

Controls

  • mouse drag rotates the camera
  • Shift mouse drag pans the camera
  • mouse wheel zooms in/out
  • R resets the camera to its original position
  • L toggles lagging (smooth camera navigation)

Credits

This example was originally contributed by Nghia Truong.

Source

Full source code is linked below and also available in the magnum-examples GitHub repository. The ArcBall.h and ArcBall.cpp files are completely standalone, depending only on the Math library, and ready to be integrated into your project. The ArcBallCamera.h file provides an optional SceneGraph integration that you can but don't have to use.

The ports branch contains additional patches for Emscripten support that aren't present in master in order to keep the example code as simple as possible.