Being able to move around a 3D chart is one of the more spectacular features of 3D graphing. It really shows off the advantages of using a 3D engine and it will allow your users to see the same data in many different ways.
We'll use the previous recipe and add mouse interaction to it. So start by making a copy of the previous recipe's code and either copy it to a different package, or give it a different name. Don't forget to change the document class.
We'll need to store a few bits of data to calculate the mouse movements and convert them to camera changes:
We will start by adding a number of variables to the
Main
class:private var _cameraController:HoverController; private var _moving:Boolean = false; private var _lastPanAngle:Number; private var _lastTiltAngle:Number; private var _lastMouseX:Number; private var _lastMouseY:Number;
Now in the constructor method, remove the code that set up the camera and replace it with the following code...