Threejs 官网 - 怎样执行本地的东西(How to run things locally)

Threejs 官网 - 怎样执行本地的东西(How to run things locally)

太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es)

本文遵循“署名-非商业用途-保持一致”创作公用协议

转载请保留此句:太阳火神的漂亮人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino,否则。出自本博客的文章拒绝转载或再转载,谢谢合作。

怎样执行本地的东西(How to run things locally)

nme01 edited this page on 26 Nov 2013 · 13 revisions

Procedural content

If you use just procedural geometries and don‘t load any textures, webpages should work straight from the file system, just double-click on HTML file in 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 from a file system will fail with a security exception.

There are two 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, be aware that you may open yourself to some vulnerabilities if using the same browser for a regular web surfing. You may want to create a separate browser profile / shortcut used just for local development to be safe.


Change local files security policy

Safari

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 is also worth noting safari has some odd behaviour with caches, so it is 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 is probably to create a special shortcut which has added flag (right-click on shortcut -> properties -> target).

Firefox

  1. Go to about: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 be enough to run this from a command line:

# Python 2.x
python -m SimpleHTTPServer
# Python 3.x
python -m http.server

This will serve files from the current directory at localhost under port 8000:

http://localhost:8000/

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

ruby -r webrick -e "s = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => Dir.pwd); trap(‘INT‘) { s.shutdown }; s.start"

PHP also has 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 are 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 is a very lightweight general purpose webserver (on MAC OSX):

  1. Install it via homebrew brew install lighttpd
  2. Create a configuration file called lighttpd.conf in the directory where you want to run your webserver. There is a sample in this page.
  3. In the conf file, change the server.document-root with the directory you want to serve
  4. Start it with lighttpd -f lighttpd.conf
  5. Navigate to http://localhost:3000/ and it will serve static files from the directory you chose.
时间: 2024-10-05 16:56:40

Threejs 官网 - 怎样执行本地的东西(How to run things locally)的相关文章

Threejs 官网 - 如何运行本地的东西(How to run things locally)

太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. 如何运行本地的东西(How to run things locally) nme01 edited this page on 26 Nov 201

Threejs 官网 - 检测使用 three.js 时的 WebGL 和浏览器兼容性(Detecting WebGL and browser compatibility with three.js)

检测使用 three.js 时的 WebGL 和浏览器兼容性(Detecting WebGL and browser compatibility with three.js) 太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章

Threejs 官网 - 不可见对象(Invisible objects)

太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. 不可见对象 Invisible objects gero3 edited this page on 8 Dec 2012 · 1 revision

在NTFS For Mac官网将会获得哪些东西

当我们使用Mac的时候,如果出现Mac无法读写移动硬盘的时候,我们会去网站上下载ntfs for mac来使用.小编在这里还是建议大家去ntfs for mac官网购买正版,正版软件对我们的苹果电脑有很大的保护.那么我们在ntfs for mac官网会获得哪些东西呢? NTFS For Mac官网发布的产品有以下几种: 1.paragon软件公司和经销商的盒包装 2.Internet和web站点的下载包 3.Ntfs for mac序列号以及CleanMyMac序列号套装 4.软件的维护和服务

Threejs 官网 - Three.js 的图形用户界面工具(GUI Tools with Three.js)

太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的漂亮人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino.否则,出自本博客的文章拒绝转载或再转载.谢谢合作. Three.js 的图形用户界面工具(GUI Tools with Three.js) mrdoob edited this page on 24

Threejs 官网 - 入门指南(Getting Started)

太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. 入门指南(Getting Started ) chinedufn edited this page on 4 Mar 2013 · 9 revis

微赞,你正在使用本地安装, 但未下载完整安装包, 请从微赞官网下载完整安装包后重试.

你正在使用本地安装, 但未下载完整安装包, 请从微赞官网下载完整安装包后重试. 解决方法: 路径中不能中文.

cv/dl/cl领域的实验室官网/牛人主页/技术论坛/比赛数据库/好玩的东西

一(自己整理的) #技术论坛 1/mit的关于关于机器人的技术review https://www.technologyreview.com/c/robotics/ 2/valse视觉与学习青年学者讨论会 http://valser.org/ 3/人工智能资讯平台/机器人/机器视觉 http://www.ailab.cn/robot/Machine_vision/ #比赛 1/pascal voc 含各种代码和数据库 http://www.eecs.berkeley.edu/Research/P

Go语言学习笔记——在本地建立一个官网查看

命令行内运行 godoc -http=:8080 运行完成后打开浏览器输入网址:http://localhost:8080能看到一个和官网一模一样的网站,然后查看帮助文档 原文地址:https://www.cnblogs.com/liyao0312/p/8342661.html