How to run the examples in threejs

After threejs is downloaded, there is an examples directory with many examples, which is very useful for learning threejs.
Insert picture description here
Enter the example directory, directly open the html files in it, and find that most of them cannot run. Because these html files need to load local files, they will encounter browser cross-domain problems, so how to run it? The official website gives the method, you can click here

You can also directly refer to my steps to operate.


step

The main principle is to use Python3 to build a simple web server, through this server to access these html examples,

  1. Start the server in the source code directory. Note that it is the source code directory, not the exmples directory. Open dos, switch to the source directory, and enter the following command
    python -m http.server
    
  2. Open the browser, enter http://localhost:8000/, it will display the source code directory, as follows,
    Insert picture description here
  3. Click the examples directory, it can run normally, and then open an example on the left
    Insert picture description here

Guess you like

Origin blog.csdn.net/whahu1989/article/details/109321086