computeVertexNormals doesn't work with model from JsonLoader

混江龙づ霸主 提交于 2019-12-25 06:25:23

问题


Model always display in FlatShading even when I already have computeVertexNormals. Model is exported without normal for optimize purpose, loaded in 3JS by JsonLoader, and converted to BufferGeometry.

Material is already SmoothShading. Please see this jsFiddle for better demonstration: http://jsfiddle.net/2w9Lkjbm/6/


回答1:


The method

bufferGeometry.fromGeometry( geometry );

returns non-indexed BufferGeometry.

Also known as "triangle soup", non-indexed BufferGeometry has no shared vertices, so computeVertexNormals() sets all vertex normals to be the same as the face normal.

In your case, you need to call computeVertexNormals() on your original geometry -- before converting to BufferGeometry:

model.geometry.computeVertexNormals();

var bufferGeometry = new THREE.BufferGeometry();

bufferGeometry.fromGeometry( model.geometry );

updated fiddle: http://jsfiddle.net/2w9Lkjbm/8/

three.js r.85



来源:https://stackoverflow.com/questions/43624693/computevertexnormals-doesnt-work-with-model-from-jsonloader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!