Search code examples
collisioncannon.js

Cannon.js 2 plane overlay collision


i have a THREE.PlaneGeometry named floor set on bottom and other THREE.PlaneGeometry named grass set slightly 0.2 on top of the floor.

when my raycastvehicle wheel drive over on both of the plane, the collision randomly detect floor and grass which majority detect floor but not grass.
How can I make the collision merely detect grass but not floor cause grass should be the priority since its on top of the floor?


Solution

  • The solution for this is to use collision groups and masks for your planes and vehicle rays. This way you could choose which objects should be hit by rays and which ones that should be ignored.

    However, the CANNON.RaycastVehicle class does not yet support collision groups/masks. For a quick fix, you could patch Cannon, or perhaps monkey-patch RaycastVehicle.prototype.castRay.

    In any case, please submit a feature request for collision group/mask support in RaycastVehicle.