Last active
August 19, 2016 11:31
-
-
Save reynish/bb06fb67c247b0a32d67769c0c295d75 to your computer and use it in GitHub Desktop.
Three.js playgroundhttps://bl.ocks.org/reynish/bb06fb67c247b0a32d67769c0c295d75
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
<html> | |
<head></head> | |
<body> | |
<script src="https://rawgit.com/mrdoob/three.js/dev/build/three.js"></script> | |
<script src="script.js"></script> | |
</body> | |
</html> |
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
var scene = new THREE.Scene(); | |
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 ); | |
var renderer = new THREE.WebGLRenderer(); | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
document.body.appendChild( renderer.domElement ); | |
var geometry = new THREE.BoxGeometry( 1, 1, 1 ); | |
var material = new THREE.MeshLambertMaterial({ | |
color: 0xCC0000 | |
}); | |
var cube = new THREE.Mesh( geometry, material ); | |
// create a point light | |
var pointLight = new THREE.PointLight(0xFFFFFF); | |
// set its position | |
pointLight.position.x = 10; | |
pointLight.position.y = 50; | |
pointLight.position.z = 130; | |
// add to the scene | |
scene.add(pointLight); | |
cube.rotation.x = 0.3; | |
cube.rotation.y = -0.3; | |
scene.add( cube ); | |
camera.position.z = 5; | |
var render = function () { | |
requestAnimationFrame( render ); | |
renderer.render(scene, camera); | |
}; | |
render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment