Building a 3D Rainy Night City Scene with AI Coding Assistants

    This article explores using AI coding assistants to transform creative ideas into runnable 3D web scenes, using a "rainy night small city" as an example. It covers how to structure prompts, core technical points for implementing buildings, lighting, rain particles, and wet ground reflections, alongside practical tips for iterative communication and performance optimization.

    I. Project Origin: Turning Mental Images into Runnable Works

    Many developers have experienced this: you have a very specific picture in your mind—like a convenience store glowing with warm light on a rainy night, water droplets on the glass, and streetlights casting long reflections on the wet ground—but actually implementing it requires modeling, writing rendering code, adjusting lighting, and creating particle effects. The workload is substantial, and enthusiasm often drains away during the environment setup phase.

    As AI coding tools improve, the development approach of “describing requirements in natural language and having the tool generate runnable code” is becoming mature. This article uses a 3D “rainy night small city” scene as an example to walk through the entire process from creative description to a finished product, summarizing key techniques and common pitfalls.

    It should be noted that such projects are typically implemented based on mainstream Web 3D rendering technology systems, relying on browser graphics interfaces to draw scenes. Combined with general techniques like particle systems, post-processing, and lighting models, you can achieve great results without developers having to write low-level rendering logic from scratch.

    II. Step One: Describing Requirements with Structured Language

    The output quality of AI coding tools largely depends on the quality of the input description. A simple “make me a rainy night street” is too vague and often yields unsatisfactory results. A better approach is to break down the requirements into several layers:

    1. Scene elements: Low-rise buildings on both sides of the street, a lit convenience store, streetlights, signs, and awnings.
    2. Atmosphere: Nighttime, continuous rain, wet and reflective ground, and warm/cool lighting contrast.
    3. Interaction: Mouse to rotate the view, scroll wheel to zoom, and smooth camera movement.
    4. Technical constraints: Pure frontend implementation, single-file runnable, and smooth performance on mid-range devices.

    Writing requirements as a “checklist” helps the tool accurately understand boundaries and reduces rework. This is also the most intuitive feeling throughout the process: it’s not a one-step success. Proportions, performance, and details still require repeated communication, but the communication cost is far lower than writing all the code manually.

    III. Core Technical Points for Scene Construction

    1. Buildings and Layout
      City scenes do not require fine modeling; combining basic geometries (cubes, cylinders, planes) is sufficient. The key is the proportional relationship: building heights, street widths, and streetlight spacing must conform to real-world scale, or the scene will look “toy-like.” The convenience store’s storefront window can use a semi-transparent material with an internal point light to simulate warm light shining through the glass.

    2. Lighting Atmosphere
      The rainy night atmosphere is mainly created by lighting layers: keep the ambient light very low so the overall tone is dark and cool. Use warm point lights for streetlights and inside the store to create a warm/cool contrast. You can overlay a few emissive materials for neon signs. Note that the number of point lights directly impacts rendering performance. It is recommended to keep them in the single digits for mobile devices, and distant light sources can be “faked” using emissive textures.

    3. Rain Particle Effects
      Rainfall effects are typically implemented using a particle system: thousands of small line segments or point sprites loop falling within a space around the camera, with slight horizontal offsets to simulate wind. The raindrops themselves do not need real collision detection. The “splash” when they hit the ground can be approximated by a quickly appearing and disappearing ring expansion animation, which is visually credible enough.

    4. Wet Ground
      This is the most effective detail in a rainy night scene. The implementation idea is to give the ground material a high reflectivity: a low-cost method is to use an environment reflection map to simulate a mirror, or you can duplicate an inverted scene object to render below the ground. Paired with subtle random variations in roughness, you can achieve the texture of “waterlogged reflection without being a perfect mirror.”

    IV. Tips for Iterative Communication with AI Coding Assistants

    In practice, the first generated version is usually “it runs, but it doesn’t look right.” At this point, don’t start over; instead, provide targeted feedback, for example:

    • “The convenience store sign is too big; reduce it to one-third of the building’s width.”
    • “The raindrops fall too slowly and look weightless; speed them up and reduce the quantity.”
    • “The frame rate is low; reduce the number of point lights and use emissive materials for distant lights.”

    This type of feedback—pointing out specific problems and giving the expected direction—is much more efficient than vaguely saying “the effect is bad.” Generally, three to five rounds of iteration can polish the work to a presentable level. For developers who want to quickly validate ideas, AI coding tools are well-suited to handle the heavy lifting “from 0 to 1,” while humans focus on aesthetic judgment and the final experience.

    V. Performance Optimization Checklist

    Running 3D scenes in a browser makes performance an unavoidable topic. Here are a few general recommendations:

    1. Merge static geometries to reduce draw calls.
    2. Dynamically downgrade particle counts based on device performance.
    3. Keep texture sizes within 1024 and compress them.
    4. Enable shadows only for main objects and disable shadow calculations for distant views.
    5. Use frame rate monitoring tools to identify bottlenecks, then optimize accordingly.

    VI. Conclusion

    From a vague imagination to a rainy night city where you can rotate the view and “feel” the atmosphere, the entire process might take only one evening. AI coding tools do not make all decisions for developers, but they significantly compress the distance from idea to prototype. What truly matters remains the clear picture in your mind and your ability to articulate it clearly.