Materia DocumentationWelcome to the Materia documentation! Materia is a Kotlin Multiplatform 3D rendering engine that works seamlessly across JVM, JavaScript/WebAssembly, and Android platforms with Three.js-style ergonomics.

Materia Documentation

Welcome to the Materia documentation! Materia is a Kotlin Multiplatform 3D rendering engine that works seamlessly across JVM, JavaScript/WebAssembly, and Android platforms with Three.js-style ergonomics.

Table of Contents

Getting Started

Core Concepts

API Reference

Advanced Topics

Architecture


Key Features

  • Cross-Platform: Write once, render on JVM (Vulkan), Browser (WebGPU), and Android
  • Three.js-Style API: Familiar scene graph, materials, cameras, and lighting patterns
  • Performance-First:
    • Arena allocators and uniform ring buffers
    • GPU resource pooling
    • Automatic instancing
    • 60+ FPS on integrated GPUs
  • Complete Asset Pipeline:
    • GLTF 2.0 with Draco compression
    • OBJ, FBX, PLY, STL loaders
    • KTX2 and EXR texture support
  • Modern Rendering:
    • Physically-based rendering (PBR)
    • Image-based lighting (IBL)
    • Shadow mapping
    • Post-processing effects
  • Animation System:
    • Keyframe animation
    • Skeletal animation with GPU skinning
    • Morph targets
    • Animation blending

Platform Support

| Platform | Backend | Status | |----------|---------|--------| | JVM (Desktop) | Vulkan via LWJGL 3.3.6 | ✅ Ready | | Browser (JS/WASM) | WebGPU (WebGL2 fallback) | ✅ Ready | | Android | Vulkan (API 24+) | ✅ Ready | | iOS/macOS | MoltenVK | 🟡 In Progress |


Quick Example

import io.materia.engine.scene.Scene
import io.materia.engine.scene.EngineMesh
import io.materia.engine.camera.PerspectiveCamera
import io.materia.engine.material.StandardMaterial
import io.materia.engine.renderer.WebGPURenderer
import io.materia.engine.renderer.WebGPURendererConfig
import io.materia.engine.core.RenderLoop
import io.materia.engine.core.DisposableContainer
import io.materia.geometry.BufferGeometry
import io.materia.core.math.Color
import io.materia.core.math.Vector3

// Create scene
val scene = Scene()

// Add a camera
val camera = PerspectiveCamera(
    fov = 75f,
    aspect = 16f / 9f,
    near = 0.1f,
    far = 1000f
).apply {
    position.set(0f, 2f, 5f)
    lookAt(Vector3.ZERO)
}

// Create a mesh with BufferGeometry
val geometry = BufferGeometry().apply {
    setAttribute("position", boxVertices, 3)
}
val material = StandardMaterial(
    color = Color(0f, 1f, 0f),
    metalness = 0.3f,
    roughness = 0.4f
)
val cube = EngineMesh(geometry, material)
scene.add(cube)

// Initialize renderer (works on JVM and JS!)
val renderer = WebGPURenderer(WebGPURendererConfig(
    surface = window.surface,
    width = 1280,
    height = 720
))

// Render loop
val renderLoop = RenderLoop { deltaTime ->
    cube.rotateY(deltaTime * 0.5f)
    renderer.render(scene, camera)
}
renderLoop.start()

// Cleanup
renderLoop.stop()
cube.dispose()
material.dispose()
geometry.dispose()
renderer.dispose()

Installation

Gradle (Kotlin DSL)

// build.gradle.kts
plugins {
    kotlin("multiplatform") version "2.1.20"
}

kotlin {
    jvm()
    js(IR) { browser() }
    
    sourceSets {
        commonMain.dependencies {
            implementation("io.materia:materia-engine:0.1.0-alpha01")
        }
    }
}

Running Examples

# Clone the repository
git clone https://github.com/codeyousef/Materia.git
cd Materia

# Run Triangle demo
./gradlew :examples:triangle:runJvm          # Desktop
./gradlew :examples:triangle:jsBrowserRun    # Browser

# Run VoxelCraft (Minecraft-style)
./gradlew :examples:voxelcraft:runJvm

# Run Embedding Galaxy (particles)
./gradlew :examples:embedding-galaxy:runJvm

Getting Help


See Also

© 2025Yousef
Built withSummonSummon