Building a Rainy Night City Scene with AI Coding: A Practical Guide

    This article walks through building a rainy night convenience store scene in Three.js with the help of AI coding tools. It breaks the concept into technical modules, explains how to prompt in iterative rounds, and covers the performance and engineering work required to turn a runnable demo into something deliverable. Readers will find a reusable workflow for human-AI collaboration, along with common pitfalls and how to avoid them.

    1. Introduction: The Gap Between an Idea and a Running Build Is Shrinking

    In graphics and creative development, building an atmospheric 3D city night scene is a solid test of a developer’s overall skills. It touches on scene composition, lighting models, particle systems, performance budgets, and interaction design all at once. In the past, even a small rainy night block required a strong foundation in computer graphics and a large investment of time writing and debugging shaders and managing resource loading cycles.

    As intelligent coding tools mature, this workflow is being restructured. Developers can describe a target image in natural language, have the tool generate an initial code skeleton, and then refine it through multiple rounds of conversation. This article uses a typical practice, “building a rainy night convenience store scene in Three.js with an intelligent coding tool,” as the thread, and abstracts a reusable methodology to help readers understand the rhythm and boundaries of human-AI collaboration on real projects.

    To be clear, these tools are not a “describe once, finish once” solution. In real experience, proportions, performance, and details usually require repeated communication. Understanding this is the prerequisite for using them efficiently.

    2. Scene Breakdown: Technical Elements of a Rainy Night Town

    Before starting, breaking the vague image of a “rainy night convenience store” into implementable technical modules is the key to avoiding repeated rework later.

    2.1 Scene Skeleton and Spatial Proportions

    The core visual anchor of a rainy night town is usually a convenience store frontage: glass curtain walls, a warm-colored light box, shelf silhouettes, and standing water on the ground at the entrance. Arrange the street, streetlights, distant building outlines, and foreground occluders around it to form layers of foreground and background.

    Proportion is the most common source of deviation in the first generation round. Models tend to generate combinations that “look reasonable” but have inconsistent scale, such as a door frame height that does not match the street width, or shelf dimensions disconnected from the viewer’s eye level. The solution is to explicitly provide reference relationships in the prompt, for example, using a standard door opening height as the base unit and requiring all components to be scaled proportionally to that base.

    2.2 Lighting and Materials

    The look of a night scene is almost entirely determined by lighting. A common approach is to use low-intensity ambient light as a base, combined with a few high-brightness local light sources to create contrast: area lights inside the convenience store, emissive materials for the light box, and spotlight projection from streetlights. The wet feel of the ground is usually approximated by increasing material roughness contrast and overlaying reflection or specular maps, rather than relying on true ray-traced reflections.

    2.3 Rain and Atmospheric Particles

    Rain is a typical application of particle systems. In engineering, GPU-side instanced rendering or buffer updates are commonly used to draw large numbers of rain streaks, combined with camera-position-based looping bounds to avoid the overhead of infinite expansion. Raindrop splashes on the ground, water trails on glass, and atmospheric haze are optional enhancements that should be selected by tier according to the performance budget.

    3. Iterative Generation: The Right Way to Communicate with the Model

    3.1 First Round: Ask for the Skeleton, Not the Details

    The first prompt should focus on a runnable minimum closed loop: a scene that can render the main building, ground, and basic light sources, with camera controls attached. Asking for “more details” too early will bloat the generated code and make it harder to locate problems.

    An illustrative prompt structure is as follows:

    1. Build a Three.js scene:
    2. - The main subject is a convenience store on a night street, with a front glass curtain wall and warm interior light
    3. - The ground is wet with a reflective feel
    4. - A streetlight shines from the upper side
    5. - Provide orbit camera controls and window auto-resizing
    6. - Scale all components proportionally to a door opening height of 1 base unit
    7. Do not add rain or pedestrians yet

    3.2 Next Rounds: Single-Point Fixes

    Once you have a runnable version, change only one variable at a time. Common fix types include:

    • Proportion: point out the deviation direction of a specific component relative to the base;
    • Lighting: adjust light source intensity, color temperature, and shadow range;
    • Performance: request fewer draw calls, merged geometry, and reduced particle counts;
    • Detail: add water trails, sign text, and shelf layers.

    The value of single-point fixes is attributability. If you change three things at once, you cannot tell the source when the result gets better or worse.

    3.3 Convergence: Define Clear Stop Conditions

    Set verifiable acceptance criteria, such as “stably maintaining the target frame rate on mid-range mobile devices,” “time to first interaction no higher than a certain threshold,” and “no console errors.” Iteration without stop conditions will diverge indefinitely.

    4. Performance and Engineering: From Demo to Deliverable

    There is an engineering gap between generated code that “runs” and code that is “deliverable,” and the following areas need to be filled in.

    4.1 Rendering Budget

    Establish an explicit budget: draw call count, total triangle count, texture memory, and particle limits. When the budget is exceeded, prioritize downgrading distant scenery and particles while preserving the main silhouette and key light sources.

    4.2 Assets and Loading

    Models, textures, and environment maps should be compressed and loaded on demand. Load only necessary assets for the first screen, and fill in the rest during idle interaction periods. Static artifacts are suitable for hosting on object storage services, combined with a content delivery network to reduce latency.

    4.3 Observability

    Expose simple frame rate and memory readouts within the page to quickly judge the direction of changes during iteration; after launch, connect logging services and monitoring alerts to capture anomalies such as white screens and resource loading failures.

    4.4 Code Maintainability

    Require the generated code to be split by module: scene initialization, material library, particle system, and interaction control should be decoupled from each other, avoiding stacking everything in a single file; otherwise, any later adjustment will trigger cascading changes.

    5. Common Pitfalls and How to Avoid Them

    • Over-promising prompts: describing too many effects at once leads to generic results. Switch to phased goals.
    • Ignoring coordinate system consistency: different components using different units is the root cause of proportion chaos.
    • Replacing approximations with real physical simulation: most rainy night scenes work fine with approximate solutions; physical correctness and frame rate must be traded off.
    • No fallback path: low-end devices have no fallback strategy, directly making the scene unusable.
    • No version archiving: every usable version in each round should be kept for rollback and comparison.

    6. Conclusion

    What intelligent coding tools truly change is the cost structure of idea validation: compressing the validation cycle of “whether an idea can run” from days to tens of minutes. But they do not eliminate engineering judgment. How to set the proportion base, how to allocate the budget, and which details to discard still depend on the developer’s experience. Treating the tool as an efficient executor and keeping the methodology in your own hands is the right way to approach this kind of practice.