How can i make mesh surface smooth?

I’m creating surface mesh from a sphere with csg functions, and i want to filter the vertex data to get the surface part.
I made it, but the surface is not smooth like it before, have i lost something with vertex data?

Smooth but has other mesh faces:

Only surface but not smooth:

The difference is at line 413 to 417(filter the mesh or not).

PS: Ignore the ugly filterMesh function part, cause i’m still researching. :smiley:

Not sure to get all the maths here, maybe @JohnK our maths artist :slight_smile: might know ?

Inspired by this official doc(Updating Vertices | Babylon.js Documentation) and this PG:, i figured it out.
Use Vector.subtract(vertexPosition, sphere.position) as each vertex’s normal can solve it, PG:

1 Like