Importing Three.js as Module

Sean Bradley
Threejs Tutorials
Published in
6 min readAug 6, 2020

--

Photo by pawel szvmanski on Unsplash

When updating older Threejs projects, you may get a warning in the browser such as,

“As part of the transition to ES6 Modules, the files in ‘examples/js’ were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124).”

There are several steps involved in converting your Threejs projects to use modules, and In this article I will show you a very quick and simple way of handling this problem.

The steps I will show are,

  1. Create the basic project
  2. Install Three
  3. Create the basic NodeJS server
  4. Create the client HTML and JavaScript
  5. Create the start script
  6. Start it and see it running in the browser

This will be a simple Three.js example that uses Module Specifiers in the client.

The code demonstrated in this article can also be found at my official GitHub page at https://github.com/Sean-Bradley/Threejs-Boilerplate

Create the basic project

Create a working folder on your computer somewhere. eg, mkdir myproject

--

--

Sean Bradley
Threejs Tutorials

Developer of real time, low latency, high availability, asynchronous, multi threaded, remotely managed, fully automated and monitored solutions.