melonJS
    Preparing search index...

    Interface BodyDefinition

    Engine-portable body description, passed to PhysicsAdapter.addBody. Adapter-native fields (Box2D meters, Matter collisionFilter bits, etc.) are derived from these portable fields by each adapter.

    interface BodyDefinition {
        collisionMask?: number;
        collisionType?: number;
        density?: number;
        fixedRotation?: boolean;
        friction?: number;
        frictionAir?: number | { x: number; y: number };
        gravityScale?: number;
        isSensor?: boolean;
        maxVelocity?: { x: number; y: number };
        restitution?: number;
        shapes: BodyShape[];
        type: BodyType;
        userData?: unknown;
    }
    Index

    Properties

    collisionMask?: number

    Bit mask of collision types this body can collide with. Defaults to collision.types.ALL_OBJECT.

    collisionType?: number

    Bit flag identifying this body's collision type. See collision.types. Adapters translate to their native filter system (Matter collisionFilter.category, Box2D categoryBits).

    density?: number

    mass per unit area; defaults are adapter-specific

    fixedRotation?: boolean

    disable rotation simulation; the body keeps its initial angle

    friction?: number

    Surface coefficient of friction during contact. Matter's body.friction0 = frictionless (objects slide past each other), 1 = high stick. Determines how much tangential velocity is transferred between contacting bodies. Combined with body rotation, this is what produces "throw" between colliding circles and "english" off a wall. Distinct from frictionAir (per-step drag with no contact required). Builtin SAT adapter ignores this.

    frictionAir?: number | { x: number; y: number }

    Per-step velocity damping (Matter's frictionAir). Bleeds velocity off every frame regardless of contact, creating terminal velocity. Number applies uniformly; {x, y} damps each axis independently (melonJS-specific — Matter only supports scalar and will average).

    gravityScale?: number

    Per-body gravity multiplier. 0 disables gravity for this body; negative inverts it. Matches Matter's body.gravityScale.

    isSensor?: boolean

    the body generates collision events but no physical response

    maxVelocity?: { x: number; y: number }

    Hard cap on velocity magnitude per axis. melonJS extension — Matter has no direct equivalent and uses frictionAir-induced terminal velocity instead; MatterAdapter implements this by clamping velocity in an afterUpdate hook.

    restitution?: number

    Bounciness (coefficient of restitution): 0 = inelastic (stops on contact), 1 = perfectly elastic (rebound speed equals impact speed). Typically in [0, 1]. Values > 1 produce a super-elastic ("energy-gain") rebound — physically unrealistic but useful for arcade effects like pinball flippers, slingshot boosters, or trampoline pads. The value is not clamped at the interface level; how an adapter handles out-of-range values is adapter-specific.

    shapes: BodyShape[]

    collision shapes (one or more — compound body support)

    type: BodyType

    simulation kind

    userData?: unknown

    arbitrary user data attached to the body