[{"name":"Physics","comment":" Highly experimental toy physics engine in Elm.\n\nThe API is currently shaping up and will be most likely changed.\n\n\n## World\n\n@docs World, world, setGravity, addBody, BodyId\n\n\n## Body\n\n@docs Body, body, setMass, addShape, ShapeId, rotateBy, offsetBy\n\n\n## Shape\n\n@docs Shape, box, sphere, plane\n\n\n## Physics\n\n@docs step, fold\n\n\n## Debug\n\nThe following functions are exposed for debugging.\nCheck the [demos](https://github.com/w0rm/elm-physics/blob/master/examples/Common/Demo.elm#L325) for usage details.\n\n@docs foldContacts, foldFaceNormals, foldUniqueEdges\n\n","unions":[{"name":"Body","comment":" Body is a solid matter without any moving parts.\n","args":[],"cases":[]},{"name":"Shape","comment":" Shape is an integral part of a body. It is positioned in the\nbody’s coordinate system.\n\nWe support the following shapes:\n\n  - [box](#box),\n  - [sphere](#sphere),\n  - [plane](#plane).\n\n","args":[],"cases":[]},{"name":"World","comment":" ","args":[],"cases":[]}],"aliases":[{"name":"BodyId","comment":" A unique identifier of a body in the world.\nIt can be used to link additional information, like meshes.\n","args":[],"type":"Physics.Body.BodyId"},{"name":"ShapeId","comment":" Same as BodyId, but for shapes within a body.\n","args":[],"type":"Physics.Shape.ShapeId"}],"values":[{"name":"addBody","comment":" You can also add bodies to the world. The function\nreturns updated world and an id of the body.\n\n    addBody body world\n    --> (newWorld, bodyId)\n\n","type":"Physics.Body -> Physics.World -> ( Physics.World, Physics.BodyId )"},{"name":"addShape","comment":" Adds a [shape](#Shape) at the center of the body\nand returns a tuple of updated body and a shape id.\nFor example, call this to add a box:\n\n    addShape (box (vec3 1 1 1)) body\n    --> (newBody, shapeId)\n\n","type":"Physics.Shape -> Physics.Body -> ( Physics.Body, Physics.ShapeId )"},{"name":"body","comment":" This gives you an empty body, add shapes to turn it\ninto something meaningful.\n","type":"Physics.Body"},{"name":"box","comment":" A box shape is defined by its half extends.\nTo create a 2x2 box, call this:\n\n    box (vec3 1 1 1)\n\n","type":"Math.Vector3.Vec3 -> Physics.Shape"},{"name":"fold","comment":" Fold over each shape in the world. Use this to convert shapes into visual representation, e.g. WebGL entities.\n\n    entities =\n        fold\n        ({ transform, bodyId, shapeId } currentEntities ->\n            makeEntity transform bodyId shapeId :: currentEntities\n        )\n        []\n        world\n\n  - `transform` is a transformation matrix that offsets and rotates a shape into the world coorditantes\n\n  - `bodyId` is an id of the body the shape belongs to\n\n  - `shapeId` is an id of the shape within the body\n\nUse `bodyId` and `shapeId` to link additional information from the outside of the engine, e.g. which mesh to render\nor what color should this shape be.\n\n","type":"({ transform : Math.Matrix4.Mat4, bodyId : Physics.BodyId, shapeId : Physics.ShapeId } -> a -> a) -> a -> Physics.World -> a"},{"name":"foldContacts","comment":" Fold over the contact points in the world.\n","type":"(Math.Vector3.Vec3 -> a -> a) -> a -> Physics.World -> a"},{"name":"foldFaceNormals","comment":" Fold over all the face normals in the world,\nwhere each face normal consists of a normal vector for a face\nand a reference point within the face.\nThese are both expressed within the local shape coordinate system.\nThe transform to the current world coordinates from the shape coordinates is also provided.\n","type":"(Math.Matrix4.Mat4 -> Math.Vector3.Vec3 -> Math.Vector3.Vec3 -> a -> a) -> a -> Physics.World -> a"},{"name":"foldUniqueEdges","comment":" Fold over all the unique edges in the world, where each unique edge\nconsists of a unit direction vector that runs parallel to an edge of a\nface in the shape.\nA vertex point of the shape and a transform to the current world coordinates\nfrom the shape coordinates is also provided for context. Both the vector and\nthe point are expressed within the local shape coordinate system.\n","type":"(Math.Matrix4.Mat4 -> Math.Vector3.Vec3 -> Math.Vector3.Vec3 -> a -> a) -> a -> Physics.World -> a"},{"name":"offsetBy","comment":" Move the body from its current position.\n\n    offsetBy (vec3 0 0 12) body\n    --> elevatedBody\n\n","type":"Math.Vector3.Vec3 -> Physics.Body -> Physics.Body"},{"name":"plane","comment":" A plane shape, with a normal pointing in the direction of the z axis.\n","type":"Physics.Shape"},{"name":"rotateBy","comment":" Rotate the body around the axis by a specific angle\nfrom its current orientation.\n\n    rotateBy (vec3 1 0 0) pi body\n    --> upsideDownBody\n\n","type":"Math.Vector3.Vec3 -> Basics.Float -> Physics.Body -> Physics.Body"},{"name":"setGravity","comment":" Call it to set the world’s gravity,\ncause by default it’s an open space:\n\n    setGravity (vec3 0 0 -10) world\n    --> worldWithGravity\n\n","type":"Math.Vector3.Vec3 -> Physics.World -> Physics.World"},{"name":"setMass","comment":" After creating a body, you have to give it a mass.\nBodies without mass don’t move!\n\n    setMass 5 boxBody\n    --> heavyBoxBody\n\n","type":"Basics.Float -> Physics.Body -> Physics.Body"},{"name":"sphere","comment":" A sphere shape is defined by its radius.\n","type":"Basics.Float -> Physics.Shape"},{"name":"step","comment":" Simulate the world, given the time delta since the last step.\n\nCall this function on a message from the [onAnimationFrame](https://package.elm-lang.org/packages/elm/browser/latest/Browser-Events#onAnimationFrame) subscription!\n\n","type":"Basics.Float -> Physics.World -> Physics.World"},{"name":"world","comment":" Let be the new world!\n","type":"Physics.World"}],"binops":[]}]