three.js

v0.187.0

3D graphics library for the web built on WebGL and WebGPU.

Quick start

Add this tag to your page. This library is published as ES modules. See the complete example below for how to load it with an import map.

HTML
<script type="module" src="https://jscdns.net/libs/three/0.187.0/three.module.js"
        integrity="sha384-T/E3B9AvPtLn5PKD7aTSFqizQcA4kHDfU0lub7u0fvM4w9BMGcSb3yI7r5LqMAMn" crossorigin="anonymous"></script>

Files

FileSizeCopy
three.module.jsES module 643.5 KB
three.core.jsES module 1.41 MB

Usage

Complete example

three.js is loaded as an ES module through an import map. Modules must be served over HTTP, so run this from a local web server rather than opening the file directly.

example.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
</head>
<body>
  <canvas id="scene"></canvas>

  <script type="importmap">
  {
    "imports": {
      "three": "https://jscdns.net/libs/three/0.187.0/three.module.js"
    }
  }
  </script>

  <script type="module">
    import * as THREE from 'three';

    const canvas = document.querySelector('#scene');
    const renderer = new THREE.WebGLRenderer({ canvas, antialias: true });
    renderer.setSize(400, 300);

    const scene = new THREE.Scene();
    const camera = new THREE.PerspectiveCamera(70, 400 / 300, 0.1, 100);
    camera.position.z = 2;

    const cube = new THREE.Mesh(
      new THREE.BoxGeometry(),
      new THREE.MeshNormalMaterial()
    );
    scene.add(cube);

    renderer.setAnimationLoop(function () {
      cube.rotation.x += 0.01;
      cube.rotation.y += 0.01;
      renderer.render(scene, camera);
    });
  </script>
</body>
</html>
Good to know. three.js is published as ES modules only. three.module.js imports three.core.js from the same folder, so both are hosted side by side. An import map lets you write import from 'three' in your code.