Tutorial: How to run local webgl apps with Chrome
By dcantor . March 26, 2014 . tutorials. |
If you are developing your webgl app locally using Chrome you probably have run into the problem where geometry cannot be loaded in the background using AJAX ($.get() anyone?) The reason for this is that Chrome is rather restrictive about loading resources when you work under the file:// protocol. Usually this is not a problem when you have a local web server. With a local web server you can work under http:// without any issues.
However developing without a local web server is still possible with Chrome. All you need to do is to invoke chrome from the command line passing the flag --allow-file-access-from-files
Let’s see how to accomplish this in Ubuntu Linux 12.07 , MacOS Mavericks and Windows 7:
Add this alias to your .bashrc
file
alias chromex='/usr/lib/chromium-browser/chromium-browser --allow-file-access-from-files'
Then reload your .bashrc file, typing the following from the terminal:
source ~/.bashrc
Then you can open chrome using the alias that you just created by typing cromex
on a terminal. Make sure the flag is enabled by looking on the chrome::/version
screen:
In Mavericks the procedure is similar as in Ubuntu Linux.
Add this alias to your .bash_profile
file
alias chromex='open /Applications/Google\ Chrome.app --args --allow-file-access-from-files'
Then reload your .bashrc file, typing the following from the terminal:
source ~/.bash_profile
Then you can open chrome using the alias that you just created by typing cromex
on a terminal. Make sure the flag is enabled by looking on the chrome::/version
screen:
There are two different ways to do this in windows. The first and fastest is just to open a command prompt and write:
start chrome --allow-file-access-from-files
The second way is to create a shortcut in your desktop and modify it by adding the command line modifier like this:
Lastly, make sure you confirm the flag has been enabled by looking at the chrome://version
screen:
Leave a Reply