How danielrobertdinu/the-force works
Project type and purpose
• This is a front-end, single-page WebGL demo application.
• Its goal is to render and control a 3D particle animation in real time using hand-tracking gestures via the user’s webcam.
File structure analysis
• Top-level files only:
• index.html – the entry point, includes the HTML skeleton and script/style references
• main.js – the core orchestration code: loads Three.js, sets up the scene, runs the render loop, hooks into MediaPipe
• styles.css – any CSS styles for canvas/UI layout
• No backend or build scripts: everything runs in the browser.
• External dependencies are loaded at runtime (Three.js, MediaPipe).
README insights
• Confirms use of Three.js for 3D rendering, MediaPipe for hand-tracking, HTML5 Canvas for the viewport, JavaScript for glue logic.
• No server-side component; it’s purely client-side.
1. Browser environment
2. User’s Webcam (video feed)
3. MediaPipe Hand-Tracking pipeline
4. JavaScript orchestration layer (main.js)
5. Three.js Renderer + WebGL Context
6. HTML5 Canvas element (display viewport)
7. 3D Particle System (Three.js Scene + GPU shaders)
b. Relationships & interactions
• Browser grants camera access → Video feed flows into MediaPipe
• MediaPipe outputs hand landmarks → fed to main.js
• main.js uses landmarks to update Three.js scene parameters (e.g., particle emitter position, force vectors)
• Three.js Renderer draws the updated scene onto the Canvas each animation frame
c. Architectural patterns & design principles
• Event-driven, real-time rendering loop: requestAnimationFrame loop in main.js
• Separation of concerns:
• Media pipeline (MediaPipe)
• Rendering engine (Three.js/WebGL)
• Application logic (main.js)
• Single-responsibility modules: each library handles its domain
d. Key technologies to annotate
• Browser Web APIs: getUserMedia, requestAnimationFrame
• MediaPipe Hands (WebAssembly/C++ under the hood)
• Three.js (JavaScript library atop WebGL)
• HTML5 Canvas (with WebGL context)
• CSS for layout
Essential details
• Real-time loop (requestAnimationFrame → render → update → repeat).
• How hand landmarks map to 3D forces in the particle system.
• Minimal file-level context: index.html loads scripts/styles, main.js drives everything.