平滑着色不适用于 Three.js 场景中加载的 OBJ [英] Smooth shading not working for OBJ loaded in Three.js scene
问题描述
也就是说,OBJ 在我的 3D 建模软件中看起来很流畅,而在 Three.js 场景中看起来很古怪(三角形).我将 MeshLambertMaterial 分配给它.根据文档,该材质的默认着色为 THREE.SmoothShading.即使我手动设置并通过调试控制台检查shading"属性设置正确,场景中的模型仍然看起来不平滑.
That is, the OBJ looks smooth in my 3D modeling software while looks quirky (triangular) in Three.js scene. I assign MeshLambertMaterial to it. According to the documentation, the default shading for that material is THREE.SmoothShading. Even if I set it manually and check through the debugging console the "shading" property is properly set, the model in the scene still does not look smooth.
推荐答案
OBJ(MTL)Loader 不计算 VertexNormals.您可以事后计算它们(尚未测试):
The VertexNormals are not calculated by the OBJ(MTL)Loader. You can calculate them afterwards (haven't tested):
my3dObject.traverse( function( node ) {
if ( node instanceof THREE.Mesh ) {
node.geometry.computeVertexNormals();
}
} );
这篇关于平滑着色不适用于 Three.js 场景中加载的 OBJ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!