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 : https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Physics/IPhysicsEngine.ts
For implementation details, you can refer to cannon.js plugin: https://github.com/BabylonJS/Babylon.js/tree/master/packages/dev/core/src/Physics/Plugins/cannonJSPlugin.ts
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).