ixfx
    Preparing search index...

    Namespace Forces

    Functions

    accelerationForce

    Apples vector to acceleration, scaling according to mass, based on the mass option. It returns a function which can later be applied to a thing.

    angleFromAccelerationForce

    Yields a force function that applies the thing's acceleration.x to its angular acceleration.

    angleFromVelocityForce

    Yields a force function that applies the thing's velocity to its angle. This will mean it points in the direction of travel.

    angularForce

    Sets angle, angularVelocity and angularAcceleration based on angularAcceleration, angularVelocity, angle

    apply

    Apply a series of force functions or forces to t. Null/undefined entries are skipped silently. It also updates the velocity and position of the returned version of t.

    attractionForce

    For a given set of attractors, returns a function that a sets acceleration of attractee. Keep note though that this bakes-in the values of the attractor, it won't reflect changes to their state. For dynamic attractors, it might be easier to use computeAttractionForce.

    computeAccelerationToTarget

    Returns the acceleration to get from currentPos to targetPos.

    computeAttractionForce

    Computes the attraction force between two things. Value for gravity will depend on what range is used for mass. It's probably a good idea to keep mass to mean something relative - ie 1 is 'full' mass, and adjust the gravity value until it behaves as you like. Keeping mass in 0..1 range makes it easier to apply to visual properties later.

    computePositionFromAngle

    Compute a position based on distance and angle from origin

    computePositionFromVelocity

    Compute a new position based on existing position and velocity vector

    computeVelocity

    Compute velocity based on acceleration and current velocity

    constrainBounce

    constrainBounce yields a function that affects t's position and velocity such that it bounces within bounds.

    guard

    Throws an error if t is not of the ForceAffected shape.

    magnitudeForce

    A force based on the square of the thing's velocity. It's like velocityForce, but here the velocity has a bigger impact.

    nullForce

    Null force does nothing

    orientationForce

    A force that orients things according to direction of travel.

    pendulumForce

    The pendulum force swings something back and forth.

    springForce

    Spring force

    targetForce

    A force that moves a thing toward targetPos.

    velocityForce

    Force calculated from velocity of object. Reads velocity and influences acceleration.

    Type Aliases

    ForceAffected

    Basic properties of a thing that can be affected by forces

    ForceFn

    A function that updates values of a thing.

    ForceKind

    A vector to apply to acceleration or a force function

    MassApplication

    Logic for applying mass

    PendulumOpts

    Pendulum force options

    TargetOpts