Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PhysicsSystem

物理系统。

Hierarchy

  • System
    • PhysicsSystem

Implements

Index

Constructors

Private constructor

Properties

Private _allowSleep

_allowSleep: boolean = true

Private _deltaTime

_deltaTime: number = 1.0 / 60.0

Private _enable

_enable: boolean = true

Protected _executeInEditMode

_executeInEditMode: boolean = false

Private _gravity

_gravity: Vec3 = new Vec3(0, -10, 0)

Protected _id

_id: string = ""

Private _material

_material: PhysicMaterial | null = null

Private _maxSubStep

_maxSubStep: number = 1

Protected _priority

_priority: number = 0

Private _useFixedTime

_useFixedTime: boolean = true

physicsWorld

physicsWorld: IPhysicsWorld

raycastClosestResult

raycastClosestResult: PhysicsRayResult = new PhysicsRayResult()

Private raycastResultPool

raycastResultPool: RecyclePool<PhysicsRayResult> = new RecyclePool<PhysicsRayResult>(() => {return new PhysicsRayResult();}, 1)

raycastResults

raycastResults: PhysicsRayResult[] = []

Static ID

ID: "physics"

Static Private _instance

_instance: PhysicsSystem

Accessors

allowSleep

  • get allowSleep(): boolean
  • set allowSleep(v: boolean): void

defaultMaterial

deltaTime

  • get deltaTime(): number
  • set deltaTime(value: number): void

enable

  • get enable(): boolean
  • set enable(value: boolean): void

gravity

  • get gravity(): Vec3
  • set gravity(gravity: Vec3): void

id

  • get id(): string
  • set id(id: string): void

maxSubStep

  • get maxSubStep(): number
  • set maxSubStep(value: number): void

priority

  • get priority(): number
  • set priority(value: number): void

useFixedTime

  • get useFixedTime(): boolean
  • set useFixedTime(value: boolean): void

Static instance

  • get instance(): any

Methods

Private updateMaterial

  • _updateMaterial(): void

init

  • init(): void

postUpdate

  • postUpdate(deltaTime: number): void
  • 执行一次物理系统的模拟,目前将在每帧自动执行一次。

    Parameters

    • deltaTime: number

      与上一次执行相差的时间,目前为每帧消耗时间

    Returns void

raycast

  • raycast(worldRay: ray, mask?: number, maxDistance?: number, queryTrigger?: boolean): boolean
  • 检测所有的碰撞盒,并记录所有被检测到的结果,通过 PhysicsSystem.instance.raycastResults 访问结果

    Parameters

    • worldRay: ray

      世界空间下的一条射线

    • Default value mask: number = 4294967295

      掩码,默认为 0xffffffff

    • Default value maxDistance: number = 10000000

      最大检测距离,默认为 10000000,目前请勿传入 Infinity 或 Number.MAX_VALUE

    • Default value queryTrigger: boolean = true

      是否检测触发器

    Returns boolean

    boolean 表示是否有检测到碰撞盒

raycastClosest

  • raycastClosest(worldRay: ray, mask?: number, maxDistance?: number, queryTrigger?: boolean): boolean
  • 检测所有的碰撞盒,并记录与射线距离最短的检测结果,通过 PhysicsSystem.instance.raycastClosestResult 访问结果

    Parameters

    • worldRay: ray

      世界空间下的一条射线

    • Default value mask: number = 4294967295

      掩码,默认为 0xffffffff

    • Default value maxDistance: number = 10000000

      最大检测距离,默认为 10000000,目前请勿传入 Infinity 或 Number.MAX_VALUE

    • Default value queryTrigger: boolean = true

      是否检测触发器

    Returns boolean

    boolean 表示是否有检测到碰撞盒

update

  • update(dt: number): void

Static sortByPriority

  • sortByPriority(a: System, b: System): 1 | 0 | -1

Object literals

Private raycastOptions

raycastOptions: object

group

group: number = -1

mask

mask: number = -1

maxDistance

maxDistance: number = 10000000

queryTrigger

queryTrigger: true = true

Generated using TypeDoc