Raycast through multiple entities

PlayCanvas uses ammo.js which is a JS complied version of Bullet physics library.

Bullet allows you to do a raycast all via AllHitsRayResultCallback http://bulletphysics.org/mediawiki-1.5.8/index.php/Using_RayTest but hasn’t been explicitly exposed in ammo.js: https://github.com/kripken/ammo.js/blob/master/ammo.idl#L138

What you can do at this point:

  • Make a pull request to expose this in either the ammo.js GitHub https://github.com/kripken/ammo.js or in PlayCanvas’s fork: https://github.com/playcanvas/ammo.js
  • Use filters for the rigidbodies so you can raycast against specific groups
  • Create your own function that does raycastFirst multiple times (each one starting slightly ahead of the hit point) until you have reached a certain length or not hit anything.