How to copy shape of CANNON.js body from a THREE.js IcosahedronGeometry object?

57 views Asked by At

I am trying to make a simple 3D object with Three.JS and CANNON.js, but cannot seem to make the collider shape match the visual object's shape.

I am creating my shape

const geometry = new THREE.IcosahedronGeometry(1, 0);
const material = new THREE.MeshLambertMaterial({ color: 0x009900 });
const finalCube = new THREE.Mesh(geometry, material);

Then when I try and add a collision to the shape, there's multiple options to choose from, I went with ConvexPolyhedron because it seems like its the most flexible, only accepting an array of points and faces.

However I try to get the geometry's points and faces (I think in 3D talk that's vertices and faces), it doesn't work and wont' let me get them.

Some methods are protected, some just don't work and return a generic error code.

What I want to achieve is for the collusion box to match the 3D model.

if anyone would be able to help me I would appreciate it very much! Many thanks!

0

There are 0 answers