Files
cocos4/cocos/physics/framework/physics-interface.ts
T
jiaxin.lai 1a99b886b6 refactor physics framework & wrapper (#5667)
* basic physics abstract spec

* spec tweaks

* stash

* cannon refactor

* builtin refactor

* cannon wrapper & framework tweaks

* cannon wrapper import tweaks

* remve unneeded code

* group mask tweaks

* hiding, wait for 1.0.3

* builtin tweaks

* delete unneed code

* export CANNON

* update @cocos/cannon to 1.0.3

* using hasTigger property

* fix remove cannon body

* rebase

* update cannon version to 1.0.4

* rename stash

* rename I-rigid-body to i-rigid-body
2019-12-13 16:00:22 +08:00

109 lines
1.9 KiB
TypeScript

/**
* @category physics
*/
import { Vec3 } from '../../core/math';
import { ColliderComponent } from './components/collider/collider-component';
/**
* @zh
* 触发事件。
*/
export interface ITriggerEvent {
/**
* @zh
* 触发的事件类型
*/
readonly type: TriggerEventType;
/**
* @zh
* 触发事件中的自己的碰撞器
*/
readonly selfCollider: ColliderComponent;
/**
* @zh
* 触发事件中的另一个碰撞器
*/
readonly otherCollider: ColliderComponent;
}
/**
* @zh
* 触发事件的值类型定义。
*/
export type TriggerEventType = 'onTriggerEnter' | 'onTriggerStay' | 'onTriggerExit';
/**
* @zh
* 触发事件的回调函数签名定义。
*/
export type TriggerCallback = (event: ITriggerEvent) => void;
/**
* @zh
* 碰撞事件的碰撞信息。
*/
export interface IContactEquation {
/**
* @zh
* 碰撞信息中的碰撞点A。
*/
readonly contactA: Vec3;
/**
* @zh
* 碰撞信息中的碰撞点B。
*/
readonly contactB: Vec3;
/**
* @zh
* 碰撞信息中的法线。
*/
readonly normal: Vec3;
}
/**
* @zh
* 碰撞事件。
*/
export interface ICollisionEvent {
/**
* @zh
* 碰撞的事件类型。
*/
readonly type: CollisionEventType;
/**
* @zh
* 碰撞中的自己的碰撞器。
*/
readonly selfCollider: ColliderComponent;
/**
* @zh
* 碰撞中的另一个碰撞器。
*/
readonly otherCollider: ColliderComponent;
/**
* @zh
* 碰撞中的所有碰撞点的信息。
*/
readonly contacts: IContactEquation[];
}
/**
* @zh
* 碰撞事件的值类型定义。
*/
export type CollisionEventType = 'onCollisionEnter' | 'onCollisionStay' | 'onCollisionExit';
/**
* @zh
* 碰撞事件的回调函数签名定义。
*/
export type CollisionCallback = (event: ICollisionEvent) => void;