Mesh uniqueId repeating

Hello people of Babylon,

I’ve stumbled upon a serious issue where multiple meshes are getting assigned same uniqueId.

My scene has various meshes and one of them has uniqueId 123.
scene.getMeshByUniqueId(123) returns the appropriate mesh.
Later I’m creating several new meshes with new BABYLON.Mesh() and one of these new ones also has uniqueId as 123.

This is breaking several things in my code.

How do I solve this?

Hi @kuladeeparun

Can you repro this behavior in a playground? It would be easier for me to take a look.

Hello @Cedric, it’s part of a big application, so it’s not easy for me to reproduce this on playground.

I can give you some additional information though. It involves mesh serialization and recreation. During serialization uniqueId is stored and reassigned upon recreation. Do you think that’s a possible reason?

I don’t know the actual reason for the problem or the solution, but for now, I’ve overidden the function BABYLON.Scene.getUniqueId to check for duplicates and my problems have gone away… for now.