Last active
October 18, 2015 19:16
-
-
Save gilbox/b39b31f536b45700b903 to your computer and use it in GitHub Desktop.
three.js spinning cube
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
const renderer = new THREE.WebGLRenderer( {canvas: document.getElementById('canvas')} ); | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
renderer.autoClear = false; | |
const scene = new THREE.Scene(); | |
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); | |
const geometry = new THREE.BoxGeometry( 1, 1, 1 ); | |
const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); | |
const cube = new THREE.Mesh( geometry, material ); | |
scene.add( cube ); | |
camera.position.z = 5; | |
function render() { | |
requestAnimationFrame( render ); | |
cube.rotation.x += 0.1; | |
cube.rotation.y += 0.1; | |
renderer.render( scene, camera ); | |
} | |
render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment