Creating a Cannon.js Heightfield or Trimesh based on a Three.js plane

Hey, let’s say I have a procedural world like this: World and I want to make those planes ‘solid’. How can I do it? I’ve done some research and found out that I could use three-to-cannon but I am not able to import it correctly. I also found that you could feed a cannon.js heightfield with the geometry of the plane like on this example: Heightfield example but the problem with this is that I cannot find where do I have to place the matrix.push([]) and matrix[i].push(height). I am open to use any physics engine or approach as long as It can be implemented in the World JSFiddle provided at the start of the post. Thanks for your attention!

1 Like