我正在学习three.js。我已经将对象的.obj文件转换为.js文件,并使用JSONLoader加载该对象。它显示在Firefox浏览器上。但它在控制台中显示的javascript异常如下:
not well-formed Porsche_911_GT2.js:1:1
与我在chrome浏览器上运行的代码相同。但那个物体并没有显示出来。控制台中存在以下错误:
XMLHttpRequest cannot load file:///C:/Users/inwindow/Desktop/webGL/myTHREE.js/obj/car/Porsche_911_GT2.js. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. three.min.js:263
THREE.JSONLoader: "obj/car/Porsche_911_GT2.js" seems to be unreachable or the file is empty. three.min.js:262
Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///C:/Users/inwindow/Desktop/webGL/myTHREE.js/obj/car/Porsche_911_GT2.js'. three.min.js:263
为什么会发生这种情况?有人能帮帮我吗?
将Porsche_911_GT2.js的本地服务器相对url提供给JSONLoader。它不适用于文件协议。。。它应该在服务器上,并且可以通过http或https协议访问。