Skip to content

Class: GhostTrigger

The GhostTrigger Component represents a non-physical trigger in the physics world. It uses a ghost object to detect overlapping collisions without producing physical responses.

Hierarchy

  • ComponentBase

    GhostTrigger

Constructors

Properties

Accessors

Methods

Constructors

constructor

new GhostTrigger(): GhostTrigger

Returns

GhostTrigger

Inherited from

ComponentBase.constructor

Properties

object3D

object3D: Object3D = null

owner object3D

Inherited from

ComponentBase.object3D

Defined in

src/components/ComponentBase.ts:17


isDestroyed

Optional isDestroyed: boolean

Inherited from

ComponentBase.isDestroyed

Defined in

src/components/ComponentBase.ts:38

Accessors

shape

get shape(): btCollisionShape

Returns

btCollisionShape

Defined in

packages/physics/rigidbody/GhostTrigger.ts:19

set shape(value): void

Parameters

NameType
valuebtCollisionShape

Returns

void

Defined in

packages/physics/rigidbody/GhostTrigger.ts:22


userIndex

get userIndex(): number

Returns

number

Defined in

packages/physics/rigidbody/GhostTrigger.ts:31

set userIndex(value): void

Parameters

NameType
valuenumber

Returns

void

Defined in

packages/physics/rigidbody/GhostTrigger.ts:35


collisionFlags

get collisionFlags(): number

获取碰撞标志

Returns

number

Defined in

packages/physics/rigidbody/GhostTrigger.ts:45


ghostObject

get ghostObject(): btPairCachingGhostObject

获取幽灵对象

Returns

btPairCachingGhostObject

Defined in

packages/physics/rigidbody/GhostTrigger.ts:129


enableCollisionEvent

get enableCollisionEvent(): boolean

启用/禁用碰撞回调

Returns

boolean

Defined in

packages/physics/rigidbody/GhostTrigger.ts:144

set enableCollisionEvent(value): void

Parameters

NameType
valueboolean

Returns

void

Defined in

packages/physics/rigidbody/GhostTrigger.ts:147


collisionEvent

get collisionEvent(): (contactPoint: btManifoldPoint, selfBody: btRigidBody, otherBody: btRigidBody) => void

碰撞事件回调

Returns

fn

▸ (contactPoint, selfBody, otherBody): void

Parameters
NameType
contactPointbtManifoldPoint
selfBodybtRigidBody
otherBodybtRigidBody
Returns

void

Defined in

packages/physics/rigidbody/GhostTrigger.ts:155

set collisionEvent(callback): void

Parameters

NameType
callback(contactPoint: btManifoldPoint, selfBody: btRigidBody, otherBody: btRigidBody) => void

Returns

void

Defined in

packages/physics/rigidbody/GhostTrigger.ts:158


eventDispatcher

get eventDispatcher(): CEventDispatcher

Returns

CEventDispatcher

Inherited from

ComponentBase.eventDispatcher

Defined in

src/components/ComponentBase.ts:23

set eventDispatcher(value): void

Parameters

NameType
valueCEventDispatcher

Returns

void

Inherited from

ComponentBase.eventDispatcher

Defined in

src/components/ComponentBase.ts:28


isStart

get isStart(): boolean

Returns

boolean

Inherited from

ComponentBase.isStart

Defined in

src/components/ComponentBase.ts:40


transform

get transform(): Transform

Return the Transform component attached to the Object3D.

Returns

Transform

Inherited from

ComponentBase.transform

Defined in

src/components/ComponentBase.ts:47


enable

get enable(): boolean

Enable/disable components. The enabled components can be updated, while the disabled components cannot be updated.

Returns

boolean

Inherited from

ComponentBase.enable

Defined in

src/components/ComponentBase.ts:68

set enable(value): void

Enable/disable components. The enabled components can be updated, while the disabled components cannot be updated.

Parameters

NameType
valueboolean

Returns

void

Inherited from

ComponentBase.enable

Defined in

src/components/ComponentBase.ts:54

Methods

createAndAddGhostObject

createAndAddGhostObject(shape, position, rotation, collisionFlags?, userIndex?): btPairCachingGhostObject

创建幽灵对象并添加到物理世界。

Parameters

NameTypeDescription
shapebtCollisionShape碰撞形状。
positionVector3幽灵对象的位置。
rotationVector3幽灵对象的旋转。
collisionFlags?number可选参数,碰撞标志,默认值为 4 NO_CONTACT_RESPONSE 表示对象不参与碰撞响应,但仍会触发碰撞事件。
userIndex?number可选参数,用户索引,可作为物理对象标识。

Returns

btPairCachingGhostObject

新创建的 Ammo.btPairCachingGhostObject 对象。

Defined in

packages/physics/rigidbody/GhostTrigger.ts:103


addCollisionFlag

addCollisionFlag(value): void

添加单个碰撞标志

Parameters

NameType
valueCollisionFlags

Returns

void

Defined in

packages/physics/rigidbody/GhostTrigger.ts:52


removeCollisionFlag

removeCollisionFlag(value): void

删除单个碰撞标志

Parameters

NameType
valueCollisionFlags

Returns

void

Defined in

packages/physics/rigidbody/GhostTrigger.ts:59


start

start(): Promise<void>

Returns

Promise<void>

Overrides

ComponentBase.start

Defined in

packages/physics/rigidbody/GhostTrigger.ts:64


wait

wait(): Promise<btPairCachingGhostObject>

异步获取完成初始化的幽灵对象

Returns

Promise<btPairCachingGhostObject>

Defined in

packages/physics/rigidbody/GhostTrigger.ts:136


destroy

destroy(force?): void

Parameters

NameType
force?boolean

Returns

void

Overrides

ComponentBase.destroy

Defined in

packages/physics/rigidbody/GhostTrigger.ts:162


init

init(param?): void

Parameters

NameType
param?any

Returns

void

Inherited from

ComponentBase.init

Defined in

src/components/ComponentBase.ts:112


stop

stop(): void

Returns

void

Inherited from

ComponentBase.stop

Defined in

src/components/ComponentBase.ts:114


onEnable

onEnable(view?): any

Parameters

NameType
view?View3D

Returns

any

Inherited from

ComponentBase.onEnable

Defined in

src/components/ComponentBase.ts:115


onDisable

onDisable(view?): any

Parameters

NameType
view?View3D

Returns

any

Inherited from

ComponentBase.onDisable

Defined in

src/components/ComponentBase.ts:116


onUpdate

onUpdate(view?): any

Parameters

NameType
view?View3D

Returns

any

Inherited from

ComponentBase.onUpdate

Defined in

src/components/ComponentBase.ts:117


onLateUpdate

onLateUpdate(view?): any

Parameters

NameType
view?View3D

Returns

any

Inherited from

ComponentBase.onLateUpdate

Defined in

src/components/ComponentBase.ts:118


onBeforeUpdate

onBeforeUpdate(view?): any

Parameters

NameType
view?View3D

Returns

any

Inherited from

ComponentBase.onBeforeUpdate

Defined in

src/components/ComponentBase.ts:119


onCompute

onCompute(view?, command?): any

Parameters

NameType
view?View3D
command?GPUCommandEncoder

Returns

any

Inherited from

ComponentBase.onCompute

Defined in

src/components/ComponentBase.ts:120


onGraphic

onGraphic(view?): any

Parameters

NameType
view?View3D

Returns

any

Inherited from

ComponentBase.onGraphic

Defined in

src/components/ComponentBase.ts:121


onParentChange

onParentChange(lastParent?, currentParent?): any

Parameters

NameType
lastParent?Object3D
currentParent?Object3D

Returns

any

Inherited from

ComponentBase.onParentChange

Defined in

src/components/ComponentBase.ts:122


onAddChild

onAddChild(child): any

Parameters

NameType
childObject3D

Returns

any

Inherited from

ComponentBase.onAddChild

Defined in

src/components/ComponentBase.ts:123


onRemoveChild

onRemoveChild(child): any

Parameters

NameType
childObject3D

Returns

any

Inherited from

ComponentBase.onRemoveChild

Defined in

src/components/ComponentBase.ts:124


cloneTo

cloneTo(obj): void

clone component data to target object3D

Parameters

NameTypeDescription
objObject3Dtarget object3D

Returns

void

Inherited from

ComponentBase.cloneTo

Defined in

src/components/ComponentBase.ts:131


copyComponent

copyComponent(from): this

Parameters

NameType
fromthis

Returns

this

Inherited from

ComponentBase.copyComponent

Defined in

src/components/ComponentBase.ts:133


beforeDestroy

beforeDestroy(force?): void

before release this component, object refrences are not be set null now.

Parameters

NameType
force?boolean

Returns

void

Inherited from

ComponentBase.beforeDestroy

Defined in

src/components/ComponentBase.ts:200

Released under the MIT License