w0rm/elm-physics/3.1.0

NOTE: the latest version is 6.2.0

Physics.World

type alias World data =
Protected data

Physical world is our abstract playground for physical simulations.

empty : World data

Let be the new world!

add : Body data -> World data -> World data

Adds a body to the world.

worldWithFloor =
    add planeBody world

Check the Physics.Body module for possible bodies.

{ x : Float
, y : Float
, z : Float
}
-> World data
-> World data

Set the standard gravity, e.g.:

planetEarth =
    setGravity { x = 0, y = 0, z = -9.80665 } world
simulate : Float -> World data -> World data

Simulate the world, given the number of milliseconds since the last frame.

Call this function on a message from the onAnimationFrame subscription.

getBodies : World data -> List (Body data)

Get all bodies from the world.

Use this to convert bodies into visual representation, e.g. WebGL entities.

keepIf : (Body data -> Bool) -> World data -> World data

Keep bodies that satisfy the test.

update : (Body data -> Body data) -> World data -> World data

Apply a function to every body in the world.