在 Chrome 上使用 THREE.js 在本地图像上拒绝跨源图像加载 [英] Cross-origin image load denied on a local image with THREE.js on Chrome

查看:28
本文介绍了在 Chrome 上使用 THREE.js 在本地图像上拒绝跨源图像加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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.

当我用 Chrome 打开我的脚本时.代码如下所示:

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,three.js:拒绝跨源图片加载https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally,https://www.google.fr/search?q=Access-Control-Allow-Origin

I've read the tips in the following links : Chrome, three.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆