<!DOCTYPE html>
<html lang="en">
	<head>
		<title>THREE.GamepadControls Example</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
		<style>
			body {
				font-family: Monospace;
				background-color: #f0f0f0;
				margin: 0px;
				overflow: hidden;
			}
			#info {
				position: absolute;
				top: 0px;
				width: 100%;
				padding: 5px;
				text-align:center;
			}
		</style>
	</head>
	<body>
	
		<script src="./three.min.js"></script>
		<script src="../THREE.GamepadControls.js"></script>		

		<script>

			var container;
			var controls;

			var camera, scene, renderer;
			
			init();
			animate();

			function init() {

				container = document.createElement( 'div' );
				document.body.appendChild( container );

				camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 1, 2000 );
				camera.position.set( 0, 0, 40 );

				controls = new THREE.GamepadControls( camera );

				scene = new THREE.Scene();
				scene.add( new THREE.AmbientLight( 0x808080 ) );

				mesh = new THREE.Mesh( new THREE.BoxGeometry( 10, 10, 10 ), new THREE.MeshNormalMaterial() );
				scene.add( mesh );
				camera.lookAt( mesh.position );

				renderer = new THREE.WebGLRenderer( { antialias: true } );
				renderer.setClearColor( 0 );
				renderer.setPixelRatio( window.devicePixelRatio );
				renderer.setSize( window.innerWidth, window.innerHeight );
				container.appendChild( renderer.domElement );

				window.addEventListener( 'resize', onWindowResize, false );

			}

			function onWindowResize() {

				windowHalfX = window.innerWidth / 2;
				windowHalfY = window.innerHeight / 2;

				camera.aspect = window.innerWidth / window.innerHeight;
				camera.updateProjectionMatrix();

				renderer.setSize( window.innerWidth, window.innerHeight );
				
			}

			function animate() {

				requestAnimationFrame( animate );
				render();

			}

			function render() {

				renderer.render( scene, camera )
				
			}

		</script>

	</body>
</html>
