package classes.matuto.mt3d
{
	import classes.away3d.cameras.Camera3D;
	import classes.away3d.cameras.HoverCamera3D;
	import classes.away3d.cameras.TargetCamera3D;
	import classes.away3d.containers.View3D;
	
	import flash.display.Sprite;
	import flash.geom.Rectangle;

	public class MtCamera3D extends Sprite
	{
		
		public var cameraTarget	:TargetCamera3D;
		private var cameraHover		:HoverCamera3D;
		
		private var camera			:Camera3D;
		
		private var view			:View3D;
		
		public function MtCamera3D(_view:View3D)
		{
			view = _view;
		}
		
		//##############################################
		//TARGET
		//##############################################
		
		public function initTargetCamera3d():void
		{
		   cameraTarget 	= new TargetCamera3D();
		   cameraTarget.z   = -1000;
		   camera			= cameraTarget;
		   view.camera      = camera;
		}
		
		public function get getCameraTarget():TargetCamera3D
		{
			return cameraTarget;
		}
		
		public function moveCameraTarget(rec:Rectangle):void
		{	
			view.camera.y = -(rec.y - rec.height);
			view.camera.x = rec.x - rec.width;
		}

		//cameraTarget = new MtCamera3D(view);
		//cameraTarget.target = object3d
		//cameraTarget.initTargetCamera3d();
		//cameraTarget.moveCameraTarget(new Rectangle(mouseX,mouseY,stage.stageWidth/2,stage.stageHeight/2));

		//##############################################
		//##############################################

		
		//##############################################
		//HOVER
		//##############################################
		
		public function initHoverCamera3d(_distance:Number,_tiltAngle:Number):void
		{
			cameraHover      		 = new HoverCamera3D();
			cameraHover.z   		 = -1000;
			cameraHover.tiltAngle 	 = _tiltAngle;
			cameraHover.distance 	 = _distance;
			camera					 = cameraHover;
			view.camera      		 = camera;
		}
		
		public function updateHoverCamera(_distance:Number,_tiltAngle:Number):void
		{
			cameraHover.tiltAngle 	 = _tiltAngle;
			cameraHover.distance 	 = _distance;
		}
		
		public function get getCameraHover():HoverCamera3D
		{
			return cameraHover;
		}
		
		public function moveCameraHover(_x:Number,_width:Number):void
		{
			cameraHover.panAngle = (_x-_width);
			cameraHover.hover();
		}
		
		//cameraMt = new MtCamera3D(view);
		//cameraMt.initHoverCamera3d(2000,10);
		//cameraMt.moveCameraHover(mouseX,stage.stageWidth/2);
		
		//##############################################
		//##############################################
		
		
		
	}//end class
}