The code example for test raycast query is not working for collideWith == 3

Hi Team Babylon,

I was trying the raycast query playground code and found the collideWith == 3 option is not working as expected. Or is it that I am mistaking the feature.

Attached an image for reference to show the issue.

Hi, can you please provide actual example in Playground instead of screenshot? Thanks.

Sure, it’s in the official list of examples in the babylon website under the name Raycast Filtering Example.

I modified the box transparency to check whether the intersecting sphere are inside the box and attached the image.

cc @Cedric and @eoin

This is actually working as expected. The filter checks are performed using a bit mask:

  • The blue box has a membership of β€œ1”, or, in binary, β€œ0001”
  • The green box has a membership of β€œ2”, or, in binary, β€œ0010”
  • When the ray tests for β€œ3” (binary β€œ0011”), it should hit both, and it happens to hit the blue one first.

You can learn some more about bit masks here: Mask (computing) - Wikipedia

1 Like

@eoin Okay, thanks for answering, so is there a way we can get the list of object a ray hits in it’s length sorted with the hit distance.