Chrome
Three.js
html
使用 Three.js 加载本地纹理图片时,发现加载出来的 3D 模型会所有为黑色,发现是浏览器跨域问题。
浏览器报错为:web
index.html:1 Access to Image at 'file:///Users/inxx/Code/Github/Note/WebGL/3D%E7%94%B5%E6%B0%94%E5%AE%A4/img/floor.jpg' from origin 'null' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access.
注意: --前面有个空格
若是是 49 以上的版本:
步骤和上面的同样,只是第4步的参数稍微不同。跨域
--disable-web-security --user-data-dir=C:\MyChromeDevUserData
注:C:MyChromeDevUserData 是你本地硬盘的一个目录,你本身最好新建一个,上面的目录路径换成你新建的目录就能够了。
在终端中输入浏览器
open -a /Applications/Google\ Chrome.app --args --disable-web-security --user-data-dir