Building a Rainy Night 3D City with AI Coding Tools
This article explains how to use AI coding tools to build an atmospheric, interactive Three.js-style Web 3D scene of a convenience store on a rainy night. It covers breaking natural-language ideas into structured requirements across scene, atmosphere, interaction, and engineering layers; organizing code into reusable modules; shaping realism through scale, warm-cool lighting contrast, and restrained post-processing; and meeting performance and compatibility targets on mid-range and mobile devices. It also presents a five-round iteration checklist and possible extensions, showing that AI accelerates the jump from zero to one while developers guide quality from one to a hundred.
1. Introduction: From an Idea to a Walkable Rainy Night City
Building an atmospheric 3D scene for the web has traditionally required developers to juggle modeling, materials, lighting, post-processing, and performance tuning at the same time. As AI coding tools mature, natural language is becoming a new kind of “scene description interface”: developers break the image in their head into structured requirements, the tool generates an initial code skeleton, and the developer then validates, corrects, and refines it.
This article uses “a convenience store in a rainy night city” as its technical vehicle to discuss how to build a runnable, interactive, and extensible Three.js-style Web 3D project with AI coding tools. This kind of collaboration is not “generate once and it just works”—scale, performance, and details usually take several rounds of feedback and correction. The focus is not any specific tool, but the methodology of human-AI collaborative development.
2. Requirement Breakdown: Translating “Rainy Night Atmosphere” into Engineering Language
The first step in turning a natural-language idea into reality is removing ambiguity. It helps to split requirements into four layers:
- Scene layer: city streets, low-rise buildings, a convenience store, street lamps, wet pavement with puddles.
- Atmosphere layer: low nighttime illumination, a cool dominant palette, warm in-store lighting, rain streaks, and mist.
- Interaction layer: camera roaming, view switching, rain intensity adjustment, light toggles.
- Engineering layer: browser compatibility, frame rate targets, asset size, mobile fallback.
Example prompt structure (illustrative):
Build a nighttime city street corner scene:- A two-story building with a convenience store on the ground floor, glass doors and a warm-lit sign- Wet pavement reflecting the lights, steady light rain, thin mist in the distance- Support mouse drag to rotate and scroll to zoom, with toggles for rain amount and lights- Prioritize smooth performance on mid-range devices, minimize expensive post-processing
A structured description significantly reduces generation drift and gives later iterations a clear baseline.
3. Layered Scene Implementation: Organizing Code with a Component Mindset
A high-quality 3D scene is usually not “one big blob of code” but a clearly layered structure. The project can be split into these modules:
- Scene initialization: renderer, camera, clock, window resize handling.
- Environment construction: ground, building blocks, roads, and street furniture.
- Lighting system: ambient light, directional light, in-store point light, emissive signage.
- Weather system: rain particles, ground ripples, fog parameters.
- Interaction controls: orbit controls, parameter panel, state switching.
- Performance management: pixel ratio limits, geometry reuse, on-demand rendering.
An illustrative structure:
const app = {init() {}, // renderer and camerabuildCity() {}, // buildings and streetssetupLights() {}, // warm-cool contrast lightingstartRain() {}, // rain amount and fogbindUI() {}, // interaction and parametersoptimize() {} // performance strategy};
The value of a component-based approach: when one part looks wrong, you only regenerate or hand-edit that part instead of rebuilding the whole thing.
4. Shaping the Atmosphere: Scale, Lighting, and Post-Processing
The sense of realism in a rainy night scene comes mainly from three things:
- Accurate scale: if building height, door width, or street lamp spacing is off, even great materials will look “toy-like.” After generation, manage dimensions through centralized constants so they can be adjusted consistently.
- Warm-cool contrast: keep the environment cool blue-gray while the store interior uses warm yellow light to create a visual focal point. The sign can use an emissive material, but avoid excessive bloom.
- Wet surface reflections: the ground needs a strong roughness contrast and a moderate metallic feel, forming streaked reflections with the lights; rain can use thin elongated particles or textures, with density kept moderate.
Use post-processing sparingly. Bloom, tone mapping, and a slight vignette are enough; too many effects will noticeably hurt the frame rate.
5. Performance and Compatibility: Running Smoothly Matters More Than Looking Flashy
Common Web 3D bottlenecks include too many draw calls, excessive particle counts, overly high pixel ratio, and oversized shadow maps. Strategies include:
- Cap
devicePixelRatio(for example, 1.5–2). - Use instancing or merged geometry for buildings and repeated objects.
- Render rain particles in a single draw call, with the count adapting to screen width.
- Enable shadows only for key lights and lower shadow map resolution.
- Provide a low-spec mode: disable post-processing, reduce rain, simplify reflections.
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));rainCount = isMobile ? 1200 : 3000;
Performance targets should be written down during the requirements phase, for example “stable near 60 FPS on a mid-range laptop, with a degraded mode on mobile.”
6. Iteration Method: An Acceptance Checklist Across Multiple Rounds
AI coding tools rarely get the result right on the first try. Focus each round on a single goal and validate against verifiable criteria:
- Round 1: Does it open, and is the camera usable?
- Round 2: Are building scale and street layout reasonable?
- Round 3: Does the rainy night atmosphere hold up (lighting, reflections, fog)?
- Round 4: Are the interaction parameters complete and are the values safe?
- Round 5: Do performance and mobile fallback meet the targets?
Each round of feedback should give “symptom + expectation + constraint,” for example: “The in-store light is overexposed; I want to keep the sign details while not adding extra light sources.” This is more effective than “make it more realistic.”
7. Extensible Directions: From Demo to a Product Prototype
Once the base scene is stable, you can extend it: add pedestrian silhouettes, vehicle light trails, an enterable in-store view, day-night switching, a sound toggle, or replace the parameter panel with a friendlier graphical interface. If it eventually goes live, you can use object storage to host static assets, a content delivery network to speed up loading, and logging and monitoring services to observe runtime behavior—but all of this should be designed within the performance budget.
8. Conclusion
Building a rainy night city with AI coding tools is essentially an exercise in “engineering a creative idea”: turning vague inspiration into structured requirements, bringing generated code into a component-based architecture, and driving multiple rounds of iteration with clear metrics. The tool accelerates the journey from zero to one; the developer decides the direction and quality from one to a hundred. Master this method, and you can turn more of the images in your head into Web 3D projects that actually run and are fun to explore.
