๐ฐ Tiramisu
A type-safe 3D game engine for Gleam
Tiramisu brings the power of functional programming and static type safety to game development, leveraging Three.js for professional-grade 3D rendering while maintaining Gleamโs elegant, immutable design principles.
โจ Features
- ๐ Type-Safe: Catch bugs at compile time with Gleamโs expressive type system
- ๐ฎ 3D & 2D: Full 3D capabilities powered by Three.js, with excellent 2D support
- โก Immutable: Predictable game state management through functional updates
- ๐ฌ Effect System: MVU architecture inspired by Lustre for clean game loops
- ๐ฆ Rich API: Scene graphs, materials, lighting, animations, physics, and more
- ๐ Production Ready: Built on battle-tested Three.js with WebGL acceleration
- ๐ฏ Zero Runtime Overhead: Compiles directly to readable JavaScript
๐ Quick Start
import tiramisu
import tiramisu/effect
import tiramisu/scene
import tiramisu/transform
type Model {
Model(rotation: Float)
}
type Msg {
Frame
}
pub fn main() {
tiramisu.run(
width: 800,
height: 600,
background: 0x111111,
init: init,
update: update,
view: view,
)
}
fn init(_ctx: tiramisu.Context) {
#(Model(rotation: 0.0), effect.none())
}
fn update(model: Model, msg: Msg, ctx: tiramisu.Context) {
case msg {
Frame -> {
let new_rotation = model.rotation +. ctx.delta_time
#(Model(rotation: new_rotation), effect.none())
}
}
}
fn view(model: Model) {
[
scene.Mesh(
id: "cube",
geometry: scene.BoxGeometry(1.0, 1.0, 1.0),
material: scene.StandardMaterial(color: 0x00ff00),
transform: transform.identity
|> transform.rotate_y(model.rotation),
),
]
}
๐ฆ Installation
Add Tiramisu to your Gleam project:
gleam add tiramisu@1
Add Three.js and Rapier via Lustre to your gleam.toml
name = "my_game"
version = "0.1.0"
license = "MIT"
...
[tools.lustre.html]
scripts = [
{ type = "importmap", content = "{ \"imports\": { \"three\": \"https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js\", \"three/addons/\": \"https://cdn.jsdelivr.net/npm/three@0.180.0/examples/jsm/\", \"@dimforge/rapier3d-compat\": \"https://cdn.jsdelivr.net/npm/@dimforge/rapier3d-compat@0.11.2/+esm\" } }" }
]
๐ Documentation
- Getting Started - Your first Tiramisu game
- Scene Graph Guide - Understanding scene hierarchies
- Performance Guide - Optimization techniques
- API Reference - Complete API documentation
๐๏ธ Core Concepts
MVU Architecture
Tiramisu follows the Model-View-Update pattern:
- Model: Your immutable game state
- Update: Pure function that transforms state based on messages
- View: Declarative scene description from current state
Effect System
Side effects (network, timers, audio) are handled through a composable effect system, keeping your update logic pure and testable.
Scene Graph
Hierarchical node system powered by Three.js, with functional updates and transforms. Support for meshes, lights, cameras, groups, and more.
๐ฎ What Can You Build?
- 3D games and simulations
- 2D platformers and top-down games
- Interactive visualizations
- Architectural walkthroughs
- Educational simulations
- Physics-based experiences
- Anything that runs in a browser!
๐ ๏ธ Built With
- Gleam - Type-safe functional language
- Three.js - 3D graphics library
- Lustre - Elm-inspired web framework
๐ค Contributing
Contributions are welcome! Whether itโs bug reports, feature requests, or code contributions, please feel free to open an issue or pull request.
๐ License
MIT License - see LICENSE.md for details.
๐ Why Tiramisu?
โLike the dessert, Tiramisu is made of layers - each one adding richness and depth. From the functional purity of Gleam to the rendering power of Three.js, every layer works together to create something delightful.โ
Start building type-safe games today. โจ
Development
gleam run # Run the project
gleam test # Run the tests