Building a Rainy Night 3D Town with AI Coding Tools

    This article explains how to use AI coding tools to build a rainy night 3D town scene, using a convenience store as the core example. It covers breaking the scene into verifiable modules, writing prompts with measurable constraints instead of subjective adjectives, fixing scale and composition first, tuning lighting and wet-surface materials, managing particle and transparency budgets, adding basic interaction, iterating with small single-point changes, tracking performance and stability, and organizing code into maintainable modules. Readers will get a reusable workflow for turning natural-language ideas into runnable, testable, and extensible 3D code.

    1. Introduction: Why a Rainy Night Town Tests AI Coding Tools

    In 3D graphics and creative coding, a scene that looks simple—such as a rainy night convenience store—often tests several areas at once: geometry modeling, materials and lighting, particle systems, camera composition, interaction logic, and runtime performance. It needs both atmosphere on screen and a code structure that is clear, maintainable, and extensible. That makes it a good subject for evaluating whether an AI coding tool can turn a natural-language description into runnable code.

    From an engineering perspective, the value of this kind of task is not “generating a perfect result on the first try.” It is validating a reliable collaboration loop: whether the requirement description is precise enough, whether the generated result can be verified quickly, and whether problems can be located and fixed through stable iteration. The sections below describe a reusable method built around that loop.

    2. Breaking Down the Scene: Translating Atmosphere into Engineering Language

    In natural language, “rainy night,” “convenience store,” and “small town” are emotional descriptions. Code needs structured constraints. A practical first step is to split the scene into modules that can be implemented and accepted independently:

    • Building: store box, doors and windows, signage, steps, canopy;
    • Street environment: road surface, curbs, manhole covers, distant building silhouettes;
    • Weather system: rain streaks, ground ripples, water marks on glass, fog;
    • Lighting: cool ambient light, warm interior light, self-illuminated signage, wet-ground reflections;
    • Camera and composition: camera height, viewing angle, depth of field, slight handheld shake;
    • Interaction and performance: rotate to observe, switch viewpoints, stable frame rate.

    Once the breakdown is done, each module can be requested and checked on its own. This avoids the uncontrolled results that come from asking for everything at once.

    3. Prompt Design: Use Constraints Instead of Adjectives

    To get stable output from an AI coding tool, prompts should avoid subjective words such as “good-looking,” “premium,” or “strong atmosphere,” and favor measurable constraints. For example:

    1. Build a nighttime convenience store 3D scene with the following requirements:
    2. 1. The building is a single-story box structure with an aspect ratio of about 2:1; doors and windows are centered slightly to the right;
    3. 2. The main light source is warm white interior light with a warm color temperature; ambient light is low-intensity cool blue;
    4. 3. The ground is wet, with reflections and localized puddles;
    5. 4. Rain streaks are semi-transparent, thin, elongated particles of medium density, angled slightly;
    6. 5. The camera is across the street, at about 1.6 times human eye height, tilted slightly downward;
    7. 6. The scene must support mouse drag to rotate and scroll wheel to zoom.

    This turns “feel” into verifiable items such as proportions, light sources, particle density, and camera parameters, which noticeably reduces deviation in the generated result.

    4. Scale and Composition: Where Problems Show Up First

    The most common failure in practice is not “it doesn’t look right” but “the scale is distorted”—for example, oversized signage, overly tall steps, or a canopy intersecting the wall. It helps to lock down three kinds of scale relationships at the prompt stage:

    • Building-to-human scale: use door height as the baseline reference;
    • Proportions between components: signage width should not exceed one third of the facade width;
    • Camera-to-scene distance: avoid cropping in the foreground and emptiness in the background.

    If the generated result has scale problems, adjust the baseline dimensions and camera distance first rather than repeatedly tweaking materials. Scale errors amplify every detail problem.

    5. Lighting and Materials: The Core of the Rainy Night Mood

    The look of a rainy night scene comes mainly from “low ambient light + localized high-contrast light sources + wet reflections.” Three engineering principles apply:

    1. Keep ambient light dim to avoid an overall washed-out gray look;
    2. Let the interior light and signage light form two warm focal points that contrast with the cool environment;
    3. Lower ground roughness, raise reflection intensity, and add localized puddle areas.

    An illustrative configuration approach:

    1. // Illustrates parameter relationships only, not a specific API
    2. scene.environmentIntensity = 0.25; // weak ambient light
    3. warmLight.intensity = 2.4; // warm interior light as the main focal point
    4. ground.material.roughness = 0.18; // wet ground is smoother
    5. ground.material.metalness = 0.05;

    There is no universally “correct” value for these parameters. Adjust in small steps based on visual feedback, changing only one variable at a time so the source of each effect stays clear.

    6. Rain and Reflections: The Performance Limits of Particle Systems

    Rain streaks, ripples, and water marks add atmosphere, but they are also heavy performance consumers. A layered strategy is recommended:

    • Foreground rain streaks: fewer particles, slightly larger size, responsible for motion in the frame;
    • Distant rain curtain: replace large numbers of particles with semi-transparent planes or fog;
    • Ground ripples: simulate with a small number of looping animated tiles instead of real-time computation;
    • Glass water marks: use static or semi-static textures to reduce per-frame cost.

    Set budget limits as well, such as total particle count, number of transparent objects, and number of real-time lights. When the budget is exceeded, cut distant and transparent layers first rather than lowering the precision of the main structure.

    7. Interaction and Playability: Making the Scene Something You Can Handle

    A runnable scene that people can play with usually needs a basic interaction loop: drag to rotate, zoom to observe, switch viewpoints, pause or reset. Interaction code should stay short and independent so it is easy to extend later:

    1. // Illustrative: minimal interaction loop
    2. controls.enableDamping = true;
    3. controls.minDistance = 4;
    4. controls.maxDistance = 18;
    5. controls.maxPolarAngle = Math.PI * 0.49; // avoid going below the ground

    The point of interaction is not just “it moves.” It lets a reviewer quickly find scale, intersection, and lighting problems from different angles, which speeds up iteration.

    8. Iteration Method: Verify in Small Steps, Change One Point at a Time

    When the generated result is imperfect, a fixed loop works well:

    1. Take a screenshot or recording of the current state;
    2. List the three problems that most affect the look;
    3. Modify only one module at a time;
    4. Run again and compare;
    5. Move to the next item once it passes.

    The advantage is clear attribution. If scale, lighting, and particles are all changed at once and the result gets worse, it is hard to tell which change caused it.

    9. Performance and Stability: From “It Runs” to “It Runs Smoothly”

    Acceptance should look at at least four metrics: first-screen load time, stable frame rate, memory usage trend, and interaction response latency. Engineering recommendations include:

    • Reuse geometry as much as possible to reduce repeated creation;
    • Merge materials and textures to lower switching overhead;
    • Keep transparent object sorting and count under control;
    • Drive animation by time rather than frame count;
    • Provide a simplified mode for low-performance devices.

    If the frame rate drops, check transparent layers and real-time lights first, then geometry complexity. This usually locates most bottlenecks.

    10. From Demo to Deliverable: Structuring Code for Management

    When a scene moves from “demo” to “deliverable,” code organization matters more than visual effect. Split code by module: scene initialization, building construction, environment construction, weather system, lighting configuration, interaction control, performance switch. Each module should expose clear creation and destruction entry points for easy replacement and reuse.

    1. src/
    2. scene.js // scene and renderer initialization
    3. building.js // main building
    4. street.js // street and distant background
    5. weather.js // rain and fog
    6. lighting.js // lighting configuration
    7. controls.js // interaction
    8. perf.js // performance switch

    With a clear structure, later changes—switching seasons, changing day and night, or expanding to an entire street—can be implemented incrementally on the existing framework.

    11. Common Mistakes and How to Avoid Them

    • Mistake 1: Chasing a perfect result in one generation. Treat generation as a draft and iteration as the norm.
    • Mistake 2: Describing requirements with subjective words. Use measurable constraints such as proportion, count, and intensity.
    • Mistake 3: Prioritizing detail stacking. Secure scale and composition first, then add detail.
    • Mistake 4: Ignoring the performance budget. Set particle and light limits during the design stage.
    • Mistake 5: Unmaintainable code. Split into modules from the early stage.

    12. Conclusion

    Building a rainy night 3D town with AI coding tools is essentially an exercise in turning emotional creativity into engineering. The key to success is not how much code the tool produces in one pass, but whether the developer can break the scene into verifiable modules, replace vague descriptions with precise constraints, and keep moving forward through small-step iteration and single-point changes. When scale, lighting, particles, and interaction are all brought into a budget and acceptance system, the image in your mind can reliably become a runnable, playable, and extensible work.