Building a Rainy Night City Scene with AI Coding Tools

    This article walks through a practical methodology for using AI coding tools to build a runnable, interactive rainy night city scene in the browser with Three.js. It covers how to structure requirements across space and scale, camera perspective, atmosphere, and interaction boundaries; how to layer a maintainable scene into base, geometry, material, atmosphere, and interaction layers; and how to handle the core visual challenges of wet reflective ground, glass and light boxes, and warm-cool lighting contrast. It also outlines performance strategies such as tiered rain particle counts, shared geometry and materials, merged draw calls, on-demand rendering, and pixel ratio limits, plus an iterative workflow that converges in small steps. The key takeaway is that AI tools compress the distance from idea to working code, but believable scale, stable performance, and detailed texture still depend on clear structured prompts and disciplined engineering judgment.

    1. Introduction: Turning a Mental Image into a Running World

    Many developers have had this experience: a very specific image forms in your mind — a late-night street soaked in rain, neon swaying in the puddles, warm light spilling out of a convenience store’s glass door. Turning that image into a real 3D scene that runs, responds, and invites exploration in the browser traditionally involves a long chain of modeling, texturing, shader writing, lighting adjustments, and repeated trial and error.

    As the capabilities of intelligent coding tools keep expanding, “describe a scene in natural language and let the tool generate runnable code” has become a viable creative path. Using “building a rainy night town with an intelligent coding tool” as the technical theme, this article abstracts a general methodology: how to break a creative idea into structured requirements, how to organize a layered Three.js scene architecture, how to handle the material and lighting problems unique to a rainy night theme, and how to balance performance against detail.

    It is worth stressing that these tools are not a one-shot magic trick. Out-of-proportion geometry, performance bottlenecks, and missing details are the norm. What truly determines the quality of the result is the repeated communication and gradual convergence between the developer and the tool.

    2. Requirements: How to Describe a “Rainy Night Convenience Store” Clearly

    The upper limit of what an AI coding tool can generate is often determined by the precision of the requirements description. A vague “make a rainy night convenience store” usually yields a collage with random style and confused proportions. A reusable approach is to break the requirements into four dimensions:

    1. Space and scale: street width, store frontage, floor height, door and window dimensions. Relative proportions are best (for example, the storefront height is about 1.6 times the character’s eye level) rather than absolute values.
    2. Camera and perspective: first-person roaming, a fixed viewpoint looking around, or a freely rotatable display mode. The camera strategy directly determines the priority of modeling precision.
    3. Atmosphere elements: rain density, ground reflection strength, fog density, neon color temperature, and the contrast between warm indoor light and cool outdoor light.
    4. Interaction boundaries: whether doors need to open, raindrops need collision, lights need to flicker, or mouse parallax is required. The more interactions, the more the performance budget must be planned in advance.

    Writing these four points into structured prompt text and then handing it to the tool to generate a first version of the code can significantly reduce the number of back-and-forth reworks.

    3. Architecture: Layered Design for a Rainy Night Scene

    A maintainable 3D scene should be layered like a front-end project. A recommended division is five layers:

    • Base layer: renderer, scene, camera, clock, and window resizing.
    • Geometry layer: streets, building blocks, the convenience store body, shelves, and signage.
    • Material layer: wet ground, glass, metal, plastic, and illuminated light boxes.
    • Atmosphere layer: rain, fog, volumetric light, puddle reflections, and neon glow.
    • Interaction layer: controls, collision, state machine, and animation loop.

    A skeleton code example:

    1. // Layered initialization skeleton
    2. const renderer = new THREE.WebGLRenderer({ antialias: true });
    3. const scene = new THREE.Scene();
    4. scene.fog = new THREE.FogExp2(0x0a0f1a, 0.035);
    5. const camera = new THREE.PerspectiveCamera(55, innerWidth / innerHeight, 0.1, 200);
    6. // Atmosphere layer: rain
    7. const rain = createRainSystem({ count: 12000, area: 60, speed: 22 });
    8. scene.add(rain.points);
    9. // Interaction layer: main loop
    10. function animate(t) {
    11. requestAnimationFrame(animate);
    12. rain.update(t);
    13. controls.update();
    14. renderer.render(scene, camera);
    15. }
    16. animate(0);

    The value of layering is that when the tool generates a layer whose effect is unsatisfactory, you can regenerate or manually fine-tune only that layer instead of rebuilding the whole scene.

    4. Materials and Lighting: The Core Challenge of the Rainy Night Theme

    What makes a rainy night look good is not “adding a filter” but high-contrast reflections in a low-light environment. Three key points:

    • Wet ground feel: use a plane with low roughness and high reflectivity, combined with normal perturbation to create uneven water film; puddle areas can be overlaid with separate mirror patches.
    • Glass and light boxes: the convenience store glass must show both transmission and reflection, while the illuminated light box relies on an emissive material plus glow post-processing to create a sense of overflow.
    • Warm-cool collision: the cool blue-cyan tones outdoors and the warm orange-yellow light source indoors create color tension, which is the visual signature of the rainy night theme.

    Keep the post-processing chain lean: glow plus tone mapping plus a slight vignette is enough. Too many effects will quickly eat up the frame budget.

    5. Performance: Making the Rainy Night Run Smoothly

    Rain is a performance killer. Actionable optimization strategies include:

    1. Tiered particle counts: use different rain particle counts on desktop and mobile, with dynamic downgrade based on device capability detection.
    2. Reuse geometry and materials: raindrops, shelves, and floor tiles should share the same geometry and material instances as much as possible.
    3. Merge draw calls: merge static building block meshes to reduce draw calls.
    4. On-demand rendering: lower the render frequency when the scene is static and restore full frame rate when interaction is triggered.
    5. Resolution control: cap the pixel ratio to avoid doubling the rendering load on high-resolution screens.
    1. const isMobile = /Mobi|Android/i.test(navigator.userAgent);
    2. const rainCount = isMobile ? 4000 : 12000;
    3. renderer.setPixelRatio(Math.min(devicePixelRatio, isMobile ? 1.5 : 2));

    6. Collaboration Method: An Iterative Rhythm for Converging with AI Tools

    The most effective rhythm in practice is “small steps, fast pace”:

    • Step 1: get only the skeleton running, confirming the rendering pipeline is correct.
    • Step 2: add geometry and scale, using simple blocks to calibrate dimensions.
    • Step 3: apply materials and lighting, observing whether the atmosphere holds up.
    • Step 4: add rain and post-processing, while sampling performance at the same time.
    • Step 5: add interaction and details, then polish everything at the end.

    Keep a rollback-able version at every step, so when a problem appears you can quickly locate whether it is a deviation in the requirements description, a defect in the generated code, or an overrun of the performance budget.

    7. Conclusion

    Building a rainy night town with an intelligent coding tool is essentially a closed-loop collaboration of “idea — description — generation — calibration.” The tool compresses the distance from idea to runnable code, but whether the scale is believable, whether performance meets the target, and whether the details have texture still depend on the developer’s clear structured expression and strict engineering judgment. Layer the scene, explain the requirements thoroughly, and plan the performance budget up front, and the rain in your mind will land reliably in the browser.