How cavargas10/pagethreejs works
Project type and purpose
• This is a front-end single-page application (SPA) built with React and Vite.
• It loads 3D models (GLTF + BIN + textures) and custom GLSL shaders to render interactive graphics in the browser.
• There is no separate backend; static assets are served by Vite’s dev server or a static‐site host in production.
File structure
• Top level:
– index.html: application entry point
– package.json / vite.config.js: build/dev configuration
– public/: static folder with 3D models and textures
– src/: React source code, components, shaders, styling
• Key components:
– App.jsx: root component
– Header.jsx: UI header
– ParticleModel.jsx: 3D‐model & shader loader + renderer
– shaders/: fragment.glsl & vertex.glsl — GPU programs
• Config: .eslintrc.cjs, vite.config.js → define plugins (@vitejs/plugin-react), dev server, build output.
README
• Confirms: minimal React + Vite template with HMR and ESLint
• Mentions the use of official Vite plugins for fast refresh.
a. Main components
1. Developer Machine
– Node.js & npm/Yarn
– Source files (src/, public/)
– Configuration (vite.config.js, .eslintrc)
2. Vite Dev Server / Build Pipeline
– @vitejs/plugin-react (Babel or SWC)
– Asset handling (serves public/, inlines shaders)
– Hot Module Replacement (HMR)
3. Browser Runtime
– index.html loads built bundle
– React application (App → Header, ParticleModel)
– WebGL context via Three.js or raw WebGL, shaders loaded from .glsl
– Fetches 3D model files (scene.gltf, scene.bin, textures)
4. Static Hosting (Production)
– Dist/ directory output (not shown in file tree, implied)
– Served by any static file host (Netlify, Vercel, S3)
b. Relationships & interactions
• Developer edits src/ → Vite watches & recompiles → updates browser via HMR
• Browser requests index.html from Vite → loads JS bundle → executes React app
• ParticleModel component uses fetch/GLTFLoader to retrieve 3D assets from public/
• Shaders are imported as text modules, compiled by WebGL at runtime
• On build, Vite bundles React code, inlines small assets, copies public/ to dist/
c. Architectural patterns & design principles
• SPA architecture: single entry point, client-side routing (if added later)
• Component-based UI (React): separation of concerns (App vs. Header vs. ParticleModel)
• Asset pipeline: build-time (Vite) vs. runtime (GLTFLoader, WebGL)
• Dev/prod parity: same code paths, Vite abstracts dev server and production bundler
d. Key technologies & libraries
• React (JSX components)
• Vite (ESM dev server, Rollup‐powered build)
• @vitejs/plugin-react (fast refresh via Babel or SWC)
• GLSL shaders (vertex & fragment)
• GLTF model format (public/3d-models)
• CSS modules or global CSS (App.css, index.css)