@xr3ngine/three-physx
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

Three-Physx

Natively multithreaded physics for threejs with PhysX and an easy interface.

Credit to Milkshake inc, physx-js, three-ammo, three-to-cannon, engine-3-zjt

DISCLAIMER: this is a work in progress and API & implementation is set to change

Progress:

  • [x] Load WASM in webworker
  • [x] Set up message queue & function calls over events
  • [x] three-to-physx shape converter
  • [x] return transforms
  • [x] kinematic
  • [x] collision events
  • [x] update bodies
  • [x] new build with more bindings
  • [x] put body ids on arraybuffers for more efficient data transfer
  • [x] capsule
  • [x] character controller
  • [x] collision filtering
  • [x] trimesh and convex
  • [x] raycasts
  • [ ] raycasts ignore backface option
  • [ ] vehicle controller
  • [ ] heightfield colliders
  • [ ] fix root object scaling bug
  • [ ] geometry per instance scaling
  • [ ] add subscribe for event listeners on worker to reduce redundant transfer overhead
  • [ ] advanced & customisable collision filtering
  • [ ] full api support (eventually)
  • [ ] move most stuff to WASM for improved performance

Example

https://three-physx.netlify.app/

Netlify Status

API

-work in progress- (outdated)

This multithreaded PhysX API uses a singleton approach. This way the PhysX interface is accessible globally once instantiated.

// create the interface
new PhysXInstance(worker: Worker, onUpdate: () => void);

// load PhysX and launch the simulation
await PhysXInstance.instance.initPhysX({ jsPath: string, wasmPath: string });

// add an object
await PhysXInstance.instance.addBody(object: Object3D);

Body parameters are read from object.userData. This allows externally loaded models to be given physx bodies in their respective editors.

object.userData.physx = {
  type: PhysXBodyType,
  shapes: [
    {
      type: PhysXShapeType.Box,
      halfExtents: { x: 1, y: 1, z: 1 }
    },
    {
      type: PhysXShapeType.Sphere,
      radius: 1
    },
  ]
}

Readme

Keywords

none

Package Sidebar

Install

npm i @xr3ngine/three-physx

Weekly Downloads

1

Version

0.0.6

License

MIT

Unpacked Size

7.12 MB

Total Files

36

Last publish

Collaborators

  • shawticus