Jack_Fog

Untitled

Apr 22nd, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src="http://gamingJS.com/Three.js"></script>
  2. <script src="http://gamingJS.com/ChromeFixes.js"></script>
  3. <script>
  4.   // This is where stuff in our game will happen:
  5.   var scene = new THREE.Scene();
  6.  
  7.   // This is what sees the stuff:
  8.   var aspect_ratio = window.innerWidth / window.innerHeight;
  9.   var camera = new THREE.PerspectiveCamera(75, aspect_ratio, 1, 10000);
  10.   camera.position.z = 500;
  11.   scene.add(camera);
  12.  
  13.   // This will draw what the camera sees onto the screen:
  14.   var renderer = new THREE.CanvasRenderer();
  15.   renderer.setSize(window.innerWidth, window.innerHeight);
  16.   document.body.appendChild(renderer.domElement);
  17.  
  18.   // ******** START CODING ON THE NEXT LINE ********
  19.  
  20. var cover = new THREE.MeshNormalMaterial();
  21. var body  = new THREE.SphereGeometry(100);
  22. var avatar= new THREE.Mesh(body,cover);
  23. scene.add(avatar);
  24.  
  25. var hand = new THREE.SphereGeometry(50);
  26.  
  27. var right_hand = new THREE.Mesh(hand,cover);
  28. right_hand.position.set(-130,0,0);
  29. avatar.add(right_hand);
  30.  
  31. var left_hand = new THREE.Mesh(hand,cover);
  32. left_hand.position.set(130,0,0);
  33. avatar.add(left_hand);
  34.  
  35. var foot=new THREE.CylinderGeometry(10);
  36.  
  37. var right_foot = new THREE.Mesh(foot,cover);
  38. right_foot.position.set(-30,-120,0);
  39. avatar.add(right_foot);
  40.  
  41. var left_foot = new THREE.Mesh(foot,cover);
  42. left_foot.position.set(30,-120,0);
  43. avatar.add(left_foot);
  44.  
  45.  
  46.  
  47.   // Now, animate what the camera sees on the screen:
  48.   var is_cartwheeling =false;
  49.   var is_flipping =false;
  50.   renderer.render(scene, camera);
  51.   function animate() {
  52.   requestAnimationFrame(animate);
  53.   if(is_cartwheeling) {
  54.   avatar.rotation.z = avatar.rotation.z +0.05;
  55.   }
  56.   if (is_flipping) {
  57.   avatar.rotation.x = avatar.rotation.x +0.05;  
  58.   }
  59.   renderer.render(scene, camera);
  60.   }
  61.   animate();
  62.  
  63.   //Abhören der Tasten
  64.  
  65.   document.addEventListener('keydown',function(event) {
  66.     alert(event.KeyCode);
  67.   });
  68.   </script>
Advertisement
Add Comment
Please, Sign In to add comment