在Chrome上使用THREE.js在本地图片上拒绝跨源图片加载 [英] Cross-origin image load denied on a local image with THREE.js on Chrome
问题描述
我在使用THREE.js,并在开发人员控制台中收到这个错误:
I'm using THREE.js and I get this error in the developer console:
Cross-origin image load denied by Cross-Origin Resource Sharing policy.
代码如下:
when I open my script with Chrome. The code looks like this:
var particle_system_material = new THREE.ParticleSystemMaterial({
color: 0xffffff,
map: THREE.ImageUtils.loadTexture("images/circle.png"),
});
正如你可以猜到的:
map: THREE.ImageUtils.loadTexture("images/circle.png");
是问题。
对于Firefox,它工作得很好。
is the problem. With Firefox it works very well.
我已阅读以下链接中的提示:
CHROME,JS:跨源图片加载被拒绝,
https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally ,
https://www.google.fr/search?q=访问控制允许来源
I've read the tips in the following links : CHROME,JS: Cross-origin image load denied, https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally, https://www.google.fr/search?q=Access-Control-Allow-Origin
我也意识到了给出的命令:
I also realized the commands given:
使用命令行标志启动Chrome可执行文件:
chrome --allow-file-access-from-files
chrome --allow-file-access-from-files
没有什么工作,我会疯了。它只是我的硬盘上的一个图像与HTML和JS文件,没有服务器,没有源。
nothing works and I'm going crazy. It is just an image on my hard drive with HTML and JS files, no server, no "origin".
推荐答案
请注意,如果您使用停用网络安全标记启动Chrome,则必须先关闭所有其他Chrome实例,才能使其正常运行。
Keep in mind that if you start chrome with the disable web security flag, you must first shut down all other instances of chrome in order for it to work as you expect.
这篇关于在Chrome上使用THREE.js在本地图片上拒绝跨源图片加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!