Building a Rainy Night Town 3D Scene with an AI Coding Assistant

    This article explains how to use an AI coding assistant to build an atmospheric rainy-night town 3D scene in the browser. It covers requirement decomposition, scene skeleton generation, lighting and fog, wet-ground reflections, rain particles, performance tuning, detail polish, and deployment, and it summarizes practical patterns for collaborating with an AI coding assistant on creative 3D prototypes.

    Building a Rainy Night Town 3D Scene with an AI Coding Assistant

    1. Background: When Creative Ideas Meet the 3D Rendering Barrier

    Many front-end developers have had a similar idea: build a small town on a rainy night, with a convenience store glowing with warm light on a street corner, wet ground reflecting neon signs, and raindrops sliding down glass. This kind of scene is visually atmospheric, but once you start building it, the barrier becomes clear. Understanding 3D coordinate systems, configuring cameras and lighting, tuning materials and post-processing effects, and controlling particle-system performance all require considerable experience.

    In the past, completing a piece like this often meant first learning the core concepts of a 3D rendering library, then writing boilerplate code for cameras, renderers, geometries, and materials line by line. The whole process could take several days. Today, mature AI coding assistants have greatly compressed that path: developers can describe the desired effect in natural language, have the assistant generate a runnable code skeleton, and then refine details through multiple rounds of dialogue. This article uses the “rainy night town” as an example to review that process and summarize the methodology.

    2. Overall Approach: Break a Vague Idea into Executable Requirements

    The biggest mistake when working with an AI coding assistant is to ask directly, “Build me a rainy night town.” That description contains too little information, and the generated result is often far from expectations. A better approach is to decompose the requirements first and split the image into independent technical modules:

    • Scene skeleton: ground, roads, building volumes, and the convenience store body;
    • Atmosphere elements: night lighting, point lights for street lamps and signs, and fog;
    • Dynamic effects: rain particles, ground reflections, and water streaks on glass windows;
    • Interaction: mouse drag to rotate the view, scroll wheel to zoom, and click-triggered events.

    After decomposition, requirements can be requested round by round in the order of “skeleton first, atmosphere second, dynamics third, interaction last.” Each round focuses on only one module, making the generated code more controllable and issues easier to locate.

    3. Round One: Build the Scene Skeleton

    The goal of the first prompt is to get a minimal runnable scene. The requirement can be described like this:

    Use a mainstream front-end 3D rendering library to create a web scene: a perspective camera, a renderer, a dark ground plane, several simplified building boxes, and a convenience store on a street corner (made of a main box and a glowing sign plane). The camera’s initial position should look at the convenience store, and orbit controls should be supported.

    The assistant usually outputs a complete single-file page containing renderer initialization, scene, camera, orbit controls, basic geometries, and an animation loop. At this stage, check three things carefully:

    1. Whether the render loop is correct: whether continuous rendering is driven by requestAnimationFrame;
    2. Window adaptation: whether the resize event is listened to and the camera aspect ratio and renderer size are updated synchronously;
    3. Coordinates and proportions: whether the relative relationships among building height, road width, and convenience store size are close to the real world.

    The most common deviation in practice is proportion. For example, the convenience store sign may be larger than the entire building, or the camera may be placed at ground level and make the buildings look like skyscrapers. These issues cannot be solved in one pass. They need to be corrected in later rounds with specific numeric constraints such as “set the convenience store height to about 4 meters and keep the sign width no more than 80% of the storefront.”

    4. Round Two: Inject the Rainy Night Atmosphere

    Once the skeleton is in place, the scene usually looks like a gray-box model. Creating atmosphere is the key. Rainy-night atmosphere mainly depends on three techniques:

    1. Low-intensity ambient light plus local point lights. The ambient light of the night sky should be very weak and have a cool cast (deep blue-gray), while street lamps, the convenience store sign, and shop windows use warm point lights to create a warm-cool contrast. You can ask the assistant to “add a point light to each street lamp with slight flicker,” but note that the number of point lights directly affects performance. In general, keep it to single digits.

    2. Fog. Add exponential fog or linear fog so distant buildings naturally fade into the night. This enhances depth and also masks the lack of detail in the distance.

    3. Wet, reflective ground. This is the soul of a rainy-night scene. A low-cost approach is to set a relatively high reflectivity on the ground material and pair it with an environment map; a more advanced approach is to use a reflective plane or screen-space reflections. You can prompt the assistant: “Make the ground look wet and illuminated by lights, with blurred reflections,” then adjust the roughness parameters based on the visual result.

    5. Round Three: Dynamic Effects and Performance Trade-offs

    Rain is usually implemented with a particle system: create thousands of thin line segments or points, move them downward every frame, and loop them back to the top. Example code:

    1. const RAIN_COUNT = 3000;
    2. const positions = new Float32Array(RAIN_COUNT * 3);
    3. for (let i = 0; i < RAIN_COUNT; i++) {
    4. positions[i * 3] = (Math.random() - 0.5) * 100;
    5. positions[i * 3 + 1] = Math.random() * 50;
    6. positions[i * 3 + 2] = (Math.random() - 0.5) * 100;
    7. }
    8. // In the animation loop, move y downward each frame and reset to the top when below the ground

    This round is where performance problems are most likely to appear. Raindrop count, point-light shadows, and reflection calculations add up, and frame rate may drop noticeably on low-end devices. When communicating with the assistant, state performance goals explicitly, such as “maintain 60 fps on a mid-range laptop,” and require common optimizations:

    • Use a single geometry and material for particles instead of creating objects one by one;
    • Enable shadows only for a few key lights and disable shadow casting for the rest;
    • Cap the renderer pixel ratio to avoid overdraw on high-DPI screens;
    • Remove off-screen objects in time or pause their updates.

    This stage clearly reflects the nature of human-AI collaboration: the assistant does not get everything right in one pass, and proportions, performance, and details often require repeated communication. Developers need to act as the “acceptance reviewer,” observe results visually, quantify metrics with browser performance panels, and translate problems into specific correction instructions for the assistant.

    6. Round Four: Detail Polish and Publishing

    The final stage is polishing details that make the scene enjoyable to explore: add a translucent material that lets warm light shine through the convenience store windows, give the sign a subtle breathing-style brightness change, overlay a texture that simulates water streaks on the glass, and add a slight camera animation as an opening shot. Each detail is small on its own, but together they determine the completeness of the work.

    For publishing, a pure front-end single-page project can be deployed directly to static website hosting on object storage, paired with content delivery acceleration for a stable access experience. If you later want to add traffic statistics or user interaction, you can integrate general cloud capabilities such as logging and monitoring/alerting as needed.

    7. Methodology Summary

    Looking back at the whole process, four lessons for collaborating with an AI coding assistant stand out:

    1. Decompose before generating: break the idea into a modular requirements list and advance round by round instead of asking for the complete work all at once;
    2. Use numeric constraints instead of subjective descriptions: “a little higher” is not as good as “set the height to 4 meters”; quantitative expressions significantly reduce rework;
    3. Keep acceptance responsibility with yourself: the assistant generates candidate solutions, and developers must personally verify and provide feedback on whether proportions, atmosphere, and performance meet the bar;
    4. Accept iteration as inevitable: complex visual scenes are almost never completed in one pass; treat multiple rounds of communication as a normal process rather than a tool defect.

    For this kind of creative prototype development, AI coding assistants are already very good at quickly turning ideas into works that actually run and can be explored. What they shorten is not the thinking process, but the distance from an idea to the first runnable version—and that is exactly the stage where many creative ideas are most likely to die. When an idea can become a rainy-night town that you can drag and rotate on screen within minutes, a positive creative loop is established.