<commit_before>﻿using UnityEngine;
using System.Collections;

public class MayaCamera : MonoBehaviour {

	Vector3 lookAtPosition;

	public float tumbleSpeed	= 1f;
	public float dollySpeed		= 1f;
	public float trackSpeed		= 0.2f;
	public Vector3 mouseSpeed;
	public Vector3 mouseAccel;

	Vector3 mousePosition;
	Vector3 prevMousePosition;
	Vector3 prevMouseSpeed;
	Vector3 cameraToLookAtVector;
	float log10VectorLength;
	

	// Use this for initialization
	void Start () {
		lookAtPosition = Vector3.zero;
		mousePosition = Input.mousePosition;
		prevMousePosition = mousePosition;
		mouseSpeed = Vector3.zero;
		mouseAccel = Vector3.zero;
		Camera.main.transform.LookAt(lookAtPosition);
	}
	
	// Update is called once per frame
	void Update () {
		CalculateMousePhisics();
		CalculateCameraPhisics();
		Tumble();
		Dolly();
		Track();
		Camera.main.transform.LookAt(lookAtPosition);
	}

	void Tumble()
	{
		if (Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButton(0))
		{
			// 左クリック, tumble
			Quaternion rotation = Quaternion.LookRotation(cameraToLookAtVector);
			Camera.main.transform.rotation = rotation;
			Camera.main.transform.RotateAround(lookAtPosition, Vector3.up,					 mouseSpeed.x * tumbleSpeed);
			Camera.main.transform.RotateAround(lookAtPosition, Camera.main.transform.right, -mouseSpeed.y * tumbleSpeed);
		}
	}

	void Dolly()
	{
		if (Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButton(1))
		{
			// 右クリック, dolly
			float move_power = 
				(mouseSpeed.x - mouseSpeed.y) * dollySpeed * log10VectorLength;
			Camera.main.transform.Translate(0, 0, move_power);
		}
	}

	void Track()
	{
		if (Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButton(2))
		{
			// 中央クリック, track
			var rotate = Camera.main.transform.rotation;
			var speed_vec = rotate * (mouseSpeed * trackSpeed);
			Camera.main.transform.localPosition -= speed_vec * log10VectorLength;
			lookAtPosition -= speed_vec * log10VectorLength;
		}
	}

	void CalculateCameraPhisics()
	{
		cameraToLookAtVector = lookAtPosition - Camera.main.transform.position;
		log10VectorLength = Mathf.Log10(cameraToLookAtVector.sqrMagnitude) + 1f;
	}

	void CalculateMousePhisics()
	{
		// マウスの速度加速度等を計算
		prevMousePosition	= mousePosition;
		mousePosition		= Input.mousePosition;
		prevMouseSpeed		= mouseSpeed;
		mouseSpeed = (mousePosition - prevMousePosition) * Time.deltaTime;
		mouseAccel = (mouseSpeed    - prevMouseSpeed)    * Time.deltaTime;
	}
}<commit_msg>プロパティや変数を分ける<commit_after>﻿using UnityEngine;
using System.Collections;

public class MayaCamera : MonoBehaviour {

	Vector3 lookAtPosition;
	
	public float tumbleSpeed	= 20f;
	public float dollySpeed		= 0.2f;
	public float trackSpeed		= 0.2f;

	public Vector3 mouseSpeed		{ get; private set; }
	public Vector3 mouseAccel		{ get; private set; }
	public Vector3 mousePosition	{ get; private set; }

	Vector3 prevMousePosition;
	Vector3 prevMouseSpeed;
	Vector3 cameraToLookAtVector;
	float log10VectorLength;

	// Use this for initialization
	void Start () {
		lookAtPosition = Vector3.zero;
		mousePosition = Input.mousePosition;
		prevMousePosition = mousePosition;
		mouseSpeed = Vector3.zero;
		mouseAccel = Vector3.zero;
		gameObject.transform.LookAt(lookAtPosition);
	}
	
	// Update is called once per frame
	void Update () {
		CalculateMousePhisics();
		CalculateCameraPhisics();
		Tumble();
		Dolly();
		Track();
		gameObject.transform.LookAt(lookAtPosition);
	}

	void Tumble()
	{
		if (Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButton(0))
		{
			// 左クリック, tumble
			Quaternion rotation = Quaternion.LookRotation(cameraToLookAtVector);
			gameObject.transform.rotation = rotation;
			gameObject.transform.RotateAround(lookAtPosition, Vector3.up,					 mouseSpeed.x * tumbleSpeed);
			gameObject.transform.RotateAround(lookAtPosition, gameObject.transform.right, -mouseSpeed.y * tumbleSpeed);
		}
	}

	void Dolly()
	{
		if (Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButton(1))
		{
			// 右クリック, dolly
			float move_power = 
				(mouseSpeed.x - mouseSpeed.y) * dollySpeed * log10VectorLength;
			gameObject.transform.Translate(0, 0, move_power);
		}
	}

	void Track()
	{
		if (
			(Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButton(2)) ||
			(Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButton(0) && Input.GetMouseButton(1)))
		{
			// 中央クリック, track
			var rotate = gameObject.transform.rotation;
			var speed_vec = rotate * (mouseSpeed * trackSpeed);
			gameObject.transform.localPosition -= speed_vec * log10VectorLength;
			lookAtPosition -= speed_vec * log10VectorLength;
		}
	}

	void CalculateCameraPhisics()
	{
		cameraToLookAtVector = lookAtPosition - gameObject.transform.position;
		log10VectorLength = Mathf.Log10(cameraToLookAtVector.sqrMagnitude) + 1f;
	}

	void CalculateMousePhisics()
	{
		// マウスの速度加速度等を計算
		prevMousePosition	= mousePosition;
		mousePosition		= Input.mousePosition;
		prevMouseSpeed		= mouseSpeed;
		mouseSpeed = (mousePosition - prevMousePosition) * Time.deltaTime;
		mouseAccel = (mouseSpeed    - prevMouseSpeed)    * Time.deltaTime;
	}
}
{'fraction_non_alphanumeric': 0.10584958217270195, 'fraction_numerical': 0.013927576601671309, 'mean_word_length': 4.31957671957672, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '563885', 'n_tokens_mistral': 1907, 'n_tokens_neox': 1715, 'n_words': 315}