Module Name (not a built-in physics key)
Module Definition
declare module "konfeti" {
interface PhysicsRegistry {
magnet: { x: number; y: number; strength: number };
}
}
definePhysics("magnet", {
defaults: { x: 0.5, y: 0.5, strength: 600 },
apply: (p, dt, world, { x, y, strength }) => {
p.vx += (x * world.width - p.x) * strength * dt * 0.001;
p.vy += (y * world.height - p.y) * strength * dt * 0.001;
},
});
Konfeti.fire({ physics: { magnet: { strength: 900 } } });
Register Custom Physics Module. Declare its options on PhysicsRegistry first; enable it per burst with
physics: { name: … }. Registering the same name again replaces the definition.