Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Three.js Cookbook
  • Table Of Contents Toc
Three.js Cookbook

Three.js Cookbook

By : Jos Dirksen
4 (8)
close
close
Three.js Cookbook

Three.js Cookbook

4 (8)
By: Jos Dirksen

Overview of this book

This book is ideal for anyone who already knows JavaScript and would like to get a broad understanding of Three.js quickly, or for those of you who have a basic grasp of using Three.js but want to really make an impact with your 3D visualizations by learning its advanced features. To apply the recipes in this book you don’t need to know anything about WebGL; all you need is some general knowledge about JavaScript and HTML.
Table of Contents (9 chapters)
close
close
8
Index

Setting up a local web server with Python

The best way to test your Three.js applications, or any JavaScript application for that matter, is to run it on a local web server. This way, you have the best representation of how your users will eventually see your Three.js visualization. In this chapter, we will show you three different ways in which you can run a web server locally. The three different ways to set up a local web server are:

  • One way to do this is via a Python-based approach that you can use if you've got Python installed
  • Another way is to do if you use Node.js or have already played around with Node.js, you can use the npm command to install a simple web server
  • A third option is if you don't want to use the npm command or Python, you can also use Mongoose, which is a simple portable web server, that runs on OS X and Windows

This recipe will focus on the Python-based approach (the first bullet point).

Getting ready

If you've got Python installed, you can very easily run a simple web server. You will first need to check whether you've got Python installed. The easiest way to do this is just type in python on a console and hit enter. If you see an output as follows, you are ready to begin:

> python
Python 2.7.3 (default, Apr 10 2013, 05:09:49) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

How to do it...

  1. Once Python (http://python.org) has been installed, you can run a simple web server by just executing the following Python command. You will need to do this in the directory from where you want to host the files:
    > python -m SimpleHTTPServer
    
  2. The following output shows the web server running on port 8000:
    Serving HTTP on 0.0.0.0 port 8000...
    

If you don't have Python installed, take a look at one of the following two recipes for alternative options.

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Three.js Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon