我正在尝试使用 JSONLoader
将 3D 模型加载到 Three.js 中,并且该 3D 模型与整个网站位于同一目录中。
我收到 "Cross origin requests are only supported for HTTP."
错误,但我不知道是什么原因造成的,也不知道如何解决。
最佳答案
我的 Crystal 球说您正在使用 file://
或 C:/
加载模型,这与错误消息保持一致,因为它们不是 http://
因此,您可以在本地 PC 上安装网络服务器或将模型上传到其他地方并使用 jsonp
并将 url 更改为 http://example.com/path/to/型号
原点在 RFC-6454 中定义作为
...they have the same
scheme, host, and port. (See Section 4 for full details.)
所以即使你的文件来自同一个主机(localhost
),但只要方案不同(http
/file
),它们被视为不同的来源。
关于javascript - "Cross origin requests are only supported for HTTP."加载本地文件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10752055/