<<< Go Back to Part 2: The Geometry!
After you set up the geometry skeleton, now you can give shape to the "body." The CANNON.Body constructor creates the collision box. It gives the shape mass and a physical presence in the virtual world. The body will "wear" the physics material that we created earlier. After associating the physics material with the body, it will be able to bump into things and things can bump into it, as opposed to passing straight through.
var boxbody = new CANNON.Body(mass, boxShape);
For the mass parameter, you can insert a number to represent the mass or you can store a number in a variable and pass that to the constructor. The second parameter will take the boxShape variable that we made previously. The boxShape variable holds the CANNON.Box object. Setting the 2nd parameter equal to the boxShape object will give the rigid body its shape.
The rigid body constructor can take on a number of shapes (box, sphere, plane, etc.).
>>> Part 4: Mesh Materials!
After you set up the geometry skeleton, now you can give shape to the "body." The CANNON.Body constructor creates the collision box. It gives the shape mass and a physical presence in the virtual world. The body will "wear" the physics material that we created earlier. After associating the physics material with the body, it will be able to bump into things and things can bump into it, as opposed to passing straight through.
var boxbody = new CANNON.Body(mass, boxShape);
For the mass parameter, you can insert a number to represent the mass or you can store a number in a variable and pass that to the constructor. The second parameter will take the boxShape variable that we made previously. The boxShape variable holds the CANNON.Box object. Setting the 2nd parameter equal to the boxShape object will give the rigid body its shape.
The rigid body constructor can take on a number of shapes (box, sphere, plane, etc.).
>>> Part 4: Mesh Materials!