https://github.com/ryan-haskell/elm-3d
A package for making 3D games and apps in Elm
https://github.com/ryan-haskell/elm-3d
3d elm package
Last synced: 3 months ago
JSON representation
A package for making 3D games and apps in Elm
- Host: GitHub
- URL: https://github.com/ryan-haskell/elm-3d
- Owner: ryan-haskell
- License: other
- Created: 2024-05-05T15:27:37.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-13T14:45:39.000Z (almost 2 years ago)
- Last Synced: 2025-04-06T02:47:30.960Z (about 1 year ago)
- Topics: 3d, elm, package
- Language: Elm
- Homepage: https://package.elm-lang.org/packages/ryan-haskell/elm-3d/latest
- Size: 36 MB
- Stars: 11
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# **@ryan-haskell/elm-3d**
A package for making 3D games and apps in Elm
## **Local installation**
```
elm install ryan-haskell/elm-3d
```
## **Quick example**

```elm
import Elm3d.Camera exposing (Camera)
import Elm3d.Frame exposing (Frame)
import Elm3d.Node exposing (Node)
import Elm3d.Program exposing (Program, View)
import Elm3d.Viewport
main : Program () Model Msg
main =
Elm3d.Program.sandbox
{ init = init
, update = update
, view = view
}
-- MODEL
type alias Model =
{ angle : Float
}
init : Model
init =
{ angle = 0
}
-- UPDATE
type Msg
= Spin Frame
update : Msg -> Model -> Model
update msg model =
case msg of
Spin frame ->
{ model | angle = model.angle + frame.dt }
-- VIEW
view : Model -> View Msg
view model =
{ viewport = Elm3d.Viewport.fullscreen
, background = Elm3d.Color.white
, camera =
Elm3d.Camera.perspective
{ fov = 60
, range = ( 1, 100 )
}
|> Elm3d.Camera.withPositionZ 5
, nodes =
[ buildings model
]
}
buildings : Model -> Node Msg
buildings model =
Elm3d.Node.group
[ tavern
, church
]
|> Elm3d.Node.withOnFrame Spin
|> Elm3d.Node.withRotationY model.angle
tavern : Node Msg
tavern =
Elm3d.Node.obj { url = "/assets/tavern.obj" }
|> Elm3d.Node.withPositionX 1
church : Node Msg
church =
Elm3d.Node.obj { url = "/assets/church.obj" }
|> Elm3d.Node.withPositionX -1
```
You can [view more examples here](https://github.com/ryan-haskell/elm-3d/blob/main/example) using `elm reactor`.
## **Disclaimer**
This package was originally created from code for use on my website. Rather than keeping that code private, I extracted out and documented the parts that I thought would be helpful for others creating 3D things in Elm.
I encourage you to use this package to create your own 3D programs. Please feel welcome to modify my open source code if there are any features you would like to add.
Although my code is free to take, and the package is free to use, it __does not come with any promise for future maintenance__. This is a tiny gift from me to the Elm community, and there are many other cool Elm things I want to spend my time on after sharing it.
I would love to see support for _lighting_, _GLTF imports_, _physics_, _raycasting_, and much more. My initial goal for this package was making it the easiest way for folks to quickly create 3D games and experiences with Elm.
If you are personally interested in driving any fraction of that vision forward, I'm happy to chat about those designs and features. Please reach out to me on the [Elm Slack](https://elm-lang.org/community/slack) (`@ryan`) and we can make it happen!