Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PhysicsSystem

Physics system.

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

Gets the collision matrix。

Readonly physicsWorld

physicsWorld: IPhysicsWorld

Gets the wrappered object of the physical world through which you can access the actual underlying object.

Readonly raycastClosestResult

raycastClosestResult: PhysicsRayResult = new PhysicsRayResult()

Gets the raycastClosest test result.

Private Readonly raycastResultPool

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

Readonly raycastResults

raycastResults: PhysicsRayResult[] = []

Gets the raycast test results.

Readonly useCollisionMatrix

useCollisionMatrix: boolean

Gets or sets whether to use a collision matrix.

Readonly useNodeChains

useNodeChains: boolean

Static Readonly ID

ID: "PHYSICS" = "PHYSICS"

Gets the ID of the system.

Static Private Readonly _instance

_instance: PhysicsSystem

Accessors

allowSleep

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

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

    zh

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

    Returns boolean

  • zh

    获取或设置物理系统是否允许自动休眠,默认为 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
  • Collision detect all collider, and record all the detected results, through PhysicsSystem.Instance.RaycastResults access to the results.

    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
  • Collision detect all collider, and record and ray test results with the shortest distance by PhysicsSystem.Instance.RaycastClosestResult access to the results.

    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
  • Reset the mask corresponding to all groups of the collision matrix to the given value, the default given value is' 0xffffffff '.

    Parameters

    • Default value mask: number = 4294967295

    Returns void

setCollisionGroup

  • setCollisionGroup(group1: number, group2: number, collision?: boolean): void
  • Sets whether collisions occur between group1 and group2.

    Parameters

    • group1: number
    • group2: number
    • Default value collision: boolean = true

      is collision occurs?

    Returns void

step

  • step(fixedTimeStep: number, deltaTime?: undefined | number, maxSubSteps?: undefined | number): void
  • Perform simulation steps for the physics world.

    Parameters

    • fixedTimeStep: number
    • Optional deltaTime: undefined | number
    • Optional maxSubSteps: undefined | number

    Returns void

syncSceneToPhysics

  • syncSceneToPhysics(): void

update

  • update(dt: number): void
  • Update function of the system, it will be invoked between all components update phase and late update phase.

    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