Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RigidVehicle

Simple vehicle helper class with spherical rigid body wheels.

Hierarchy

  • RigidVehicle

Index

Constructors

constructor

  • Parameters

    • 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

chassisBody: Body

The chassis body.

constraints

constraints: (HingeConstraint & {})[]

The constraints.

wheelAxes

wheelAxes: Vec3[]

The wheel axes.

wheelBodies

wheelBodies: Body[]

The bodies of the wheels.

wheelForces

wheelForces: number[]

The wheel forces.

Methods

addToWorld

  • addToWorld(world: World): void

addWheel

  • addWheel(options?: { axis?: Vec3; body?: Body; direction?: Vec3; position?: Vec3 }): number
  • Add a wheel

    Parameters

    • 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

applyWheelForce

  • applyWheelForce(value: number, wheelIndex: number): void

disableMotor

  • disableMotor(wheelIndex: number): void
  • Set the target rotational speed of the hinge constraint.

    Parameters

    • wheelIndex: number

    Returns void

getWheelSpeed

  • getWheelSpeed(wheelIndex: number): number

removeFromWorld

  • removeFromWorld(world: World): void

setMotorSpeed

  • setMotorSpeed(value: number, wheelIndex: number): void
  • Set the target rotational speed of the hinge constraint.

    Parameters

    • value: number
    • wheelIndex: number

    Returns void

setSteeringValue

  • setSteeringValue(value: number, wheelIndex: number): void
  • Set the steering value of a wheel.

    todo

    check coordinateSystem

    Parameters

    • value: number
    • wheelIndex: number

    Returns void

setWheelForce

  • setWheelForce(value: number, wheelIndex: number): void
  • Set the wheel force to apply on one of the wheels each time step

    Parameters

    • value: number
    • wheelIndex: number

    Returns void