An elastic collision force type for the d3-force simulation engine.
This force is similar to d3.forceCollide, but allows for fully elastic collisions that conserve kinetic energy. This makes d3.forceCollide appropriate for preventing the overlap of nodes, and d3.forceBounce better suited when the intent is to achieve an elastic collision effect, with varying degrees of elasticity (coefficient of restitution).
Here's a visual comparison between the two forces.
See also d3.forceSurface.
import d3ForceBounce from 'd3-force-bounce';
d3.forceBounce = require('d3-force-bounce');
d3.forceSimulation() .nodes(<myNodes>) .force('bounce', d3.forceBounce() .radius(5) );
|elasticity([number])||Getter/setter for every collision's coefficient of restitution, aka elasticity. A value of
|radius([num or fn])||Getter/setter for the node object radius accessor function (
|mass([num or fn])||Getter/setter for the node object mass accessor function (
|onImpact([fn])||Callback function triggered at every collision, with the signature
If this project has helped you and you'd like to contribute back, you can always buy me a ☕!