Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RaycastVehicle

Vehicle helper class that casts rays from the wheel positions towards the ground and applies forces.

Hierarchy

  • RaycastVehicle

Index

Constructors

constructor

  • new RaycastVehicle(options: { chassisBody: Body; indexForwardAxis?: number; indexRightAxis?: number; indexUpAxis?: number }): RaycastVehicle
  • Parameters

    • options: { chassisBody: Body; indexForwardAxis?: number; indexRightAxis?: number; indexUpAxis?: number }
      • chassisBody: Body

        The car chassis body.

      • Optional indexForwardAxis?: number

        Index of the forward axis. x=0, y=1, z=2

      • Optional indexRightAxis?: number

        Index of the right axis. x=0, y=1, z=2

      • Optional indexUpAxis?: number

        Index of the up axis. x=0, y=1, z=2

    Returns RaycastVehicle

Properties

chassisBody

chassisBody: Body

The car chassis body.

constraints

constraints: Constraint[]

The constraints.

indexForwardAxis

indexForwardAxis: number

Index of the forward axis. x=0, y=1, z=2

indexRightAxis

indexRightAxis: number

Index of the right axis. x=0, y=1, z=2

indexUpAxis

indexUpAxis: number

Index of the up axis. x=0, y=1, z=2

numWheelsOnGround

numWheelsOnGround: number

Number of wheels on the ground.

preStepCallback

preStepCallback: () => void

Type declaration

    • (): void
    • Optional pre-step callback.

      Returns void

sliding

sliding: boolean

Will be set to true if the car is sliding.

wheelInfos

wheelInfos: WheelInfo[]

The wheels.

Methods

addToWorld

  • addToWorld(world: World): void

addWheel

  • addWheel(options?: undefined | { axleLocal?: Vec3; axleWorld?: Vec3; chassisConnectionPointLocal?: Vec3; chassisConnectionPointWorld?: Vec3; clippedInvContactDotSuspension?: number; customSlidingRotationalSpeed?: number; dampingCompression?: number; dampingRelaxation?: number; deltaRotation?: number; directionLocal?: Vec3; directionWorld?: Vec3; forwardAcceleration?: number; frictionSlip?: number; isFrontWheel?: boolean; maxSuspensionForce?: number; maxSuspensionTravel?: number; radius?: number; rollInfluence?: number; rotation?: number; sideAcceleration?: number; skidInfo?: number; slipInfo?: number; steering?: number; suspensionForce?: number; suspensionLength?: number; suspensionMaxLength?: number; suspensionRelativeVelocity?: number; suspensionRestLength?: number; suspensionStiffness?: number; useCustomSlidingRotationalSpeed?: boolean }): number
  • Add a wheel. For information about the options, see WheelInfo.

    Parameters

    • options: undefined | { axleLocal?: Vec3; axleWorld?: Vec3; chassisConnectionPointLocal?: Vec3; chassisConnectionPointWorld?: Vec3; clippedInvContactDotSuspension?: number; customSlidingRotationalSpeed?: number; dampingCompression?: number; dampingRelaxation?: number; deltaRotation?: number; directionLocal?: Vec3; directionWorld?: Vec3; forwardAcceleration?: number; frictionSlip?: number; isFrontWheel?: boolean; maxSuspensionForce?: number; maxSuspensionTravel?: number; radius?: number; rollInfluence?: number; rotation?: number; sideAcceleration?: number; skidInfo?: number; slipInfo?: number; steering?: number; suspensionForce?: number; suspensionLength?: number; suspensionMaxLength?: number; suspensionRelativeVelocity?: number; suspensionRestLength?: number; suspensionStiffness?: number; useCustomSlidingRotationalSpeed?: boolean } = {}

    Returns number

applyEngineForce

  • applyEngineForce(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

getWheelTransformWorld

  • getWheelTransformWorld(wheelIndex: number): Transform

removeFromWorld

  • removeFromWorld(world: World): void

setBrake

  • setBrake(brake: number, wheelIndex: number): void

setSteeringValue

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

updateWheelTransform

  • updateWheelTransform(wheelIndex: number): void
  • Update one of the wheel transform. Note when rendering wheels: during each step, wheel transforms are updated BEFORE the chassis; ie. their position becomes invalid after the step. Thus when you render wheels, you must update wheel transforms before rendering them. See raycastVehicle demo for an example.

    Parameters

    • wheelIndex: number

      The wheel index to update.

    Returns void