mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
34c8e6650d
* Rename built-in-*** to builtin-*** * Rename r to radius and c to center; * Add method : transkateAndRotate & setScale to obb & sphere; Delete unneed class box in box.ts file * Fix builtin physics Bug of #751 & Modify the physics relative component * Add macro condition, some method is not declare in builtin * Rename CC_PHYISCS_*** to CC_PHYSICS_***; * rename BuiltIn*** to Builtin*** * Typing intersect
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
|
|
declare const global: any;
|
|
const _global = typeof window === 'undefined' ? global : window;
|
|
|
|
// tslint:disable: no-string-literal
|
|
if (typeof _global['CC_PHYSICS_CANNON'] === 'undefined') {
|
|
_global['CC_PHYSICS_CANNON'] = false;
|
|
}
|
|
|
|
if (typeof _global['CC_PHYSICS_AMMO'] === 'undefined') {
|
|
_global['CC_PHYSICS_AMMO'] = false;
|
|
}
|
|
|
|
if (typeof _global['CC_PHYSICS_BUILT_IN'] === 'undefined') {
|
|
_global['CC_PHYSICS_BUILT_IN'] = true;
|
|
}
|
|
|
|
// Cannon
|
|
import { CannonBoxShape, CannonRigidBody, CannonSphereShape, CannonWorld } from './cannon-impl';
|
|
|
|
// Ammo
|
|
// import { AmmoBoxShape, AmmoRaycastResult, AmmoRigidBody, AmmoSphereShape, AmmoWorld, } from './ammo-impl';
|
|
|
|
// built-in
|
|
import { BuiltInBody } from './cocos/builtin-body';
|
|
import { BuiltInWorld } from './cocos/builtin-world';
|
|
import { BuiltinBoxShape } from './cocos/shapes/builtin-box-shape';
|
|
import { BuiltinSphereShape } from './cocos/shapes/builtin-sphere-shape';
|
|
|
|
export let BoxShape: typeof CannonBoxShape | typeof BuiltinBoxShape;
|
|
export let SphereShape: typeof CannonSphereShape | typeof BuiltinSphereShape;
|
|
export let RigidBody: typeof CannonRigidBody | typeof BuiltInBody;
|
|
export let PhysicsWorld: typeof CannonWorld | typeof BuiltInWorld;
|
|
|
|
if (CC_PHYSICS_CANNON) {
|
|
BoxShape = CannonBoxShape;
|
|
SphereShape = CannonSphereShape;
|
|
RigidBody = CannonRigidBody;
|
|
PhysicsWorld = CannonWorld;
|
|
} else if (CC_PHYSICS_AMMO) {
|
|
// TODO : 选择AMMO
|
|
} else if (CC_PHYSICS_BUILT_IN) {
|
|
BoxShape = BuiltinBoxShape;
|
|
SphereShape = BuiltinSphereShape;
|
|
RigidBody = BuiltInBody;
|
|
PhysicsWorld = BuiltInWorld;
|
|
}
|