Unable to click on an imported mesh from blender

Hi,

I would like to execute some custom code when i click on a mesh.
So i did this :

mesh.actionManager.registerAction(new ExecuteCodeAction(ActionManager.OnPickTrigger, (event) => console.log(‘HEY!’)));

The callback is never called when i click on the mesh. So i tried to debug, and this is what i found :
when the code flow hit the AbstractMesh.Intersect function, this conditional statement is evaluated:

if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
return pickingInfo;

Every conditions returns true until the ray.intersectsBox call. This one return false, so i got a pickingInfo without a picked mesh. This might be the source of the problem.

A bit of context : i’m coding in typescript with the modular ES6 version of Babylonjs.
I got others problems before this one, the latest was resolved by including this import :

import “@babylonjs/core/Culling/ray”;

I was thinking maybe an other import is missing, but if it’s the case, i don’t know wich one. I tried to import the pickingInfo module, but it doesn’t make a difference. I think this one might be loaded as a side effect somewhere.

Also, my mesh was imported from Blender, so i might need to set some properties on it.
It’s basically the first time i use this framework, so i don’t know much. Feel free to ask for more context if it can help the diagnostic

Hi.

My first thought (and I might be very wrong, or you already done this). is to try to set isPickable to true. so

mesh.isPickable = true;

Hi, thank you for your answer.
Yes, i already checked that. I did not have to explicitely set it to true though, because it was true already once deserialized from the ImportMeshAsync call

Can you repro your problem in the playground? It could be useful to see it live

The problem came from the imported mesh : there were not one but two meshes in the file. I was working with the wrong one, which was invisible. :woozy_face:
I think it was the default object loaded in the new project template in Blender. I deleted it in Blender though. I’ll look into this more.

2 Likes