Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PhysicsSystem

物理系统。

Hierarchy

  • System
    • PhysicsSystem

Implements

Index

Constructors

Private constructor

Properties

Private _accumulator

_accumulator: number = 0

Private _allowSleep

_allowSleep: boolean = true

Private _autoSimulation

_autoSimulation: boolean = true

Private _enable

_enable: boolean = true

Protected _executeInEditMode

_executeInEditMode: boolean = false

Private _fixedTimeStep

_fixedTimeStep: number = 1.0 / 60.0

Private Readonly _gravity

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

Protected _id

_id: string = ""

Private Readonly _material

_material: PhysicMaterial = new PhysicMaterial()

Private _maxSubSteps

_maxSubSteps: number = 1

Protected _priority

_priority: number = 0

Private _sleepThreshold

_sleepThreshold: number = 0.1

Private _subStepCount

_subStepCount: number = 0

Readonly collisionMatrix

collisionMatrix: ICollisionMatrix = new CollisionMatrix() as unknown as ICollisionMatrix

获取碰撞矩阵。

Readonly physicsWorld

physicsWorld: IPhysicsWorld

获取物理世界的封装对象,通过它你可以访问到实际的底层对象。

Readonly raycastClosestResult

raycastClosestResult: PhysicsRayResult = new PhysicsRayResult()

获取 raycastClosest 的检测结果。

Private Readonly raycastResultPool

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

Readonly raycastResults

raycastResults: PhysicsRayResult[] = []

获取 raycast 的检测结果。

Readonly useCollisionMatrix

useCollisionMatrix: boolean

获取或设置是否开启碰撞矩阵。

Readonly useNodeChains

useNodeChains: boolean

Static Readonly ID

ID: "PHYSICS" = "PHYSICS"

获取此系统的ID。

Static Private Readonly _instance

_instance: PhysicsSystem

Accessors

allowSleep

  • get allowSleep(): boolean
  • set allowSleep(v: boolean): void
  • Gets or sets whether the physical system allows automatic sleep, which defaults to true.

    zh

    获取或设置物理系统是否允许自动休眠,默认为 true。

    Returns boolean

  • Gets or sets whether the physical system allows automatic sleep, which defaults to true.

    zh

    获取或设置物理系统是否允许自动休眠,默认为 true。

    Parameters

    • v: boolean

    Returns void

autoSimulation

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

defaultMaterial

enable

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

fixedTimeStep

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

gravity

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

id

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

maxSubSteps

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

priority

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

sleepThreshold

  • get sleepThreshold(): number
  • set sleepThreshold(v: number): void

Static PHYSICSAMMO

  • get PHYSICSAMMO(): boolean

Static PHYSICSBUILTIN

  • get PHYSICSBUILTIN(): boolean

Static PHYSICSCANNON

  • get PHYSICSCANNON(): boolean

Static PHYSICSNONE

  • get PHYSICSNONE(): boolean

Static PhysicsGroup

Static instance

Methods

Private updateMaterial

  • _updateMaterial(): void

emitEvents

  • emitEvents(): void

init

  • init(): void

isCollisionGroup

  • isCollisionGroup(group1: number, group2: number): number | false

postUpdate

  • postUpdate(deltaTime: number): 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 表示是否有检测到碰撞盒

resetAccumulator

  • resetAccumulator(time?: number): void

resetCollisionMatrix

  • resetCollisionMatrix(mask?: number): void

setCollisionGroup

  • setCollisionGroup(group1: number, group2: number, collision?: boolean): void

step

  • step(fixedTimeStep: number, deltaTime?: undefined | number, maxSubSteps?: undefined | number): void

syncSceneToPhysics

  • syncSceneToPhysics(): void

update

  • update(dt: number): void
  • 系统的帧更新函数,它会在所有组件的 update 和 lateUpdate 之间被调用

    Parameters

    • dt: number

      Delta time after the last frame

    Returns void

updateCollisionMatrix

  • updateCollisionMatrix(): void

Static sortByPriority

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

Object literals

Private Readonly raycastOptions

raycastOptions: object

group

group: number = -1

mask

mask: number = -1

maxDistance

maxDistance: number = 10000000

queryTrigger

queryTrigger: true = true

Generated using TypeDoc