Repository navigation
Architecture
Heaven3D is deliberately simple to ship: the whole engine and editor is one Python file, Heaven3D.py (~44,000 lines). This page is a map for people who want to read or change it.
| File | Lines | Role |
|---|---|---|
Heaven3D.py |
~44k | engine, editor, importers, physics, gameplay kit, exporter |
Heaven3D_runtime.py |
~41k | the game player used by exported games (no editor) |
Heaven3D_Hub.py |
~3.4k | Tk launcher: projects, templates, tutorials, packages, export |
FILEBURNER.py |
~1k | legacy portability tool |
install.py |
dependency installer | |
packages/ |
included packages | |
templates/ |
project templates | |
tutorials/ |
Learn-page Markdown | |
tools/standalone/ |
builds the standalone editions and the logo-stamped launchers (launcher.c, launcher.rc) |
|
tests/ |
test suites — see Testing |
Python 3.10+ · ModernGL (OpenGL 3.3 Core; 4.1 core on macOS) · pygame (window, input, audio) · PyGLM (math) · NumPy · Numba (optional JIT) · tkinter (Hub and native dialogs).
The file is organised in numbered sections (search for SECTION):
| Section | Contents |
|---|---|
| 0 | defensive imports (optional libraries degrade gracefully) |
| 1 |
Scene graph — SceneNode, Scene
|
| 2 / 2A / 2B |
Importers — GlbImporter, ObjImporter, BlendImporter (all from scratch) |
| 3 |
Mesh — vertex arrays, tangents, primitives |
| 4 |
Material — PBR descriptor |
| 5 |
Blueprint system — Blueprint, @blueprint, BlueprintRegistry
|
| 6 | lights — SunLight, PointLight, SpotLight, AmbientLight, CloudSettings
|
| 7 |
Camera (free-fly editor camera), InputState
|
| 8 |
Project save / load — ProjectSerializer (.heaven3d JSON) |
| 9–11 |
Shader library, fullscreen quad, editor grid, deferred Renderer
|
| 12–12d | gizmos: transform, lights, spawns, collider shape editor, view gizmo |
| 13 | UI renderer — the editor's panels, drawn with GL quads |
| 14 | terrain (heightmap) |
| 14A |
CPU physics — colliders, RigidBody, BVH, PhysicsWorld, CharacterController
|
| 14B | AudioSystem |
| 14C | HUDRenderer |
| 14D | FPS gameplay kit — the Built-in Blueprints |
| 15 |
HeavenEngine — window, main loop, editor and runtime modes, scripting API |
| 15b | GPU instancing, ocean, manifolds, islands, sweep-and-prune |
| 15c | procedural building system (biomes, sector generator) |
| 16 | entry point (main(), argument parsing) |
| 17 | branding — embedded logo, welcome banner, boot splash |
| later | portability layer (H3DPortable), save games, exporter, package loader, macOS support, 2.7.x fixes |
Later releases extend earlier classes in place (by wrapping methods), which is why some features — save_game, asset_path, spawn_impact_fx, the package system — are attached to HeavenEngine near the end of the file.
HeavenEngine.run()
├─ poll pygame events → InputState, editor UI, gizmos
├─ editor update (camera fly, gizmo drag, inspector edits) [editor mode]
├─ if playing:
│ ├─ blueprint on_tick(dt) for every attached blueprint
│ ├─ scheduler (engine.schedule)
│ ├─ PhysicsWorld.step() — fixed steps, substeps, solver iterations
│ │ └─ collision / trigger callbacks → blueprints
│ └─ deferred destroy_node()
├─ package events: update / play_tick
├─ Renderer: shadow → G-buffer → SSAO → lighting → sky/clouds/ocean → transparency → SSR/bloom → tone map → FXAA
├─ HUD, editor UI, package `render` event
└─ InputState.end_frame()
HeavenEngine(mode="editor") builds the UI, gizmos and grid; mode="runtime" skips them and starts in Play. Exported games run Heaven3D_runtime.py in runtime mode on the project's main.heaven3d.
When the engine is started as a script it is the module __main__; it registers itself as sys.modules["Heaven3D"] so project scripts doing from Heaven3D import Blueprint share the same blueprint registry.
The package loader (near the end of Heaven3D.py, and in the Hub) reads package.json, resolves requires, imports engine.py as h3dpkg_<id>, calls register(h3d), and dispatches events. Exceptions in packages are caught and logged; a per-frame handler that keeps failing is switched off. See Writing Packages.
- Memoised local matrices (the cache stores copies of the TRS values so in-place edits are always seen).
- Single scene walk per frame; non-recursive world matrices; skipped redundant material binds; shadow-caster culling.
- Cached collider shapes and transforms in physics; one broad-phase query per character move.
- Numba kernels for hot loops (heightfield raycasts, etc.) with bit-identical pure-Python fallbacks, compiled in a background thread.
- Every optimisation is verified pixel- or bit-identical against the unoptimised path.
☁️ Heaven3D · Repository · Report a bug · Apache License 2.0
☁️ Heaven3D
Getting started
Using the editor
Making games
Packages
- Packages
- Writing Packages
- MakeHuman Characters
- Tropical Islands
- HQ FPS Weapons
- Car Race Kit and Spline Roads
- Physics Plus and Light Theme
Shipping
Reference