Get Mesh Metadata Value

With the code below, I am able to click on an mesh and retrieve its name.

  scene.onReadyObservable.add( function(){
        cloneB.isPickable = true;
        cloneB.actionManager = new BABYLON.ActionManager(scene);

            new BABYLON.ExecuteCodeAction(
                BABYLON.ActionManager.OnPickTrigger, function() {
                    text1.text =;


However, when I use the same code to retrieve mesh metadata values, the scene crashes :thinking:
Example: text1.text = cloneB.metadata.energyValue

I think I need to “call” or “get” that value first, but I haven’t found anything in the documentation for this.

Thanks in advance for any help or suggestions!

As usual please post a simplified PG with the issue not just some code. If your mesh has metadata it should retrieve it.

You can get the metadata from sphere because it has been set but not possible from ground where it has not been set.

If you think you have set the metadata for cloneB somewhere then your code above is running before that setting occurs.

1 Like

Hello again @JohnK, and thanks for taking a look at this. I forgot to add that the metadata changes over time, so it’s not a constant value. Here’s a PG where sphere2 should add 1 to metadata.test whenever it collides with a border.

Don’t see the problem, no cloneB in sight.

I actually made a new PG, but it’s the same basic issue, which is getting metadata values that are actively changing over time. So for the PG above, I would want to display how many times a sphere2 clone collides with a border (stored in sphere2.metadata.test).

Hello everyone,

I’m still having trouble solving this problem, so I created a PG that will hopefully better illustrate what I’m trying to achieve:

In the PG above, when you click on a sphere, its name will be displayed.

However, when I add the line to display metadata (text1.text = sphereInstance.metadata.test;), the scene crashes (see PG below). :thinking:

Any help or suggestions would be greatly appreciated :smiley: :+1:

Not a metadata problem as such. Covert sphereInstance.metadata.test to a string using


or by concatenating a string as in this PG you will get results in the text block but not sure they are what you expect.

As I do not want to second guess about what you expect in the text block please post your expectations.

1 Like

That’s exactly right, thanks! I knew the metadata was there, I just didn’t know that it had to be converted to a string first.

Thanks again @JohnK! :smiley: :+1: