Three.js (https://threejs.org/)
  • is a cross-browser JavaScript library and API used to create and display animated 3D computer graphics in a web browser
  • is a WebGL framework

Introduction

Fundamentals

Example HTML

<html>
<head>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r71/three.min.js"></script>
	<style>
		/* We want our scene to span the entire window */
		body { margin: 0; }
	</style>
</head>
<body>
	<script>
		var scene;
		var camera;
		var renderer;
 
		// function to set up scene & camera
		function scene_setup(){
			// First Initialize Scene & Camera
			scene = new THREE.Scene();
			camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
 
			// Create WebGL renderer, then add it into document
			renderer = new THREE.WebGLRenderer();
			renderer.setSize( window.innerWidth, window.innerHeight );
			document.body.appendChild( renderer.domElement );
		}
 
		// function to render everything
		function render() {
			requestAnimationFrame( render );
			renderer.render( scene, camera );
		}
 
		scene_setup();
		// TODO: add your code here!
		render();
	</script>
</body>
</html>

Other