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

Error

(line 14, column 21): unexpected "(" expecting WHITESPACE, NEWLINE, reserved word `as`, reserved word `exposing` or FRESH_LINE
module Engine.Mesh.Cube where

{-| This module contains the definition of a cube mesh and of a cube
renderable object.

# Cube Mesh
@docs cubeMesh

# Cube (Renderable)
@docs cube

-}

import Math.Vector3 (Vec3, add, vec3)
import Engine.Mesh.Mesh (Mesh)
import Engine.Mesh.Rectangle (rectangle, rectangleMesh)
import Engine.Render.Renderable (Renderable)


{-| Function that takes a center point/vector and a size and returns a
cube mesh.

    cube center size
-}
cubeMesh : Vec3 -> Float -> Mesh
cubeMesh center size =
  let hs = size / 2
      ftl = center `add` vec3 -hs hs -hs
      ftr = center `add` vec3 hs hs -hs
      fbr = center `add` vec3 hs -hs -hs
      fbl = center `add` vec3 -hs -hs -hs
      btl = center `add` vec3 -hs hs hs
      btr = center `add` vec3 hs hs hs
      bbr = center `add` vec3 hs -hs hs
      bbl = center `add` vec3 -hs -hs hs
  in (rectangleMesh ftl ftr btr btl) ++
     (rectangleMesh ftl fbl fbr ftr) ++
     (rectangleMesh fbl fbr bbr bbl) ++
     (rectangleMesh btr bbr bbl btl) ++
     (rectangleMesh ftl fbl bbl btl) ++
     (rectangleMesh ftr fbr bbr btr)

{-| Default cube renderable object
-}
cube : Renderable
cube = {
  rectangle | mesh <- cubeMesh (vec3 0 0 0) 1 }