I am going to check the project structure and installed dependencies.
I will read package.json to inspect the available dependencies.
I will install three, @types/three, and lucide-react.
I will check index.html to update the title and meta information.
I will read src/index.css.
I will test the project build to ensure baseline stability.
I will now create src/types/traffic.ts to define the data structures for traffic lights, vehicles, pedestrians, camera views, and simulation configuration.
I will create src/sim/soundManager.ts with Web Audio API sound synthesis for vehicle engines, turn signal clicks, pedestrian signals, and sirens.
I will remove the unused variable in src/sim/soundManager.ts.
I will create src/sim/trafficController.ts to manage the US MUTCD traffic signal phases and pedestrian mutual exclusion timing.
I will create src/sim/pedestrianManager.ts to manage pedestrian AI, curb waiting, crosswalk traversal, and safety bounding zones.
I will create src/sim/vehicleManager.ts to manage vehicle kinematics, path planning, the Car-Following Model (IDM), and the US Right Turn on Red (RTOR) decision engine.
I will fix the typescript type checking in src/sim/vehicleManager.ts.
I will create src/components/ThreeCanvas.tsx with the Three.js 3D renderer, asphalt roads, crosswalks, traffic light gantries, animated vehicles, pedestrians, and dynamic lighting.
I will update src/components/ThreeCanvas.tsx to handle car raycasting clicks and remove the unused variable warning.
I will create src/components/HUD.tsx for the top navigation bar, real-time safety score, camera selector, time of day toggle, and audio control.
I will update src/components/HUD.tsx to display the active signal phase name badge directly inside the header and clean up unused variables.
I will remove the unused Activity import in src/components/HUD.tsx.
I will create src/components/ControlPanel.tsx for the simulation controller.
I will create src/components/VehicleInspector.tsx to inspect individual vehicle telemetry, right-turn-on-red state machines, and pedestrian safety distances.
I will create src/components/USLawGuideModal.tsx to provide the visual educational guide for US traffic laws and pedestrian priority rules.
I will create src/App.tsx to tie together all the 3D rendering, physics simulation loops, UI controls, and sound management.
I will now update index.html to reflect the 3D US traffic and pedestrian intersection simulation title.
I will now verify that the project builds cleanly.
已成功实现基于 Three.js 的 3D 十字路口红绿灯智能车流与行人模拟系统(严格遵循美国交通法规与 MUTCD 信号标准)。
🌟 核心功能与交通法规实现亮点
-
🇺🇸 美国交通法律核心原则与特例实现
- 红灯右转(Right Turn on Red - RTOR)特例逻辑:
- 必须完全刹停(Full Stop):AI 车辆在红灯右转车道到达停止线(Stop Bar)时,必须将车速完全降为 0 并静止至少 1.2 秒(拒绝滑行溜车)。
- 雷达探测与间隙确认:实时扫描目标斑马线上是否有行人、横向主干道是否有绿灯直行车辆以及对向是否有保护左转车辆。
- 安全汇入:在确保人车均无冲突时,执行合规合法的红灯右转,并在顶部仪表盘实时统计 RTOR 成功通行次数。
- 支持 RTOR 规则开关:控制台中可随时切换允许/禁止红灯右转,直观对比车流通行效率。
-
🚶♂️ 行人过街系统与人车信号严格互斥(MUTCD 规范)
- 信号完全互斥:南北向直行车辆绿灯时,平行方向的东西侧斑马线显示
WALK(绿色小人通行);垂直冲突方向的南北斑马线严格显示 DON'T WALK(红色手掌禁止通行)。
- 行人最高路权保护(Pedestrian Right-of-Way):即便车辆处于绿灯或右转状态,只要斑马线有行人通过,AI 车辆均会立刻平稳刹停礼让,彻底杜绝人车碰撞。
- 3D 行人动作动画:行人在过街时具有腿部与手臂摆动动画,红灯时在路沿安全岛礼貌等候。
-
🚗 严防车辆重叠与追尾碰撞(Intelligent Driver Model)
- 智能跟车安全气泡(IDM):同车道前后车根据车速与车身长度动态保持安全跟车距离,前后车零重叠、零追尾。
- 路口冲突区扫掠锁(Box Junction Lock):无保护左转车辆在路口中心自动礼让对向直行车流,确认空档后沿平滑贝塞尔曲线完成 90° 转向。
-
🎨 Three.js 3D 视觉与动态光照系统
- 多种场景时间模式:支持 白天(阳光柔和阴影)、黄昏(暖色落日长影) 与 夜景模式(路灯、3D 信号灯透镜发光、车辆前照大灯锥体照亮路面、刹车尾灯与转向灯闪烁)。
- 精致道路与城市模型:双黄实线、白色虚线、宽幅停止线、斑马线、悬臂式红绿灯杆、行人信号灯盒以及周边写字楼街景。
- 多视角切换:
- 🎥 3D 自由环视视角(鼠标拖拽旋转、滚轮缩放)
- 🏙️ 指挥中心俯瞰视角(Top-down)
- 🏎️ 第一人称驾驶员视角(沉浸式跟车体验)
- 🚶 行人斑马线过街视角
-
🎛️ 实时控制中心与交互面板
- 信号机模式切换:自动 4 相位循环、全红清空刹停、手动强切南北/东西绿灯。
- 流量调节:车流生成速率与行人密度滑块、模拟倍速(0.5x ~ 4x)与暂停。
- 🚨 急救车优先抢通按钮:一键生成警笛救护车,优先通过十字路口。
- 车辆状态侦测器:点击场景内任意车辆可查看其实时车速、转向意图、红灯右转等待判定与安全车距状态。
Files built: src/types/traffic.ts, src/sim/soundManager.ts, src/sim/trafficController.ts, src/sim/pedestrianManager.ts, src/sim/vehicleManager.ts, src/components/ThreeCanvas.tsx, src/components/HUD.tsx, src/components/ControlPanel.tsx, src/components/VehicleInspector.tsx, src/components/USLawGuideModal.tsx, src/App.tsx, index.html