Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Your own Minecraft, 
thanks to three.js!

Your own Minecraft, 
thanks to three.js!

Everything is possible thanks to JavaScript. The only limit is your imagination!

Bert Timmermans

March 15, 2015
Tweet

More Decks by Bert Timmermans

Other Decks in Programming

Transcript

  1. 1 5 2 2 4 1 0 3 2 5

    3 2 0 5 3 4
  2. 5 4 4 5 3 1 2 1 1 1

    2 3 2 3 4 3 3 2 0 1 0 0 1 1 2 2 3 4 5 5 4 3 1 1 4 4 3 3 2 2 2 2 4 3 3 4 3 2 1 1 0 0 0 4 3 3 2 2 3 2 4 5 3 3
  3. 5 4 4 5 3 1 2 1 1 1

    2 3 2 3 4 3 3 2 0 1 0 0 1 1 2 2 3 4 5 5 4 3 1 1 4 4 3 3 2 2 2 2 4 3 3 4 3 2 1 1 0 0 0 4 3 3 2 2 3 2 4 5 3 3
  4. 1

  5. <html> <head> <title>My first Three.js app</title> <style> body { margin:

    0px; } canvas { width: 100%; height: 100%; } </style> </head> <body> <script src=“js/three.js"></script> <script> // Our code goes here </script> </body> </html> Example.html
  6. // Scene var scene = new THREE.Scene(); // Renderer var

    renderer = new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); // Camera var camera = new THREE.PerspectiveCamera(75, window.innerWidth/ window.innerHeight, 1, 10000); camera.position.z = 4; scene.add(camera); // Cube var geometry = new THREE.BoxGeometry(1, 1, 1); var material = new THREE.MeshLambertMaterial({ color: 'blue' }); var cube = new THREE.Mesh(geometry, material); scene.add(cube); // Ambient lighting var ambientLight = new THREE.AmbientLight(0x000044); scene.add(ambientLight); Example.html
  7. // Directional lighting var directionalLight = new THREE.DirectionalLight(0xffffff); directionalLight.position.set(1, 1,

    1); scene.add(directionalLight); // Render function function render() { requestAnimationFrame(render); cube.rotation.x += 0.01; cube.rotation.y += 0.01; renderer.render(scene, camera); }; render(); Example.html
  8. “ Ambient occlusion is a shading and rendering technique used

    to calculate how exposed each point in a scene is to ambient lighting. ” Ambient occlusion
  9. 5 4 4 5 3 1 2 1 1 1

    2 3 2 3 4 3 3 2 0 1 0 0 1 1 2 2 3 4 5 5 4 3 1 1 4 4 3 3 2 2 2 2 4 3 3 4 3 2 1 1 0 0 0 4 3 3 2 2 3 2 4 5 3 3
  10. 5 4 4 5 3 1 2 1 1 1

    2 3 2 3 4 3 3 2 0 1 0 0 1 1 2 2 3 4 5 5 4 3 1 1 4 4 3 3 2 2 2 2 4 3 3 4 3 2 1 1 0 0 0 4 3 3 2 2 3 2 4 5 3 3