Reverse FlatShadedMesh

Is there a way or function to make the opposite of what convertToFlatShadedMesh does?

Except cloning the mesh before converting it?


Hi PichouPichou,

As far as I know, there isn’t an existing function that does this. It would be a pretty neat feature to add, though! The code for convertToFlatShadedMesh() is pretty self-contained, so it probably wouldn’t be too hard to adapt the logic to smooth the normals, although the output could be a little funky depending on the geometry being modified.

I think mesh.forceSharedVertices() should do it :slight_smile:

1 Like

Wouhou I was afraid it was a “no going back” convertion.

See it works: Babylon.js Playground

I guess this is a 4.0 new function @Deltakosh? Because it doesn’t exist on mesh in 3.3. :scream:

oh yeah…I told you to move to 4.0 already :smiley:

Haha my bad!

But the new assetloader “policy” will make it a bit hard as a lot of the model we load are in gltf and not always in gltf2 so we have to make sure first that every model will work in 4.0 before switching.

I don’t like it but for now I copy-pasted the forceSharedVertices function in my code in order to make it work with 3.3.

1 Like