How jwalts37/retroflightsim works
Main Components
a. Browser Host & Web Platform
– The ultimate runtime environment: HTML5 + Canvas/WebGL + Audio APIs.
b. Entry Point & Bootstrapping
– src/index.html, webpack.config.js → Builds dist/index.html & bundle.js.
c. Core Kernel / Game Loop
– src/script/core/kernel.ts orchestrates the fixed-timestep update and render cycle.
d. Configuration Service
e. Input Subsystem
– Keyboard & Joystick devices under src/script/input/devices.
f. Audio Subsystem
– audioResources.ts loads .ogg assets; audioSystem.ts plays engine loops, effects.
g. State Management
– src/script/state/game.ts + camera updaters. Holds world state, game definitions, and camera logic.
h. Physics Engine
– Models (debug, arcade, realistic) in src/script/physics/model, plus particle emitters under particles.
i. Scene Graph & Rendering Pipeline
– Scene setup in src/script/scene/scene.ts, entity management, materials & shaders, plus Canvas/WebGL painters and helpers in src/script/render.
j. OSD / UI Layer
– On-screen display panels under src/script/osd, overlays, HUD, messages.
k. Asset Data
– GLTF/GLB models in assets/, Blender sources in data/.
Relationships & Interactions
– The Kernel drives the cycle:
1) Read Config (palette, profile) & Input (keyboard/joystick)
2) Update Game State (controls, physics, particles)
3) Update Camera via camera updaters
4) Execute Render Pipeline (scene traversal, shader passes, canvas painter)
5) Dispatch Audio events (engine sound, effects)
– Assets (models, audio loops) are loaded at startup by their respective subsystems.
– Config Service injects palette definitions into the renderer for day/night and IR modes.
– Physics Engine writes back updated positions to the Scene Graph, which the Renderer reads.
Architectural Patterns & Principles
– Modular Subsystems: clear separation of concerns (Input, Audio, Physics, Render, State).
– Entity-Component-System Flavor: Entities in the scene, components (physics model, visual model, particle emitter).
– Fixed-Timestep Game Loop for determinism.
– Dependency Injection via services (ConfigService, AudioResources).
– Immutable vs Mutable State: state updates happen in a single pass per tick.
Essential Details to Capture
– Asset Loading phase (at startup).
– ConfigService feeding into multiple subsystems (Render uses palette, Input uses keyboard layout).
– State as the single source of truth for world and camera data.
– The two separate output channels:
• Visual → Canvas/WebGL (scene + OSD)
• Audio → Web Audio API