Search code examples
three.jscannon.js

CANNON.js custom rigid body


I'm tinkering a bit with cannon.js and three.js, and i wish to have terrain. This would require a custom CANNON.RigidBody. I've seen the predefined shapes, like plane, box and sphere, but i cannot seem to figure out where or how cannon defines its shapes. is there a way to create a CANNON.RigidBody from a THREE.Geometry, or THREE.Mesh or even define it poly, by poly?


Solution

  • If you want to construct a terrain, you could use the CANNON.Heightfield class. See the example.

    There's currently no way to feed an arbitrary polygon/trimesh directly into Cannon.js. More on the subject here.

    UPDATE: The new CANNON.Trimesh class can be used for trimesh collisions. It is currently limited to sphere and plane collisions.