Create a 3d voxel simulation of city. City, ai cars, traffic lights and ai humans. And…
- User
Create a 3d voxel simulation of city. City, ai cars, traffic lights and ai humans. And settings.
Assistant
I'll build a 3D voxel city simulation with AI cars, traffic lights, pedestrians, and a settings panel. Let me first explore the project structure.
I need Three.js libraries and zustand for state management. Installing them now.
Packages installed. Now I'll create the settings store and simulation core (clock, RNG, traffic light logic).
Now the city generator — layout, voxel buildings, trees, road dashes.
Now the city scene renderer with instanced voxel buildings, windows, trees, roads, and sidewalks.
Now the AI cars with traffic-light awareness, car-following, and turning at intersections.
Let me clean up the shared material handling in Cars — I'll use
useMemomaterials instead of the fragile inline creation.Now I'll fix the useFrame block and the JSX to use the shared materials directly.
Cars component is clean now. Next: AI pedestrians walking on sidewalks.
I left a stray placeholder line — removing it.
Now the traffic lights component — poles at each intersection with shared lamp materials driven by the global cycle.
Now the settings UI panel with sliders and toggles.
Now the main App with the 3D canvas, day/night environment rig, and sim clock. Let me also check index.css and index.html.
Let me check the ref callback in Cars.tsx (React 19 is strict about ref callback return values) and then build.
The build succeeded. The 3D voxel city simulation is complete. Here's what I built:
🏙️ Voxel City Simulation
City generation (
src/city.ts)- Procedurally generated grid of city blocks (seeded RNG, so "Regenerate" gives a brand-new city)
- Voxel skyscrapers with color palettes, roof caps, and glassy window voxels that glow at night
- Parks with voxel trees, raised sidewalks, grass, asphalt roads with yellow lane dashes
AI cars (
src/components/Cars.tsx)- Right-hand-traffic lane driving with individual max speeds
- Obey traffic lights — brake smoothly at stop lines on red/yellow
- Car-following behavior — queue up behind slower cars without collisions
- Randomly turn left/right/straight at intersections, with smooth rotation, headlights/taillights that brighten at night, and edge wrap-around
Traffic lights (
src/components/TrafficLights.tsx)- Poles at every intersection with dual heads (N-S and E-W traffic)
- Synchronized green → yellow → red cycle driven by the shared sim clock
AI humans (
src/components/Humans.tsx)- Colorful voxel pedestrians strolling the sidewalk loops around blocks with walk-bobbing animation and random direction changes
Settings panel (
src/components/Panel.tsx)- City size (2×2 – 5×5 blocks), car count (0–60), people count (0–100)
- Simulation speed (0–3×, pausable), traffic light cycle length
- Toggles: Night mode (sky/fog/lighting cross-fade, stars, glowing windows & headlights), traffic lights on/off, auto-rotating camera
- Regenerate city button, collapsible glassmorphism UI
Performance: buildings, windows, trees, and road markings are all rendered via instanced meshes, so even the largest city stays smooth. Orbit/zoom the camera freely with mouse or touch.
Files built:
src/store.ts,src/sim.ts,src/city.ts,src/components/CityScene.tsx,src/components/Cars.tsx,src/components/Humans.tsx,src/components/TrafficLights.tsx,src/components/Panel.tsx,src/App.tsx,index.html
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.