Skip to content

Instantly share code, notes, and snippets.

@vppillai
Last active August 29, 2015 14:07
Show Gist options
  • Save vppillai/27be400ccfc334ba140f to your computer and use it in GitHub Desktop.
Save vppillai/27be400ccfc334ba140f to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<div id="container"></div>
<script src="three.js"></script>
<script src="stats.min.js"></script>
<script defer="defer">
// revolutions per second
var items = [[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36],
[0.75,0.32,-0.45,0.36]];
var i, j=0, entry;
// this function is executed on each animation frame
function animate(){
if (j<items.length-1) j++;
else
document.body.removeChild(renderer.domElement);
var entry = items[j];
plane.quaternion.set(entry[1],entry[2],entry[3],entry[0]);
renderer.render(scene, camera);
stats.update();
requestAnimationFrame(function(){ animate()});
}
// renderer
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// camera
var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.y = -450;
camera.position.z = 400;
camera.rotation.x = 45 * (Math.PI / 180);
// scene
var scene = new THREE.Scene();
// plane
var plane = new THREE.Mesh(new THREE.BoxGeometry(300, 300,20), new THREE.MeshNormalMaterial());
//var plane = new THREE.Mesh(new THREE.PlaneGeometry(300, 300), new THREE.MeshNormalMaterial());
plane.overdraw = true;
scene.add(plane);
plane.useQuaternion = true;
plane.quaternion.set(0,0,0,0);
container = document.createElement( 'div' );
document.body.appendChild( container );
stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
container.appendChild( stats.domElement );
// request new frame
animate()
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment