w0rm/elm-physics/6.0.0

NOTE: the latest version is 6.2.0

Physics.Material

type alias Material kind =
Material kind

Material encodes friction, bounciness, and optionally density.

The type parameter tracks capabilities:

  • Material Dense — carries density (required for volumetric bodies)
  • Material Surface — surface properties only (for static bodies and point masses)

Friction controls how much a body resists sliding against another. 0 means frictionless (like ice), 1 means maximum grip (like rubber).

Bounciness (coefficient of restitution) controls how much kinetic energy is preserved after a collision. 0 means no bounce (the body absorbs the impact), 1 means a perfectly elastic bounce.

When two shapes collide, their friction values are combined using the geometric mean √(f1 · f2), so a slippery surface dominates. Bounciness uses the maximum of the two values, so the bouncier surface wins.

wood : Material any

Density 700 kg/m³, friction 0.4, bounciness 0.3.

rubber : Material any

Density 1100 kg/m³, friction 0.8, bounciness 0.7.

steel : Material any

Density 7800 kg/m³, friction 0.3, bounciness 0.2.

ice : Material any

Density 900 kg/m³, friction 0.03, bounciness 0.1.

plastic : Material any

Density 1050 kg/m³, friction 0.35, bounciness 0.45.

Custom materials

type Dense

Material with density, required for dynamic bodies where mass is computed from geometry.

{ density : Density
, friction : Float
, bounciness : Float
}
-> Material Dense

Create a dense material.

Density is clamped to at least 1 kg/m³. Friction and bounciness are clamped to [0, 1].

type Surface

Material with surface properties only — friction and bounciness, no density. Used for static bodies and point masses.

{ friction : Float
, bounciness : Float
}
-> Material Surface

Create a surface material.

Friction and bounciness are clamped to [0, 1].