Galaxy Quest: Cinematic Web Engine
By : SAMUELSON G
A broadcast-standard, state-driven cinematic workspace built entirely in vanilla web technologies. This project proves that the modern browser can operate as a lightweight, real-time animation studio by orchestrating HTML5 Canvas for procedural 2D kinematics, WebGL for post-processing, and the Web Speech API for generative audio.
🎯 Project Objective
Architect a broadcast-standard cinematic workspace featuring state-driven playback, procedural 2D IK (Inverse Kinematics) rigging, WebGL post-processing, and real-time audio transport controls without relying on heavy external game engines or frameworks.
✨ Core Features
- Procedural 2D Kinematics: Utilizes custom Spring physics and Two-Joint Inverse Kinematics (IK) to drive character animation dynamically, eliminating the need for pre-baked sprite sheets.
- Real-Time Lip Syncing: Parses generative text-to-speech (TTS) into phonemes and maps them to custom visemes (mouth shapes) strictly synchronized with the Web Speech API's
onboundary events.
- Cinematic GPU Pipeline: A custom WebGL shader pipeline applied over the 2D canvas buffer, delivering real-time chromatic aberration, CRT scanlines, and cosmic grain (noise).
- Broadcast-Standard HUD: A professional-grade DOM interface featuring a native-feeling custom volume fader, timeline scrubbing, dynamic telemetry (DPR, RES, FPS), and director toggles (TV Safe Areas, Theme switching).
- Zero Dependencies: 100% Vanilla JavaScript, HTML, and CSS. No Node modules, no build steps, no external libraries.
🏗️ Architecture
The engine is divided into three harmonized subsystems running in a single-threaded web environment:
- The Physics & Render Buffer (Canvas 2D): Handles the mathematical state of the world. Calculates spring velocities, IK target resolutions, and character drawing routines to a hidden off-screen buffer (
#c2d-buffer).
- The Post-Processing Layer (WebGL): Takes the 2D buffer as a texture and passes it through a fragment shader to apply high-performance cinematic lighting and lens effects to the final presentation canvas (
#webgl-canvas).
- The Director (DOM & Web API): Orchestrates the playback state machine (
STOPPED, PLAYING, PAUSED), manages the Web Speech API queue, and binds user inputs (volume, theme, transport controls) to the engine state.
🚀 Quick Start
Because this engine has zero dependencies and requires no build steps, running it is instantaneous.
- Clone the repository:
git clone [https://github.com/Samuelson777/Galaxy-Quest-Cinematic-Engine.git](https://github.com/Samuelson777/Galaxy-Quest-Cinematic-Engine.git)
- Navigate to the project directory:
cd Galaxy-Quest-Cinematic-Engine
- Serve the file (using any local web server to avoid CORS restrictions on Canvas/Audio, though local file execution works in most modern browsers):
npx http-server .
# or
python3 -m http.server 8000
- Open
http://localhost:8000 in your browser and click Initialize Engine.
🎮 Director Controls
- Transport Rack: Play, Pause, and Stop the sequence. The timeline fill dynamically updates based on the current utterance index.
- Audio Rack: Mute toggle and output gain. (Note: Due to Web Speech API constraints, volume changes apply strictly to the next generated utterance).
- Telemetry & HUD: Monitor real-time Frames Per Second (FPS) and Canvas resolution scaling based on Device Pixel Ratio (DPR).
- Cinematography: Use the sidebar sliders to inject variables directly into the WebGL fragment shader in real-time.
🏁 Conclusion
Architecturally, this engine successfully proves that the modern browser can operate as a lightweight, real-time animation studio. By bypassing the traditional, time-consuming rendering pipeline, it excels at rapid prototyping and interactive storytelling. It demonstrates how complex systems—like physics-based IK rigging, GPU shader pipelines, and DOM-based telemetry—can run harmoniously without dropping frames.
🛣️ Future Enhancements (Roadmap)
To evolve this from a functional prototype into a production-ready enterprise tool, the following architectural upgrades are planned:
- Dedicated Render & Export Node: Integrate the
MediaRecorder API to capture the HTMLCanvasElement.captureStream() and system audio simultaneously, allowing users to export the web execution into a standard .mp4 or .webm video file.
- Advanced Audio & Spatial Processing: Route audio through a dedicated Web Audio API context. Implement dynamic
StereoPannerNode adjustments based on the active character's X-coordinate to create an immersive left/right soundstage. Replace native browser TTS with API calls to neural networks (e.g., ElevenLabs) for higher fidelity.
- Non-Linear Editor (NLE) Interface: Upgrade the hardcoded JSON script into a draggable, multi-track visual sequencer where directors can place audio clips, camera movements, and character animations on a visual timeline.
- Asset Pipeline & External Rigging: Build an ingest pipeline that accepts industry-standard 2D skeletal animation formats (like Spine) and modular vector assets to replace the strictly procedural drawing routines.
License
Distributed under the MIT License. See LICENSE for more information.