setup.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!DOCTYPE html><html lang="en"><head>
  2. <meta charset="utf-8">
  3. <title>Setup</title>
  4. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  5. <meta name="twitter:card" content="summary_large_image">
  6. <meta name="twitter:site" content="@threejs">
  7. <meta name="twitter:title" content="Three.js – Setup">
  8. <meta property="og:image" content="https://threejs.org/files/share.png">
  9. <link rel="shortcut icon" href="../../files/favicon_white.ico" media="(prefers-color-scheme: dark)">
  10. <link rel="shortcut icon" href="../../files/favicon.ico" media="(prefers-color-scheme: light)">
  11. <link rel="stylesheet" href="../resources/lesson.css">
  12. <link rel="stylesheet" href="../resources/lang.css">
  13. <script type="importmap">
  14. {
  15. "imports": {
  16. "three": "../../build/three.module.js"
  17. }
  18. }
  19. </script>
  20. </head>
  21. <body>
  22. <div class="container">
  23. <div class="lesson-title">
  24. <h1>Setup</h1>
  25. </div>
  26. <div class="lesson">
  27. <div class="lesson-main">
  28. <p>This article is one in a series of articles about three.js.
  29. The first article was <a href="fundamentals.html">about three.js fundamentals</a>.
  30. If you haven't read that yet you might want to start there.</p>
  31. <p>Before we go any further we need to talk about setting up your
  32. computer as a development environment. In particular, for security reasons,
  33. WebGL cannot use images from your hard drive directly. That means
  34. in order to do development you need to use a web server. Fortunately
  35. development web servers are super easy to setup and use.</p>
  36. <p>First off if you'd like you can download this entire site from <a href="https://github.com/gfxfundamentals/threejsfundamentals/archive/gh-pages.zip">this link</a>.
  37. Once downloaded double click the zip file to unpack the files.</p>
  38. <p>Next download one of these simple web servers.</p>
  39. <p>If you'd prefer a web server with a user interface there's
  40. <a href="https://greggman.github.io/servez">Servez</a></p>
  41. <p></p><div class="threejs_image border">
  42. <img class="" src="../resources/servez.gif">
  43. </div>
  44. <p></p>
  45. <p>Just point it at the folder where you unzipped the files, click "Start", then go to
  46. in your browser <a href="http://localhost:8080/"><code class="notranslate" translate="no">http://localhost:8080/</code></a> or if you'd
  47. like to browse the samples go to <a href="http://localhost:8080/threejs"><code class="notranslate" translate="no">http://localhost:8080/threejs</code></a>.</p>
  48. <p>To stop serving click stop or quit Servez.</p>
  49. <p>If you prefer the command line (I do), another way is to use <a href="https://nodejs.org">node.js</a>.
  50. 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.</p>
  51. <p>Then install the <a href="https://github.com/greggman/servez-cli"><code class="notranslate" translate="no">servez</code></a> by typing</p>
  52. <pre class="prettyprint showlinemods notranslate notranslate" translate="no">npm -g install servez
  53. </pre><p>If you're on OSX use</p>
  54. <pre class="prettyprint showlinemods notranslate notranslate" translate="no">sudo npm -g install servez
  55. </pre><p>Once you've done that type</p>
  56. <pre class="prettyprint showlinemods notranslate notranslate" translate="no">servez path/to/folder/where/you/unzipped/files
  57. </pre><p>Or if you're like me</p>
  58. <pre class="prettyprint showlinemods notranslate notranslate" translate="no">cd path/to/folder/where/you/unzipped/files
  59. servez
  60. </pre><p>It should print something like</p>
  61. <p></p><div class="threejs_image ">
  62. <img class="" src="../resources/servez-response.png">
  63. </div>
  64. <p></p>
  65. <p>Then in your browser go to <a href="http://localhost:8080/"><code class="notranslate" translate="no">http://localhost:8080/</code></a>.</p>
  66. <p>If you don't specify a path then servez will serve the current folder.</p>
  67. <p>If either of those options are not to your liking
  68. <a href="https://stackoverflow.com/questions/12905426/what-is-a-faster-alternative-to-pythons-servez-or-simplehttpserver">there are many other simple servers to choose from</a>.</p>
  69. <p>Now that you have a server setup we can move on to <a href="textures.html">textures</a>.</p>
  70. </div>
  71. </div>
  72. </div>
  73. <script src="../resources/prettify.js"></script>
  74. <script src="../resources/lesson.js"></script>
  75. </body></html>