Created
November 7, 2017 03:33
-
-
Save jyuko/532f900588637f8388c2fc0fa4f8a4b5 to your computer and use it in GitHub Desktop.
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="ja"> | |
<head> | |
<title>Hello three.js</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, user-scalable=no, | |
minimum-scale=1.0, maximum-scale=1.0"> | |
</head> | |
<body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/88/three.min.js"></script> | |
<script> | |
var camera, scene, renderer; | |
var geometry, material, mesh; | |
init(); | |
animate(); | |
function init() { | |
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 ); | |
camera.position.z = 1; | |
scene = new THREE.Scene(); | |
geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 ); | |
material = new THREE.MeshNormalMaterial(); | |
mesh = new THREE.Mesh( geometry, material ); | |
scene.add( mesh ); | |
renderer = new THREE.WebGLRenderer( { antialias: true } ); | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
document.body.appendChild( renderer.domElement ); | |
} | |
function animate() { | |
requestAnimationFrame( animate ); | |
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