Three.js Rainy-Night Scene with an AI Coding Assistant: A Convenience Store Example

    This article explains how to use an AI coding assistant to build a Three.js rainy-night convenience store scene. It covers translating atmosphere into technical requirements, combining materials and lighting for mood, optimizing raindrop particles for performance, balancing fog and color tone, and running a three-round iteration process for proportions, performance, and details.

    1. From Idea to Output: How AI-Assisted 3D Development Changes the Workflow

    In traditional 3D web development, a scene such as a “rainy-night convenience store” often requires the developer to have Three.js programming skills, graphics knowledge, an art sense, and a lot of patience for debugging. With an AI coding assistant, the workflow changes noticeably: the developer acts more as the idea proposer and acceptance tester, while the tool generates the initial code framework and detail implementation.

    In practice, however, this process is not always one-shot. Distorted scene proportions, tight rendering performance, and missing details are still common, and developers need to communicate and iterate repeatedly. Understanding this is a prerequisite for using AI coding tools efficiently: they are accelerators, not fully automated replacements.

    2. Breaking Down Requirements: Translating “Atmosphere” into Technical Targets

    Using a rainy-night convenience store as an example, the first step is not to write code. It is to break a vague idea into executable technical points:

    1. Scene structure: street ground, convenience store body with glass windows and a storefront sign, streetlights, and a few cars or miscellaneous objects as accents;
    2. Lighting system: low-intensity cool ambient night light, warm point lights inside the windows, emissive sign materials, and cone lighting from streetlights;
    3. Rainy-night atmosphere: raindrop particle system, wet and reflective ground, fog for depth, and water ripples or raindrop splashes;
    4. Interaction and animation: camera orbit observation, sign flicker, and dynamic elements such as pedestrians or windshield wipers.

    Writing these points as a structured prompt is far more effective than saying “make me a rainy-night convenience store.” Example:

    1. Use Three.js to build a rainy-night convenience store scene:
    2. - Convenience store box model + semi-transparent glass window + warm interior point light
    3. - Ground with high metalness and low roughness to simulate a wet, reflective surface
    4. - 1,000 raindrop particles falling vertically in a loop
    5. - Set scene.fog to blue-gray fog to enhance nighttime depth
    6. - Target 60fps; use Points for particles instead of individual Meshes

    3. Core Implementation Points

    3.1 Materials and Lighting Carry the Atmosphere

    The key to a rainy-night mood is not model precision but the combination of material parameters. Ground reflection depends on pairing high metalness with low roughness; window glass can use transmission or a semi-transparent material with an interior light source to create a “bright inside, dark outside” contrast; signs can use self-emissive materials, with code controlling periodic intensity fluctuations to simulate flicker.

    1. const ground = new THREE.Mesh(
    2. new THREE.PlaneGeometry(100, 100),
    3. new THREE.MeshStandardMaterial({
    4. color: 0x111318,
    5. metalness: 0.9,
    6. roughness: 0.15
    7. })
    8. );

    3.2 Performance Trade-offs for Rain Particles

    A common problem in initial generated code is creating a separate Mesh for every raindrop. One thousand raindrops then mean one thousand draw calls, and the frame rate quickly collapses. The correct approach is to use Points with BufferGeometry, update vertex positions each frame, and keep the whole system to a single draw call. This is an optimization point worth proactively raising when communicating with the AI assistant.

    3.3 Unified Fog and Color Tone

    The color contrast between cold blue-gray fog and warm yellow window light is the source of a “cinematic” feel. The fog near and far distances determine the scene’s sense of depth; generally, setting the fog end distance at about two-thirds of the camera’s visible range produces a natural result.

    4. Iterative Communication: Three Rounds for Proportions, Performance, and Detail

    Practical experience shows that an AI-generated first version usually needs about three rounds of iteration:

    • Round 1: Fix proportions. The convenience store may be too large or too small relative to the street. Specify unit dimensions directly (e.g., “storefront 8 meters wide and 4 meters high; street 60 meters long”) to correct it quickly.
    • Round 2: Fix performance. If the frame rate drops, ask to merge geometries, limit the number of lights, and use instanced rendering for repeated objects.
    • Round 3: Add details. Raindrop splash ripples, sign neon, shelf silhouettes in the window, and similar details should be raised incrementally, item by item, to avoid large one-time changes that break existing effects.

    Focusing each iteration on one topic is an effective strategy for controlling generation quality.

    5. Lessons Learned

    AI coding tools are already well suited to turning ideas into runnable, playable 3D work quickly. But to maximize their value, developers need three abilities: clear technical requirement expression, judgment based on graphics fundamentals, and a small-step, fast-iteration mindset. Tools lower the implementation barrier, while creative breakdown and aesthetic control remain core capabilities that developers cannot replace.