[{"name":"Physics.Body","comment":"\n\n@docs Body, box, plane, sphere\n@docs setMass, setPosition, getTransformation, setMaterial\n\n\n## Positioning\n\n@docs moveBy, getPosition\n\n\n## Orientation\n\n@docs rotateBy, setOrientation, getOrientation\n\n\n## User-Defined Data\n\n@docs setData, getData\n\n\n## Advanced\n\n@docs compound\n\n","unions":[],"aliases":[{"name":"Body","comment":" Represents a physical body containing\nuser defined data, like a WebGL mesh.\n\nBy default a body is positioned in the center\nof the world and has zero mass. To change this,\nuse [setPosition](#setPosition) or [setMass](#setMass).\nBodies with zero mass don’t move!\n\nThe supported bodies are:\n\n  - [box](#box),\n  - [plane](#plane),\n  - [sphere](#sphere).\n\nFor complex bodies check [compound](#compound).\n\n","args":["data"],"type":"Internal.Body.Protected data"}],"values":[{"name":"box","comment":" A box is defined by its dimensions along the corresponding axes.\nTo create a 1x1 box, call this:\n\n    box { x = 1, y = 1, z = 1 } data\n\n","type":"{ x : Basics.Float, y : Basics.Float, z : Basics.Float } -> data -> Physics.Body.Body data"},{"name":"compound","comment":" Make a compound body from a list of [shapes](Physics-Shape#Shape).\n\nFor example, the [sphere](#sphere) from above can be defined like this:\n\n    sphere radius data =\n        compound [ Shape.sphere radius ] data\n\nWe only support [rigid bodies](https://en.wikipedia.org/wiki/Rigid_body).\n\n","type":"List.List Physics.Shape.Shape -> data -> Physics.Body.Body data"},{"name":"getData","comment":" Get user-defined data.\n","type":"Physics.Body.Body data -> data"},{"name":"getOrientation","comment":" Get orientation as a unit quaternion.\n","type":"Physics.Body.Body data -> { x : Basics.Float, y : Basics.Float, z : Basics.Float, w : Basics.Float }"},{"name":"getPosition","comment":" ","type":"Physics.Body.Body data -> { x : Basics.Float, y : Basics.Float, z : Basics.Float }"},{"name":"getTransformation","comment":" Get the position and the orientation of the body in a single matrix.\n\nElements are given by their row and column indices, starting at 1,\nso `m23` means the element in the second row, third column.\n\nTo use this with WebGL, pass the result to [`Math.Matrix4.fromRecord`](https://package.elm-lang.org/packages/elm-explorations/linear-algebra/latest/Math-Matrix4#fromRecord).\n\n","type":"Physics.Body.Body data -> { m11 : Basics.Float, m21 : Basics.Float, m31 : Basics.Float, m41 : Basics.Float, m12 : Basics.Float, m22 : Basics.Float, m32 : Basics.Float, m42 : Basics.Float, m13 : Basics.Float, m23 : Basics.Float, m33 : Basics.Float, m43 : Basics.Float, m14 : Basics.Float, m24 : Basics.Float, m34 : Basics.Float, m44 : Basics.Float }"},{"name":"moveBy","comment":" Move the body by a vector offset from the current position.\n","type":"{ x : Basics.Float, y : Basics.Float, z : Basics.Float } -> Physics.Body.Body data -> Physics.Body.Body data"},{"name":"plane","comment":" A plane with the normal that points\nin the direction of the z axis.\n\nA plane is collidable in the direction of the normal.\n\n","type":"data -> Physics.Body.Body data"},{"name":"rotateBy","comment":" Rotate the body by a specific angle around the axis\nfrom the current orientation. Angle must be specified in radians.\n","type":"Basics.Float -> { x : Basics.Float, y : Basics.Float, z : Basics.Float } -> Physics.Body.Body data -> Physics.Body.Body data"},{"name":"setData","comment":" Set user-defined data.\n","type":"data -> Physics.Body.Body data -> Physics.Body.Body data"},{"name":"setMass","comment":" Set the body mass. Bodies with zero mass don’t move!\n","type":"Basics.Float -> Physics.Body.Body data -> Physics.Body.Body data"},{"name":"setMaterial","comment":" Set the [material](Physics-Material) to controll friction and bounciness.\n","type":"Physics.Material.Material -> Physics.Body.Body data -> Physics.Body.Body data"},{"name":"setOrientation","comment":" Set the body orientation to a [unit quaternion](https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation).\n","type":"{ x : Basics.Float, y : Basics.Float, z : Basics.Float, w : Basics.Float } -> Physics.Body.Body data -> Physics.Body.Body data"},{"name":"setPosition","comment":" Set the absolute position of the body in the world.\n","type":"{ x : Basics.Float, y : Basics.Float, z : Basics.Float } -> Physics.Body.Body data -> Physics.Body.Body data"},{"name":"sphere","comment":" A sphere is defined by its radius.\n","type":"Basics.Float -> data -> Physics.Body.Body data"}],"binops":[]},{"name":"Physics.Constraint","comment":"\n\n@docs Constraint\n\n@docs pointToPoint, hinge\n\n","unions":[],"aliases":[{"name":"Constraint","comment":" Constraint allows to limit the freedom of movement\nof two bodies with relation to each other.\n","args":[],"type":"Internal.Constraint.Constraint"}],"values":[{"name":"hinge","comment":" Keep two bodies connected with each other like pointToPoint,\nbut also limit the freedom of rotation. Useful for e.g. connecting\na window to a window frame.\n","type":"{ pivot1 : { x : Basics.Float, y : Basics.Float, z : Basics.Float }, axis1 : { x : Basics.Float, y : Basics.Float, z : Basics.Float }, pivot2 : { x : Basics.Float, y : Basics.Float, z : Basics.Float }, axis2 : { x : Basics.Float, y : Basics.Float, z : Basics.Float } } -> Physics.Constraint.Constraint"},{"name":"pointToPoint","comment":" Connect a point on the first body with a point on the second body.\nPoints are defined within the bodies’ local coordinate systems.\n","type":"{ pivot1 : { x : Basics.Float, y : Basics.Float, z : Basics.Float }, pivot2 : { x : Basics.Float, y : Basics.Float, z : Basics.Float } } -> Physics.Constraint.Constraint"}],"binops":[]},{"name":"Physics.Debug","comment":" A list of utilities that may be useful for debugging.\n\n@docs getContacts\n\n@docs FaceNormal, getFaceNormals\n\n@docs UniqueEdge, getUniqueEdges\n\n","unions":[],"aliases":[{"name":"FaceNormal","comment":" A face normal consists of a normal vector for a face\nand a reference point on the face.\n\nThese are both expressed within the local body coordinate system.\n\n","args":[],"type":"{ normal : { x : Basics.Float, y : Basics.Float, z : Basics.Float }, point : { x : Basics.Float, y : Basics.Float, z : Basics.Float } }"},{"name":"UniqueEdge","comment":" A unique edge consists of a unit direction vector\nthat runs parallel to an edge of a face.\n\nA vertex point of the body is also provided for context.\n\nThese are both expressed within the local body coordinate system.\n\n","args":[],"type":"{ direction : { x : Basics.Float, y : Basics.Float, z : Basics.Float }, point : { x : Basics.Float, y : Basics.Float, z : Basics.Float } }"}],"values":[{"name":"getContacts","comment":" Get the contact points in the world.\n","type":"Physics.World.World data -> List.List { x : Basics.Float, y : Basics.Float, z : Basics.Float }"},{"name":"getFaceNormals","comment":" Get the face normals of the body.\n","type":"Physics.Body.Body data -> List.List Physics.Debug.FaceNormal"},{"name":"getUniqueEdges","comment":" Get the unique edges of the body.\n","type":"Physics.Body.Body data -> List.List Physics.Debug.UniqueEdge"}],"binops":[]},{"name":"Physics.Material","comment":"\n\n@docs Material, default, custom\n\n","unions":[],"aliases":[{"name":"Material","comment":" Materials allow to control friction and bounciness.\nYou can change materials using [Body.setMaterial](Physics-Body#setMaterial).\n","args":[],"type":"Internal.Material.Protected"}],"values":[{"name":"custom","comment":" Creates a custom material, e.g.\n\n    slippery =\n        custom { friction = 0, bounciness = 0 }\n\n    bouncy =\n        custom { friction = 0.3, bounciness = 0.9 }\n\nWhen two materials collide, their properties are averaged\nand clamped between 0 and 1.\n\n","type":"{ friction : Basics.Float, bounciness : Basics.Float } -> Physics.Material.Material"},{"name":"default","comment":" All bodies initially use this material, it is defined like this:\n\n    default =\n        custom { friction = 0.3, bounciness = 0 }\n\n","type":"Physics.Material.Material"}],"binops":[]},{"name":"Physics.Shape","comment":"\n\n@docs Shape, box, plane, sphere\n\n\n## Positioning and Orientation\n\nShapes are positioned in the local body coordinate system,\nthey can be moved and rotated just like bodies in the world.\n\n@docs moveBy, rotateBy, setPosition, setOrientation\n\n","unions":[],"aliases":[{"name":"Shape","comment":" Shapes are only needed for creating [compound](Physics-Body#compound) bodies.\n\nIf you need a body with a single shape, use the corresponding functions\nfrom the [Physics.Body](Physics-Body) module.\n\nThe supported shapes are:\n\n  - [box](#box),\n  - [plane](#plane),\n  - [sphere](#sphere).\n\n","args":[],"type":"Internal.Shape.Protected"}],"values":[{"name":"box","comment":" A box is defined by dimensions along the corresponding axes.\n","type":"{ x : Basics.Float, y : Basics.Float, z : Basics.Float } -> Physics.Shape.Shape"},{"name":"moveBy","comment":" Move the shape in a body by a vector offset from\nthe current local position.\n","type":"{ x : Basics.Float, y : Basics.Float, z : Basics.Float } -> Physics.Shape.Shape -> Physics.Shape.Shape"},{"name":"plane","comment":" A plane with the normal that points in the\ndirection of the z axis.\n","type":"Physics.Shape.Shape"},{"name":"rotateBy","comment":" Rotate the shape in a body by a specific angle\naround the axis from the current local orientation.\n","type":"Basics.Float -> { x : Basics.Float, y : Basics.Float, z : Basics.Float } -> Physics.Shape.Shape -> Physics.Shape.Shape"},{"name":"setOrientation","comment":" Set the local shape orientation to a [unit quaternion](https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation).\n","type":"{ x : Basics.Float, y : Basics.Float, z : Basics.Float, w : Basics.Float } -> Physics.Shape.Shape -> Physics.Shape.Shape"},{"name":"setPosition","comment":" Set the local position of the shape in a body.\n","type":"{ x : Basics.Float, y : Basics.Float, z : Basics.Float } -> Physics.Shape.Shape -> Physics.Shape.Shape"},{"name":"sphere","comment":" A sphere is defined by a radius and a position.\n","type":"Basics.Float -> Physics.Shape.Shape"}],"binops":[]},{"name":"Physics.World","comment":"\n\n@docs World, empty, add, setGravity\n\n@docs simulate, getBodies, raycast, RaycastResult\n\n@docs keepIf, update\n\n@docs constrain, constrainIf\n\n","unions":[],"aliases":[{"name":"RaycastResult","comment":" The Raycast result includes the intersected body,\nintersection point and normal vector on the face,\nexpressed within the local body coordinate system.\n","args":["data"],"type":"{ body : Physics.Body.Body data, point : { x : Basics.Float, y : Basics.Float, z : Basics.Float }, normal : { x : Basics.Float, y : Basics.Float, z : Basics.Float } }"},{"name":"World","comment":" Physical world is our abstract playground for physical simulations.\n","args":["data"],"type":"Internal.World.Protected data"}],"values":[{"name":"add","comment":" Adds a body to the world.\n\n    worldWithFloor =\n        add planeBody world\n\nCheck the [Physics.Body](Physics-Body) module for possible bodies.\n\n","type":"Physics.Body.Body data -> Physics.World.World data -> Physics.World.World data"},{"name":"constrain","comment":" Configure constraints between pairs of bodies. Constraints allow to limit the\nfreedom of movement of two bodies with relation to each other.\n\nCheck the [Physics.Constraint](Physics-Constraint) module for possible constraints.\n\n    worldWithACar : World { part : String }\n    worldWithACar =\n        constrain\n            (\\b1 b2 ->\n                case ( (Body.getData b1).part, (Body.getData b2).part ) of\n                    ( \"wheel1\", \"base\" ) ->\n                        [ hingeConstraint1 ]\n\n                    ( \"wheel2\", \"base\" ) ->\n                        [ hingeConstraint2 ]\n\n                    ( \"wheel3\", \"base\" ) ->\n                        [ hingeConstraint3 ]\n\n                    ( \"wheel4\", \"base\" ) ->\n                        [ hingeConstraint4 ]\n\n                    _ ->\n                        []\n            )\n            worldWithCarParts\n\nNote that this example only works for a single car, otherwise it would\nconnect wheels of one car with the base of another another. You might want\nto use `constrainIf` to apply constraints on a subset of bodies.\n\n    constrain =\n        constrainIf (always True)\n\n","type":"(Physics.Body.Body data -> Physics.Body.Body data -> List.List Physics.Constraint.Constraint) -> Physics.World.World data -> Physics.World.World data"},{"name":"constrainIf","comment":" Configure constraints for a subset of bodies that satisfy the test.\n\nFor the above example we can tag each part of a car with the `carId`,\nand preselect parts of a single car with:\n\n    constrainCar carId =\n        constrainIf (\\body -> (Body.getData body).carId == carId)\n\n","type":"(Physics.Body.Body data -> Basics.Bool) -> (Physics.Body.Body data -> Physics.Body.Body data -> List.List Physics.Constraint.Constraint) -> Physics.World.World data -> Physics.World.World data"},{"name":"empty","comment":" Let be the new world!\n","type":"Physics.World.World data"},{"name":"getBodies","comment":" Get all bodies from the world.\n\nUse this to convert bodies into visual representation,\ne.g. WebGL entities.\n\n","type":"Physics.World.World data -> List.List (Physics.Body.Body data)"},{"name":"keepIf","comment":" Keep bodies that satisfy the test.\n","type":"(Physics.Body.Body data -> Basics.Bool) -> Physics.World.World data -> Physics.World.World data"},{"name":"raycast","comment":" Find the closest intersection of a ray against\nall the bodies in the world.\n","type":"{ from : { x : Basics.Float, y : Basics.Float, z : Basics.Float }, direction : { x : Basics.Float, y : Basics.Float, z : Basics.Float } } -> Physics.World.World data -> Maybe.Maybe (Physics.World.RaycastResult data)"},{"name":"setGravity","comment":" Set the [standard gravity](https://en.wikipedia.org/wiki/Standard_gravity), e.g.:\n\n    planetEarth =\n        setGravity { x = 0, y = 0, z = -9.80665 } world\n\n","type":"{ x : Basics.Float, y : Basics.Float, z : Basics.Float } -> Physics.World.World data -> Physics.World.World data"},{"name":"simulate","comment":" Simulate the world, given the number of milliseconds since the last frame.\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.World data -> Physics.World.World data"},{"name":"update","comment":" Apply a function to every body in the world.\n","type":"(Physics.Body.Body data -> Physics.Body.Body data) -> Physics.World.World data -> Physics.World.World data"}],"binops":[]}]