Building a Three.js Rainy Night Scene with an AI Coding Assistant: A Practical Workflow Guide

    Learn how to build a "rainy night city" scene in Three.js with AI assistance. This guide covers a step-by-step workflow for AI-assisted 3D development, including scene scaffolding, translating visual goals into parameters, iterative refinement, performance tuning, and common pitfalls to avoid.

    Why a Rainy Night Scene Is a Great Practice Project

    In web 3D development, a classic progression path goes from static geometry to a complete scene with lighting, particles, animation, and interaction. A “rainy night convenience store” scene covers most of the knowledge points along this path:

    • Night lighting system: Combining ambient light, point lights, spotlights, and emissive materials to create the contrast between neon signs and warm-lit windows;
    • Particle systems: Falling raindrops, ground splashes, and reflective puddles are all foundational exercises in particles and shaders;
    • Atmosphere rendering: Fog, tone mapping, and post-processing bloom determine whether the “rainy night” feel actually works;
    • Scene storytelling: Details like signs, shelves, glass doors, and streetlight halos test your ability to organize models and textures.

    Projects like this share a common trait: the visual results are immediate, the code structure is clear, and they make an ideal testing ground for AI-assisted programming. You can describe your goal in natural language, let the AI generate an initial version, then refine the details through multiple rounds of dialogue.

    The Overall Workflow for AI-Assisted 3D Development

    In practice, a reusable workflow breaks down into four steps:

    1. Define the scene skeleton before the atmosphere

    Don’t start by asking the AI to “generate a rainy night convenience store”—the result tends to be a pile of elements with poor proportions. A more effective approach is to describe the scene structure first:

    1. Please build the following scene skeleton with Three.js:
    2. 1. Ground: a 10x10 plane with a dark wet-road material (MeshStandardMaterial, roughness 0.2);
    3. 2. Main building: a 4x3x5 box with a glass curtain wall on the front, using a transparent material;
    4. 3. Sign: a glowing plane hanging above the building, emissive material, warm yellow;
    5. 4. Camera: fixed perspective at position (8, 4, 10), looking at the front of the building.
    6. Skip the rain and fog for now—make sure the skeleton's proportions are correct first.

    Issuing instructions in stages and verifying proportions and composition at each step is the key to avoiding “generate once, fix everywhere” rework.

    2. Describe visual effects with parametric language

    Atmosphere-related requests are most prone to the problem of “the rainy night the AI understands isn’t the one you have in mind.” The solution is to translate subjective feelings into quantifiable parameters:

    • “The rain should be fine and dense” → 3,000–5,000 particles, falling speed 15–20 units/second, line segment length 0.3;
    • “The neon sign should have a glow” → enable UnrealBloomPass with a strength threshold of 0.8 and a radius of 0.6;
    • “The ground should have puddle reflections” → lower the ground roughness, or add a semi-transparent reflective plane on top.

    3. Iterate in rounds and lock in verified parts

    When modifying code, AI tends to “casually” break logic that was already working. For each iteration round, state explicit constraints such as “keep the existing lighting parameters unchanged; only modify the rain system.” Use version control to commit after each confirmed step so you can roll back whenever something goes wrong.

    4. Let the AI diagnose performance, but own the metrics

    Open your browser’s performance panel to observe draw call counts, frame rate, and memory usage, then feed the concrete numbers to the AI for analysis. For example: “The scene currently has 2,000 draw calls and the frame rate has dropped to 30—how can I optimize it?” The AI will typically suggest merging geometry, using InstancedMesh, reducing real-time lights, and compressing textures. These judgments need to be validated with real data—not accepted blindly.

    Common Pitfalls and How to Handle Them

    Proportion failures: AI-generated buildings, characters, and props often lack a unified scale reference. The fix is to introduce reference objects yourself (e.g., “the door height should be 2.2 units”) and require all models to use that as the baseline.

    Runaway light counts: Night scenes easily accumulate large numbers of point lights, wrecking performance. The rule of thumb: keep real-time lights to 3–4, and simulate all other ambient lighting with emissive materials plus bloom post-processing.

    Unconvincing rain: Rain made from ordinary particles often looks like snow. Switching to elongated line segments or a custom shader, combined with slight random horizontal drift, looks far better.

    High communication cost on details: Details like sign text and shelf placement are cheaper to describe completely up front than to patch over multiple rounds. A good approach is to have the AI output a list of scene elements first, confirm it manually, then implement.

    The Boundaries and Real Value of AI-Assisted Creation

    It must be said that today’s AI coding assistants do not always get 3D development right on the first try: proportions, performance, and visual details still require repeated communication, verification, and correction from the developer. Their real value lies in compressing the cycle “from idea to runnable prototype”—work that once took half a day of reading docs, building the skeleton, and tuning lighting can now show a first version within half an hour.

    For developers, the right positioning is: the AI handles rapid generation and trial-and-error, while you handle aesthetic judgment, performance oversight, and architectural decisions. Mastering this collaboration rhythm is the most worthwhile skill for frontend and graphics developers in the AI era. When the cost of bringing an idea to life drops low enough, every little city in your imagination deserves to be built.