mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
65b0478c69
* 3d v1.1.1-exp physics expriment (#6787) * activate when not awake (#6781) * activate when not awake * cannon too * off event listener when onDestroy * add clearVelocity & clearForces * add CC_CONFIG to ammo\cannon * add convex mesh & reuse mesh * cache enable false by default * terrain collider * cone collider * fix scale of ammo box & sphere * simple collider * add worldBounds & boundingSphere to collider * add clear*** to rigid body * enhance physics material * enhance event * plane collider * stash * tweaks * update @cocos/ammo to v1.0.7-beta.1 * typing * enchance update shape dynamic * absolute scale cannon-box * expose allowsleep * fix warning of generate declaration * remove physics_builtin * DO NOT MERGE * Better reuse * Correct construct and deconstruct * avoid ammo memory leaks * minor refactor contact data * fix cannon terrain tileSize * stash * optimize auto wakeup * [Ammo] fix update by re add * 400~ * overwrite ArrayCollisionMatrix.prototype.reset * Export enum by namespace * stash * fix remove child shape of btCompound * fix event with CCD * dynamic instantiate * STASH * add group to rigid body * update attachedRigidBody of collider in editor * stash physics config * tweaks of ammo config * stash * stash * collision matrix * stash * rename deltaTime to fixedTimeStep * group mask collider * allow get mask * set default group to Layers.Enum.DEFAULT * add group change fallback * cannon collision matrix * fix * update @cocos/ammo to 1.0.7-beta.2 * more prop * fix * disable on 1.1.1-exp * tweaks * fix circular dependency * tweaks * rename simple to simplex * rename collider -> colliders * stash * ammo p2p * hinge constraint * adapt cannon p2p pivotB * ammo p2p setPivotB * constraint * tweaks * remove macro of physics * refactor physics selector * import ammo from ammo-instantiated * update @cocos/ammo * update @cocos/cannon
205 lines
5.0 KiB
TypeScript
205 lines
5.0 KiB
TypeScript
/**
|
|
* @category physics
|
|
*/
|
|
|
|
import { IVec3Like } from '../../core/math';
|
|
import { ColliderComponent } from './components/colliders/collider-component';
|
|
|
|
/**
|
|
* @en
|
|
* The definition of the triggering event.
|
|
* @zh
|
|
* 触发事件。
|
|
*/
|
|
export interface ITriggerEvent {
|
|
/**
|
|
* @en
|
|
* The type of trigger event.
|
|
* @zh
|
|
* 触发的事件类型。
|
|
*/
|
|
readonly type: TriggerEventType;
|
|
|
|
/**
|
|
* @en
|
|
* The collider component instance of the event owner.
|
|
* @zh
|
|
* 触发事件中的自己的碰撞器
|
|
*/
|
|
readonly selfCollider: ColliderComponent;
|
|
|
|
/**
|
|
* @en
|
|
* Trigger another collider in event.
|
|
* @zh
|
|
* 触发事件中的另一个碰撞器
|
|
*/
|
|
readonly otherCollider: ColliderComponent;
|
|
|
|
/**
|
|
* @en
|
|
* Gets the lowLevel object, through which all the exposed properties can be accessed.
|
|
* @zh
|
|
* 获取实现对象,通过它可以访问到底层暴露的所有属性。
|
|
*/
|
|
readonly impl: any
|
|
}
|
|
|
|
/**
|
|
* @en
|
|
* The value type definition of the trigger event.
|
|
* @zh
|
|
* 触发事件的值类型定义。
|
|
*/
|
|
export type TriggerEventType = 'onTriggerEnter' | 'onTriggerStay' | 'onTriggerExit';
|
|
|
|
/**
|
|
* @en
|
|
* Signature definition of the callback function that triggers the event.
|
|
* @zh
|
|
* 触发事件的回调函数签名定义。
|
|
*/
|
|
export type TriggerCallback = (event?: ITriggerEvent) => void;
|
|
|
|
/**
|
|
* @en
|
|
* Collision information for collision events.
|
|
* @zh
|
|
* 碰撞事件的碰撞信息。
|
|
*/
|
|
export interface IContactEquation {
|
|
/**
|
|
* @en
|
|
* Gets the lowLevel object, through which all the exposed properties can be accessed.
|
|
* @zh
|
|
* 获取实现对象,通过它可以访问到底层暴露的所有属性。
|
|
*/
|
|
readonly impl: any;
|
|
|
|
/**
|
|
* @en
|
|
* Gets whether the rigid body bound to the selfCollider is A.
|
|
* @zh
|
|
* 获取`selfCollider`所绑定的刚体是否为 A 。
|
|
*/
|
|
readonly isBodyA: boolean;
|
|
|
|
/**
|
|
* @en
|
|
* Gets the contact point relative to the rigid body A in the local coordinate system.
|
|
* @zh
|
|
* 获取本地坐标系中相对于刚体 A 的碰撞点。
|
|
* @param out used to storage the output.
|
|
*/
|
|
getLocalPointOnA (out: IVec3Like): void;
|
|
|
|
/**
|
|
* @en
|
|
* Gets the contact point relative to the rigid body B in the local coordinate system.
|
|
* @zh
|
|
* 获取本地坐标系中相对于刚体 B 的碰撞点。
|
|
* @param out used to storage the output.
|
|
*/
|
|
getLocalPointOnB (out: IVec3Like): void;
|
|
|
|
/**
|
|
* @en
|
|
* Gets the contact point relative to the rigid body A in the world coordinate system.
|
|
* @zh
|
|
* 获取世界坐标系中相对于刚体 A 的碰撞点。
|
|
* @param out used to storage the output.
|
|
*/
|
|
getWorldPointOnA (out: IVec3Like): void;
|
|
|
|
/**
|
|
* @en
|
|
* Gets the contact point relative to the rigid body B in the world coordinate system.
|
|
* @zh
|
|
* 获取世界坐标系中相对于刚体 B 的碰撞点。
|
|
* @param out used to storage the output.
|
|
*/
|
|
getWorldPointOnB (out: IVec3Like): void;
|
|
|
|
/**
|
|
* @en
|
|
* Gets the contact normal relative to the rigid body B in the local coordinate system.
|
|
* @zh
|
|
* 获取本地坐标系中相对于刚体 B 的碰撞法线。
|
|
* @param out used to storage the output.
|
|
*/
|
|
getLocalNormalOnB (out: IVec3Like): void;
|
|
|
|
/**
|
|
* @en
|
|
* Gets the contact normal relative to the rigid body B in the world coordinate system.
|
|
* @zh
|
|
* 获取世界坐标系中相对于刚体 B 的碰撞法线。
|
|
* @param out used to storage the output.
|
|
*/
|
|
getWorldNormalOnB (out: IVec3Like): void;
|
|
}
|
|
|
|
/**
|
|
* @en
|
|
* The definition of the collision event.
|
|
* @zh
|
|
* 碰撞事件。
|
|
*/
|
|
export interface ICollisionEvent {
|
|
/**
|
|
* @en
|
|
* The type of collision event.
|
|
* @zh
|
|
* 碰撞的事件类型。
|
|
*/
|
|
readonly type: CollisionEventType;
|
|
|
|
/**
|
|
* @en
|
|
* The collider component instance of the event owner.
|
|
* @zh
|
|
* 碰撞中的自己的碰撞器。
|
|
*/
|
|
readonly selfCollider: ColliderComponent;
|
|
|
|
/**
|
|
* @en
|
|
* Another collider in collision.
|
|
* @zh
|
|
* 碰撞中的另一个碰撞器。
|
|
*/
|
|
readonly otherCollider: ColliderComponent;
|
|
|
|
/**
|
|
* @en
|
|
* Information about all points of impact in a collision event.
|
|
* @zh
|
|
* 碰撞中的所有碰撞点的信息。
|
|
*/
|
|
readonly contacts: IContactEquation[];
|
|
|
|
/**
|
|
* @en
|
|
* Gets the lowLevel object, through which all the exposed properties can be accessed.
|
|
* @zh
|
|
* 获取实现对象,通过它可以访问到底层暴露的所有属性。
|
|
*/
|
|
readonly impl: any;
|
|
}
|
|
|
|
/**
|
|
* @en
|
|
* Value type definitions for collision events.
|
|
* @zh
|
|
* 碰撞事件的值类型定义。
|
|
*/
|
|
export type CollisionEventType = 'onCollisionEnter' | 'onCollisionStay' | 'onCollisionExit';
|
|
|
|
/**
|
|
* @en
|
|
* Callback function signature definition for collision events.
|
|
* @zh
|
|
* 碰撞事件的回调函数签名定义。
|
|
*/
|
|
export type CollisionCallback = (event?: ICollisionEvent) => void;
|