Threejs Official website-How do I do local things (how to run things locally)

Source: Internet
Author: User
Tags base64 image png

Threejs Official website-How do I do local things (how to run things locally)

The beautiful Life of the Sun Vulcan (http://blog.csdn.net/opengl_es)

This article follows "Attribution-non-commercial use-consistent" authoring public agreement

Reprint Please keep this sentence: Sun Vulcan's Beautiful Life-this blog focuses on Agile development and mobile and IoT device research: IOS, Android, HTML5, Arduino, Pcduino , or else. From this blog article refused to reprint or re-reproduced, thank you for your cooperation.




How do I do local things (how to run things locally) nme01 edited this pageon + Nov· Revisions

Procedural content

If you use just procedural geometries and don ' t load any textures, webpages should work straight from the file system, jus t double-click on HTML file-a file manager and it should appear working in the browser (accessed as file:///example ).

Content loaded from external files

IF you load models or textures from external files, due to browsers ' "Same Origin policy" security restrictions, loading F Rom a file system would fail with a security exception.

There is ways how to solve this:

    1. change Security for local files in a browser (Access page As file:///example )

    2. run files from a local server (Access page As http://localhost/example )

if You use option 1, being aware that you may open yourself to some vulnerabilities If using the same BR Owser for a regular web surfing. Want to create a separate browser profile/shortcut used just for local development to be safe.

Change local Files Security Policysafari

Enable the Develop menu using the Preferences panel, under Advanced--"Show develop menu in menu bar"

Then from the Safari "Develop" menu, select "Disable Local file Restrictions", it's also worth noting Safari has some odd Behaviour with caches, so it's advisable to use the ' Disable caches ' option in the same menu; If you are editing & debugging using Safari.

Chrome

Close all running chrome instances first. Then start Chrome executable with a command line flag:

chrome --allow-file-access-from-files

On Windows, the easiest are probably to create a special shortcut which have added flag (right-click on shortcut Prope Target, Rties.

Firefox
  1. Go toabout:config
  2. Find security.fileuri.strict_origin_policy parameter
  3. Set It to false
Run Local server

The simplest probably is to use Python's built-in HTTP server.

If you have Python installed, it should is enough to run the from a command line:

# Python 2.xpython-m simplehttpserver
# Python 3.xpython-m http.server

This would serve files from the current directory at localhost under Port 8000:

Http://localhost:8000/

If you have a Ruby installed, you can get the same result running this instead:

"s = webrick::httpserver.new (:P ort = 8000,:D ocumentroot = dir.pwd); Trap (' INT ') {s.shutdown}; S.start "

PHP also have a built-in Web server, starting with PHP 5.4.0:

Php-s localhost:8000

node. JS has a simple HTTP server package. To install:

NPM Install Http-server-g

To run:

Http-server.

Other simple alternatives is discussed here on Stack Overflow.

Of course, you can use any other regular full-fledged Web server like Apache or Nginx.

Example with LIGHTTPD, which are a very lightweight general purpose webserver (on MAC OSX):

  1. Install it via homebrewbrew install lighttpd
  2. Create a configuration file called lighttpd.conf in the directory where you want to run your webserver. There is a sample on this page.
  3. In the conf file, change the server.document-root with the directory you want to serve
  4. Start it withlighttpd -f lighttpd.conf
  5. Navigate to Http://localhost:3000/and It'll serve static files from the directory you chose.


Threejs Official website-How do I do local things (how to run things locally)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.