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: https://playground.babylonjs.com/#07QQ27#2
image

Only surface but not smooth: https://playground.babylonjs.com/#07QQ27#3
image

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: https://playground.babylonjs.com/#H05E9H#11, i figured it out.
Use Vector.subtract(vertexPosition, sphere.position) as each vertex’s normal can solve it, PG: https://playground.babylonjs.com/#07QQ27#7

1 Like