Javascript Three.js加载的模型缺少凹凸贴图和镜面反射贴图
在three.js中,我很难在导入的模型上使用凹凸贴图和镜面反射贴图 我将模型从3DS Max导出到.obj文件,然后使用convert_obj_three.py脚本将其转换为.js。在model.js文件中,我可以看到凹凸贴图和镜面反射贴图:Javascript Three.js加载的模型缺少凹凸贴图和镜面反射贴图,javascript,three.js,3dsmax,.obj,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,
"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 );
}
非常感谢您的任何想法!谢谢
编辑
这是我的现场演示的链接-
编辑2
因此,在使用它之后,我可以看到转换后的.js模型中缺少以下数据:
"shading" : "phong",
"mapSpecular" : "powerday_sat_8_specular.png",
"shininess" : 1000,
"mapBumpScale" : 5,
因此,很明显,我从Max导出到.obj,或者将.obj转换为.js时出现了问题。如果有人已经解决了这个问题,我会非常感激你是如何做到的!谢谢:)我最终手动编辑了.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
}
是否有任何理由要转换为js,而不仅仅是使用OBJLoader类加载.obj文件?您使用MeshFaceMaterial而不是MeshPhongMaterial有什么原因吗?您的
材质
数组中有哪些材质类型?需要是Phong
。Hi@2pha:OBJLoader
类不加载纹理,尝试使用objmtloader
,然后我会丢失凹凸贴图和镜面反射贴图,模型不会投射阴影如果我用MeshPhongMaterial
替换MeshFaceMaterial
则纹理根本不会出现(全是白色)。您好@WestLangley,加载的材质数组中充满了MeshLambertMaterial
类型的材质,但是当我从3DS Max导出时,它们被设置为Phong。您可以提供一个非常简单的实例吗?Shinity=specularCoef