After threejs is downloaded, there is an examples directory with many examples, which is very useful for learning threejs.
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,
- 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
- Open the browser, enter
http://localhost:8000/
, it will display the source code directory, as follows,
- Click the examples directory, it can run normally, and then open an example on the left