Class ContactMaterial

Defines what happens when two materials meet, such as what friction coefficient to use. You can also set other things such as restitution, surface velocity and constraint parameters.

Also see Material

Example

var ice = new Material();
var wood = new Material();
var iceWoodContactMaterial = new ContactMaterial(ice, wood, {
friction: 0.2,
restitution: 0.3
});
world.addContactMaterial(iceWoodContactMaterial);

Hierarchy

  • ContactMaterial

Constructors

Properties

contactSkinSize: number

Offset to be set on ContactEquations. A positive value will make the bodies penetrate more into each other. Can be useful in scenes where contacts need to be more persistent, for example when stacking. Aka "cure for nervous contacts".

friction: number

Friction coefficient to use in the contact of these two materials. Friction = 0 will make the involved objects super slippery, and friction = 1 will make it much less slippery. A friction coefficient larger than 1 will allow for very large friction forces, which can be convenient for preventing car tires not slip on the ground.

Default

0.3
frictionRelaxation: number

Relaxation of the resulting friction force. The default value should be good for most simulations. Default value is DEFAULT_RELAXATION

frictionStiffness: number

Stiffness of the resulting friction force. For most cases, the value of this property should be a large number. I cannot think of any case where you would want less frictionStiffness. Default value is DEFAULT_STIFFNESS

id: number

The contact material identifier. Read only.

materialA: Material

First material participating in the contact material

materialB: Material

Second material participating in the contact material

relaxation: number

Relaxation of the resulting ContactEquation that this ContactMaterial will generate. Default value is DEFAULT_RELAXATION

restitution: number

Restitution, or "bounciness" to use in the contact of these two materials. A restitution of 0 will make no bounce, while restitution=1 will approximately bounce back with the same velocity the object came with.

Default

0
stiffness: number

Hardness of the contact. Less stiffness will make the objects penetrate more, and will make the contact act more like a spring than a contact force. Default value is DEFAULT_STIFFNESS

surfaceVelocity: number

Will add surface velocity to this material. If bodyA rests on top if bodyB, and the surface velocity is positive, bodyA will slide to the right.

idCounter: number = 0

Id counter for created contact materials.