using UnityEngine;
using System.Collections;

// Orbital camera rotator. Move its angles by mouse and keyboard. For demonstration scenes.
public class RotationController : MonoBehaviour {
	Vector2 startMousePosition;
	bool isMouseDown = false;
	const float mouseRotationAspect = 0.4f;

	void Update () {
		if (Input.GetMouseButtonDown (0)) {
			isMouseDown = true;
			startMousePosition = Input.mousePosition;
		}
		if (Input.GetMouseButtonUp (0)) {
			isMouseDown = false;
		}
		if (isMouseDown) {
			var pos = Input.mousePosition;
			transform.localEulerAngles += new Vector3((startMousePosition.y - pos.y) * mouseRotationAspect, (startMousePosition.x - pos.x) * - mouseRotationAspect, 0);
			startMousePosition = pos;
		}
	}
}
