setup.html 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. Title: Three.js Setup
  2. Description: How to setup your development environment for three.js
  3. TOC: Setup
  4. This article is one in a series of articles about three.js.
  5. The first article was [about three.js fundamentals](threejs-fundamentals.html).
  6. If you haven't read that yet you might want to start there.
  7. Before we go any further we need to talk about setting up your
  8. computer to do development. In particular, for security reasons,
  9. WebGL cannot use images from your hard drive directly. That means
  10. in order to do development you need to use a web server. Fortunately
  11. development web servers are super easy to setup and use.
  12. First off if you'd like you can download this entire site from [this link](https://github.com/gfxfundamentals/threejsfundamentals/archive/gh-pages.zip).
  13. Once downloaded double click the zip file to unpack the files.
  14. Next download one of these simple web servers.
  15. If you'd prefer a web server with a user interface there's
  16. [Servez](https://greggman.github.io/servez)
  17. {{{image url="resources/servez.gif" className="border" }}}
  18. Just point it at the folder where you unzipped the files, click "Start", then go to
  19. in your browser [`http://localhost:8080/`](http://localhost:8080/) or if you'd
  20. like to browse the samples go to [`http://localhost:8080/threejs`](http://localhost:8080/threejs).
  21. To stop serving pick stop or quit Servez.
  22. If you prefer the command line (I do), another way is to use [node.js](https://nodejs.org).
  23. Download it, install it, then open a command prompt / console / terminal window. If you're on Windows the installer will add a special "Node Command Prompt" so use that.
  24. Then install the [`servez`](https://github.com/greggman/servez-cli) by typing
  25. npm -g install servez
  26. If you're on OSX use
  27. sudo npm -g install servez
  28. Once you've done that type
  29. servez path/to/folder/where/you/unzipped/files
  30. Or if you're like me
  31. cd path/to/folder/where/you/unzipped/files
  32. servez
  33. It should print something like
  34. {{{image url="resources/servez-response.png" }}}
  35. Then in your browser go to [`http://localhost:8080/`](http://localhost:8080/).
  36. If you don't specify a path then servez will serve the current folder.
  37. If either of those options are not to your liking
  38. [there are many other simple servers to choose from](https://stackoverflow.com/questions/12905426/what-is-a-faster-alternative-to-pythons-servez-or-simplehttpserver).
  39. Now that you have a server setup we can move on to [textures](threejs-textures.html).