playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
116 lines (115 loc) • 3.96 kB
TypeScript
/**
* The Ammo.js (Bullet) physics backend. Expects the `Ammo` global to be available when
* constructed - the RigidBodyComponentSystem only creates it after the Ammo WasmModule has
* loaded.
*
* @ignore
*/
export class AmmoPhysicsWorld extends PhysicsWorld {
/**
* Create a new AmmoPhysicsWorld instance.
*
* @param {object} [options] - The world options. See {@link PhysicsWorld}.
*/
constructor(options?: object);
/** @private */
private _gravityFloat32;
/**
* Built triangle data cached per geometry source id, shared by all mesh shapes created
* from the same geometry. Entries live until the world is destroyed.
*
* @type {Map<number, object>}
* @ignore
*/
_triMeshCache: Map<number, object>;
/**
* The shared static body world-pinned joints attach to, lazily created.
*
* @type {object|null}
* @ignore
*/
_fixedBody: object | null;
/**
* The fixed timestep of the last simulation step, used by joint motor conversions.
*
* @ignore
*/
_fixedTimeStep: number;
collisionConfiguration: any;
dispatcher: any;
overlappingPairCache: any;
solver: any;
_useTickCallback: boolean;
_contactPair: AmmoContactPair;
_btVec1: any;
_btVec2: any;
_btQuat: any;
_btTransform: any;
_btRayStart: any;
_btRayEnd: any;
/**
* @param {PhysicsBodyDesc} desc - The body descriptor.
* @returns {AmmoPhysicsBody} The new body.
*/
createBody(desc: PhysicsBodyDesc): AmmoPhysicsBody;
destroyBody(body: any): void;
addBody(body: any, group: any, mask: any): void;
removeBody(body: any): void;
destroyShape(shape: any): void;
addCompoundChild(compound: any, child: any, position: any, rotation: any): void;
updateCompoundChild(compound: any, child: any, position: any, rotation: any): void;
removeCompoundChild(compound: any, child: any): void;
getCompoundChildCount(compound: any): any;
/**
* @param {PhysicsJointDesc} desc - The joint descriptor.
* @returns {AmmoPhysicsJoint} The new joint.
*/
createJoint(desc: PhysicsJointDesc): AmmoPhysicsJoint;
destroyJoint(joint: any): void;
step(dt: any, maxSubSteps: any, fixedTimeStep: any): void;
/**
* Walks the dispatcher's contact manifolds and reports each contacting pair with entities
* on both bodies to the contact listener.
*
* @private
*/
private _walkContacts;
raycastFirst(start: any, end: any, options?: {}): RaycastResult;
raycastAll(start: any, end: any, options?: {}): RaycastResult[];
}
import { PhysicsWorld } from '../physics-world.js';
/**
* @import { ContactPoint } from '../../components/rigid-body/contact-point.js'
* @import { PhysicsBodyDesc, PhysicsJointDesc, PhysicsShapeDesc } from '../physics-world.js'
*/
/**
* The reused contact pair reported to the contact listener. Reads contact point data straight
* from the current native manifold - nothing is allocated.
*
* @ignore
*/
declare class AmmoContactPair {
entityA: any;
entityB: any;
triggerA: boolean;
triggerB: boolean;
contactCount: number;
/**
* The native btPersistentManifold currently being reported.
*
* @private
*/
private _manifold;
/**
* @param {number} index - The contact point index.
* @param {ContactPoint} out - The contact point to fill, from body A's perspective.
*/
readContact(index: number, out: ContactPoint): void;
}
import type { PhysicsBodyDesc } from '../physics-world.js';
import { AmmoPhysicsBody } from './ammo-physics-body.js';
import type { PhysicsJointDesc } from '../physics-world.js';
import type { AmmoPhysicsJoint } from './ammo-physics-joint.js';
import { RaycastResult } from '../../components/rigid-body/raycast-result.js';
import type { ContactPoint } from '../../components/rigid-body/contact-point.js';
export {};