I'm already depending on two NPM packages for 2D collision and differential equations:
I've a basic simulation structure, but don't know where to start with to use these two packages in my step()
forward method that should iterate rigid bodies and their joints:
export default class Simulation {
/**
* Global gravity.
*/
gravity: Vector;
/**
* Timestep length during a step.
*/
timestepLength: number;
// Contained rigid bodies
private readonly _bodies: Body[] = [];
// Joints between rigid bodies
private readonly _joints: Joint[] = [];
constructor(options: SimulationOptions) {
this.gravity = options.gravity;
this.timestepLength = options.timestepLength === undefined ? 1 / 60 : options.timestepLength;
}
step() {
for (const body of this._bodies) {
//
}
}
}
```