 		}
 		
 		
+		private function onStageMouseDown(ev : MouseEvent) : void
+		{
+			_prevMouseX = ev.stageX;
+			_prevMouseY = ev.stageY;
+		}
+		
+		private function onStageMouseMove(ev : MouseEvent) : void
+		{
+			if (ev.buttonDown) {
+				_hoverCtrl.panAngle += (ev.stageX - _prevMouseX);
+				_hoverCtrl.tiltAngle += (ev.stageY - _prevMouseY);
+			}
+			
+			_prevMouseX = ev.stageX;
+			_prevMouseY = ev.stageY;
+		}
+		
+		private function onStageMouseWheel(ev : MouseEvent) : void
+		{
+			_hoverCtrl.distance -= ev.delta * 5;
+			
+			if (_hoverCtrl.distance < 100)
+				_hoverCtrl.distance = 100;
+			else if (_hoverCtrl.distance > 2000)
+				_hoverCtrl.distance = 2000;
+		}
+		
+		
 		private function onEnterFrame(ev : Event) : void
 		{
-			_view.camera.y = stage.mouseY - stage.stageHeight/2;
-			_view.camera.x = stage.mouseX - stage.stageWidth/2;
-			_view.camera.lookAt(_loader.position);
+			_hoverCtrl.update();
 			_view.render();
 		}
 	}

package
{
	import away3d.containers.View3D;
	import away3d.entities.Mesh;
	import away3d.events.AssetEvent;
	import away3d.events.LoaderEvent;

		private var _view : View3D;
		private var _loader : Loader3D;
		
		private var _hoverCtrl : HoverController;
		private var _prevMouseX : Number;
		private var _prevMouseY : Number;
		
		public function AWDViewer()
		{
			init();
			load(loaderInfo.parameters['awd'] || 'default.awd');
		}
		
		
		private function init() : void
		{
			_view = new View3D();
			_view.antiAlias = 4;
			_view.camera.lens.far = 5000;
			addChild(_view);
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
			
			_hoverCtrl = new HoverController(_view.camera);
			_hoverCtrl.tiltAngle = 0;
			_hoverCtrl.panAngle = 180;
			_hoverCtrl.minTiltAngle = -60;
			_hoverCtrl.maxTiltAngle = 60;
			
			stage.addEventListener(MouseEvent.MOUSE_DOWN, onStageMouseDown);
			stage.addEventListener(MouseEvent.MOUSE_MOVE, onStageMouseMove);
			stage.addEventListener(MouseEvent.MOUSE_WHEEL, onStageMouseWheel);
		}
		
		
