nape-js API
    Preparing search index...

    Interface RadialGravityFieldOptions

    Configuration options for RadialGravityField.

    interface RadialGravityFieldOptions {
        bodyFilter?: BodyFilter | null;
        enabled?: boolean;
        falloff?: GravityFalloff;
        maxRadius?: number;
        minRadius?: number;
        scaleByMass?: boolean;
        softening?: number;
        source: Vec2 | Body;
        strength: number;
    }
    Index

    Properties

    bodyFilter?: BodyFilter | null

    Predicate deciding which bodies the field affects. null (default) means "all dynamic bodies". Static and kinematic bodies are always skipped (forces have no effect on them anyway).

    null

    enabled?: boolean

    When false, calls to RadialGravityField.apply are no-ops.

    true

    falloff?: GravityFalloff

    Falloff law.

    "inverse-square"

    maxRadius?: number

    Bodies farther than this from the source receive zero force — useful for bounded gravity wells with hard edges.

    Infinity

    minRadius?: number

    Distance values used in the falloff calculation are clamped to be at least this — prevents singularities at the source center.

    1

    scaleByMass?: boolean

    Multiply the resulting force by body.mass (Newtonian gravity).

    true

    softening?: number

    Softening epsilon added to for the inverse-square falloff (smooths out near-source spikes without disabling the pull). Has no effect on other falloff laws.

    0

    source: Vec2 | Body

    The field's anchor point. May be a Vec2 (fixed world position — captured by reference, so mutating it after construction moves the field), or a Body (the field tracks body.position automatically each step).

    strength: number

    Field strength scaling — units depend on falloff (see GravityFalloff).