I've been working with Three.JS and CANNON.js to create a simple 3D object, but I'm having trouble getting the collider shape to align with the visual object's shape.
First, I create my shape:
const geometry = new THREE.IcosahedronGeometry(1, 0);
const material = new THREE.MeshLambertMaterial({ color: 0x009900 });
const finalCube = new THREE.Mesh(geometry, material);
When attempting to add collision to the shape, I have various options to choose from. I decided on using ConvexPolyhedron as it seems to be the most versatile, requiring an array of points and faces.
However, when trying to access the points and faces of the geometry (or vertices and faces in 3D terms), I encountered issues. Some methods are protected, while others simply return generic error codes.
My goal is to have the collision box accurately match the 3D model.
If anyone can offer assistance, I would greatly appreciate it! Thank you so much!