"physi.js" raises an error: "Script cannot be retrieved from source" null ""

I was trying to play with physi.js library (). I followed these steps:

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 was with the line:

this._worker = new Worker( Physijs.scripts.worker || 'physijs_worker.js' );

      

What caused this problem? Google Chrome browser. I have verified that the "physijs_worker.js" file appears in the correct location.

+3


source to share


3 answers


Deploy your website on a web server. Without the web server, I get the same error.



+2


source


Browsers do not allow creating workers from local files as this would be a security issue.

See also this question:



Why doesn't Chrome let web workers run in JavaScript?

+2


source


Just add a chrome extension https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb?hl=en

and use the extension to run index.html. Since it will now run on localhost, there will be no error

0


source







All Articles