three.js
JavaScript 3D library
The aim of the project is to create an easy to use, lightweight, 3D library with a default WebGL renderer. The library also provides Canvas 2D, SVG and CSS3D renderers in the examples.
Examples —
Documentation —
Wiki —
Migrating —
Questions —
Forum —
Gitter —
Slack
Usage
Download the minified library and include it in your HTML, or install and import it as a module,
Alternatively, see how to build the library yourself.
1 | <script src="js/three.min.js"></script> |
This code creates a scene, a camera, and a geometric cube, and it adds the cube to the scene. It then creates a WebGL
renderer for the scene and camera, and it adds that viewport to the document.body
element. Finally, it animates the cube within the scene for the camera.
1 | var camera, scene, renderer; |
If everything went well you should see this.