Native three.js rapier physical body

I was looking at the rapier example

https://threejs.org/examples/?q=rapi#physics_rapier_instancing

And I tried using:

import { RapierPhysics } from "three/addons/physics/RapierPhysics.js";

const physics = await RapierPhysics();

physics.addScene(scene);

works fine, affect all meshes with mass:

mesh.userData = {
    physics: {
        mass: 1
    }
}

But when I tried to get the physical body of any affected mesh, I couldn’t find it :frowning:

So, I’m asking:

  1. How to move a mesh with this native rapier?
  2. Shoud I use @dimforge/rapier3d instead?

This seems to be relatively new and undocumented (for now).
(three.js/examples/jsm/physics/RapierPhysics.js at 37d6f280a5cd642e801469bb048f52300d31258e · mrdoob/three.js · GitHub)

From the source code, only four methods are exposed. The world variable is private, with no external access and limited access to Rapier’s API.

If you need more control over the engine, I suppose you’ll have to go with option 2 and use @dimforge/rapier3d, at least for the time being.

1 Like