API Docs for: 0.7.1
Show:

ContactMaterial Class

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.

Constructor

ContactMaterial

(
  • materialA
  • materialB
  • [options]
)

Parameters:

  • materialA Material
  • materialB Material
  • [options] Object optional
    • [friction=0.3] Number optional

      Friction coefficient.

    • [restitution=0] Number optional

      Restitution coefficient aka "bounciness".

    • [stiffness] Number optional

      ContactEquation stiffness.

    • [relaxation] Number optional

      ContactEquation relaxation.

    • [frictionStiffness] Number optional

      FrictionEquation stiffness.

    • [frictionRelaxation] Number optional

      FrictionEquation relaxation.

    • [surfaceVelocity=0] Number optional

      Surface velocity.

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 Equation.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 Equation.DEFAULT_STIFFNESS.

id

Number

The contact material identifier

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 generate. Default value is Equation.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 Equation.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.

Default: 0