How hnthap/car-ride works
Project type and purpose
• This is a single-page, front-end 3D simulation (“Car Ride in Paris”) built with React, TypeScript, Three.js and Vite.
• Purpose: render a drivable car and Paris landmarks in WebGL, controlled via keyboard.
File structure
• Top-level:
• public/ — static 3D assets (.glb) and images
• src/ — application source
• components/ — React components for each model (EiffelTower, Car, Ground, etc.)
• hooks/ — custom React hooks (useControls, useWheels, useMessages)
• models/ — model preload wrappers (.jsx)
• utils.ts — helper functions
• App.tsx, MainScene.tsx, LandmarkChart.tsx — entry components
• Config & tooling files:
• vite.config.ts, tsconfig.json, package.json
README for additional insights
• Confirms it’s a NodeJS-based React app, built and served with Vite.
• No backend or database—pure front-end.
• Dev vs. production modes via npm run dev and npm run preview.
a. Main components:
• Browser Client (runtime)
• React Application Layer
• Three.js Renderer / WebGL Context
• Static Asset Store (public/*.glb, images, appconfig.json)
• Build Toolchain / Dev Server (Vite + NodeJS)
b. Relationships & interactions:
• User → Browser Client (keyboard input)
• Browser Client → React App (event handlers via useControls hook)
• React App → Three.js (MainScene renders scene graph)
• Three.js → Static Asset Store (loads .glb via fetch)
• React App → Hooks & Models (manage car physics, wheel rotation, messages)
• Vite Dev Server → Browser Client in dev; static server in preview.
c. Architectural patterns:
• Component-based UI (React)
• Data-flow with custom hooks (stateful logic separated)
• Asset-driven scene (declarative scene graph in TSX)
• Build/serve pipeline (Vite with HMR in dev, static serve in preview)
d. Key technologies:
• React + TypeScript
• Three.js (GLTFLoader, WebGLRenderer)
• Vite (development server, bundling)
• GLB 3D models (public folder)
• React hooks (useControls, useWheels, useMessages)
Detailed capture of architectural elements
• React component category (scene entrypoints vs. leaf model components).
• Custom hooks as middleware between UI and renderer.