“physi.js”导致错误:“无法从原点‘null’访问脚本”

Dar*_*kas 5 javascript physics-engine three.js physijs

我正在尝试使用 physi.js 库 ()。我遵循了给出的所有步骤:

https://github.com/chandlerprall/Physijs/wiki/Basic-Setup

但是,我得到了错误:

Uncaught SecurityError: Failed to construct 'Worker': Script at 'file://172.16.159.200/js/physijs_worker.js' cannot be accessed from origin 'null'.
Run Code Online (Sandbox Code Playgroud)

我试图更深入,并看到该行的问题:

this._worker = new Worker( Physijs.scripts.worker || 'physijs_worker.js' );
Run Code Online (Sandbox Code Playgroud)

是什么导致了这个问题?浏览器是谷歌浏览器。我检查过,文件“physijs_worker.js”出现在正确的位置。

小智 3

在网络服务器上部署您的网站。如果没有网络服务器,我也会遇到同样的错误。