This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

Here4.Body

We did not parse any module docs.
module Here4.Body exposing (..)

import Here4.Appearance exposing (Appearance)
import Here4.Camera.Types exposing (..)
import Here4.Orientation as Orientation exposing (Orientation)
import Math.Vector3 exposing (Vec3, vec3)
import Math.Vector3 as V3


type Anchor
    = AnchorGround
    | AnchorElevation Float
    | AnchorSky
    | AnchorHUD



{-
   type alias Body =
       { anchor : Anchor
       , scale : Vec3
       , position : Vec3
       , orientation : Orientation
       , appear : Appearance
       }
-}


type alias Anchored a =
    { a | anchor : Anchor }


type alias Visible a =
    { a | scale : Vec3, appear : Appearance }


type alias Oriented a =
    { a | position : Vec3, orientation : Orientation }


type alias Moving a =
    Oriented { a | velocity : Vec3 }


type alias Massive a =
    { a | mass : Float }


type alias Spherical a =
    { a | radius : Float }


type alias HasBody a =
    Oriented (Visible (Anchored a))


type alias Body =
    HasBody {}



-- | Use anything Oriented and Visible as a Body


toBody : Oriented (Visible a) -> Body
toBody x =
    { anchor = AnchorGround
    , scale = x.scale
    , position = x.position
    , orientation = x.orientation
    , appear = x.appear
    }



-- | Reposition a Body


reposition : Vec3 -> Oriented a -> Oriented a
reposition t thing =
    { thing | position = t }


copyMotion : Moving a -> Moving b -> Moving b
copyMotion motion thing =
    { thing
        | position = motion.position
        , orientation = motion.orientation
        , velocity = motion.velocity
    }



-- | Resize a Body


resize : Float -> Body -> Body
resize scale body =
    { body | scale = V3.scale scale body.scale }



-- | Translate a Body


translate : Vec3 -> Oriented a -> Oriented a
translate t body =
    { body | position = V3.add t body.position }


put : Vec3 -> Appearance -> Body
put position appear =
    { anchor = AnchorGround
    , scale = vec3 1 1 1
    , position = position
    , orientation = Orientation.initial
    , appear = appear
    }


anchorSky : Body -> Body
anchorSky body =
    { body | anchor = AnchorSky }