Created
May 12, 2018 16:20
-
-
Save guillaumeportails/c01721c57b08b1a8de2295f3bcce5ecc to your computer and use it in GitHub Desktop.
Hello THREE // source https://jsbin.com/duweqer
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="Hello THREE"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r82/three.min.js"></script> | |
<title>Hello THREE</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var camera, scene, renderer, mesh; | |
init(); | |
animate(); | |
function init() { | |
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 ); | |
camera.position.z = 400; | |
scene = new THREE.Scene(); | |
var geometry = new THREE.BoxBufferGeometry( 200, 200, 200 ); | |
var texture = new THREE.TextureLoader().load( 'https://upload.wikimedia.org/wikipedia/commons/c/c2/Snowman_icon.png' ); | |
var material = new THREE.MeshBasicMaterial( { | |
map: texture, | |
color: "green", | |
wireframe: false }); | |
mesh = new THREE.Mesh( geometry, material ); | |
scene.add( mesh ); | |
renderer = new THREE.WebGLRenderer( { antialias: true } ); | |
renderer.setPixelRatio( window.devicePixelRatio ); | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
document.body.appendChild( renderer.domElement ); | |
// | |
window.addEventListener( 'resize', onWindowResize, false ); | |
} | |
function onWindowResize() { | |
camera.aspect = window.innerWidth / window.innerHeight; | |
camera.updateProjectionMatrix(); | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
} | |
function animate() { | |
requestAnimationFrame( animate ); | |
mesh.rotation.x += 0.005; | |
mesh.rotation.y += 0.01; | |
renderer.render( scene, camera ); | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var camera, scene, renderer, mesh; | |
init(); | |
animate(); | |
function init() { | |
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 ); | |
camera.position.z = 400; | |
scene = new THREE.Scene(); | |
var geometry = new THREE.BoxBufferGeometry( 200, 200, 200 ); | |
var texture = new THREE.TextureLoader().load( 'https://upload.wikimedia.org/wikipedia/commons/c/c2/Snowman_icon.png' ); | |
var material = new THREE.MeshBasicMaterial( { | |
map: texture, | |
color: "green", | |
wireframe: false }); | |
mesh = new THREE.Mesh( geometry, material ); | |
scene.add( mesh ); | |
renderer = new THREE.WebGLRenderer( { antialias: true } ); | |
renderer.setPixelRatio( window.devicePixelRatio ); | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
document.body.appendChild( renderer.domElement ); | |
// | |
window.addEventListener( 'resize', onWindowResize, false ); | |
} | |
function onWindowResize() { | |
camera.aspect = window.innerWidth / window.innerHeight; | |
camera.updateProjectionMatrix(); | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
} | |
function animate() { | |
requestAnimationFrame( animate ); | |
mesh.rotation.x += 0.005; | |
mesh.rotation.y += 0.01; | |
renderer.render( scene, camera ); | |
} | |
</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 camera, scene, renderer, mesh; | |
init(); | |
animate(); | |
function init() { | |
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 ); | |
camera.position.z = 400; | |
scene = new THREE.Scene(); | |
var geometry = new THREE.BoxBufferGeometry( 200, 200, 200 ); | |
var texture = new THREE.TextureLoader().load( 'https://upload.wikimedia.org/wikipedia/commons/c/c2/Snowman_icon.png' ); | |
var material = new THREE.MeshBasicMaterial( { | |
map: texture, | |
color: "green", | |
wireframe: false }); | |
mesh = new THREE.Mesh( geometry, material ); | |
scene.add( mesh ); | |
renderer = new THREE.WebGLRenderer( { antialias: true } ); | |
renderer.setPixelRatio( window.devicePixelRatio ); | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
document.body.appendChild( renderer.domElement ); | |
// | |
window.addEventListener( 'resize', onWindowResize, false ); | |
} | |
function onWindowResize() { | |
camera.aspect = window.innerWidth / window.innerHeight; | |
camera.updateProjectionMatrix(); | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
} | |
function animate() { | |
requestAnimationFrame( animate ); | |
mesh.rotation.x += 0.005; | |
mesh.rotation.y += 0.01; | |
renderer.render( scene, camera ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment