Created
September 15, 2013 10:00
-
-
Save sheldonh/6569315 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <body></body> | |
| <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 shape = new THREE.SphereGeometry(100); | |
| var cover = new THREE.MeshNormalMaterial(); | |
| var ball = new THREE.Mesh(shape, cover); | |
| scene.add(ball); | |
| ball.position.set(250,150,1); | |
| var shape = new THREE.CubeGeometry(300, 100, 20); | |
| var cover = new THREE.MeshNormalMaterial(); | |
| var box = new THREE.Mesh(shape, cover); | |
| scene.add(box); | |
| box.rotation.set(0.5, 0.5, 0); | |
| box.position.set(250, -200, 0); | |
| var shape = new THREE.CylinderGeometry(1, 30, 50, 4); | |
| var cover = new THREE.MeshNormalMaterial(); | |
| var tube = new THREE.Mesh(shape, cover); | |
| scene.add(tube); | |
| tube.rotation.set(10, 5, 10); | |
| tube.position.set(20, -10, 200); | |
| var shape = new THREE.PlaneGeometry(300, 100); | |
| var cover = new THREE.MeshNormalMaterial(); | |
| var ground = new THREE.Mesh(shape, cover); | |
| scene.add(ground); | |
| ground.rotation.set( 0.5, 0, 0); | |
| ground.position.set(260, -20, -250); | |
| var shape = new THREE.TorusGeometry(100, 25, 8, 25, 3.14); | |
| var cover = new THREE.MeshNormalMaterial(); | |
| var donut = new THREE.Mesh(shape, cover); | |
| scene.add(donut); | |
| var clock = new THREE.Clock(); | |
| function animate() { | |
| requestAnimationFrame(animate) | |
| var t = clock.getElapsedTime(); | |
| box.rotation.set(t, 3*t, 0); | |
| ball.rotation.set(t, 3*t, 0); | |
| renderer.render(scene, camera); | |
| } | |
| animate(); | |
| // Now, show what the camera sees on the screen: | |
| renderer.render(scene, camera); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment