Unique identifier for mesh loaded from GLB

When I load a GLB , is it possible to find a (deeply nested) mesh by a unique ID or so? By default we have mesh.id, mesh.name, but these are not per se unique.

Background: I like to save to save some metadata for a specific (nested) mesh in a database and apply each time I load the GLB.

I load the GLB via BABYLON.SceneLoader.LoadAssetContainer.

Thanks !

You can use scene.getMeshByUniqueId. A uniqueId is assigned to a mesh at creation time and can be accessed by mesh.uniqueId.

1 Like

What happens to this uniqueId in case the nested mesh is part of a series of GLB files loaded, and the loading sequence varies? It seems the uniqueId is a scene node counter, am I correct?

I was hoping for an ID that somehow is based on the node-path or so.

Yes, uniqueId comes from a scene counter, so is unique for the current session.

The unique ids may not be the same depending on how you load the objects but they will still be uniquely distributed among objects for the current session.

You can reassign the uniqueId property of objects after they have been loaded/created if you want to use a different scheme.

1 Like