1-- elm install elm-explorations/linear-algebra
2-- elm install elm-explorations/webgl
6import Browser.Events as E
7import Html exposing (Html)
8import Html.Attributes exposing (width, height, style)
9import Math.Matrix4 as Mat4 exposing (Mat4)
10import Math.Vector3 as Vec3 exposing (Vec3, vec3)
23 , subscriptions = subscriptions
35init : () -> (Model, Cmd Msg)
48update : Msg -> Model -> (Model, Cmd Msg)
49update msg currentTime =
52 ( delta + currentTime, Cmd.none )
59subscriptions : Model -> Sub Msg
61 E.onAnimationFrameDelta TimeDelta
68view : Model -> Html msg
71 [ width 400, height 400, style "display" "block"
73 [ WebGL.entity vertexShader fragmentShader mesh { perspective = perspective (t / 1000) }
77perspective : Float -> Mat4
80 (Mat4.makePerspective 45 1 0.01 100)
81 (Mat4.makeLookAt (vec3 (4 * cos t) 0 (4 * sin t)) (vec3 0 0 0) (vec3 0 1 0))
94mesh : WebGL.Mesh Vertex
97 [ ( Vertex (vec3 0 0 0) (vec3 1 0 0)
98 , Vertex (vec3 1 1 0) (vec3 0 1 0)
99 , Vertex (vec3 1 -1 0) (vec3 0 0 1)
113vertexShader : WebGL.Shader Vertex Uniforms { vcolor : Vec3 }
116 attribute vec3 position;
117 attribute vec3 color;
118 uniform mat4 perspective;
122 gl_Position = perspective * vec4(position, 1.0);
128fragmentShader : WebGL.Shader {} Uniforms { vcolor : Vec3 }
131 precision mediump float;
135 gl_FragColor = vec4(vcolor, 1.0);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list