dahngeek
2/4/2015 - 10:58 PM

gistfile1.txt

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style>
			body {
				background-color: #ffffff;
				margin: 0;
				overflow: hidden;
			}
		</style>
	</head>
	<body>
		
		<script src="http://brangerbriz.net/labs/threejs_playGnd/js/three.min.js"></script>
		<script src="http://brangerbriz.net/labs/threejs_playGnd/js/Detector.js"></script>
		<script>

			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
			
			var camera, scene, renderer;
			var geometry, material, mesh;
			
			function setup() {

				var W = window.innerWidth, H = window.innerHeight;
				renderer = new THREE.WebGLRenderer();
				renderer.setSize( W, H );
				document.body.appendChild( renderer.domElement );

				camera = new THREE.PerspectiveCamera( 50, W/H, 1, 10000 );
				camera.position.z = 500;

				scene = new THREE.Scene();
				bg = document.body.style;
				bg.background = '#000000';
				var i = 0;
				// paste your code from the geometryGUI here
				while (i<100){
					geometry = new THREE.PlaneGeometry(200, 200, 4, 4);
					material = new THREE.MeshNormalMaterial({shading: THREE.FlatShading});
					mesh = new THREE.Mesh(geometry, material);
					mesh.position.x = Math.random() * 1000 - 500;
					mesh.position.y = Math.random() * 1000 - 500;
					mesh.position.z = Math.random() * 1000 - 500;
					mesh.rotation.x = Math.random() * 2 * Math.PI;
					mesh.rotation.y = Math.random() * 2 * Math.PI;
					mesh.rotation.z = Math.random() * 2 * Math.PI;
					scene.add( mesh );
					i = i+1
				}

			}		

			function draw() {

				requestAnimationFrame( draw );
				
				// experiment with code from the snippets menu here
				camera.position.z = Math.sin( Date.now() * 0.0001 ) * 500;
				camera.position.y = Math.cos( Date.now() * 0.0002 ) * 300;
				camera.lookAt(mesh.position);
				renderer.render( scene, camera );

			}

			setup();
			draw();

		</script>
		
	</body>
</html>