Metalx1000 Posted November 13, 2015 Share Posted November 13, 2015 I'm using ThreeJS and I've created a basic scene in which I've imported some objects from a dae file.Everything is going great except when I try to apply a basic box body to an imported mesh with CannonJS.If I create a cube with code and apply Physics to it, it works fine.But, if I try and added Physics to an imported model it seems that the bound box shape for the Physics is to big (I'm guessing that's what it happening).Here is the scene:http://filmsbykris.com/tmp/cannonjs/You will see that the smaller boxes and the large ground box, seem to work just fine.But, the larger box seems to be floating. I've set it to flip every 2 seconds just so you can see how it's moving.The function I've put together this function to apply the physics. (I'm guessing that this is where the problem is) function addBoxPhy(obj){ var mesh = obj.children[0]; if(mesh.type == "Mesh"){ var halfExtents = new CANNON.Vec3(.5,.5,.5); var boxShape = new CANNON.Box(halfExtents); var boxBody = new CANNON.Body({ mass: 5 }); boxBody.addShape(boxShape); world.add(boxBody); boxBody.position.copy(mesh.position); boxMeshes.push(mesh); boxes.push(boxBody); daeBox = boxBody; } }I've been trying to figure this out for a day or two now.Any help would be great.Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.