<commit_before><!DOCTYPE html>

<!-- 
Web VR API experiment of Cardboard
author: daoshengmu, http://dsmu.me
date: 04/23/2015
-->

<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
		<link href="css/style.css" rel="stylesheet">
		<script src="lib/three.min.js"></script>
		<script src="js/threejs/VREffect.js"></script>
		<script src="js/threejs/DeviceOrientationControls.js"></script>
		<title>Web VR Demo - Mobile</title>		
	</head>
	<body>
		<div id="info">
			The panorama image is from <a href="http://www.lemis.com/grog/photos/Photos.php?dirdate=20120601" target="_blank">Greg</a>
		</div>
		<div id="container"></div>
		<script type="text/javascript">
			var camera, scene, renderer;
			var vrHMD, vrPosSensor;
			var vrDeviceEffect;
			var control;
			var bCardboard = false;

			init();

			function init() {

				var container, mesh;

				container = document.getElementById('container');
				camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 1, 1100);

				camera.target = new THREE.Vector3(0, 0, 0);

				scene = new THREE.Scene();

				var geometry = new THREE.SphereGeometry(500, 60, 40);
				geometry.applyMatrix(new THREE.Matrix4().makeScale(-1, 1, 1));

				var material = new THREE.MeshBasicMaterial( {
					map: THREE.ImageUtils.loadTexture('images/verandah-centre-equirectangular.jpg')
				});

				mesh = new THREE.Mesh(geometry, material);
				scene.add(mesh);

				var attributes = {
					stencil: false
				};
       
				renderer = new THREE.WebGLRenderer( attributes );
				// In order to support v.69, I comment this line. When we are ready to v.71, we can enable it. 
				renderer.setPixelRatio( window.devicePixelRatio );
				renderer.setSize( window.innerWidth, window.innerHeight );

				vrDeviceEffect = new THREE.VREffect( renderer );

				window.addEventListener( 'resize', onWindowResize, false );
				container.appendChild( renderer.domElement );

				if ( navigator.getVRDevices ) {
					navigator.getVRDevices().then( vrDeviceCallback );
				} else if ( navigator.mozGetVRDevices ) {
					navigator.mozGetVRDevices( vrDeviceCallback );
				}

				control = new THREE.DeviceOrientationControls( camera );
			
				gameLoop();
			}

			function onWindowResize() {

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

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

			function vrDeviceCallback(devices) {

				if ( !devices.length ) {
					return;
				}

				for ( var i = 0; i < devices.length; ++i ) {

					if ( devices[i] instanceof HMDVRDevice ) {
						vrHMD = devices[i];
					}	

					if ( vrHMD && devices[i] instanceof PositionSensorVRDevice
						&& devices[i].hardwareUnitId == vrHMD.hardwareUnitId ) {
						vrPosSensor = devices[i];

						if ( vrPosSensor.deviceName.indexOf( 'Cardboard' ) >= 0 ) {
							bCardboard = true;
						}
						// We just want to get the first VR device.
						break;
					}
				}

				vrDeviceEffect.setFullScreen( true );
			}

			function gameLoop() {

				requestAnimationFrame( gameLoop );

				// vrPosSensor if has been supported on mobile devices?
				if ( vrPosSensor ) {
					var state = vrPosSensor.getState();

					if ( state.hasPosition ) {

						//console.log( state.position );
					}

					if ( state.hasOrientation ) {
			
						if ( bCardboard ) {

							var q0 = new THREE.Quaternion( state.orientation.x,
							state.orientation.z,
							state.orientation.y,
							state.orientation.w );
							var q1 = new THREE.Quaternion( -Math.sqrt( 0.5 ), 0, 0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis, camera at right version

							q0.multiply( q1 ); // camera looks out the back of the device, not the top
							camera.quaternion.set(
							q0.x, 
							q0.z,
							q0.y, 
							q0.w);

						} else {
							// Oculus device
							camera.quaternion.set(
							state.orientation.x, 
							state.orientation.y,
							state.orientation.z, 
							state.orientation.w);
						}		

						//console.log(state.orientation);
					} else {

						control.update(); // For some devices that do not support sensor. 	
					}
				} else {

					control.update(); // For some devices that do not support sensor. 	
				}

				vrDeviceEffect.render( scene, camera );
			}

		</script>	
	</body>
</html><commit_msg>Cardboard orientation bug is resolved.<commit_after><!DOCTYPE html>

<!-- 
Web VR API experiment of Cardboard
author: daoshengmu, http://dsmu.me
date: 04/23/2015
-->

<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
		<link href="css/style.css" rel="stylesheet">
		<script src="lib/three.min.js"></script>
		<script src="js/threejs/VREffect.js"></script>
		<script src="js/threejs/DeviceOrientationControls.js"></script>
		<title>Web VR Demo - Mobile</title>		
	</head>
	<body>
		<div id="info">
			The panorama image is from <a href="http://www.lemis.com/grog/photos/Photos.php?dirdate=20120601" target="_blank">Greg</a>
		</div>
		<div id="container"></div>
		<script type="text/javascript">
			var camera, scene, renderer;
			var vrHMD, vrPosSensor;
			var vrDeviceEffect;
			var control;
			var bCardboard = false;

			init();

			function init() {

				var container, mesh;

				container = document.getElementById('container');
				camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 1, 1100);

				camera.target = new THREE.Vector3(0, 0, 0);

				scene = new THREE.Scene();

				var geometry = new THREE.SphereGeometry(500, 60, 40);
				geometry.applyMatrix(new THREE.Matrix4().makeScale(-1, 1, 1));

				var material = new THREE.MeshBasicMaterial( {
					map: THREE.ImageUtils.loadTexture('images/verandah-centre-equirectangular.jpg')
				});

				mesh = new THREE.Mesh(geometry, material);
				scene.add(mesh);

				var attributes = {
					stencil: false
				};
       
				renderer = new THREE.WebGLRenderer( attributes );
				// In order to support v.69, I comment this line. When we are ready to v.71, we can enable it. 
				renderer.setPixelRatio( window.devicePixelRatio );
				renderer.setSize( window.innerWidth, window.innerHeight );

				vrDeviceEffect = new THREE.VREffect( renderer );

				window.addEventListener( 'resize', onWindowResize, false );
				container.appendChild( renderer.domElement );

				if ( navigator.getVRDevices ) {
					navigator.getVRDevices().then( vrDeviceCallback );
				} else if ( navigator.mozGetVRDevices ) {
					navigator.mozGetVRDevices( vrDeviceCallback );
				}

				control = new THREE.DeviceOrientationControls( camera );
			
				gameLoop();
			}

			function onWindowResize() {

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

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

			function vrDeviceCallback(devices) {

				if ( !devices.length ) {
					return;
				}

				for ( var i = 0; i < devices.length; ++i ) {

					if ( devices[i] instanceof HMDVRDevice ) {
						vrHMD = devices[i];
					}	

					if ( vrHMD && devices[i] instanceof PositionSensorVRDevice
						&& devices[i].hardwareUnitId == vrHMD.hardwareUnitId ) {
						vrPosSensor = devices[i];

						if ( vrPosSensor.deviceName.indexOf( 'Cardboard' ) >= 0 ) {
							bCardboard = true;
						}
						// We just want to get the first VR device.
						break;
					}
				}

				vrDeviceEffect.setFullScreen( true );
			}

			function gameLoop() {

				requestAnimationFrame( gameLoop );

				// vrPosSensor if has been supported on mobile devices?
				if ( vrPosSensor ) {
					var state = vrPosSensor.getState();

					if ( state.hasPosition ) {

						//console.log( state.position );
					}

					if ( state.hasOrientation ) {
			
						// Cardboard orientation is fixed on Android Firefox. Needs to confirm FxOS.
						// if ( bCardboard ) {

						// 	var q0 = new THREE.Quaternion( state.orientation.x,
						// 	state.orientation.z,
						// 	state.orientation.y,
						// 	state.orientation.w );
						// 	var q1 = new THREE.Quaternion( -Math.sqrt( 0.5 ), 0, 0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis, camera at right version

						// 	q0.multiply( q1 ); // camera looks out the back of the device, not the top
						// 	camera.quaternion.set(
						// 	q0.x, 
						// 	q0.z,
						// 	q0.y, 
						// 	q0.w);

						// } else {
							// Oculus device
							camera.quaternion.set(
							state.orientation.x, 
							state.orientation.y,
							state.orientation.z, 
							state.orientation.w);
						//}		

						//console.log(state.orientation);
					} else {

						control.update(); // For some devices that do not support sensor. 	
					}
				} else {

					control.update(); // For some devices that do not support sensor. 	
				}

				vrDeviceEffect.render( scene, camera );
			}

		</script>	
	</body>
</html>
{'fraction_non_alphanumeric': 0.13230297051408527, 'fraction_numerical': 0.014030472432313932, 'mean_word_length': 2.656913827655311, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5913670', 'n_tokens_mistral': 3894, 'n_tokens_neox': 2928, 'n_words': 670}