mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 19:42:39 +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
42 lines
903 B
TypeScript
42 lines
903 B
TypeScript
/**
|
|
* @hidden
|
|
*/
|
|
interface IPhysicsWrapperObject {
|
|
PhysicsWorld: any,
|
|
RigidBody?: any,
|
|
|
|
BoxShape: any,
|
|
SphereShape: any,
|
|
CapsuleShape?: any,
|
|
TrimeshShape?: any,
|
|
CylinderShape?: any,
|
|
ConeShape?: any,
|
|
TerrainShape?: any,
|
|
SimplexShape?: any,
|
|
PlaneShape?: any,
|
|
|
|
PointToPointConstraint?: any,
|
|
HingeConstraint?: any,
|
|
ConeTwistConstraint?: any,
|
|
}
|
|
|
|
export let WRAPPER: IPhysicsWrapperObject;
|
|
type WrapperCallBack = () => IPhysicsWrapperObject | null;
|
|
let callback: WrapperCallBack[] = [];
|
|
export function registerSelectorCB (cb: WrapperCallBack) {
|
|
const index = callback.indexOf(cb);
|
|
if (index < 0) {
|
|
callback.push(cb);
|
|
}
|
|
}
|
|
|
|
export function initPhysicsSelector () {
|
|
for (let i = 0; i < callback.length; i++) {
|
|
const obj = callback[i]();
|
|
if (obj) {
|
|
WRAPPER = obj;
|
|
return;
|
|
}
|
|
}
|
|
}
|