Why scene.pickWithRay !== mesh.intersects?

Hi everyone,

Please see here: Babylon.js Playground

I do not see why the mesh.intersects-intersection is where it is. I would expect both markers are at the same spot (i.e. violet) :thinking:

Best wishes
Joe

Internally both ways use the same intersects function. Let me take a look.

1 Like

In case of pickWithRay, ray is transformed from world coordinates (origin, direction) to local coordinates of the mesh.
in case of intersect, ray is expected to be already in local coordinates to the mesh.

So, multiplying by invert matrix gives the same result

More infos here : Babylon.js docs

2 Likes

Thanks :smiley:


Overview of raycasting methods: https://playground.babylonjs.com/#CM4BLK#3

1 Like

Docs are updated… Update mesh picking doc by PatrickRyanMS · Pull Request #1182 · BabylonJS/Documentation (github.com)

2 Likes