Search code examples
javascript3dthree.jscannon.js

CANNON.js: Visual representation of a RigidBody


I have a THREE.js Scene where Objects have physcis applied to them using CANNON.js. The RigidBody is initialized like so:

let shape = new CANNON.Box(new CANNON.Vec3(1, 1, 1));
let body = new CANNON.Body({
    mass: 5,
    shape: shape
});

I would like to have a visual representation of the CANNON.Body using my THREE.Scene.

How do I visually represent a RigidBody?


Solution

  • The easiest way to debug render Cannon.js physics objects in Three.js is probably using the THREE.CannonDebugRenderer.