# Moved extruded polygons don't intersect with rays?

**URL:** <https://forum.babylonjs.com/t/moved-extruded-polygons-dont-intersect-with-rays/40694>\
**Category:** Questions\
**Tags:** ray, intersection\
**Created:** [May 11, 2023, 10:04am UTC](https://forum.babylonjs.com/t/moved-extruded-polygons-dont-intersect-with-rays/40694 "2023-05-11T10:04:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex1998ander](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alex1998ander/32/30714_2.png) [@alex1998ander](https://forum.babylonjs.com/u/alex1998ander)\
**Post date:** [May 11, 2023, 10:04am UTC](https://forum.babylonjs.com/t/moved-extruded-polygons-dont-intersect-with-rays/40694/1 "2023-05-11T10:04:19Z")

</div>

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](https://playground.babylonjs.com/#1UC229#108) 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

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 11, 2023, 2:21pm UTC](https://forum.babylonjs.com/t/moved-extruded-polygons-dont-intersect-with-rays/40694/3 "2023-05-11T14:21:40Z")

</div>

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 (babylonjs.com)](https://playground.babylonjs.com/#1UC229#113)

Opened a PR to clarify this in the docstring 🙂 [Add clarification to expected coordinate spaces when using Ray.inters… by carolhmj · Pull Request #13849 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/13849)

---

<div class="post-metadata">

**Author:** ![alex1998ander](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alex1998ander/32/30714_2.png) [@alex1998ander](https://forum.babylonjs.com/u/alex1998ander)\
**Post date:** [May 11, 2023, 2:59pm UTC](https://forum.babylonjs.com/t/moved-extruded-polygons-dont-intersect-with-rays/40694/4 "2023-05-11T14:59:09Z")

</div>

That explains it, thank you very much!
