Installed

elm/browser
1.0.2
elm/core
1.0.5
elm/html
1.0.0
elm-explorations/linear-algebra
1.0.3
elm-explorations/webgl
1.1.3

Registry

elm/http
2.0.0
elm/random
1.0.0
elm/time
1.0.0
elm/file
1.0.5
elm/json
1.1.3
elm/svg
1.0.1
evancz/elm-playground
1.0.3
w0rm/elm-physics
5.1.3
rtfeldman/elm-css
18.0.0
mdgriffith/elm-ui
1.1.8
​x
        [ WebGL.entity vertexShader fragmentShader crateMesh (toUniforms model.angle texture)
 
1
-- Demonstrate how to load textures and put them on a cube.
2
--
3
-- Dependencies:
4
--   elm install elm-explorations/linear-algebra
5
--   elm install elm-explorations/webgl
6
--
7
​
8
import Browser
9
import Browser.Events as E
10
import Html exposing (Html)
11
import Html.Attributes exposing (width, height, style)
12
import Math.Matrix4 as Mat4 exposing (Mat4)
13
import Math.Vector2 as Vec2 exposing (Vec2, vec2)
14
import Math.Vector3 as Vec3 exposing (Vec3, vec3)
15
import Result
16
import Task
17
import WebGL
18
import WebGL.Texture as Texture
19
​
20
​
21
​
22
-- MAIN
23
​
24
​
25
main =
26
  Browser.element
27
    { init = init
28
    , view = view
29
    , update = \msg model -> (update msg model, Cmd.none)
30
    , subscriptions = subscriptions
31
    }
32
​
33
​
34
​
35
-- MODEL
36
​
37
​
38
type alias Model =
39
  { angle : Float
40
  , texture : Maybe Texture.Texture
41
  }
42
​
43
​
44
init : () -> (Model, Cmd Msg)
45
init () =
46
  ( { angle = 0
47
    , texture = Nothing
48
    }
49
  , Task.attempt GotTexture (Texture.load "https://elm-lang.org/images/wood-crate.jpg")