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