我正在尝试加载.mtl
和.obj
文件。从我所看到的渲染,我们得到.obj
,有点正确:
但是,如果我在Blender中加载相同的.obj
文件,我会得到:
以下是与.mtl
相关联的.obj
文件,该文件指的是完全相同文件夹中的.tif
和.jpg
个文件:
newmtl Material_01_01
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 0.6627 0.6471 0.6471
Kd 0.6627 0.6471 0.6471
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
newmtl Material_01_02
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 0.6627 0.6471 0.6471
Kd 0.6627 0.6471 0.6471
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
map_Ka Map_01.tif
map_Kd Map_01.tif
newmtl Material_01_03
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 1.0000 1.0000 1.0000
Kd 1.0000 1.0000 1.0000
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
newmtl Material_01_04
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 0.6627 0.6471 0.6471
Kd 0.6627 0.6471 0.6471
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
map_Ka Map_02.jpg
map_Kd Map_02.jpg
我看过mrdoobs对OBJLoader
和MTLLoader
here的实现并完全实现了它,但我既没有获得图像也没有获得灰色。为什么呢?
let canvas = {}, shape, objLoader;
let manager = new THREE.LoadingManager();
const PATH = 'http://localhost:8080/';
const FILENAME = 'Sample_01_OBJ';
let mtlLoader = new THREE.MTLLoader();
mtlLoader.setPath(PATH)
mtlLoader.load(FILENAME+'.mtl', (materials) => {
materials.preload();
objLoader = new THREE.OBJLoader();
objLoader.setMaterials(materials);
objLoader.setPath(PATH);
this.setup(canvas, true, false);
this.image = image;
objLoader.load(FILENAME+'.obj', (obj) => {
canvas['scene'].add(obj);
canvas['shape'] = obj;
this.addRendererToElement(EXAMPLE_ITEMS, canvas);
this.addCameraControls(canvas);
this.render(canvas, canvas['update'], 'blender0');
});
});