How lhpcode/three3d works
Project type and purpose
• This is a browser-based Single-Page Application built with Vue 3.
• It renders 3D scenes (Three.js), data charts (ECharts) and UI controls (Element Plus) for “patrol route” visualization, first-person navigation, device positioning, region detection and alarm highlighting.
File structure
Top-level files and folders:
• Configuration
– .env.development / .env.production (runtime configs)
– tsconfig.json / tsconfig.node.json (TypeScript)
– vite.config.ts (Vite build)
– .eslintrc.cjs, .prettierrc (linters/formatters)
• Public assets
– public/fbx, public/gltf (3D models)
– public/texture, public/image (textures & images)
• Source code (src/)
– main.ts, index.html, style.css (app bootstrap & global styles)
– App.vue (root component)
– src/components/… (Vue UI components, e.g. card/index.vue)
– src/hooks/… (composables: useThree, useEcharts, useVModel, useEchartsData)
– src/utils/…
· createDom (DOM helper for mounting canvases, etc.)
· threeUtils (abstractions: SpriteThree, lightThree, modelThree, shader, three)
· index.ts (general helpers)
Extract insights from README
• Core libraries: Vue 3, Three.js (0.160), ECharts (5.5), Element Plus (2.6)
• Main features: route patrol, trajectory display, FPS view, shader rendering, device locators, region-entry alerts
Main components
a. Front-end SPA (Browser)
• Presentation Layer: Vue 3 components (Element Plus UI, custom <card> component)
• 3D Engine Layer: Three.js + shader modules + model loaders (gltf/fbx)
• Chart Layer: ECharts instances driven by useEchartsData composable
• Composables Layer: Reactive hooks (useThree, useVModel, useEcharts, etc.)
• Utilities Layer: DOM creation helpers, threeUtils abstractions, general utils
b. Static Assets
• 3D Models (public/gltf, public/fbx)
• Textures & images (public/texture, public/image)
c. Build & Config
• Vite dev server & builder
• .env files for environment config
d. External Services (implicit)
• HTTP API endpoints for patrol‐route data, device status, region definitions (to be represented as “Backend Services” even if not in this repo)
Relationships & interactions
1. Browser → loads index.html → main.ts initializes Vue app
2. App.vue composes UI components and hooks
3. Components call composables:
– useThree sets up WebGL canvas, uses threeUtils to load models & shaders
– useEcharts mounts chart DOM, fetches/updates patrol data
4. Composables fetch JSON from external APIs (routes, device positions, region metadata)
5. Models & textures loaded from public/ assets by threeUtils
6. Charts & 3D scenes render side-by-side; UI controls (Element Plus) dispatch view-mode changes (first-person ↔ top-down)
7. Region detection runs in shaders or JS, triggers alarm UI overlays
Architectural patterns & principles
– Modular composition (Vue 3 Composition API for reusability)
– Separation of concerns: Presentation → Business logic (composables) → Data access (utils/fetch) → Static assets
– Layered resource management: asset folder vs. code folder
– Build abstraction: Vite/TS compile chain separate from runtime