function addBox1() { var shape = new CANNON.Box(new CANNON.Vec3(radius,radius,radius)); var body = new CANNON.Body({ mass: 0 }); body.addShape(shape); body.position.set(0,0,0); world.addBody(body); } |
function addBox2() { var shape = new THREE.BoxGeometry( radius*2, radius*2, radius*2 ); var mat = new THREE.MeshNormalMaterial(); var mesh = new THREE.Mesh( shape, mat ); mesh.position.set(0, 0, 0); scene2.add( mesh ); } |
Note: When a 1x1x1 cube is added to cannon the size of that cube is different than a 1x1x1 cube in 3js. This is bad. Oddly, a 1x1x1 cube in cannonjs is a 2x2x2 cube in three js.
What this means is that when you add a 1x1x1 cube into a cannonjs world the corresponding threejs cube needs to be 2x2x2.