I was trying to play with physi.js library (). I followed all the steps given:
https://github.com/chandlerprall/Physijs/wiki/Basic-Setup
However, I got the error:
Uncaught SecurityError: Failed to construct 'Worker': Script at 'file://172.16.159.200/js/physijs_worker.js' cannot be accessed from origin 'null'.
I tried to go deeper, and saw that the problem with the line:
this._worker = new Worker( Physijs.scripts.worker || 'physijs_worker.js' );
What did cause that issue? The browser is Google Chrome. I checked, the file "physijs_worker.js" appears in the right location.
Browsers don't allow creating workers from local files because that would be a security issue.
See also this question:
Why does not Chrome allow Web Workers to be run in JavaScript?
Just add the chrome extension https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb?hl=en
and use the extension to launch your index.html. As now it will be running in localhost, there will be no error
Deploy your website on a web server. Without the web server I get the same error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With