Interface for physics manager.

物理管理器的接口。

interface IPhysicsManager {
    addCollider(collider: ICollider): void;
    destroy(): void;
    enableDebugDrawer(value: boolean): void;
    rayCast(
        ray: Ray,
        outHitResult: HitResult,
        distance?: number,
        collisonGroup?: number,
        collisionMask?: number,
    ): boolean;
    rayCastAll(
        ray: Ray,
        out: HitResult[],
        distance?: number,
        collisonGroup?: number,
        collisionMask?: number,
    ): boolean;
    removeCollider(collider: ICollider): void;
    setActiveCollider(collider: ICollider, value: boolean): void;
    setGravity(gravity: Vector3): void;
    shapeCast(
        shape: IColliderShape,
        fromPosition: Vector3,
        toPosition: Vector3,
        out: HitResult,
        fromRotation?: Quaternion,
        toRotation?: Quaternion,
        collisonGroup?: number,
        collisionMask?: number,
        allowedCcdPenetration?: number,
    ): boolean;
    shapeCastAll(
        shape: IColliderShape,
        fromPosition: Vector3,
        toPosition: Vector3,
        out: HitResult[],
        fromRotation?: Quaternion,
        toRotation?: Quaternion,
        collisonGroup?: number,
        collisionMask?: number,
        allowedCcdPenetration?: number,
    ): boolean;
    update(elapsedTime: number): void;
}

实现于

方法

  • 参数

    • ray: Ray

      The ray to cast.

    • outHitResult: HitResult

      The result of the raycast.

    • 可选distance: number

      Maximum distance of the raycast.

    • 可选collisonGroup: number

      Collision group for filtering.

    • 可选collisionMask: number

      Collision mask for filtering.

    返回 boolean

    Perform a raycast to find the first collision.

    执行射线检测以找到第一个碰撞。

  • 参数

    • ray: Ray

      The ray to cast.

    • out: HitResult[]

      Array to store all hit results.

    • 可选distance: number

      Maximum distance of the raycast.

    • 可选collisonGroup: number

      Collision group for filtering.

    • 可选collisionMask: number

      Collision mask for filtering.

    返回 boolean

    Perform a raycast to find all collisions.

    执行射线检测以找到所有碰撞。

  • 参数

    • shape: IColliderShape

      The shape to cast.

    • fromPosition: Vector3

      Start position of the cast.

    • toPosition: Vector3

      End position of the cast.

    • out: HitResult

      The result of the shape cast.

    • 可选fromRotation: Quaternion

      Start rotation of the cast.

    • 可选toRotation: Quaternion

      End rotation of the cast.

    • 可选collisonGroup: number

      Collision group for filtering.

    • 可选collisionMask: number

      Collision mask for filtering.

    • 可选allowedCcdPenetration: number

      Allowed continuous collision detection penetration.

    返回 boolean

    Perform a shape cast to find the first collision.

    执行形状投射以找到第一个碰撞。

  • 参数

    • shape: IColliderShape

      The shape to cast.

    • fromPosition: Vector3

      Start position of the cast.

    • toPosition: Vector3

      End position of the cast.

    • out: HitResult[]

      Array to store all hit results.

    • 可选fromRotation: Quaternion

      Start rotation of the cast.

    • 可选toRotation: Quaternion

      End rotation of the cast.

    • 可选collisonGroup: number

      Collision group for filtering.

    • 可选collisionMask: number

      Collision mask for filtering.

    • 可选allowedCcdPenetration: number

      Allowed continuous collision detection penetration.

    返回 boolean

    Perform a shape cast to find all collisions.

    执行形状投射以找到所有碰撞。

  • 参数

    • elapsedTime: number

      Step time for the update.

    返回 void

    Update the physics world, called on every frame to update object poses.

    更新物理世界,每帧调用以更新对象姿态。