Skip to content

Commit

Permalink
Merge pull request #319 from ccamel/feat/terrain
Browse files Browse the repository at this point in the history
Feat/terrain
  • Loading branch information
ccamel authored Dec 31, 2024
2 parents 1630c16 + 109b216 commit 82a96e7
Show file tree
Hide file tree
Showing 8 changed files with 500 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ The demo is a pure [SPA][] (100% clientside application) written in [elm][].

List of showcases:

- [terrain](https://ccamel.github.io/playground-elm/#terrain): A retro-inspired endless terrain flyover, featuring a procedurally generated 1D landscape, rendered in [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics).

- [glsl](https://ccamel.github.io/playground-elm/#glsl): A dynamic [WebGL](https://www.khronos.org/webgl/) electricity effect created with [GLSL](https://en.wikipedia.org/wiki/OpenGL_Shading_Language) shaders, featuring interactive 3D rotation with smooth inertia.

- [soundWave toggle](https://ccamel.github.io/playground-elm/#sound-wave-toggle): A simple sound wave toggle button
Expand Down
3 changes: 3 additions & 0 deletions src/App/Messages.elm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Page.Maze
import Page.Physics
import Page.SoundWaveToggle
import Page.Term
import Page.Terrain
import Url exposing (Url)


Expand All @@ -27,6 +28,7 @@ type Page
| Dapp
| SoundWaveToggle
| Glsl
| Terrain


type Msg
Expand All @@ -45,3 +47,4 @@ type Msg
| DappPageMsg Page.Dapp.Msg
| SoundWaveTogglePageMsg Page.SoundWaveToggle.Msg
| GlslPageMsg Page.Glsl.Msg
| TerrainPageMsg Page.Terrain.Msg
5 changes: 4 additions & 1 deletion src/App/Models.elm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Page.Maze
import Page.Physics
import Page.SoundWaveToggle
import Page.Term
import Page.Terrain


type alias PagesModel =
Expand All @@ -28,6 +29,7 @@ type alias PagesModel =
, dappPage : Maybe Page.Dapp.Model
, soundWaveTogglePage : Maybe Page.SoundWaveToggle.Model
, glslPage : Maybe Page.Glsl.Model
, terrainPage : Maybe Page.Terrain.Model
}


Expand All @@ -41,7 +43,7 @@ type alias Model =
}


emptyPagesModel : { aboutPage : Maybe a, calcPage : Maybe b, lissajousPage : Maybe c, digitalClockPage : Maybe d, mazePage : Maybe e, physicsPage : Maybe f, termPage : Maybe g, asteroidsPage : Maybe h, dappPage : Maybe i, soundWaveTogglePage : Maybe j, glslPage : Maybe k }
emptyPagesModel : { aboutPage : Maybe a, calcPage : Maybe b, lissajousPage : Maybe c, digitalClockPage : Maybe d, mazePage : Maybe e, physicsPage : Maybe f, termPage : Maybe g, asteroidsPage : Maybe h, dappPage : Maybe i, soundWaveTogglePage : Maybe j, glslPage : Maybe k, terrainPage : Maybe l }
emptyPagesModel =
{ aboutPage = Nothing
, calcPage = Nothing
Expand All @@ -54,4 +56,5 @@ emptyPagesModel =
, dappPage = Nothing
, soundWaveTogglePage = Nothing
, glslPage = Nothing
, terrainPage = Nothing
}
5 changes: 5 additions & 0 deletions src/App/Pages.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Page.Maze
import Page.Physics
import Page.SoundWaveToggle
import Page.Term
import Page.Terrain


emptyNode : Html msg
Expand Down Expand Up @@ -48,6 +49,7 @@ pages =
, Dapp
, SoundWaveToggle
, Glsl
, Terrain
]


Expand Down Expand Up @@ -120,6 +122,9 @@ pageSpec page =
Glsl ->
toSpec Page.Glsl.info Page.Glsl.view Page.Glsl.subscriptions GlslPageMsg (\model -> model.pages.glslPage)

Terrain ->
toSpec Page.Terrain.info Page.Terrain.view Page.Terrain.subscriptions TerrainPageMsg (\model -> model.pages.terrainPage)


pageName : Page -> String
pageName page =
Expand Down
4 changes: 4 additions & 0 deletions src/App/Routing.elm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Page.Maze
import Page.Physics
import Page.SoundWaveToggle
import Page.Term
import Page.Terrain
import Url exposing (Url)
import Url.Parser exposing (Parser, fragment, map, oneOf, parse, s)

Expand Down Expand Up @@ -73,6 +74,9 @@ parseFragment fragment =
else if p == Page.Glsl.info.name then
Page Glsl

else if p == Page.Terrain.info.name then
Page Terrain

else
NotFoundRoute

Expand Down
10 changes: 10 additions & 0 deletions src/App/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Page.Maze
import Page.Physics
import Page.SoundWaveToggle
import Page.Term
import Page.Terrain
import Task
import Tuple exposing (first, second)
import Url
Expand Down Expand Up @@ -95,6 +96,9 @@ update msg model =

( glslModel, glslCmd ) =
Page.Glsl.init

( terrainModel, terrainCmd ) =
Page.Terrain.init
in
case newRoute of
NotFoundRoute ->
Expand Down Expand Up @@ -136,6 +140,9 @@ update msg model =
Page Glsl ->
( { clearedModel | route = newRoute, pages = { emptyPagesModel | glslPage = Just glslModel } }, Cmd.map GlslPageMsg glslCmd )

Page Terrain ->
( { clearedModel | route = newRoute, pages = { emptyPagesModel | terrainPage = Just terrainModel } }, Cmd.map TerrainPageMsg terrainCmd )

-- messages from pages
AboutPageMsg m ->
convert model m .aboutPage Page.About.update (\mdl -> { model | pages = { pages | aboutPage = Just mdl } }) AboutPageMsg
Expand Down Expand Up @@ -170,6 +177,9 @@ update msg model =
GlslPageMsg m ->
convert model m .glslPage Page.Glsl.update (\mdl -> { model | pages = { pages | glslPage = Just mdl } }) GlslPageMsg

TerrainPageMsg m ->
convert model m .terrainPage Page.Terrain.update (\mdl -> { model | pages = { pages | terrainPage = Just mdl } }) TerrainPageMsg


init : Flags -> Url.Url -> Nav.Key -> ( Model, Cmd App.Messages.Msg )
init flags url navKey =
Expand Down
Loading

0 comments on commit 82a96e7

Please sign in to comment.