xr-frame / Exports / ShapeInteract
# Class: ShapeInteract
拥有ShapeInterace组件的Shape才能与其他Shape发生交互。
将collide属性设置为true来与其他Shape进行物理碰撞,仅当两个Shape的collide属性都为true时它们才能发生碰撞。
# Hierarchy
-
↳
ShapeInteract
# Table of contents
# Constructors
# Events
# Properties
# Accessors
# Methods
# Constructors
# constructor
• new ShapeInteract()
# Overrides
# Events
# onAdd
▸ onAdd(parent, data): void
所挂载的element被挂载到场景时触发的回调。
# Parameters
| Name | Type |
|---|---|
parent | Element |
data | IShapeInteractData |
# Returns
void
# Inherited from
# onRelease
▸ onRelease(data): void
从被挂载的element上被移除,或是element被销毁时,触发的回调。
一般用于释放持有的资源。
# Parameters
| Name | Type |
|---|---|
data | IShapeInteractData |
# Returns
void
# Inherited from
# onRemove
▸ onRemove(parent, data): void
所挂载的element从父节点parent被移除时,或者自己从element上被移除时,触发的回调。
一般用于消除功能的运作。
如果一个组件的元素直接被销毁了,那这个组件就不会经历onRemove而是直接进入onRelease。
# Parameters
| Name | Type |
|---|---|
parent | Element |
data | IShapeInteractData |
# Returns
void
# Inherited from
# onTick
▸ onTick(deltaTime, data): void
渲染每帧触发的回调。
# Parameters
| Name | Type | Description |
|---|---|---|
deltaTime | number | 单位为毫秒(ms)。 |
data | IShapeInteractData | - |
# Returns
void
# Inherited from
# onUpdate
▸ onUpdate(data, preData): void
数据更新时触发的回调。
# Parameters
| Name | Type |
|---|---|
data | IShapeInteractData |
preData | IShapeInteractData |
# Returns
void
# Inherited from
# Properties
# priority
• Readonly priority: number
自定义组件的更新优先级。
# Inherited from
# schema
• Readonly schema: IComponentSchema
自定义组件的schema。
# Overrides
# EVENTS
▪ Static EVENTS: string[] = []
# Inherited from
# Accessors
# bounceCombine
• get bounceCombine(): CombineMode
如何结合发生碰撞的两个物体的弹性系数。
default {@link CombineMode.Average}
# Returns
CombineMode
• set bounceCombine(v): void
如何结合发生碰撞的两个物体的弹性系数。
# Parameters
| Name | Type |
|---|---|
v | CombineMode |
# Returns
void
# bounciness
• get bounciness(): number
弹性系数,决定碰撞时的能量损失比例。
弹性系数 = 1时,碰撞无能量损失。
limit 0 <= bounciness <= 1
default 0
# Returns
number
• set bounciness(): void
弹性系数,决定碰撞时的能量损失比例。
弹性系数 = 1时,碰撞无能量损失。
# Returns
void
# dynamicFriction
• get dynamicFriction(): number
动摩擦系数。
limit 0 <= dynamicFriction <= 1
default 0.6
# Returns
number
• set dynamicFriction(): void
动摩擦系数。
# Returns
void
# el
• get el(): Element
挂载的元素。
# Returns
# frictionCombine
• get frictionCombine(): CombineMode
如何结合发生碰撞的两个物体的摩擦系数。
default {@link CombineMode.Average}
# Returns
CombineMode
• set frictionCombine(v): void
如何结合发生碰撞的两个物体的摩擦系数。
# Parameters
| Name | Type |
|---|---|
v | CombineMode |
# Returns
void
# scene
• get scene(): Scene
当前场景。
# Returns
# staticFriction
• get staticFriction(): number
静摩擦系数
limit 0 <= staticFriction <= 1
default 0.6
# Returns
number
• set staticFriction(): void
静摩擦系数
# Returns
void
# version
• get version(): number
当前版本,每次有数据更新都会增加,可以用作和其他组件合作的依据。
# Returns
number
# Methods
# getData
▸ getData<T>(key): IShapeInteractData[T]
获取一个当前值。
# Type parameters
| Name | Type |
|---|---|
T | extends keyof IShapeInteractData |
# Parameters
| Name | Type |
|---|---|
key | T |
# Returns
# Inherited from
# getInteractType
▸ getInteractType(): EShapeInteractType
# Returns
EShapeInteractType
# setData
▸ setData(data): void
不通过xml而是直接设置data,注意值的类型需要和schema中一致。
# Parameters
| Name | Type |
|---|---|
data | Partial<IShapeInteractData> |
# Returns
void
# Inherited from
# setDataOne
▸ setDataOne<T>(key, value): void
设置一个数据。
# Type parameters
| Name | Type |
|---|---|
T | extends keyof IShapeInteractData |
# Parameters
| Name | Type |
|---|---|
key | T |
value | IShapeInteractData[T] |
# Returns
void