karylo Posted September 17, 2018 Share Posted September 17, 2018 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, physicsMaterial, 0.0, // friction coefficient 1.0 // restitution ); // We must add the contact materials to the world world.addContactMaterial(physicsContactMaterial); // 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 }); 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.