Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="http://gamingJS.com/Three.js"></script>
- <script src="http://gamingJS.com/ChromeFixes.js"></script>
- <script>
- // This is where stuff in our game will happen:
- var scene = new THREE.Scene();
- // This is what sees the stuff:
- var aspect_ratio = window.innerWidth / window.innerHeight;
- var camera = new THREE.PerspectiveCamera(75, aspect_ratio, 1, 10000);
- camera.position.z = 500;
- scene.add(camera);
- // This will draw what the camera sees onto the screen:
- var renderer = new THREE.CanvasRenderer();
- renderer.setSize(window.innerWidth, window.innerHeight);
- document.body.appendChild(renderer.domElement);
- // ******** START CODING ON THE NEXT LINE ********
- var cover = new THREE.MeshNormalMaterial();
- var body = new THREE.SphereGeometry(100);
- var avatar= new THREE.Mesh(body,cover);
- scene.add(avatar);
- var hand = new THREE.SphereGeometry(50);
- var right_hand = new THREE.Mesh(hand,cover);
- right_hand.position.set(-130,0,0);
- avatar.add(right_hand);
- var left_hand = new THREE.Mesh(hand,cover);
- left_hand.position.set(130,0,0);
- avatar.add(left_hand);
- var foot=new THREE.CylinderGeometry(10);
- var right_foot = new THREE.Mesh(foot,cover);
- right_foot.position.set(-30,-120,0);
- avatar.add(right_foot);
- var left_foot = new THREE.Mesh(foot,cover);
- left_foot.position.set(30,-120,0);
- avatar.add(left_foot);
- // Now, animate what the camera sees on the screen:
- var is_cartwheeling =false;
- var is_flipping =false;
- renderer.render(scene, camera);
- function animate() {
- requestAnimationFrame(animate);
- if(is_cartwheeling) {
- avatar.rotation.z = avatar.rotation.z +0.05;
- }
- if (is_flipping) {
- avatar.rotation.x = avatar.rotation.x +0.05;
- }
- renderer.render(scene, camera);
- }
- animate();
- //Abhören der Tasten
- document.addEventListener('keydown',function(event) {
- alert(event.KeyCode);
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment