Three.js加载模型缺失凹凸和镜面映射

时间:2014-03-04 15:06:12

标签: javascript three.js 3dsmax .obj

我在使用three.js中的导入模型进行凹凸和镜面映射时遇到了麻烦。

我正在将模型从3DS Max导出到.obj文件,然后使用convert_obj_three.py脚本将其转换为.js。在model.js文件中,我可以看到凹凸和高光贴图正在出现:

"materials": [  {
    "DbgColor" : 15658734,
    "DbgIndex" : 0,
    "DbgName" : "flloor_bump_test",
    "illumination" : 2,
    "mapAmbient" : "sat_8.jpg",
    "mapBump" : "sat_8_bump.jpg",
    "mapDiffuse" : "sat_8.jpg",
    "mapSpecular" : "sat_8_spec.png",
    "opticalDensity" : 1.5,
    "specularCoef" : 25.0,
    "transparency" : 0.0
},

以下是我将模型加载到场景中的方法:

var jsonLoader = new THREE.JSONLoader();
jsonLoader.load( "model.js", addModelToScene );

function addModelToScene( geometry, materials )
{
    var material = new THREE.MeshFaceMaterial( materials );
    model = new THREE.Mesh( geometry, material );
    model.scale.set(0.01,0.01,0.01);

    model.castShadow = true;
    model.receiveShadow = true;

    scene.add( model );
}

任何想法都非常感谢!谢谢!

修改

以下是我的现场演示的链接 - http://benbeckford.com/temp/

编辑2

因此,在使用它之后,我可以看到转换后的.js模型中缺少以下数据:

"shading" : "phong",
"mapSpecular" : "powerday_sat_8_specular.png",
"shininess" : 1000,
"mapBumpScale" : 5,

很明显,我从Max导出到.obj或将.obj转换为.js时出现问题。如果有人解决了这个问题,我真的很感激你是如何做到的!谢谢:))

1 个答案:

答案 0 :(得分:2)

我最终手动编辑.js模型并添加字段使其如下所示:

"materials": [  {
    "DbgColor" : 15658734,
    "DbgIndex" : 0,
    "DbgName" : "21___Default",
    "colorAmbient" : [0.588235, 0.588235, 0.588235],
    "colorDiffuse" : [0.588235, 0.588235, 0.588235],
    "colorSpecular" : [0.117, 0.117, 0.117],
    "illumination" : 2,
    "mapAmbient" : "texture_8.jpg",
    "mapDiffuse" : "texture_8.jpg",
    "shading" : "phong",
    "mapSpecular" : "texture_8_specular.png",
    "shininess" : 1000,
    "mapBumpScale" : 5,
    "mapBump" : "texture_8_bump.jpg",
    "opticalDensity" : 1.5,
    "specularCoef" : 1000,
    "transparency" : 0.0
}