Advertisement
pcwizz

three.js test thingy

May 1st, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var scene = new THREE.Scene();
  2. var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight , 0.1, 1000 );
  3. var renderer = new THREE.WebGLRenderer();
  4. renderer.setSize( window.innerWidth/1.7, (window.innerHeight/1.7) );
  5. document.body.appendChild( renderer.domElement );
  6. var geometry = new THREE.CubeGeometry(1,1,1);
  7. var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
  8. var cube = new THREE.Mesh( geometry, material );
  9. scene.add( cube );
  10. var geometry2 = new THREE.CubeGeometry(2,2,2);
  11. var material2 = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
  12. var cube2 = new THREE.Mesh( geometry2, material2 );
  13. cube2.position.z = -3;
  14. scene.add(cube2);
  15. var geometry3 = new THREE.CubeGeometry(4,4,4);
  16. var material3 = new THREE.MeshBasicMaterial( { color: 0x0000ff } );
  17. var cube3 = new THREE.Mesh( geometry3, material3 );
  18. cube3.position.z = -10;
  19. scene.add(cube3);
  20. camera.position.z = 5;
  21. function render() {
  22.     requestAnimationFrame(render);
  23.     cube.rotation.x += 0.01;
  24.     cube.rotation.y += 0.01;
  25.     cube2.rotation.x += 0.03;
  26.     cube2.rotation.y += 0.03;
  27.     cube3.rotation.x += 0.05;
  28.     cube3.rotation.y += 0.05;  
  29.     renderer.render(scene, camera);
  30.     }
  31. render();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement