Moved extruded polygons don't intersect with rays?

Hello everyone, I found some weird behaviour with extruded polygons and rays. It seems that when you move an extruded polygon, somehow rays don’t intersect with the polygon at the new position and instead intersect with where it was originally created.
I created a Playground to summarize the problem. You can see the extruded polygon which was moved upwards and two rays, visualized by colored squares and spheres, one going through the moved polygon and one below it. When a ray intersects with the polygon, a third cube/sphere is created at the intersection point. I would expect the first ray to intersect and the blue cube to appear in the middle of the polygon, but it’s the other way around and the sphere below spawns instead.
Is this expected behaviour? Is simply moving the position of the polygon not enough and I need to update some state or behaviour? Or did I find a bug?

EDIT: Added rayhelpers to visualize rays further

Hello there! Sorry for the confusion, we’re missing a crucial bit of information in the Mesh.intersects documentation. We didn’t state it, but the ray has to be transformed to the Mesh’s local coordinate space. Alternatively, you could use the Ray.intersectsMesh function which already does this bit of transforming the ray to local mesh space. Here’s your PG with the two appraches: Babylon.js Playground (

Opened a PR to clarify this in the docstring :slight_smile: Add clarification to expected coordinate spaces when using Ray.inters… by carolhmj · Pull Request #13849 · BabylonJS/Babylon.js (


That explains it, thank you very much!