public/js/lib/Player.js
/*
		A Player class to handle all the intricacies of our player
		we will store such things as:
				* 3D mesh
				* position and velocity
				* collision
		This player class can only be called from within the callback of a THREE.JSONLoader()'s load() function
		as it needs to store the resulting mesh asynchronously so we can reference it properly.
	*/
A Player class to handle all the intricacies of our player
we will store such things as:
3D mesh
position and velocity
collision
                This player class can only be called from within the callback of a THREE.JSONLoader()'s load() function
                as it needs to store the resulting mesh asynchronously so we can reference it properly.
A Player class to handle all the intricacies of our player we will store such things as : 3D mesh position and velocity collision This player class can only be called from within the callback of a THREE . JSONLoader () ' s load () function as it needs to store the resulting mesh asynchronously so we can reference it properly .
function Player(obj){
	this.mesh = obj.mesh;	
	this.actions = {}; 
	this.mixer = new THREE.AnimationMixer(obj.mesh); 
	this.trackerBall; 
	this.controls = {}; 
	this.socketId = obj.socketId; 
	this.pauseRotate = 0; 
	this.scene = obj.scene;
	var parent = this;
		}
function Player ( obj ) { this . mesh = obj . mesh ; this . actions = { } ; this . mixer = new THREE . AnimationMixer ( obj . mesh ) ; this . trackerBall ; this . controls = { } ; this . socketId = obj . socketId ; this . pauseRotate = 0 ; this . scene = obj . scene ; var parent = this ; }
A Player class to handle all the intricacies of our player
we will store such things as:
 3D mesh
 position and velocity
 collision
                This player class can only be called from within the callback of a THREE.JSONLoader()'s load() function
                as it needs to store the resulting mesh asynchronously so we can reference it properly.
A Player class to handle all the intricacies of our player we will store such things as : 3D mesh position and velocity collision This player class can only be called from within the callback of a THREE . JSONLoader () ' s load () function as it needs to store the resulting mesh asynchronously so we can reference it properly .
/*
		obj = {
			pos: {
				x: float,
				y: float
			},
			vel: {
				x: float,
				y: float
			},
			mesh: tempMesh,
			mixer: tempMixer,
			socketId: socket.id,
			scene: THREE.Scene();
			
		}
	
	*/ // a new THREE.SkinnedMesh object
 // an object to hold arbitrary action (animation clip) names
 // a new THREE.AnimationMixer
 // a mesh object used to point the character model when moving
 // stores our controls from the phone
	this.position = {x:0, y:0, z:0}; // xyz position
	this.velocity = {x:0, y:0, z:0}; // xyz velocity
	this.velocityGoal = {x:0, y:0, z:0}; // xyz velocity goal for lerping movement
 // the socket to the controller for this player
 // when we pause, rotate proud a bit. Track the rotation in this variable. Radians
 // add our trackerBall
	var mySphereGeometry = new THREE.SphereGeometry( 0.5, 12, 8 );
	var mySphereMaterial = new THREE.MeshBasicMaterial( { transparent: true, opacity: 0, wireframe: true } );
	this.trackerBall = new THREE.Mesh( mySphereGeometry, mySphereMaterial );
	this.scene.add( this.trackerBall );
	
	
	this.control = function(controls){
		this.controls = controls;
		// use the cartesian offset from the joystick on the controller
		// to decide how to move the player
		if(controls.joystickDown == 1){
			// joystick is being manipulated
			var trackToX = this.mesh.position.x - (this.controls.cart.x / 15);
			var trackToY = this.mesh.position.y - (this.controls.cart.y / 15);
			if(trackToX > 25) trackToX = 25;
			if(trackToX < -25) trackToX = -25;
			if(trackToY > 16) trackToY = 16;
			if(trackToY < -8) trackToY = -8;
			this.trackerBall.position.x = trackToX;
			this.trackerBall.position.y = trackToY;
			this.mesh.lookAt(this.trackerBall.position);
		} else if(controls.joystickDown == 0){
 // joystick released, spring the trackerBall back to the player
