interface IPhysicsEngine {
    debugRenderColliders: boolean;
    debugRenderRaycasts: boolean;
    get gravity(): Vec3;
    set gravity(vec3: Vec3): void;
    get isInitialized(): boolean;
    get isUpdating(): boolean;
    get world(): any;
    addBoxCollider(collider: ICollider, size: Vector3): any;
    addCapsuleCollider(
        collider: ICollider,
        radius: number,
        height: number,
    ): any;
    addFixedJoint(body1: IRigidbody, body2: IRigidbody): any;
    addForce(rb: IRigidbody, vec: Vec3, wakeup: boolean): any;
    addHingeJoint(
        body1: IRigidbody,
        body2: IRigidbody,
        anchor: Vec3,
        axis: Vec3,
    ): any;
    addMeshCollider(
        collider: ICollider,
        mesh: Mesh,
        convex: boolean,
        scale?: Vector3,
    ): any;
    addSphereCollider(collider: ICollider): any;
    applyImpulse(rb: IRigidbody, vec: Vec3, wakeup: boolean): any;
    clearCaches(): any;
    getAngularVelocity(rb: IRigidbody): null | Vec3;
    getBody(obj: ICollider | IRigidbody): any;
    getBody(obj: ICollider | IRigidbody): any;
    getComponent(rapierObject: object): null | IComponent;
    getLinearVelocity(rb: ICollider | IRigidbody): null | Vec3;
    initialize(): Promise<boolean>;
    isSleeping(rb: IRigidbody): undefined | boolean;
    postStep(): any;
    raycast(
        origin?: Vec3 | Vec2,
        direction?: Vec3,
        options?: {
            filterGroups?: number;
            filterPredicate?: (collider: ICollider) => boolean;
            maxDistance?: number;
            queryFilterFlags?: QueryFilterFlags;
            solid?: boolean;
        },
    ): RaycastResult;
    raycastAndGetNormal(
        origin?: Vec3 | Vec2,
        direction?: Vec3,
        options?: {
            filterGroups?: number;
            filterPredicate?: (collider: ICollider) => boolean;
            maxDistance?: number;
            queryFilterFlags?: QueryFilterFlags;
            solid?: boolean;
        },
    ): RaycastResult;
    removeBody(body: IComponent): any;
    resetForces(rb: IRigidbody, wakeup: boolean): any;
    resetTorques(rb: IRigidbody, wakeup: boolean): any;
    setAngularVelocity(rb: IRigidbody, vec: Vec3, wakeup: boolean): any;
    setLinearVelocity(rb: IRigidbody, vec: Vec3, wakeup: boolean): any;
    sphereOverlap(point: Vector3, radius: number): SphereOverlapResult[];
    step(dt: number): void;
    updateBody(
        comp: ICollider | IRigidbody,
        translation: boolean,
        rotation: boolean,
    ): any;
    updatePhysicsMaterial(collider: ICollider): any;
    updateProperties(rb: ICollider | IRigidbody): any;
    wakeup(rb: IRigidbody): any;
}

Implemented by

Properties

debugRenderColliders: boolean

Enable to render collider shapes

debugRenderRaycasts: boolean

Enable to visualize raycasts in the scene with gizmos

Accessors

  • get gravity(): Vec3

    Returns Vec3

  • set gravity(vec3: Vec3): void

    Parameters

    • vec3: Vec3

    Returns void

  • get isInitialized(): boolean

    Returns boolean

  • get isUpdating(): boolean

    Returns boolean

  • get world(): any

    Returns any

Methods

  • Parameters

    • collider: ICollider
    • radius: number
    • height: number

    Returns any

  • Parameters

    Returns any

  • Parameters

    Returns any

  • Parameters

    Returns any

  • clear all possibly cached data (e.g. mesh data when creating scaled mesh colliders)

    Returns any

  • Get the Needle Engine component for a rapier object

    Parameters

    • rapierObject: object

    Returns null | IComponent

  • Returns Promise<boolean>

  • Returns any

  • Fast raycast against physics colliders

    Parameters

    • Optionalorigin: Vec3 | Vec2

      ray origin in screen or worldspace

    • Optionaldirection: Vec3

      ray direction in worldspace

    • Optionaloptions: {
          filterGroups?: number;
          filterPredicate?: (collider: ICollider) => boolean;
          maxDistance?: number;
          queryFilterFlags?: QueryFilterFlags;
          solid?: boolean;
      }

      additional options

      • OptionalfilterGroups?: number

        Raycast filter groups. Groups are used to apply the collision group rules for the scene query. The scene query will only consider hits with colliders with collision groups compatible with this collision group (using the bitwise test described in the collision groups section). See https://rapier.rs/docs/user_guides/javascript/colliders#collision-groups-and-solver-groups
        For example membership 0x0001 and filter 0x0002 should be 0x00010002

      • OptionalfilterPredicate?: (collider: ICollider) => boolean

        Return false to ignore this collider

      • OptionalmaxDistance?: number
      • OptionalqueryFilterFlags?: QueryFilterFlags
      • Optionalsolid?: boolean

        True if you want to also hit objects when the raycast starts from inside a collider

    Returns RaycastResult

  • raycast that also gets the normal vector. If you don't need it use raycast()

    Parameters

    • Optionalorigin: Vec3 | Vec2
    • Optionaldirection: Vec3
    • Optionaloptions: {
          filterGroups?: number;
          filterPredicate?: (collider: ICollider) => boolean;
          maxDistance?: number;
          queryFilterFlags?: QueryFilterFlags;
          solid?: boolean;
      }
      • OptionalfilterGroups?: number

        Raycast filter groups. Groups are used to apply the collision group rules for the scene query. The scene query will only consider hits with colliders with collision groups compatible with this collision group (using the bitwise test described in the collision groups section). See https://rapier.rs/docs/user_guides/javascript/colliders#collision-groups-and-solver-groups
        For example membership 0x0001 and filter 0x0002 should be 0x00010002

      • OptionalfilterPredicate?: (collider: ICollider) => boolean

        Return false to ignore this collider

      • OptionalmaxDistance?: number
      • OptionalqueryFilterFlags?: QueryFilterFlags
      • Optionalsolid?: boolean

        True if you want to also hit objects when the raycast starts from inside a collider

    Returns RaycastResult

  • Parameters

    Returns any

  • Parameters

    Returns any

  • Parameters

    Returns any

  • Parameters

    • dt: number

    Returns void

  • Parameters

    Returns any