Testing and Experimenting with the Examples
Explore the process of setting up, building, and running Three.js example projects, including installing dependencies, using build tools like webpack, and testing 3D scenes in a browser. Understand the project structure and workflow that helps you efficiently create and render your first 3D scene with Three.js.
We'll cover the following...
Install the dependencies
First, we need to download the external libraries. For instance, Three.js is one of the dependencies we need to download.
We need two types of dependencies, one for runtime and the other for development. In the dependencies section (lines 8–19), we have the library three (line 13). This is the primary library for 3D graphics. We also need a build tool to bundle and optimize our projects. In the devDependencies section (lines 20–24), we will use webpack (line 23) for this purpose.
To download all the dependencies, we run the following command:
The preceding command will start downloading all the required JavaScript libraries and store these in the node_modules folder.
Next, we need to build the examples. Doing so will combine our source code and the external libraries into a single file, which we can show ...