嘿伙计们我正在尝试在本地加载一个文件作为测试THREE.js的测试,但无论出于何种原因我得到了这个:
THREE.WebGLRenderer 66 three.min.js:433
XMLHttpRequest cannot load http://localhost:8000/treehouse_logo.js. No 'Access-Control-Allow- Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. playground.html:1
THREE.JSONLoader: "http://localhost:8000/treehouse_logo.js" seems to be unreachable or the file is empty. three.min.js:236
我正在使用Node js http-server调用:
http-server -p 8000
这是我的html文件中的脚本:
var loader = new THREE.JSONLoader();
loader.load("http://localhost:8000/treehouse_logo.js", function (geometry){
var material = new THREE.MeshLambertMaterial({color:0x55b663});
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
});
html,js文件和http-server调用都在同一目录中。如果你能发现我做错了什么就会很棒。对不起,我对这一切都有点新鲜。