Class RigidVehicle

Simple vehicle helper class with spherical rigid body wheels.

Constructors

  • Parameters

    • Optional options: {
          chassisBody?: Body;
          coordinateSystem?: Vec3;
      }
      • Optional chassisBody?: Body

        Optionally pass a body for the chassis

      • Optional coordinateSystem?: Vec3

        A Vector3 defining the world coordinate system.

        Default

        new Vec3(1, 2, 3)
        

    Returns RigidVehicle

Properties

chassisBody: Body

The chassis body.

constraints: (HingeConstraint & {
    motorTargetVelocity?: number;
})[]

The constraints.

coordinateSystem: Vec3
wheelAxes: Vec3[]

The wheel axes.

wheelBodies: Body[]

The bodies of the wheels.

wheelForces: number[]

The wheel forces.

Methods

  • Add the vehicle including its constraints to the world.

    Parameters

    Returns void

  • Add a wheel

    Parameters

    • Optional options: {
          axis?: Vec3;
          body?: Body;
          direction?: Vec3;
          position?: Vec3;
      }
      • Optional axis?: Vec3

        Axis of rotation of the wheel, locally defined in the chassis.

      • Optional body?: Body

        The wheel body

      • Optional direction?: Vec3

        Slide direction of the wheel along the suspension.

      • Optional position?: Vec3

        Position of the wheel, locally in the chassis body.

    Returns number

  • Apply a torque on one of the wheels.

    Parameters

    • value: number
    • wheelIndex: number

    Returns void

  • Set the target rotational speed of the hinge constraint.

    Parameters

    • wheelIndex: number

    Returns void

  • Get current rotational velocity of a wheel

    Parameters

    • wheelIndex: number

    Returns number

  • Remove the vehicle including its constraints from the world.

    Parameters

    Returns void

  • Set the target rotational speed of the hinge constraint.

    Parameters

    • value: number
    • wheelIndex: number

    Returns void

  • Set the steering value of a wheel.

    Parameters

    • value: number
    • wheelIndex: number

    Returns void

    Todo

    check coordinateSystem

  • Set the wheel force to apply on one of the wheels each time step

    Parameters

    • value: number
    • wheelIndex: number

    Returns void