Besides these text-based editors, which you can use to edit and experiment with the sources from this book, Three.js currently also provides an online editor.
With this editor, which you can find at http://threejs.org/editor/, you can create Three.js scenes using a graphical approach.
Figure 1.4 – Firefox debugger
All the examples in this book will work just as well with Chrome as they do with Firefox. So, if that’s your browser of choice, you can, of course, use that one instead.
Throughout this book, I’ll give you pointers on debugger usage and other debugging tips and tricks. That’s enough by way of an introduction for now; let’s get the source code and start with the first scene.
Getting the source code
All the code for this book is available on GitHub (https://github.com/PacktPublishing/Learn-Three.js-Fourth-edition). GitHub is a site that hosts Git repositories. You can use these to store, access, and version source code. There are a couple of ways that you can get the sources for yourself. You can do either of the following:
- Clone the Git repository. This means you use the
gitcommand-line tool to get the latest version of the sources for this book.
- Download and extract an archive from GitHub, which contains everything.
Using git to clone the repository
One way to get all the examples is to clone this repository using the
git command-line tool. To do this, you need to download a Git client for your operating system. If you’ve got an up-to-date operating system, you probably already have Git installed. You can quickly check this by running the following in a terminal:
$ git --version git version 2.30.1 (Apple Git-130)
If the command isn’t installed yet, you can get a client and instructions on how to install it from here: http://git-scm.com. After installing Git, you can use the
git command-line tool to clone this book’s repository. Open a command prompt and go to the directory where you want to download the sources. In that directory, run the following:
$ git clone https://github.com/PacktPublishing/Learn-Three.js-Fourth-edition. git clone [email protected]:PacktPublishing/Learn-Three.js-Fourth-edition.git Cloning into 'learning-threejs-fourth'... remote: Enumerating objects: 96, done. remote: Counting objects: 100% (96/96), done. remote: Compressing objects: 100% (85/85), done. fetch-pack: unexpected disconnect while reading sideband packet ...
Downloading and extracting the archive
If you don’t want to use
git to download the sources directly from GitHub, you can also download an archive. Open https://github.com/PacktPublishing/Learn-Three.js-Fourth-edition in a browser and click on the Code button on the right-hand side. This will give you the option to download all the sources in a single ZIP file by clicking on the Download ZIP option:
Figure 1.5 – Downloading the archive from GitHub
After extracting this to a directory of your choice, all the examples will become available.
You can also download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files emailed directly to you.