melonJS
    Preparing search index...

    Interface JointDefinition

    What World#addJoint joins, and how. Distances are in pixels and angles in radians, as everywhere else in melonJS; the adapter converts them to its engine's units. Anchors are points in each renderable's own space, the space its bodyDef shapes are written in.

    // a door that opens up to 90 degrees, hinged at its top-left corner
    app.world.addJoint({
    type: "hinge",
    a: frame,
    b: door,
    anchorA: { x: 4, y: 0 },
    anchorB: { x: 0, y: 0 },
    limits: { min: 0, max: Math.PI / 2 },
    });
    interface JointDefinition {
        a: Renderable;
        anchorA?: { x: number; y: number; z?: number };
        anchorB?: { x: number; y: number; z?: number };
        axis?: { x: number; y: number; z?: number };
        b: Renderable;
        collideConnected?: boolean;
        limits?: { max: number; min: number };
        maxLength?: number;
        type: JointType;
    }
    Index

    the first body: a renderable with a body in the world

    anchorA?: { x: number; y: number; z?: number }

    where the joint holds a, in a's own space. Default: the point of a under b's anchor when the joint is made, so nothing moves; for a "rope", the centre of a's body. z is its depth, for an adapter whose bodies have depth (AdapterCapabilities.bodies3d); a 2D adapter ignores it.

    anchorB?: { x: number; y: number; z?: number }

    where the joint holds b, in b's own space; default: the centre of its body. z as for anchorA.

    axis?: { x: number; y: number; z?: number }

    "slider": the direction b slides in, in a's own space; default: along x. On an adapter whose bodies have depth (AdapterCapabilities.bodies3d) it may carry a z, and a "hinge" takes it as the axis the bodies turn about (default: z, as a 2D hinge turns); a 2D adapter ignores both.

    the second body. To pin a to a fixed point, join it to a renderable with a "static" body.

    collideConnected?: boolean

    whether a and b still collide with each other; default false

    limits?: { max: number; min: number }

    "hinge": the range of b's angle minus a's, in radians. "slider": the range of travel along axis, in pixels, measured between the two anchors: from where b starts, when anchorA is left out. Unbounded when left out.

    maxLength?: number

    "rope": the most the anchors can be apart, in pixels; default: their distance when the joint is made

    type: JointType

    the kind of joint