So does this mean I should not be using raycastFirst because it’s legacy?
So you mean that both functions are the same and return ALL entities the raycast detects?
I did have a look at the API, and this is what I understood:
Both the functions have the same syntax.
raycastFirst returns one RaycastResult object
raycastAll returns an array of RaycastResult objects.
And I still don’t understand why my code didn’t work.
The callback param shouldn’t be used in raycastFirst (you should see a warning in the console log about it when it is used). The API was changed several years ago but we kept the third param (the callback function) as optional legacy so old projects wouldn’t break.
raycastAll takes two params, from and to vec3s.
The third param you used (the callback) is ignored because the function is only expecting two params.