# Is there a merge vertices / smooth normals utility with a crease angle argument available?

Hello! I have an STL model that is a set of faces with face normals but I’d like to smooth them. Right now my process is to remove the existing normals, merge the geometry vertices and then run “computeVertexNormals” but that has the undesired effect of smoothing the “hard edges”, as well. Think a cyclinder geometry where you want to smooth the caps and body of the geometry without smoothing the hard end edges.

Here’s an old code pen (three.js r86) but it’s only built for the legacy Geometry class: codepen.

Does anyone know if there’s one available for a modern three.js BufferGeometry?

1 Like

For a cylinder geometry I achieve the desired result using a stock LatheGeometry and duplicating the path vertices where I want hard edges. This may be a hack, but for LatheGeometries it trips the ‘computeVertexNormal’ algorithm in the desired way.

1 Like

A cylinder is just a simple demonstration case. As I mentioned I have an STL file that is basically just a soup of triangles that I need to remerge the vertices for.

1 Like

If you want UVs and seamless mesh, the answer is no!

To do “hard edges”, there are 2 ways:

• Group the target faces with material flatShading: !0.
• Make sure the faces do not share any vertices.

BTW, there is no all scenario algorithm can do normals that can deal wtth seams, and hard/smoth edges.

My question isn’t about whether or not it’s possible - I know it is. I provided a demonstration above working for the old THREE.Geometry. And I’ve written algorithms like this myself previously.

What I’m asking for is whether or not one has already been written so I don’t have to look into building on myself.

I went ahead and wrote a function:

2 Likes

I didn’t check whether your solution is sound, but I like your attitude!

The key words here are merge vertices as indicated in your question. By doing so, there is a high chance that you will end up with messed up uvs, normal and other attributes that depend on overlapping vertices.