Jump to content

CannonJS elastic collisions


Recommended Posts

A newbie with CannonJS, I want to have spheres collide with elasticity such that there is no loss of kinetic energy.

All the spheres have the same physicsMaterial and the ContactMaterial has friction = 0.0 and restitution = 1.0.

I was hoping that would give me 100% elastic collisions yet I see that the spheres lose significant energy with every collision.

Is there something else I could or should be doing?  TIA


    // Create a slippery material (friction coefficient = 0.0)
    // and very bouncy (restitution coefficient = 1.0)
    var physicsMaterial = new CANNON.Material("bouncyMaterial");
    var physicsContactMaterial = new CANNON.ContactMaterial(physicsMaterial,
                                                            0.0, // friction coefficient
                                                            1.0  // restitution
    // We must add the contact materials to the world

  // CANNON body
  this.body = new CANNON.Body({
       mass: this.mass,
       position: this.loc,
       shape: new CANNON.Sphere(this.radius),
       velocity: this.vel,
       linearDamping: 0,
       material: physicsMaterial

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...