I will start by listing the files in the project to understand the structure.
I will install lucide-react for icons and clsx and tailwind-merge for styling utilities (though cn.ts might already exist).
I will update the index.html title to "海啸传播实验室 (Tsunami Propagation Lab)".
I'll read the index.html file to verify its content.
I will update the index.html title to "海啸传播实验室 (Tsunami Propagation Lab)".
I will now design the simulation engine. I'll use a 2D Shallow Water Equations (SWE) solver implemented in WebGL/Canvas or directly in JS if the grid size is small enough (e.g., 128x128) for real-time interaction. Given the requirement for "pseudo-3D" and "height fields", a Canvas-based 2D grid with height-based rendering is efficient.
I'll create several files:
src/engine/simulation.ts: The core logic for shallow water equations.
src/components/LabCanvas.tsx: The visualizer using Canvas API.
src/components/Controls.tsx: UI for earthquake parameters.
src/App.tsx: Main layout.
First, let's create the engine.
Now I will create the src/components/LabCanvas.tsx which will handle the rendering of the simulation using Canvas. I'll include a pseudo-3D height map view and a 2D heat map view.
I will fix the lint errors in src/components/LabCanvas.tsx.
Now I will create the src/components/Controls.tsx for parameter tuning and simulation state management.
Now I will update src/App.tsx to integrate everything. I will also add a cross-section view at the bottom to show the wave profile.
I will fix the lint errors in src/App.tsx.
I'll fix the useRef initialization in src/App.tsx.
I'll check src/utils/cn.ts to see if I need to use it.
I'll improve the terrain generation in src/engine/simulation.ts to make it more interesting and realistic.
I will now build the project to ensure everything is correct.
The project built successfully. I have created a functional Tsunami Propagation Lab with:
- Simulation Engine: Implemented 2D Shallow Water Equations for realistic wave propagation, refraction, and shoaling effects.
- Terrain System: Procedural seabed with deep ocean trenches, continental shelves, and islands.
- Visualization:
- 2D view with depth shading and wave elevation.
- Heatmap mode for better wave tracking.
- Pseudo-3D isometric height-field view.
- Dynamic cross-section view showing seabed and water profile.
- Interaction: Users can click on the map to trigger earthquakes, adjust magnitude and fault direction, and control simulation speed.
- UI: Professional lab-style interface using Tailwind CSS and Lucide icons.
I'm ready to finish.
I have completed the "海啸传播实验室" (Tsunami Propagation Lab).
核心功能亮点:
- 物理驱动仿真:采用二维浅水方程(Shallow Water Equations)模拟波浪传播,真实还原波浪在经过深海、海岭及大陆架时的折射与能量积聚(浅水效应导致波高增加)。
- 动态地形系统:程序化生成的复杂海底地形,包含海沟、大陆架及随机分布的岛屿。
- 多维度可视化:
- 2D 视图:结合海深渲染与实时波纹,支持波高热力图切换。
- 伪 3D 视图:等轴测投影的高度场展示,直观感受水面起伏。
- 实时横截面:动态展示西-东轴线上的水深与波浪形态。
- 参数化交互:
- 点击地图任意位置触发地震。
- 实时调整震级(影响波浪能量)与断层方向(影响波浪传播的偶极指向性)。
- 变速模拟,支持慢动作观察精细传播过程。
技术实现:
- 前端框架:React + Vite + TypeScript。
- 渲染技术:高性能 Canvas 2D 用于网格计算与渲染。
- 样式方案:Tailwind CSS 实现深色实验室界面。
- 物理计算:基于 CPU 的有限差分法,支持 128x128 实时稳定网格模拟。
项目已成功构建并优化。
Files built: index.html, src/engine/simulation.ts, src/components/LabCanvas.tsx, src/components/Controls.tsx, src/App.tsx