Get mesh name on mesh click?

I want to include mesh name in header.textContent at the click of that mesh.
onclick MESH {
header.textContent =;
} else {
header.textContent = “No Picked Mesh”;
I tried Picking Collisions and Use Actions, both examples I wrote in the babylon playground on lines 70 and 81.
I think after the export from blender objects are in pickable = false, so i tried to test it with true but without success …
One solution, the simplest … ???

Works like this:

myMeshesOne[0].isPickable = true;
myMeshesTwo[0].isPickable = true;
myMeshesThree[0].isPickable = true;

 scene.onPointerDown = function (evt, pickResult) {
        // We try to pick an object
        if (pickResult.hit) {
            header.textContent =;


Thx D!

Also, you can go with “pure actionManagers” and no DOM events.

I added a scene.onDispose, too… keeps older HTML from jumping across playground saves. :slight_smile:

Aldin… interpolateValue action is for changing a value “gradually” (slowly animated)… almost always a number.

ExecuteCode action is better for you. This action runs a function, with a ‘bjsevt’ arriving in arg0. The bjsevt.source is the clicked object. Party on.

1 Like

Here’s another…

I turned ON the DOM eventListener again… just to set “No Picked Mesh” if the pick misses all mesh.

1 Like

Thank you for your answers
I like Action because I want to add visibility later, and this is described in Actions.
Since I’m still learning, I’d like to clarify a little.
If I add;
myMeshesOne [0] .isPickable = true;
I have to add
myMeshesOne [1] .isPickable = true;
for another model … if I have a lot of models it’s too [0,1 … a lot].
Wingnut has solved this with:
scene.onReadyObservable.add (function () {
for (var i = 0; i <scene.meshes.length; i ++) {
var mesh = scene.meshes [i];
mesh.isPickable = true;
mesh.actionManager = new BABYLON.ActionManager (scene);

scenes.onReadyObservable as I understand it serves to trigger an event at a particular moment. (An event triggered when the scene is ready)
Since I’m not the best in javascript, can i just explain it a bit:
for (var i = 0; i <scene.meshes.length; i ++) {
var mesh = scene.meshes [i];
mesh.isPickable = true;
mesh.actionManager = new

Is there a simpler way to get all Meshs in the scene isPickable = true? (of course if they are by defult false)

BABYLON.ExecuteCodeAction (trigger, func, condition): Executes code …, a few more explanations?
In actions bjsevt.source = mesh name?


I am trying to get the pickResult.pickedMesh.parent but it is returned as an object.

How do I echo out this please.

pickResult.pickedMesh[‘parent’] give [object Object]

pickResult.pickedMesh.parent[0]) gives undefined


Steve Warby ?

Thats the one thanks.

I did find it … by accident…


Steve Warby

1 Like

Is it possible to show the mesh name , just near to the mesh. (i.e like tool-tip) instead of name in top right corner box?

Else on click of button, all the mesh name to show on top of the mesh. on second click of the button to switch off the mesh name.


You could rely on the babylon gui system for this and attach the label to the mesh.