Small ammojs-like wrapper around the C++ bullet physics engine
https://guillaumebouchetepitech.github.io/FrankenPhys/samples/browser-test-bed/index.html
- FrankenPhys.0.0.1.js -> ~600ko (~60ko after server compression)
- FrankenPhys.0.0.1.wasm -> ~600ko (~250ko after server compression)
- TypeSafety, easy to get started, harder to make mistakes
- the TypeScript wrapper hide and handle the wasm memory allocations/deallocations
- no wasm memory leaks detected
- A "TypeScript Game Logic" can be reused on both server/client
- Worth checking the
/samplesfolder
- worth checking the
/samples/browser-test-bedfolder
- physical world
- rigid bodies
- shapes:
- box
- sphere
- cylinder
- capsule
- mesh
- compound (<- group of sub shapes)
- dynamic vehicles
- 6dof joints v1 (<- 6 degrees of freedom joins)
- 6dof joints v2 (<- twice slower but many times more stable than v1)
- hinges joints (<- this support motor torque)
Example at the physic world level:
interface ContactDataWorld {
contactId: number,
rigidBodyA: IPhysicBody,
rigidBodyB: IPhysicBody,
position: glm.vec3,
normalB: glm.vec3,
}
physicWorld.addEventListener('beginContact', (event) => {
console.log('beginContact', event.data.position);
});
physicWorld.addEventListener('updateContact', (event) => {
console.log('updateContact', event.data.position);
});
physicWorld.addEventListener('endContact', (event) => {
console.log('endContact', event.data.position);
});
// ccd -> "continuous collision detection"
physicWorld.addEventListener('ccdContact', (event) => {
console.log('ccdContact', event.data.position);
});Example at the physic body level:
export interface ContactDataBody {
contactId: number,
other: IPhysicBody,
position: glm.vec3,
normalB: glm.vec3,
}
physicBody.addEventListener('beginContact', (event) => {
console.log('beginContact', event.data.position);
});
physicBody.addEventListener('updateContact', (event) => {
console.log('updateContact', event.data.position);
});
physicBody.addEventListener('endContact', (event) => {
console.log('endContact', event.data.position);
});
// ccd -> "continuous collision detection"
physicBody.addEventListener('ccdContact', (event) => {
console.log('ccdContact', event.data.position);
});the contact event are not that reliable on dynamic mesh colliders
Useful when shooting "spherical physical bullet"
This prevent the faster "spherical physical bullet" from passing through objects
Example:
// ccd start when going faster than 0.4 units/sec
physicBody.setCcdMotionThreshold(0.4);
// ccd radius sphere is 0.5 units
physicBody.setCcdSweptSphereRadius(0.5);- Soft Volumes/Bodies -> this save some serious wasm-size/bandwidth