使用.mtl和.obj文件时未加载的图像

时间:2016-09-20 14:02:59

标签: javascript three.js

我正在尝试加载.mtl.obj文件。从我所看到的渲染,我们得到.obj,有点正确:

enter image description here

但是,如果我在Blender中加载相同的.obj文件,我会得到:

enter image description here

以下是与.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对OBJLoaderMTLLoader 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');
    });
  });  

0 个答案:

没有答案