问题描述
我在使用Three.js尝试加载.json和.mtl文件。 使用Firefox Webbrowser。
var loaders = new THREE.OBJLoader();
// using the loader in a call back to load the model which is json here
loader.load('Access-Control-Allow-Origin:http://localhost:8080/earth.json',function(object){
scene.add(object);
},
它没有给出任何错误,但未显示任何结果。 在调试代码时,我发现调试指针不在load()方法内部。
样本观察是针对MTLLoader的,即调试指针不在load()内部。 编码有问题吗?我错过了什么吗?
var mtlLoader = new THREE.MTLLoader(); // mtl loader
mtlLoader.load('Access-Control-Allow-Origin:http://localhost:8081/Gargoyle_1.mtl',function (materials) {
materials.preload(); // preloading the mtl first
var objLoader = new THREE.OBJLoader(); // use the OBJLoader for .obj files
objLoader.setMaterials(materials);
objLoader.setPath('/models/Gargoyle_1_Obj/');
objLoader.load('Gargoyle_1.obj',function (object) {
scene.add(object);
object.position.y -= 70; //positioning the model in the scene
object.position.x += 10;
object.translateZ(10);
var light = new THREE.PointLight( 0xff0000,1,100 ); // light type
light.position.set( 50,50,50 ); // light position
scene.add( light ); //adding light to scene
});
});
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)