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).
Further reading
Using A Physics Engine
Learn how to use one of the available physics engines in Babylon.js.

Forces
Learn all about applying physical forces in Babylon.js.

Joints
Learn all about using joints in physics engines within Babylon.js.

Pivots and Axes
Learn all about physics pivots and axes in Babylon.js.

Compound Bodies
Learn all about physics compound bodies in Babylon.js.

Soft Bodies
Learn all about physics soft bodies in Babylon.js.

Advanced Physics Features
Unlock the full potential of physics with advanced physics features in Babylon.js.
