A block is created from elm-geometry Block3d. To create a 1x1x1 cube, centered at the origin of the body, call this:
cubeBody =
block
(Block3d.centeredOn
Frame3d.origin
( meters 1, meters 1, meters 1 )
)
dataA plane with the normal that points in the direction of the z axis.
A plane is collidable in the direction of the normal. Planes don’t collide with other planes and are always static.
A sphere is created from elm-geometry Sphere3d.
To create a 1 meter radius sphere, that is centered at the origin of the body, call this:
sphereBody =
sphere
(Sphere3d.atOrigin (meters 1))
dataA particle is an abstract point that doesn’t have dimensions. Particles don’t collide with each other.
Bodies may have static or dynamic behavior.
Dynamic bodies move and react to forces and collide with other dynamic and static bodies.
Change the behavior, e.g. to make a body dynamic:
dynamicBody =
staticBody
|> setBehavior (dynamic (Mass.kilograms 5))Get the position and orientation of the body in the world as Frame3d.
This is useful to transform points and directions between world and body coordinates.
Set the position of the body in the world, e.g. to raise a body 5 meters above the origin:
movedBody =
body
|> moveTo (Point3d.meters 0 0 5)Move the body in the world relative to its current position, e.g. to translate a body down by 5 meters:
translatedBody =
body
|> translateBy (Vector3d.meters 0 0 -5)Rotate the body in the world around axis, e.g. to rotate a body 45 degrees around Z axis:
movedBody =
body
|> rotateAround Axis3d.z (Angle.degrees 45)Get the origin point of a body in the world
Set user-defined data.
Get user-defined data.
Set the material to controll friction and bounciness.
Make a compound body from a list of shapes.
For example, the sphere from above can be defined like this:
sphere radius data =
compound
[ Shape.sphere
(Sphere3d.atOrigin (meters 1))
]
dataWe only support rigid bodies.
Represents a physical body containing user defined data, like a WebGL mesh.
By default bodies don’t move. To change this, use setBehavior.
All bodies start out centered on the origin, use moveTo to set the position.
The supported bodies are:
For complex bodies check compound.