Created
May 28, 2011 13:38
-
-
Save Andrea/996865 to your computer and use it in GitHub Desktop.
"hello world" with three
This file contains 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
<!DOCTYPE HTML> | |
<html lang="en"> | |
<head> | |
<title>three.js webgl - materials - shaders [Fresnel]</title> | |
<meta charset="utf-8"> | |
<style type="text/css"> | |
body { | |
background:#000; | |
padding:0; | |
margin:0; | |
font-weight: bold; | |
overflow:hidden; | |
} | |
#info { | |
position: absolute; | |
top: 0px; width: 100%; | |
color: #ffffff; | |
padding: 5px; | |
font-family:Monospace; | |
font-size:13px; | |
text-align:center; | |
z-index:1000; | |
} | |
a { | |
color: #ffffff; | |
} | |
#log { position:absolute; top:50px; text-align:left; display:block; z-index:100 } | |
#oldie a { color:#0b0 } | |
</style> | |
</head> | |
<body> | |
<pre id="log"></pre> | |
<div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - webgl cube Fresnel shader demo. texture by <a href="http://www.humus.name/index.php?page=Textures" target="_blank">Humus</a> </div> | |
<script type="text/javascript" src="three_js/build/Three.js"></script> | |
<script type="text/javascript" src="js/RequestAnimationFrame.js"></script> | |
<!-- <script type="text/javascript" src="js/Detector.js"></script> | |
<script type="text/javascript" src="js/RequestAnimationFrame.js"></script> | |
--> | |
<script type="text/javascript"> | |
var camera, scene, renderer, | |
geometry, material, mesh, light; | |
init(); | |
animate(); | |
function init() { | |
camera = new THREE.Camera( 95, window.innerWidth / window.innerHeight, 1, 10000 ); | |
camera.position.z = 1000; | |
scene = new THREE.Scene(); | |
light = new THREE.Light(); | |
geometry = new THREE.Cube( 200, 200, 200 ); | |
geometry2 = new THREE.Cube( 200, 200, 200 ); | |
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } ); | |
mesh = new THREE.Mesh( geometry, material ); | |
scene.addObject( mesh ); | |
renderer = new THREE.CanvasRenderer(); | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
document.body.appendChild( renderer.domElement ); | |
} | |
function animate() { | |
// Include examples/js/RequestAnimationFrame.js for cross-browser compatibility. | |
requestAnimationFrame( animate ); | |
render(); | |
} | |
function render() { | |
mesh.rotation.x += 0.01; | |
mesh.rotation.y += 0.02; | |
renderer.render( scene, camera ); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment