Cannon SAPBroadphase not working with CannonJSPlugin

I’m trying to set the cannon broadphase to SAPBroadphase, however everything just falls through the ground.

I’ve setup a quick playground showing the bug
It seems to work ok with the naive broadphase, however this broadphase it as it name suggests pretty naive.

I’ve hunted through the docs but cant find anything mentioning broadphases. If anyone can point me in the right direction that would be awesome.

Pinging @trevordev

Hey @Mr_K,


I think setting this after creating the physics engine but prior to enabling physics should work. Enabling physics might already start using the world so modifying it after that could cause issues.

This is a specific feature to cannon and is not exposed through babylons physics abstraction layer so the only docs around this will likely be provided be found with cannon.

Thanks for the suggestion @trevordev

Sadly it seems to be the same result as before. It works for the NaiveBroadphase but not for the SAPBroadphase.

I’m trying to see if I can work around the issue by not using the CannonJSPlugin but I’m having a lot of trouble generating the imposter for the height field, so at this point I’m kinda stuck.

Eureka! I’ve worked out where I’m going wrong. When using the SAPBroadphase you have to manually specify the physics world like so;

Thanks again for the help @trevordev, your an absolute legend!