Add Your Own Physics Engine

Define your plugin

You can create your own plugin by creating a class that provides the interface defined in this TypeScript file :

For implementation details, you can refer to cannon.js plugin:

Using your plugin

When you launch the physics simulation, you can add a new parameter to enablePhysics function to indicate which plugin to use:

scene.enablePhysics(null, new BABYLON.CannonJSPlugin()),

The first parameter can be used to define gravity (which is (0, -9.807, 0) by default).

Further reading