admin管理员组文章数量:1208155
I have created a custom geometry in Three.js. Now, I would like to create a mesh that uses a smooth-shaded Lambert material. Using a loop, I have created the array of vertices, then faces, and afterwards I have called
geometryputeCentroids();
geometryputeFaceNormals();
geometryputeVertexNormals();
var colorMaterial = new THREE.MeshLambertMaterial( {color: 0x0000ff, side: THREE.DoubleSide} );
var mesh = new THREE.Mesh( geometry, colorMaterial );
scene.add(mesh);
The result is almost perfect, except that it appears as though the material is using shading: THREE.FlatShading
as seen below:
while I was expecting the default appearance one normally expects with shading: THREE.SmoothShading
. What do I need to add/change to obtain a smooth Lambert shading?
(If it helps, a complete live example is at .js/Marching-Cubes.html and the geometry and mesh are created around lines 250-280.)
I have created a custom geometry in Three.js. Now, I would like to create a mesh that uses a smooth-shaded Lambert material. Using a loop, I have created the array of vertices, then faces, and afterwards I have called
geometry.computeCentroids();
geometry.computeFaceNormals();
geometry.computeVertexNormals();
var colorMaterial = new THREE.MeshLambertMaterial( {color: 0x0000ff, side: THREE.DoubleSide} );
var mesh = new THREE.Mesh( geometry, colorMaterial );
scene.add(mesh);
The result is almost perfect, except that it appears as though the material is using shading: THREE.FlatShading
as seen below:
while I was expecting the default appearance one normally expects with shading: THREE.SmoothShading
. What do I need to add/change to obtain a smooth Lambert shading?
(If it helps, a complete live example is at http://stemkoski.github.io/Three.js/Marching-Cubes.html and the geometry and mesh are created around lines 250-280.)
Share Improve this question asked Jun 15, 2013 at 1:03 StemkoskiStemkoski 9,0453 gold badges48 silver badges62 bronze badges1 Answer
Reset to default 25It's because neighboring faces do not share vertices in your model.
If you call geometry.mergeVertices()
right after you complete the creation of your geometry, and before you call geometry.computeVertexNormals()
, then your shading will look smoother.
three.js r.58
本文标签: javascriptThreejsproblems smooth shading a Lambert material on custom geometryStack Overflow
版权声明:本文标题:javascript - Three.js - problems smooth shading a Lambert material on custom geometry - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738687030a2106880.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论