How ahmedaziz703/ahmedgames3d works
Project Type and Purpose
• Folio 2025 is a front-end–only, interactive 3D portfolio built with Three.js and Vite.
• It uses Node.js + Vite for bundling/dev, and serves a Single-Page Application (SPA) that renders a WebGL scene, loads 3D models (GLB via DRACO), shaders (GLSL), textures, and sounds.
Key Architectural Components
a. Build & Deployment Pipeline
• Vite Development Server (npm run dev)
• Vite Bundler → transforms ES modules, inlines shaders, copies static assets to dist/
• Production Build (npm run build) → dist/ folder
b. Runtime (Browser)
• index.html → main.js (entry point)
• Application.js → Initializes Three.js Renderer, Scene, Camera, Controls
• Resources Manager → loads models (GLTFLoader + DRACOLoader), shaders, textures, sounds
• World Module → organizes scene graph into Areas, Sections, Objects, Physics, Sounds, EasterEggs
• Geometries & Materials → custom geometry and material classes pairing GLSL shaders with mesh data
• Post-processing Passes → Blur, Glow, Shadow passes
• Utils → EventEmitter (pub/sub for inter-module events), Sizes, Time, Loader helpers
Relationships & Data Flows
• Browser loads index.html → main.js → Application.initialize()
• Application hooks Time.tick() → update loop →
• Resources Manager ensures assets are loaded
• World.update():
– Controls → user input → modifies camera/physics
– Physics → collision checks using imported meshes (collision.glb)
– Objects/EasterEggs → change state or fire events via EventEmitter
– Sounds → triggered by events or physics results
• Render Passes: Scene rendered by Three.js Renderer → post-processing pipeline → canvas
• Static assets (models/, sounds/, favicons/) served by Vite or copied to dist/
Architectural Patterns & Principles
• Modularity: Clear separation of concerns (Loader, World, Geometries, Materials, Passes, Utils)
• Pub/Sub: EventEmitter decouples modules (e.g., World triggers sound events)
• Data-driven Scene Graph: World → Areas → Sections → Objects loaded from static models
• Pipeline Stages: Asset loading → Scene setup → Update loop → Render → Post-process
1. “Vite Dev & Build” (purple)
– npm run dev → dev server
– npm run build → dist/
– models/ (GLB + collision meshes)
– sounds/ (MP3/WAV)
– shaders/ (.glsl partials & modules)
3. “Resources Manager” (blue)
– Loader.js + EventEmitter
– DRACOLoader (WASM) & GLTFLoader
– Fetches assets over HTTP
4. “Application Core” (blue)
– Application.js: sets up Three.js renderer, scene, camera, loop
– Time.js & Sizes.js for frame/timing
5. “World” (blue)
– Areas, Sections, Objects, Physics, Sounds, EasterEggs
– organizes scene graph hierarchy
6. “Materials & Geometries” (blue/orange)
– Custom classes pairing Three.js Mesh + ShaderMaterial + geometry data
7. “Post-Processing Passes” (orange)
– Blur, Glow, Shadow passes feeding off renderer output
8. “Renderer & Canvas” (orange)
– Three.js WebGLRenderer → output to HTMLCanvasElement
9. “Controls & Events” (blue)
– Controls.js → user input → camera/physics → EventEmitter events → World modules