<commit_before><!DOCTYPE html>
<html lang="en">
	<head>
		<title>Terrain Generation</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    	<link href="../vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
		<style>
			body {
				color: #61443e;
				font-family:Monospace;
				font-size:13px;
				text-align:center;
				background-color: #bfd1e5;
				margin: 0px;
				overflow: hidden;
			}
			#info {
				position: absolute;
				top: 5px; left: 5px;
				width: 40px; height:56px;
			}
			a {
				width: 40px; height:56px;
			}
		</style>
	</head>
	<body>
		<div id="container">
		</div>
		<div id="info">
			<a href="../#portfolio"><span><i class="fa fa-chevron-left fa-3" aria-hidden="true"></span></i></a>
		</div>
		<script src="build/three.js"></script>

		<script src="js/controls/OrbitControls.js"></script>
		
		<script src="js/Mirror.js"></script>
		<script src="js/WaterShader.js"></script>
		<script src="js/SkyShader.js"></script>


		<script src="js/ImprovedNoise.js"></script>
		<script src="js/Detector.js"></script>
		<script src="js/libs/dat.gui.min.js"></script>

		<script>
			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();

			var container = document.getElementById( 'container' );

			var camera, controls, scene, renderer;
			var sky, sunSphere;

			var parameters = {
				width: 2000,
				height: 2000,
				widthSegments: 250,
				heightSegments: 250,
				depth: 1500,
				param: 4,
				filterparam: 1
			};

			var worldWidth = 512, worldDepth = 512,
			worldHalfWidth = worldWidth / 2, worldHalfDepth = worldDepth / 2;

			init();
			render();

			function initSky() {
				// Add Sky Mesh
				sky = new THREE.Sky();
				scene.add( sky.mesh );
				// Add Sun Helper
				sunSphere = new THREE.Mesh(
					new THREE.SphereBufferGeometry( 20000, 16, 8 ),
					new THREE.MeshBasicMaterial( { color: 0xffffff } )
				);
				sunSphere.position.y = - 700000;
				sunSphere.visible = false;
				scene.add( sunSphere );
				/// GUI
				var effectController  = {
					turbidity: 10,
					rayleigh: 2,
					mieCoefficient: 0.005,
					mieDirectionalG: 0.8,
					luminance: 1,
					inclination: 0.49, // elevation / inclination
					azimuth: 0.25, // Facing front,
					sun: ! true
				};
				var distance = 400000;
				var uniforms = sky.uniforms;
				uniforms.turbidity.value = effectController.turbidity;
				uniforms.rayleigh.value = effectController.rayleigh;
				uniforms.luminance.value = effectController.luminance;
				uniforms.mieCoefficient.value = effectController.mieCoefficient;
				uniforms.mieDirectionalG.value = effectController.mieDirectionalG;
				var theta = Math.PI * ( effectController.inclination - 0.5 );
				var phi = 2 * Math.PI * ( effectController.azimuth - 0.5 );
				sunSphere.position.x = distance * Math.cos( phi );
				sunSphere.position.y = distance * Math.sin( phi ) * Math.sin( theta );
				sunSphere.position.z = distance * Math.sin( phi ) * Math.cos( theta );
				sunSphere.visible = effectController.sun;
				sky.uniforms.sunPosition.value.copy( sunSphere.position );
				renderer.render( scene, camera );
			}
			function initWater(){
				var light = new THREE.DirectionalLight( 0xffffbb, 1 );
				light.position.set( - 1, 1, - 1 );
				scene.add( light );

				var waterloader = new THREE.TextureLoader();
				waterloader.setCrossOrigin('anonymous');
				waterNormals = new THREE.TextureLoader().load( 'textures/waternormals.jpg' );
				waterNormals.wrapS = waterNormals.wrapT = THREE.RepeatWrapping;
				water = new THREE.Water( renderer, camera, scene, {
					textureWidth: 512,
					textureHeight: 512,
					waterNormals: waterNormals,
					alpha: 	1.0,
					sunDirection: light.position.clone().normalize(),
					sunColor: 0xffffff,
					waterColor: 0x001e0f,
					distortionScale: 50.0
				} );
				mirrorMesh = new THREE.Mesh(
					new THREE.PlaneBufferGeometry( parameters.width * 500, parameters.height * 500 ),
					water.material
				);
				mirrorMesh.add( water );
				mirrorMesh.rotation.x = - Math.PI * 0.5;
				mirrorMesh.position.y = 100;
				scene.add( mirrorMesh );

			}
			function initMountains(){
				data = generateHeight( worldWidth, worldDepth );
				var geometry = new THREE.PlaneBufferGeometry( 7500, 7500, worldWidth - 1, worldDepth - 1 );
				geometry.rotateX( - Math.PI / 2 );
				var vertices = geometry.attributes.position.array;
				for ( var i = 0, j = 0, l = vertices.length; i < l; i ++, j += 3 ) {
					vertices[ j + 1 ] = data[ i ] * 10;
				}
				texture = new THREE.CanvasTexture( generateTexture( data, worldWidth, worldDepth ) );
				texture.wrapS = THREE.ClampToEdgeWrapping;
				texture.wrapT = THREE.ClampToEdgeWrapping;
				mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map: texture } ) );
				scene.add( mesh );
			}

			function generateHeight( width, height ) {
				var size = width * height, data = new Uint8Array( size ),
				perlin = new ImprovedNoise(), quality = 1, z = Math.random() * 100;
				for ( var j = 0; j < 4; j ++ ) {
					for ( var i = 0; i < size; i ++ ) {
						var x = i % width, y = ~~ ( i / width );
						data[ i ] += Math.abs( perlin.noise( x / quality, y / quality, z ) * quality * 1.75 );
					}
					quality *= 5;
				}
				return data;
			}
			function generateTexture( data, width, height ) {
				var canvas, canvasScaled, context, image, imageData,
				level, diff, vector3, sun, shade;
				vector3 = new THREE.Vector3( 0, 0, 0 );
				sun = new THREE.Vector3( 1, 1, 1 );
				sun.normalize();
				canvas = document.createElement( 'canvas' );
				canvas.width = width;
				canvas.height = height;
				context = canvas.getContext( '2d' );
				context.fillStyle = '#000';
				context.fillRect( 0, 0, width, height );
				image = context.getImageData( 0, 0, canvas.width, canvas.height );
				imageData = image.data;
				for ( var i = 0, j = 0, l = imageData.length; i < l; i += 4, j ++ ) {
					vector3.x = data[ j - 2 ] - data[ j + 2 ];
					vector3.y = 2;
					vector3.z = data[ j - width * 2 ] - data[ j + width * 2 ];
					vector3.normalize();
					shade = vector3.dot( sun );
					imageData[ i ] = ( 96 + shade * 128 ) * ( 0.5 + data[ j ] * 0.007 );
					imageData[ i + 1 ] = ( 32 + shade * 96 ) * ( 0.5 + data[ j ] * 0.007 );
					imageData[ i + 2 ] = ( shade * 96 ) * ( 0.5 + data[ j ] * 0.007 );
				}
				context.putImageData( image, 0, 0 );
				// Scaled 4x
				canvasScaled = document.createElement( 'canvas' );
				canvasScaled.width = width * 4;
				canvasScaled.height = height * 4;
				context = canvasScaled.getContext( '2d' );
				context.scale( 4, 4 );
				context.drawImage( canvas, 0, 0 );
				image = context.getImageData( 0, 0, canvasScaled.width, canvasScaled.height );
				imageData = image.data;
				for ( var i = 0, l = imageData.length; i < l; i += 4 ) {
					var v = ~~ ( Math.random() * 5 );
					imageData[ i ] += v;
					imageData[ i + 1 ] += v;
					imageData[ i + 2 ] += v;
				}
				context.putImageData( image, 0, 0 );
				return canvasScaled;
			}
			function init() {
				camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 100, 2000000 );
				camera.position.set( 0, 750, 2000 );

				//camera.setLens(20);
				scene = new THREE.Scene();
				renderer = new THREE.WebGLRenderer();
				renderer.setPixelRatio( window.devicePixelRatio );
				renderer.setSize( window.innerWidth, window.innerHeight );
				container.appendChild( renderer.domElement );
				controls = new THREE.OrbitControls( camera, renderer.domElement );
				controls.addEventListener( 'change', render );
				//controls.maxPolarAngle = Math.PI / 2;
				//controls.enableZoom = false;
				//controls.enablePan = false;
				initSky();
				initWater();
				initMountains();
				camera.position.y = data[ worldHalfWidth + worldHalfDepth * worldWidth ] * 10 + 500;
				window.addEventListener( 'resize', onWindowResize, false );
			}
			function onWindowResize() {
				camera.aspect = window.innerWidth / window.innerHeight;
				camera.updateProjectionMatrix();
				renderer.setSize( window.innerWidth, window.innerHeight );
				render();
			}
			function render() {
				water.material.uniforms.time.value += 1.0 / 60.0;
				water.render();
				renderer.render( scene, camera );
			}

		</script>

	</body>
</html><commit_msg>pls button work<commit_after><!DOCTYPE html>
<html lang="en">
	<head>
		<title>Terrain Generation</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
		<!-- favicon -->
    	<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon">
    	<link rel="icon" href="img/favicon.ico" type="image/x-icon">

  		<!-- Custom Fonts -->
    	<link href="../vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

		<style>
			body {
				color: #61443e;
				font-family:Monospace;
				font-size:13px;
				text-align:center;
				background-color: #bfd1e5;
				margin: 0px;
				overflow: hidden;
			}
			#info {
				position: absolute;
				top: 5px; left: 5px;
				width: 40px; height:56px;
			}
		</style>
	</head>
	<body>
		<div id="container">
		</div>
		<div id="info">
			<a href="../#portfolio"><i class="fa fa-chevron-left fa-3x" aria-hidden="true"></i></a>
		</div>

		<script src="build/three.js"></script>

		<script src="js/controls/OrbitControls.js"></script>
		
		<script src="js/Mirror.js"></script>
		<script src="js/WaterShader.js"></script>
		<script src="js/SkyShader.js"></script>


		<script src="js/ImprovedNoise.js"></script>
		<script src="js/Detector.js"></script>
		<script src="js/libs/dat.gui.min.js"></script>

		<script>
			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();

			var container = document.getElementById( 'container' );

			var camera, controls, scene, renderer;
			var sky, sunSphere;

			var parameters = {
				width: 2000,
				height: 2000,
				widthSegments: 250,
				heightSegments: 250,
				depth: 1500,
				param: 4,
				filterparam: 1
			};

			var worldWidth = 512, worldDepth = 512,
			worldHalfWidth = worldWidth / 2, worldHalfDepth = worldDepth / 2;

			init();
			render();

			function initSky() {
				// Add Sky Mesh
				sky = new THREE.Sky();
				scene.add( sky.mesh );
				// Add Sun Helper
				sunSphere = new THREE.Mesh(
					new THREE.SphereBufferGeometry( 20000, 16, 8 ),
					new THREE.MeshBasicMaterial( { color: 0xffffff } )
				);
				sunSphere.position.y = - 700000;
				sunSphere.visible = false;
				scene.add( sunSphere );
				/// GUI
				var effectController  = {
					turbidity: 10,
					rayleigh: 2,
					mieCoefficient: 0.005,
					mieDirectionalG: 0.8,
					luminance: 1,
					inclination: 0.49, // elevation / inclination
					azimuth: 0.25, // Facing front,
					sun: ! true
				};
				var distance = 400000;
				var uniforms = sky.uniforms;
				uniforms.turbidity.value = effectController.turbidity;
				uniforms.rayleigh.value = effectController.rayleigh;
				uniforms.luminance.value = effectController.luminance;
				uniforms.mieCoefficient.value = effectController.mieCoefficient;
				uniforms.mieDirectionalG.value = effectController.mieDirectionalG;
				var theta = Math.PI * ( effectController.inclination - 0.5 );
				var phi = 2 * Math.PI * ( effectController.azimuth - 0.5 );
				sunSphere.position.x = distance * Math.cos( phi );
				sunSphere.position.y = distance * Math.sin( phi ) * Math.sin( theta );
				sunSphere.position.z = distance * Math.sin( phi ) * Math.cos( theta );
				sunSphere.visible = effectController.sun;
				sky.uniforms.sunPosition.value.copy( sunSphere.position );
				renderer.render( scene, camera );
			}
			function initWater(){
				var light = new THREE.DirectionalLight( 0xffffbb, 1 );
				light.position.set( - 1, 1, - 1 );
				scene.add( light );

				var waterloader = new THREE.TextureLoader();
				waterloader.setCrossOrigin('anonymous');
				waterNormals = new THREE.TextureLoader().load( 'textures/waternormals.jpg' );
				waterNormals.wrapS = waterNormals.wrapT = THREE.RepeatWrapping;
				water = new THREE.Water( renderer, camera, scene, {
					textureWidth: 512,
					textureHeight: 512,
					waterNormals: waterNormals,
					alpha: 	1.0,
					sunDirection: light.position.clone().normalize(),
					sunColor: 0xffffff,
					waterColor: 0x001e0f,
					distortionScale: 50.0
				} );
				mirrorMesh = new THREE.Mesh(
					new THREE.PlaneBufferGeometry( parameters.width * 500, parameters.height * 500 ),
					water.material
				);
				mirrorMesh.add( water );
				mirrorMesh.rotation.x = - Math.PI * 0.5;
				mirrorMesh.position.y = 100;
				scene.add( mirrorMesh );

			}
			function initMountains(){
				data = generateHeight( worldWidth, worldDepth );
				var geometry = new THREE.PlaneBufferGeometry( 7500, 7500, worldWidth - 1, worldDepth - 1 );
				geometry.rotateX( - Math.PI / 2 );
				var vertices = geometry.attributes.position.array;
				for ( var i = 0, j = 0, l = vertices.length; i < l; i ++, j += 3 ) {
					vertices[ j + 1 ] = data[ i ] * 10;
				}
				texture = new THREE.CanvasTexture( generateTexture( data, worldWidth, worldDepth ) );
				texture.wrapS = THREE.ClampToEdgeWrapping;
				texture.wrapT = THREE.ClampToEdgeWrapping;
				mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map: texture } ) );
				scene.add( mesh );
			}

			function generateHeight( width, height ) {
				var size = width * height, data = new Uint8Array( size ),
				perlin = new ImprovedNoise(), quality = 1, z = Math.random() * 100;
				for ( var j = 0; j < 4; j ++ ) {
					for ( var i = 0; i < size; i ++ ) {
						var x = i % width, y = ~~ ( i / width );
						data[ i ] += Math.abs( perlin.noise( x / quality, y / quality, z ) * quality * 1.75 );
					}
					quality *= 5;
				}
				return data;
			}
			function generateTexture( data, width, height ) {
				var canvas, canvasScaled, context, image, imageData,
				level, diff, vector3, sun, shade;
				vector3 = new THREE.Vector3( 0, 0, 0 );
				sun = new THREE.Vector3( 1, 1, 1 );
				sun.normalize();
				canvas = document.createElement( 'canvas' );
				canvas.width = width;
				canvas.height = height;
				context = canvas.getContext( '2d' );
				context.fillStyle = '#000';
				context.fillRect( 0, 0, width, height );
				image = context.getImageData( 0, 0, canvas.width, canvas.height );
				imageData = image.data;
				for ( var i = 0, j = 0, l = imageData.length; i < l; i += 4, j ++ ) {
					vector3.x = data[ j - 2 ] - data[ j + 2 ];
					vector3.y = 2;
					vector3.z = data[ j - width * 2 ] - data[ j + width * 2 ];
					vector3.normalize();
					shade = vector3.dot( sun );
					imageData[ i ] = ( 96 + shade * 128 ) * ( 0.5 + data[ j ] * 0.007 );
					imageData[ i + 1 ] = ( 32 + shade * 96 ) * ( 0.5 + data[ j ] * 0.007 );
					imageData[ i + 2 ] = ( shade * 96 ) * ( 0.5 + data[ j ] * 0.007 );
				}
				context.putImageData( image, 0, 0 );
				// Scaled 4x
				canvasScaled = document.createElement( 'canvas' );
				canvasScaled.width = width * 4;
				canvasScaled.height = height * 4;
				context = canvasScaled.getContext( '2d' );
				context.scale( 4, 4 );
				context.drawImage( canvas, 0, 0 );
				image = context.getImageData( 0, 0, canvasScaled.width, canvasScaled.height );
				imageData = image.data;
				for ( var i = 0, l = imageData.length; i < l; i += 4 ) {
					var v = ~~ ( Math.random() * 5 );
					imageData[ i ] += v;
					imageData[ i + 1 ] += v;
					imageData[ i + 2 ] += v;
				}
				context.putImageData( image, 0, 0 );
				return canvasScaled;
			}
			function init() {
				camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 100, 2000000 );
				camera.position.set( 0, 750, 2000 );

				//camera.setLens(20);
				scene = new THREE.Scene();
				renderer = new THREE.WebGLRenderer();
				renderer.setPixelRatio( window.devicePixelRatio );
				renderer.setSize( window.innerWidth, window.innerHeight );
				container.appendChild( renderer.domElement );
				controls = new THREE.OrbitControls( camera, renderer.domElement );
				controls.addEventListener( 'change', render );
				//controls.maxPolarAngle = Math.PI / 2;
				//controls.enableZoom = false;
				//controls.enablePan = false;
				initSky();
				initWater();
				initMountains();
				camera.position.y = data[ worldHalfWidth + worldHalfDepth * worldWidth ] * 10 + 500;
				window.addEventListener( 'resize', onWindowResize, false );
			}
			function onWindowResize() {
				camera.aspect = window.innerWidth / window.innerHeight;
				camera.updateProjectionMatrix();
				renderer.setSize( window.innerWidth, window.innerHeight );
				render();
			}
			function render() {
				water.material.uniforms.time.value += 1.0 / 60.0;
				water.render();
				renderer.render( scene, camera );
			}

		</script>

	</body>
</html>
{'fraction_non_alphanumeric': 0.1436505640728956, 'fraction_numerical': 0.031240960370263235, 'mean_word_length': 2.5255965735264123, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 89, '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': '920377', 'n_tokens_mistral': 7499, 'n_tokens_neox': 5635, 'n_words': 1351}