melonJS
    Preparing search index...

    Interface CollisionResponse

    Collision response passed to the modern collision lifecycle hooks (onCollisionStart, onCollisionActive, onCollisionEnd) on every adapter.

    Receiver-symmetric: a is always the renderable whose handler is firing (response.a === this), b is always the partner (response.b === other). The same overlap is dispatched once to each side as a separate response with a/b swapped accordingly.

    NOT the same contract as the legacy onCollision. The legacy handler receives a different response shape (fixed a/b per pair, overlapV sign convention from b → a, fires 2× per frame for dynamic-dynamic pairs). See Renderable.onCollision JSDoc for that one.

    onCollisionActive(response, other) {
    if (response.normal.y < -0.7) {
    // push-me-up direction ⇒ I'm on top of `other` (stomp)
    }
    }
    interface CollisionResponse {
        a: Renderable;
        b: Renderable;
        depth: number;
        normal: { x: number; y: number };
        overlap?: number;
        overlapN?: { x: number; y: number };
        overlapV?: { x: number; y: number };
        pair?: unknown;
    }
    Index

    Properties

    the renderable whose handler is firing — always === this.

    the partner renderable — always === other.

    depth: number

    Penetration depth along the shortest-separation axis (always positive).

    normal: { x: number; y: number }

    Unit minimum-translation vector for the receiver: the direction a must move to separate from b. Same sign convention across every adapter — in canvas coordinates (y grows downward):

    • normal.y < -0.7 → push me up ⇒ I'm on top of b (stomp / landed on)
    • normal.y > 0.7 → push me down ⇒ I'm underneath b
    • Math.abs(normal.x) > 0.7 → mostly horizontal contact (side hit)
    overlap?: number

    Use depth. Built-in SAT legacy field; kept on modern handler dispatches for migration. undefined under @melonjs/matter-adapter.

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

    Use normal. Built-in SAT legacy field; flipped per receiver so the sign convention aligns with normal on the modern dispatch. undefined under @melonjs/matter-adapter.

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

    Built-in SAT legacy field, equal to normal × depth. Flipped per receiver. undefined under @melonjs/matter-adapter.

    pair?: unknown

    Engine-native contact pair object. Shape is adapter-specificMatter.Pair under @melonjs/matter-adapter, a ContactPair-shaped object under a future Rapier adapter, a b2Contact under a future Box2D adapter, etc. Reading this commits your code to a specific engine; use the portable normal / depth fields for adapter-portable handlers.

    Present only when the active adapter has a native pair concept; undefined under the built-in SAT adapter (which has no native pair representation — the SAT detector works pair-by-pair without persisting them).